/* The Veramass console.
 *
 * Palette lifted from the Citation DB mark so the page and the logo agree
 * in both schemes: ink #1f1d1e on paper #fefefd, accent #2135f4, and the
 * dark inversion the logo's own <style> block already carries.
 *
 * No framework, no build step, no web font. The page is served from the
 * binary and has to render on a router with no internet, so everything it
 * needs is here. */

:root {
  --paper: #fefefd;
  --surface: #ffffff;
  --surface-2: #f4f4f2;
  --ink: #1f1d1e;
  --ink-2: #55525a;
  --ink-3: #8b8890;
  --line: #e2e1e6;
  --mark: #2135f4;
  --mark-soft: #e8eaff;
  --ok: #1a7f4b;
  --warn: #a86a00;
  --bad: #c2261c;
  --shadow: 0 1px 2px rgba(20, 20, 30, .06), 0 8px 24px rgba(20, 20, 30, .05);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #101218;
    --surface: #16181e;
    --surface-2: #1c1f27;
    --ink: #ececf1;
    --ink-2: #a8a7b4;
    --ink-3: #74737f;
    --line: #282b35;
    --mark: #7f8dff;
    --mark-soft: #202542;
    --ok: #4fc98a;
    --warn: #e3a33a;
    --bad: #ff7b6e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

/* `[hidden]` is a user-agent rule, so ANY author rule that sets `display`
 * silently beats it. Three here do -- `.modal`, `.signin` and `label` --
 * which meant the document editor rendered on every page load from the
 * day the console was written, with the dashboard behind it hiding the
 * fact. Toggling `.hidden` in script reported the attribute faithfully
 * and told us nothing about what was on screen.
 *
 * One rule, applied to everything, rather than patching the three known
 * offenders: the next `display` rule added above a hidden element would
 * reintroduce exactly this bug, and would be just as invisible to a test
 * that reads attributes. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 620; letter-spacing: -.01em; }
h2 { font-size: 15px; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
a { color: var(--mark); }

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

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: baseline; gap: 12px; min-width: 0; text-decoration: none; }
.brand-logo { height: 26px; width: auto; display: block; }
.brand-sub {
  font-size: 13px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  color: var(--mark); padding-left: 12px; border-left: 1px solid var(--line);
  align-self: center;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.pill {
  font: 500 11.5px/1 var(--mono); color: var(--ink-2);
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 5px 8px; border-radius: 999px; white-space: nowrap;
}
.live { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); }

/* --------------------------------------------------------------- tabs */

.tabs {
  display: flex; gap: 2px; padding: 0 20px;
  border-bottom: 1px solid var(--line); background: var(--surface);
  position: sticky; top: 51px; z-index: 19;
}
/* Links, not buttons: each tab is a page with its own URL, so it can be
 * bookmarked, opened in a new tab, and reached by the back button. */
.tab {
  display: inline-block; text-decoration: none;
  border-bottom: 2px solid transparent;
  color: var(--ink-2); font: 600 13px/1 var(--sans); padding: 12px 14px;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--mark); border-bottom-color: var(--mark); }

main { padding: 20px; max-width: 1500px; margin: 0 auto; }

/* -------------------------------------------------------------- cards */

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 16px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px; flex-wrap: wrap;
}
.card-actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .two-col { grid-template-columns: 1fr; } }

.prose { color: var(--ink-2); margin: 0 0 12px; max-width: 78ch; }
.prose code { background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }
.prose.warn {
  border-left: 3px solid var(--warn); padding: 10px 12px;
  background: var(--surface-2); border-radius: 0 6px 6px 0;
}
.muted { color: var(--ink-3); font-size: 12.5px; }
/* Two words for a cell that is a judgement rather than a value: a
 * certificate with a month left, or one with a week. */
.ok { color: var(--ok); }
.bad { color: var(--bad); }

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

.tiles {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.tile {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 13px 15px; box-shadow: var(--shadow);
}
.tile-label { font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); }
.tile-value { font: 620 26px/1.25 var(--sans); letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile-note { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }

/* ------------------------------------------------------------- charts */

canvas { width: 100%; display: block; }
.legend { display: flex; gap: 16px; margin-top: 10px; font-size: 12px; color: var(--ink-2); }
.legend span { display: flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.swatch-req { background: var(--mark); }
.swatch-qry { background: var(--ok); }
.swatch-err { background: var(--bad); }
.swatch-lat { background: var(--ink-3); }

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-top: 12px; }
.kv div { background: var(--surface-2); border-radius: 6px; padding: 8px 10px; }
.kv b { display: block; font: 600 15px/1.3 var(--sans); font-variant-numeric: tabular-nums; }
.kv span { font-size: 11.5px; color: var(--ink-3); }

.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 26%) 1fr auto; gap: 10px; align-items: center; }
.bar-name { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--surface-2); border-radius: 999px; height: 8px; overflow: hidden; }
.bar-fill { background: var(--mark); height: 100%; border-radius: 999px; }
.bar-value { font: 500 12px/1 var(--mono); color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- tables */

.table-scroll { overflow: auto; max-height: 420px; border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
thead th {
  position: sticky; top: 0; background: var(--surface-2); z-index: 1;
  text-align: left; font-weight: 600; color: var(--ink-2);
  padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--mark-soft); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
td.mono, th.mono { font-family: var(--mono); }
td .cell { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.status-2 { color: var(--ok); }
.status-4 { color: var(--warn); }
.status-5 { color: var(--bad); }
.empty { padding: 22px; text-align: center; color: var(--ink-3); }

/* ------------------------------------------------------------ buttons */

button {
  appearance: none; font: 600 13px/1 var(--sans); cursor: pointer;
  border-radius: 7px; padding: 8px 13px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
}
button:hover { border-color: var(--ink-3); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--mark); border-color: var(--mark); color: #fff; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); border-color: var(--line); }
button.danger:hover { border-color: var(--bad); }
button.ghost { background: transparent; color: var(--ink-2); }
button.tiny { padding: 4px 8px; font-size: 12px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: var(--surface); padding: 6px 11px; font-size: 12.5px; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.is-active { background: var(--mark); color: #fff; }

/* ------------------------------------------------------------- inputs */

input[type=text], input[type=number], input[type=password], select, textarea {
  font: 13px/1.45 var(--sans); color: var(--ink);
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 7px; padding: 8px 10px; width: 100%;
}
textarea, #raw-dsl, #modal-editor, #install-settings { font-family: var(--mono); font-size: 12.5px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--mark); outline-offset: -1px; border-color: var(--mark); }
label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); }
label > input, label > select, label > textarea, label > .digest-row { margin-top: 5px; font-weight: 400; }
label.inline, label.inline-check { display: flex; align-items: center; gap: 7px; font-weight: 500; }
label.inline input, label.inline-check input { width: auto; margin: 0; }

.form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.form-row label { flex: 1 1 220px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } }
.digest-row { display: flex; gap: 8px; }

/* --------------------------------------------------------------- data */

.data-layout { display: grid; grid-template-columns: 250px 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .data-layout { grid-template-columns: 1fr; } }
.sidebar {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px; position: sticky; top: 96px;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.collection-list { list-style: none; margin: 0; padding: 0; max-height: 60vh; overflow: auto; }
.collection-list li {
  padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 13px;
  display: flex; justify-content: space-between; gap: 8px; align-items: baseline;
}
.collection-list li:hover { background: var(--surface-2); }
.collection-list li.is-active { background: var(--mark-soft); color: var(--mark); font-weight: 600; }
.collection-list .count { font: 500 11.5px/1 var(--mono); color: var(--ink-3); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font: 500 11.5px/1 var(--mono); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 9px; color: var(--ink-2);
}
.schema summary { cursor: pointer; font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
pre { background: var(--surface-2); border-radius: 8px; padding: 12px; overflow: auto; margin: 8px 0 0; max-height: 340px; }

.conditions { display: flex; flex-direction: column; gap: 8px; }
.condition { display: grid; grid-template-columns: 1.2fr .9fr 1.6fr auto; gap: 8px; align-items: center; }
@media (max-width: 760px) { .condition { grid-template-columns: 1fr 1fr; } }
.builder-row { display: flex; gap: 14px; align-items: center; margin-top: 10px; }
.builder-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line);
  align-items: end;
}

/* -------------------------------------------------------------- keys */

.reveal { margin-top: 14px; border: 1px solid var(--mark); border-radius: 8px; overflow: hidden; }
.reveal-head { background: var(--mark-soft); color: var(--mark); font-weight: 600; font-size: 12.5px; padding: 8px 12px; }
.reveal-body { display: flex; align-items: center; gap: 10px; padding: 12px; }
.reveal-body code { flex: 1; word-break: break-all; }
.tag { font: 600 11px/1 var(--sans); padding: 3px 7px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; }
.tag-admin { background: var(--mark-soft); color: var(--mark); }
.tag-read { background: var(--surface-2); color: var(--ink-2); }
.tag-revoked { background: var(--surface-2); color: var(--bad); }
.tag-live { background: var(--surface-2); color: var(--ok); }

/* ----------------------------------------------------------- bolt-ons */

.bolton-list { display: flex; flex-direction: column; gap: 12px; }
.bolton {
  border: 1px solid var(--line); border-radius: 9px; padding: 13px 15px; background: var(--paper);
}
.bolton-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bolton-name { font-weight: 620; font-size: 14px; }
.bolton-summary { color: var(--ink-2); margin: 7px 0 0; font-size: 12.5px; max-width: 82ch; }
.bolton-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 9px; }
.bolton-actions { display: flex; gap: 8px; margin-top: 11px; flex-wrap: wrap; align-items: center; }
.bolton-actions input[type=text] { width: 170px; }
.dot { width: 8px; height: 8px; border-radius: 999px; display: inline-block; }
.dot-running { background: var(--ok); }
.dot-parked { background: var(--ink-3); }
.dot-error { background: var(--bad); }
.dot-off { background: var(--line); border: 1px solid var(--ink-3); }

/* ------------------------------------------------------------ banners */

.banner {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px; font-size: 12.5px; font-weight: 500;
  border-bottom: 1px solid var(--line);
}
.banner-warn { background: var(--surface-2); color: var(--warn); }
.banner code { font-family: var(--mono); }

/* ------------------------------------------------------------- sign-in */

/* The login and forced-password-change surfaces. Full-page rather than a
 * modal over the console: there is nothing behind them to look at, and a
 * dimmed dashboard would imply the data is one dismissal away. */
/* The sign-in and password pages are documents of their own, so the
 * centring belongs to the body rather than to a fixed overlay sitting on
 * top of a dashboard that is no longer there. */
body.centred {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px; gap: 12px;
}
.centred-form { text-align: center; }
.signin-card {
  width: min(400px, 100%); background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  padding: 28px; display: flex; flex-direction: column; gap: 14px;
}
.signin-logo { height: 30px; width: auto; align-self: center; }
.signin-sub {
  align-self: center; font-size: 12.5px; font-weight: 600; letter-spacing: .14em;
  text-transform: uppercase; color: var(--mark); margin-top: -4px; margin-bottom: 4px;
}
.signin-prose { color: var(--ink-2); font-size: 13px; margin: 0; }
.signin-hint { color: var(--ink-3); font-size: 12px; margin-top: -6px; }
.signin-card label { display: block; }
.signin-error {
  background: var(--surface-2); border-left: 3px solid var(--bad);
  border-radius: 0 6px 6px 0; padding: 9px 12px; font-size: 12.5px; color: var(--bad);
}
.signin-note {
  background: var(--mark-soft); border-radius: 8px;
  padding: 10px 12px; font-size: 12.5px; color: var(--mark);
}
.signin-federated { font-size: 12.5px; color: var(--ink-3); text-align: center; }
button.wide { width: 100%; }

.whoami {
  font-size: 12.5px; color: var(--ink-2); padding-left: 10px;
  border-left: 1px solid var(--line); white-space: nowrap;
}
.whoami b { color: var(--ink); font-weight: 620; }

/* Hidden for a viewer. Cosmetic only: the server refuses the calls
 * regardless, which is where the actual rule lives. */
.admin-only[hidden] { display: none; }

.role-pill { font: 600 11px/1 var(--sans); padding: 3px 7px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; }
.role-admin { background: var(--mark-soft); color: var(--mark); }
.role-viewer { background: var(--surface-2); color: var(--ink-2); }

/* -------------------------------------------------------------- flash */

/* What a page says happened. Rendered by the server after a redirect, so
 * it survives a refresh being a GET, and cannot carry a sentence an
 * attacker chose: the code in the URL is looked up in a fixed table. */
.flash {
  border: 1px solid var(--line); border-left-width: 3px; border-radius: 8px;
  padding: 10px 14px; margin-bottom: 16px; font-size: 13px;
}
.flash-ok { border-left-color: var(--ok); }
.flash-bad { border-left-color: var(--bad); color: var(--bad); }
.flash-info { border-left-color: var(--mark); }

/* ------------------------------------------------------------- forms */

/* A table row's action is a one-button form, so it is a POST rather than
 * a link that writes. These strip the block layout a form would bring. */
.inline-form { display: inline; }
.inline-form input[type=text] { width: 150px; display: inline-block; margin-right: 6px; }

/* An anchor that should read as a button: "back", "next page". They are
 * navigation, so they stay links. */
a.button {
  display: inline-block; text-decoration: none;
  font: 600 13px/1 var(--sans); border-radius: 7px; padding: 8px 13px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
a.button:hover { border-color: var(--ink-3); }

.seg a {
  display: inline-block; text-decoration: none;
  background: var(--surface); padding: 6px 11px; font-size: 12.5px; color: var(--ink-2);
  border-left: 1px solid var(--line);
}
.seg a:first-child { border-left: 0; }
.seg a.is-active { background: var(--mark); color: #fff; }

/* ------------------------------------------------------------- chart */

/* Server-rendered SVG. Colours come from the same custom properties as
 * everything else, so a re-skin restyles the chart and both themes work
 * without the renderer knowing which is in force. */
.chart { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-label { fill: var(--ink-3); font: 10px var(--mono); }
.chart-requests { stroke: var(--mark); stroke-width: 1.8; stroke-linejoin: round; }
.chart-queries { stroke: var(--ok); stroke-width: 1.6; stroke-linejoin: round; }
.chart-errors { stroke: var(--bad); stroke-width: 1.6; stroke-linejoin: round; }

/* ------------------------------------------------------------- misc */

.collection-list a { text-decoration: none; color: inherit; }
.collection-list li.is-active { background: var(--mark-soft); }
.collection-list li.is-active a { color: var(--mark); font-weight: 600; }
.bolton-summary.error { color: var(--bad); }
.whoami .muted { font-size: 11.5px; }
td a { color: var(--mark); text-decoration: none; }
td a:hover { text-decoration: underline; }

/* ------------------------------------------------------ guided screens */

/* The template picker. Each card is a link, so choosing a starting shape
 * is a GET that re-renders the builder with that shape's defaults, and
 * the back button undoes it. */
.template-grid {
  display: grid; gap: 10px; margin-top: 12px;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}
.template-card {
  display: block; text-decoration: none; color: inherit;
  border: 1px solid var(--line); border-radius: 9px; padding: 12px 14px;
  background: var(--surface);
}
.template-card:hover { border-color: var(--ink-3); }
.template-card.is-active { border-color: var(--mark); background: var(--mark-soft); }
.template-card b { display: block; font-size: 13.5px; margin-bottom: 4px; }
.template-card span { display: block; font-size: 12px; color: var(--ink-2); line-height: 1.45; }

/* The field table. Names and types are wide because they are what gets
 * read back; the two flags are checkboxes and want no room at all. */
.schema-grid td { vertical-align: middle; }
.schema-grid input[type=text], .schema-grid select { width: 100%; margin: 0; }
.schema-grid th.tight, .schema-grid td.tight { width: 84px; text-align: center; }

.type-help { margin: 8px 0 0; }
.type-help dt { font-size: 12.5px; font-weight: 600; margin-top: 10px; }
.type-help dd { margin: 3px 0 0; font-size: 12.5px; color: var(--ink-2); line-height: 1.5; }

/* Radios stacked with their explanation beside them, rather than a row of
 * bare labels: the explanation is the part that decides the answer. */
.choice-stack { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.choice { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; line-height: 1.5; }
.choice input { margin-top: 3px; }
.choice span { color: var(--ink-2); }
.choice strong { color: var(--ink); }

/* ------------------------------------------- the add-document form */

.field-block {
  border-top: 1px solid var(--line); padding: 14px 0;
}
.field-block:first-child { border-top: 0; padding-top: 4px; }
.field-block.has-error { border-left: 3px solid var(--bad); padding-left: 12px; }
.field-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin-bottom: 6px;
}
.field-head label { margin: 0; font-size: 13.5px; }
.field-block input[type=text], .field-block input[type=number], .field-block textarea {
  width: 100%; margin: 0;
}
.type-pill {
  font: 600 11px/1 var(--sans); color: var(--ink-3);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 9px; white-space: nowrap;
}
.field-error { color: var(--bad); font-size: 12.5px; margin: 6px 0 0; }
.radio-row { display: flex; gap: 16px; align-items: center; }
.radio { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; margin: 0; }

/* ------------------------------------------------- endpoint disclosure */

/* One line per audience, most private first. The exposed ones are marked
 * because "who can reach this" is the question the page exists to answer,
 * and a URL that reads the same whether it is loopback or the internet
 * answers it badly. */
.address-list { display: flex; flex-direction: column; gap: 10px; margin: 12px 0 18px; }
.address {
  border: 1px solid var(--line); border-left-width: 3px; border-radius: 8px;
  padding: 11px 14px; background: var(--surface);
}
.address.is-exposed { border-left-color: var(--warn, var(--bad)); }
.address-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin-bottom: 6px;
}
.address-audience { font: 600 12.5px/1 var(--sans); color: var(--ink-2); }
.address-url {
  display: block; font: 13px/1.5 var(--mono); color: var(--ink);
  word-break: break-all; user-select: all;
}
.address .hint { margin: 6px 0 0; }
.chip-warn { border-color: var(--bad); color: var(--bad); }

/* A port is a number, not a paragraph. */
label.narrow { max-width: 180px; }

/* ---------------------------------------------------------------------
 * The topology map.
 *
 * Everything is a token from the palette above, so the map inverts with
 * the rest of the page rather than being a bright rectangle in a dark
 * console. The land is deliberately quiet: it is the backdrop, and the
 * instances are the content.
 * ------------------------------------------------------------------- */

.map-panel { padding-bottom: 14px; }
.map-frame {
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; background: var(--surface-2); margin: 6px 0 12px;
}
.worldmap { display: block; width: 100%; height: auto; }
.worldmap .sea { fill: var(--surface-2); }
.worldmap .grid line { stroke: var(--line); stroke-width: 1; }
.worldmap .land path {
  fill: var(--surface); stroke: var(--line); stroke-width: 1.2;
  stroke-linejoin: round;
}

/* A failover relationship, not a border: dashed, and it animates so the
 * direction reads without an arrowhead cluttering a small map. */
.worldmap .link {
  fill: none; stroke: var(--ink-3); stroke-width: 1.4;
  stroke-dasharray: 5 6; opacity: .65;
}
.worldmap .link-standby { stroke: var(--mark); opacity: .8; }

.worldmap .halo { fill: var(--paper); opacity: .85; }
.worldmap .dot { stroke: var(--paper); stroke-width: 1.6; }
.worldmap .site-primary .dot { fill: var(--mark); }
.worldmap .site-standby .dot { fill: var(--ok); }
.worldmap .site-replica .dot { fill: var(--ink-3); }
.worldmap .site-coordinator .dot { fill: var(--warn); }

/* Unreachable wins over duty: it is the thing worth seeing first. */
.worldmap .site-down .dot { fill: var(--bad); }
.worldmap .site-down .halo { fill: var(--bad); opacity: .18; }

.worldmap .label {
  font: 600 12.5px/1 var(--sans); fill: var(--ink);
  paint-order: stroke; stroke: var(--paper); stroke-width: 3.5;
  stroke-linejoin: round;
}
.worldmap .sub {
  font: 11px/1 var(--sans); fill: var(--ink-2);
  paint-order: stroke; stroke: var(--paper); stroke-width: 3;
  stroke-linejoin: round;
}

.map-legend {
  display: flex; flex-wrap: wrap; gap: 14px;
  font: 12.5px/1 var(--sans); color: var(--ink-2);
}
.map-legend .key { display: inline-flex; align-items: center; gap: 6px; }
.map-legend .key i {
  width: 10px; height: 10px; border-radius: 50%; display: inline-block;
}
.map-legend .key-primary i { background: var(--mark); }
.map-legend .key-standby i { background: var(--ok); }
.map-legend .key-replica i { background: var(--ink-3); }
.map-legend .key-coordinator i { background: var(--warn); }
.map-legend .key-unreachable i { background: var(--bad); }

.warn-panel { border-left: 3px solid var(--warn); }
.warn-list { margin: 4px 0 0; padding-left: 20px; }
.warn-list li { margin: 5px 0; color: var(--ink-2); font-size: 13.5px; }

.tag-warn { border-color: var(--warn); color: var(--warn); }
.tag-duty-primary { border-color: var(--mark); color: var(--mark); }
.tag-duty-standby { border-color: var(--ok); color: var(--ok); }
.tag-duty-replica { border-color: var(--line); color: var(--ink-2); }
.tag-duty-coordinator { border-color: var(--warn); color: var(--warn); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.form-grid .form-actions { grid-column: 1 / -1; }

/* The deployment plan: commands somebody has to be able to read and
 * object to before they run. */
.steps { margin: 10px 0 16px; padding-left: 22px; }
.steps li { margin: 10px 0; }
.step-what { font: 600 13px/1.4 var(--sans); color: var(--ink); margin-bottom: 4px; }
.step-cmd, .step-out {
  margin: 0; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface-2); font: 12px/1.55 var(--mono); color: var(--ink-2);
  white-space: pre-wrap; word-break: break-all; max-height: 320px; overflow: auto;
}
.steps .step-ok .step-what { color: var(--ok); }
.steps .step-bad .step-what { color: var(--bad); }
.steps .step-bad .step-out { border-color: var(--bad); }

.identity { margin: 4px 0 10px; font-size: 13.5px; }
.identity.ok { color: var(--ink-2); }
.identity.bad { color: var(--bad); }
.estimate { margin: 0 0 12px; font-size: 13.5px; color: var(--ink-2); }

/* True things that are not refusals: no admin token, an untrusted
 * certificate, a geography about to have a primary and no standby.
 * Beside the button rather than in a document, and marked as advice
 * rather than as an error, because every one of them is a legitimate
 * thing to do deliberately. */
.warnings {
  margin: 0 0 14px; padding: 10px 12px 10px 28px;
  border: 1px solid var(--warn); border-radius: 8px;
  background: var(--surface-2); color: var(--ink-2);
  font-size: 13px; line-height: 1.55;
}
.warnings li { margin: 4px 0; }

/* The deploy form is long enough to need grouping. A fieldset per
 * subject, so a coordinator's operator can skip the follower fields
 * rather than read past them. */
.stack > fieldset {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px 16px; margin: 0 0 14px;
}
.stack > fieldset > legend {
  padding: 0 6px; font: 600 12px/1 var(--sans);
  letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3);
}

/* ------------------------------------------------------- settings sub-nav */

/* The second row under the Settings tab. Same anatomy as the top tabs,
 * quieter, so the two rows read as section and page rather than as two
 * competing menus. */
.subtabs {
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  padding: 0 20px;
}
.subtabs .tab { font-size: 13px; padding: 8px 2px; }

/* The Settings hub: one card per sub-page, description included, so the
 * first visit reads like a map rather than a menu. */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.settings-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  color: inherit;
  text-decoration: none;
}
.settings-card:hover { border-color: var(--mark); }
.settings-card h2 { margin: 0 0 6px; font-size: 15px; color: var(--mark); }
.settings-card p { margin: 0; color: var(--ink-2); font-size: 13px; }

/* ------------------------------------------------------ results controls */

/* The Table / JSON switch. Links, not buttons: a view is part of the
 * query URL, so it can be bookmarked and sent like everything else. */
.seg-group {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.seg {
  padding: 3px 12px;
  font-size: 12.5px;
  text-decoration: none;
  color: var(--ink-2);
}
.seg + .seg { border-left: 1px solid var(--line); }
.seg.is-active { background: var(--mark-soft); color: var(--mark); font-weight: 600; }

/* The narrow-these-results box. Hidden until script unhides it, because
 * it filters the fetched page only and cannot honestly exist without the
 * script that does that. */
.result-filter {
  width: 100%;
  margin: 10px 0 2px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
}

/* The JSON view: one block per document. */
.doc-list { display: grid; gap: 10px; margin-top: 10px; }
.doc-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 10px 12px;
}
.doc-block-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.doc-block pre { margin: 0; white-space: pre-wrap; word-break: break-word; }

/* -------------------------------------------------------------- hints */

/* The little circled question mark beside a label. Pure CSS, no script:
 * the explanation is in `data-tip`, shown on hover and on keyboard focus
 * (it is tabbable), and read by assistive tech from `aria-label` which
 * the server sets to the same text. (`.tip`, not `.hint`: `.hint` is the
 * long-standing class for explanatory paragraphs.) */
.tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  margin-left: 5px;
  border: 1px solid var(--ink-3);
  border-radius: 50%;
  color: var(--ink-3);
  font: 600 10px/1 var(--sans);
  cursor: help;
  position: relative;
  vertical-align: text-bottom;
}
.tip:hover, .tip:focus-visible { border-color: var(--mark); color: var(--mark); }
.tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 280px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  font: 400 12px/1.45 var(--sans);
  text-align: left;
  white-space: normal;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease-in;
  z-index: 30;
}
.tip:hover::after, .tip:focus-visible::after { opacity: 1; }

/* A guide box: the collapsible explanation of a page's optional
 * settings. `details`, so it works everywhere and remembers nothing. */
.guide-box {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 10px 14px;
}
.guide-box summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink-2);
  font-size: 13px;
}
.guide-box[open] summary { margin-bottom: 8px; }
.guide-box dl { margin: 0; }
.guide-box dt { font-weight: 600; font-size: 13px; margin-top: 8px; }
.guide-box dd { margin: 2px 0 0 0; color: var(--ink-2); font-size: 13px; }

/* The optional extra query conditions. */
.more-conditions { margin: 8px 0; }
.more-conditions summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.more-conditions .condition { margin-top: 6px; }
.more-conditions p { margin: 6px 0 0; font-size: 12.5px; }

/* ------------------------------------------------------ getting started */

.getting-started { border-left: 3px solid var(--mark); }
.getting-started .steps { margin: 4px 0 10px; padding-left: 22px; }
.getting-started .steps li { margin: 6px 0; }

/* ------------------------------------------------------- configuration */

/* One setting: name, provenance, what it is running with, the control,
 * and the explanation. Dense enough to scan a group, verbose enough that
 * nobody has to go reading source to know what a knob does. */
.setting-list { display: grid; gap: 14px; margin-top: 10px; }
.setting {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 10px 12px;
}
.setting-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.setting-head code { font-size: 11.5px; }
.setting-now { font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; }
.setting-now code { color: var(--ink); }
.setting input[type=text], .setting input[type=number], .setting select {
  width: 100%;
  max-width: 460px;
  margin: 0 0 4px;
}
.setting .hint { margin: 4px 0 0; }

/* The role page's glossary. */
.rolelist dt { font-weight: 600; font-size: 13px; margin-top: 10px; }
.rolelist dd { margin: 2px 0 0; color: var(--ink-2); font-size: 13px; }

/* --------------------------------------------------- password reveal */

/* The button is injected by console.js, so these rules describe
 * something that exists only when script runs. The eye is drawn here
 * rather than in the script: a mask plus `currentColor` themes itself in
 * both schemes, and it keeps the script inside its budget. */
:root {
  --eye: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M1.5 12S5 5.5 12 5.5 22.5 12 22.5 12 19 18.5 12 18.5 1.5 12 1.5 12z'/%3E%3Ccircle cx='12' cy='12' r='3.2'/%3E%3C/svg%3E");
  --eye-off: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M1.5 12S5 5.5 12 5.5 22.5 12 22.5 12 19 18.5 12 18.5 1.5 12 1.5 12z'/%3E%3Ccircle cx='12' cy='12' r='3.2'/%3E%3C/svg%3E")OFF;
}
.reveal-wrap { position: relative; display: block; }
.reveal-wrap input { width: 100%; padding-right: 38px; }
.reveal-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink-3);
  cursor: pointer;
}
.reveal-toggle:hover, .reveal-toggle:focus-visible { color: var(--mark); }
.reveal-toggle::before {
  content: "";
  width: 17px;
  height: 17px;
  background: currentColor;
  -webkit-mask: var(--eye) center / contain no-repeat;
  mask: var(--eye) center / contain no-repeat;
}
/* Struck through while the password is visible, so the icon shows what
 * pressing it would do next rather than what it did last. */
.reveal-toggle.is-revealed::before {
  -webkit-mask-image: var(--eye-off);
  mask-image: var(--eye-off);
}

/* -------------------------------------------------- structured / raw */

/* A two-panel switch with no script and no page reload: two radios, two
 * labels styled as segments, and sibling selectors deciding which panel
 * shows. The radios are the state, so the browser remembers the choice
 * across a back-navigation for free and a keyboard reaches it the way it
 * reaches any radio group. */
.viewswitch > input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.viewswitch .seg { cursor: pointer; user-select: none; }
.viewswitch > input:first-of-type:checked ~ .seg-group .seg:first-child,
.viewswitch > input:nth-of-type(2):checked ~ .seg-group .seg:last-child {
  background: var(--mark-soft);
  color: var(--mark);
  font-weight: 600;
}
/* Keyboard focus has to be visible on a control whose input is off
 * screen, or tabbing to it looks like nothing happened. */
.viewswitch > input:focus-visible ~ .seg-group {
  outline: 2px solid var(--mark);
  outline-offset: 2px;
}
.viewswitch .panel-raw { display: none; }
.viewswitch > input:nth-of-type(2):checked ~ .panel-raw { display: block; }
.viewswitch > input:nth-of-type(2):checked ~ .panel-structured { display: none; }
.viewpanel { margin-top: 10px; }

/* The structured schema itself. */
.schema-facts { display: grid; gap: 4px; margin: 10px 0; }
.schema-facts div { display: flex; gap: 10px; font-size: 13px; align-items: baseline; }
.schema-facts dt { color: var(--ink-2); min-width: 210px; flex: none; }
.schema-facts dd { margin: 0; }
.fieldtable { width: 100%; }
.fieldtable td.flag, .fieldtable th.flag { text-align: center; width: 88px; }
.fieldtable .no { color: var(--ink-3); }
