/* Visual language borrowed from site/src/pages/proto-f/index.astro on
 * purpose: this is the same instrument-panel register (bordered readout
 * boxes, a technical overlay, a travelling-wave field underneath) applied
 * to real operational data instead of commit counts. The field is
 * decoration; every rule below that touches a value or a label exists to
 * keep it legible over that field, never the other way around. */

:root {
  --paper: #ececec;
  --ink: #0a0a0a;
  --panel-bg: rgba(236, 236, 236, 0.94);
  --live: #0a5c1e;
  --muted: #555555;
  --unreachable: #8a1a1a;
  --border: 2px solid var(--ink);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.5 ui-monospace, "SF Mono", "JetBrains Mono", monospace;
}

#field {
  position: fixed;
  inset: 0;
  z-index: 0;
}

header.col, main {
  position: relative;
  z-index: 1;
}

header.col {
  max-width: 40rem;
  margin: 0 auto;
  padding: 24px 20px 12px;
  background: var(--panel-bg);
  border-bottom: var(--border);
}

h1 {
  font-size: 1.25em;
  font-weight: normal;
  margin: 0 0 12px;
}

/* The way to the analytics page, which reads this same sign-in. */
.title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
}
.crosslink { color: var(--ink); }

/* Every control on this page is built by the signed-in render, so the
 * focus ring is defined here, once, for all of them: an operator who
 * reaches a control by keyboard has to be able to see which one is about
 * to fire. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid #1a4fd6;
  outline-offset: 2px;
}

.signin-note {
  font-size: 12px;
  color: #333;
  max-width: 34rem;
  margin: 12px 0 0;
}

main {
  max-width: 72rem;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.readout {
  border: var(--border);
  background: var(--panel-bg);
  padding: 14px 16px;
  /* High-contrast, opaque background: the wave field must never make a
   * value or a label harder to read, at any amplitude. */
  /* A grid item's default `min-width: auto` refuses to shrink below its
   * content's min-content size, which an unbroken placeholder token or a
   * DID is wide enough to blow past any column width on a narrow screen.
   * `min-width: 0` lets the track (and this item) actually shrink to the
   * `minmax(260px, 1fr)`/`1fr` the layout asks for, and `overflow-wrap`
   * lets a long unbreakable string wrap inside it instead of forcing the
   * width back out. */
  min-width: 0;
  overflow-wrap: anywhere;
}

.panel-body {
  overflow-x: auto;
}

.readout h2 {
  font-size: 1em;
  font-weight: bold;
  margin: 0 0 10px;
  text-transform: lowercase;
}

.panel-body dl {
  margin: 0;
  font-size: 13px;
}
.panel-body dt { color: #333; margin-top: 6px; }
.panel-body dd { margin: 0; font-weight: bold; }

.panel-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.panel-body th, .panel-body td {
  text-align: left;
  padding: 3px 6px 3px 0;
  border-bottom: 1px solid #bbb;
}

/* The panel states, made visually distinct at a glance rather than only by
 * the text inside them — a `data-state` attribute drives them, so a
 * screenshot alone shows which is which. */
.readout[data-state="live"] { border-color: var(--live); }
.readout[data-state="live"] h2::after { content: " \2014 live"; color: var(--live); font-weight: normal; font-size: 0.8em; }

.readout[data-state="unreachable"] { border-color: var(--unreachable); }
.readout[data-state="unreachable"] h2::after { content: " \2014 unreachable"; color: var(--unreachable); font-weight: normal; font-size: 0.8em; }
.readout[data-state="unreachable"] .panel-body { color: var(--unreachable); font-weight: bold; }

.hint {
  font-size: 11px;
  color: #444;
  margin: 8px 0 0;
}

.trust-note {
  border-color: var(--ink);
}
.trust-note p {
  font-size: 12px;
  margin: 0;
}

/* The operator's own records, one row each. The left edge marks the rows
   naming an account this deployment holds; a row for somewhere else is an
   ordinary thing for an operator's repository to carry, so it is drawn in
   the page's own ink rather than in the colour of a failure. */
.operator-records {
  list-style: none;
  margin: 0;
  padding: 0;
}
.operator-records li {
  border-left: 3px solid var(--muted);
  padding-left: 8px;
  margin-bottom: 10px;
}
.operator-records li[data-hosted="here"] {
  border-left-color: var(--live);
}
.operator-records li dl + dl {
  margin-top: 6px;
}

/* A panel nobody has signed in to is not a failure and not an unbuilt
   epic: it is the ordinary state of a control with a door in front of it,
   so it reads as neither red nor grey. */
.readout[data-state="signed-out"] { border-style: solid; }

/* The e-stop panel's own controls. Bordered and square like every other
   readout on this page: this is an instrument panel, not a web form. */
.estop-state {
  font-weight: bold;
  margin: 0 0 8px;
}

.estop-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.estop-controls button,
.filter-controls button,
a.signin {
  font: inherit;
  font-size: 12px;
  padding: 6px 10px;
  border: var(--border);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

a.signin {
  display: inline-block;
  text-decoration: none;
}

/* What the server said when it refused a control: the operator pressed it
   and nothing happened, so it reads in the colour of a failure. */
.refusal {
  margin: 8px 0 0;
  font-size: 12px;
  font-weight: bold;
  color: var(--unreachable);
}

/* Revoke ends every token and releasing does not bring them back, so it
   does not look like the other two. */
.estop-controls button[data-action="revoke"] {
  border-color: var(--unreachable);
  color: var(--unreachable);
  font-weight: bold;
}

.estop-controls button:hover,
.filter-controls button:hover,
a.signin:hover {
  background: var(--ink);
  color: var(--paper);
}

.estop-controls button[data-action="revoke"]:hover {
  background: var(--unreachable);
  color: var(--paper);
}

/* Never `outline: none`: this page's controls stop a swarm, and a keyboard
   operator has to be able to see which one is about to fire. */
.estop-controls button:focus-visible,
.filter-controls button:focus-visible,
a.signin:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

/* Scoped to this panel: the about panel has its own `dl` and its own
   layout, and a rule written for the counts here would silently restyle
   it. */
#panel-estop dl {
  display: grid;
  grid-template-columns: auto auto;
  justify-content: start;
  gap: 2px 12px;
  margin: 0;
  font-size: 12px;
}
#panel-estop dt { color: #444; }
#panel-estop dd { margin: 0; text-align: right; }

/* The stop, the tab bar and the one list shown each take the whole row:
   the lists are tables, wider than one 260px column. */
#panel-estop,
.tabs,
.readout.list,
.trust-note {
  grid-column: 1 / -1;
}

/* One tab per list, the one shown filled in. Square and bordered like
   every other control here. */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tabs[hidden] { display: none; }
.tabs button {
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  border: var(--border);
  background: var(--panel-bg);
  color: var(--ink);
  cursor: pointer;
}
.tabs button[aria-selected="true"] {
  background: var(--ink);
  color: var(--paper);
}
.tabs button:hover { background: #d6d6d6; }
.tabs button[aria-selected="true"]:hover { background: var(--ink); }
.tabs button:focus-visible {
  outline: 3px solid #1a4fd6;
  outline-offset: 2px;
}
.tabs .count:not(:empty)::before { content: "("; }
.tabs .count:not(:empty)::after { content: ")"; }

.list-filter {
  margin: 0 0 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 16px;
}

/* Where the page is in its list, between the buttons that move it. */
.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  font-size: 12px;
}
.pager button {
  font: inherit;
  font-size: 12px;
  padding: 5px 10px;
  border: var(--border);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.pager button:hover:not(:disabled) {
  background: var(--ink);
  color: var(--paper);
}
.pager button:disabled {
  border-color: #999;
  color: #777;
  cursor: default;
}
.pager button:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

.empty {
  margin: 0;
  color: #333;
}

.readout.list .hint {
  margin: 0 0 12px;
}

.filter-field {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #333;
}

.filter-field input,
.filter-field select {
  font: inherit;
  font-size: 12px;
  padding: 5px 8px;
  border: var(--border);
  background: transparent;
  color: var(--ink);
  min-width: 14rem;
  max-width: 100%;
}

.filter-controls {
  display: flex;
  gap: 8px;
  margin: 0;
}

/* Ending an app's logins cannot be undone by putting them back, so it is
   drawn the way the stop's own irreversible setting is. */
button.end-logins,
button.delete-accounts,
button.remove-credential {
  font: inherit;
  font-size: 11px;
  padding: 3px 8px;
  border: 2px solid var(--unreachable);
  background: transparent;
  color: var(--unreachable);
  font-weight: bold;
  cursor: pointer;
  white-space: nowrap;
}

button.end-logins:hover,
button.delete-accounts:hover,
button.remove-credential:hover {
  background: var(--unreachable);
  color: var(--paper);
}

button.end-logins:focus-visible,
button.delete-accounts:focus-visible,
button.remove-credential:focus-visible,
button.show-account:focus-visible,
a.export-account:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

button.show-account,
a.export-account {
  font: inherit;
  font-size: 11px;
  padding: 3px 8px;
  border: var(--border);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}

a.export-account {
  display: inline-block;
  text-decoration: none;
}

.account-export {
  margin-top: 10px;
  font-size: 12px;
}

button.show-account:hover,
a.export-account:hover {
  background: var(--ink);
  color: var(--paper);
}

.filter-field input[type="checkbox"] {
  min-width: 0;
  align-self: flex-start;
}

/* Account names are long and the columns beside them short, so a list
   scrolls sideways rather than breaking a word across lines. A refusal's
   reason is prose, and wraps. */
.table-scroll {
  overflow-x: auto;
}
.readout.list th,
.readout.list td {
  white-space: nowrap;
}
#panel-refusal-log td:nth-child(6) {
  white-space: normal;
  min-width: 16rem;
}

#panel-accounts dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px;
  font-size: 12px;
}
#panel-accounts dt { margin-top: 0; }

.account-detail h3 {
  font-size: 13px;
  margin: 14px 0 6px;
  overflow-wrap: anywhere;
}

.account-detail table {
  margin-top: 10px;
}

/* A fingerprint or an issuer is long, and the remove button beside it has
   to stay in view at a phone's width, so that column wraps. */
#panel-accounts .account-credentials td:nth-child(2) {
  white-space: normal;
  overflow-wrap: anywhere;
}

.credential-add {
  margin-top: 10px;
}

/* The homepage at `/` (`src/home.rs`) borrows this sheet. Its boxes hold a
   few lines each, so each keeps its own height, and the claim command
   wraps rather than scrolling out of its box. */
body[data-claim] main { align-items: start; }
body[data-claim] pre {
  margin: 10px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-weight: bold;
}

@media (max-width: 700px) {
  main { grid-template-columns: 1fr; }
  header.col { padding: 16px; }
  .tabs button { font-size: 12px; padding: 5px 8px; }
}
