/*
 * The production Studio management surface.
 *
 * Dark, dense and operational: this is a page somebody opens to find out
 * whether a network is up, not one they browse. Every colour that means
 * something is defined once, and the classes that carry meaning -- MANAGED
 * SELF-HOST against OBSERVE ONLY, a validator answering against one that is
 * not -- are visually distinct rather than distinguished by a word in the
 * middle of a sentence.
 *
 * No framework, no build step. This file is what ships.
 */

:root {
  --ink: #e8eaf0;
  --ink-dim: #9aa3b8;
  --ground: #0d1017;
  --panel: #151a24;
  --panel-edge: #232a38;
  --accent: #5b8cff;
  --ok: #3ecf8e;
  --warn: #f2b544;
  --bad: #ff6b6b;
  --managed: #3ecf8e;
  --observe: #7a8296;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

code, pre {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.86em;
}

/* ------------------------------------------------------------------- chrome */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--panel-edge);
  background: #0a0d13;
  position: sticky;
  top: 0;
  z-index: 2;
}

.mark { font-weight: 650; letter-spacing: 0.04em; }
.mark span { color: var(--accent); }

.bar-right { display: flex; align-items: center; gap: 12px; }

/* Says what this surface IS, permanently. A development fixture network and a
   production self-host must never be confused, and the first place that is
   decided is the top of the page. */
.env {
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ink-dim);
  border: 1px solid var(--panel-edge);
  border-radius: 999px;
  padding: 3px 10px;
}

main { max-width: 980px; margin: 0 auto; padding: 24px 20px 64px; }

.panel { background: var(--panel); border: 1px solid var(--panel-edge); border-radius: var(--radius); padding: 22px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }

h1 { font-size: 22px; margin: 6px 0 10px; }
h2 { font-size: 14px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-dim); margin: 26px 0 10px; }

.muted { color: var(--ink-dim); font-size: 14px; }
.error { color: var(--bad); font-size: 14px; margin-top: 12px; white-space: pre-wrap; }

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

label { display: block; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-dim); margin: 14px 0 6px; }

input, select {
  width: 100%;
  padding: 10px 12px;
  background: #0b0e15;
  color: var(--ink);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

button, .ghost {
  font: inherit;
  border-radius: 8px;
  padding: 9px 14px;
  border: 1px solid var(--panel-edge);
  background: #1b2130;
  color: var(--ink);
  cursor: pointer;
  /* 24px is the smallest thing worth asking somebody to hit. */
  min-height: 38px;
}

button:hover { border-color: var(--accent); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.primary { background: var(--accent); border-color: var(--accent); color: #07101f; font-weight: 600; margin-top: 16px; }
.danger { background: #2a1519; border-color: #58242c; color: #ffb4b4; }
.danger:hover { border-color: var(--bad); }
a.ghost { display: inline-flex; align-items: center; text-decoration: none; }

/* ------------------------------------------------------------------- lists */

.list { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; }

.row {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "name tag" "genesis genesis";
  gap: 6px 12px;
  text-align: left;
  padding: 14px 16px;
}

.row-name { grid-area: name; font-weight: 600; }
.row-genesis { grid-area: genesis; color: var(--ink-dim); word-break: break-all; }
.row .tag { grid-area: tag; }

.tag {
  font-size: 11px;
  letter-spacing: 0.08em;
  border-radius: 999px;
  padding: 3px 10px;
  border: 1px solid;
  white-space: nowrap;
}

.tag-managed { color: var(--managed); border-color: color-mix(in srgb, var(--managed) 45%, transparent); }
.tag-observe { color: var(--observe); border-color: var(--panel-edge); }
.tag-other { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }

.class { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }

.state { font-size: 11px; letter-spacing: 0.08em; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--panel-edge); }
.state-ready { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.state-stopped { color: var(--ink-dim); }
.state-starting { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.state-degraded { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.state-error { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.state-registered { color: var(--ink-dim); }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.facts dt { color: var(--ink-dim); font-size: 13px; }
.facts dd { margin: 0; word-break: break-all; }

.members, .readiness { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.member, .ready { padding: 8px 12px; border-radius: 8px; border: 1px solid var(--panel-edge); background: #0f131c; font-size: 14px; }
.member.ok { border-left: 3px solid var(--ok); }
/* NOT ANSWERING BECAUSE IT WAS ASKED TO STOP. The same fact as `.silent` and a
   different meaning, so a different treatment: dimmed and quiet rather than
   red. Red on an intentional stop is a fault report for a fault that is not
   there, and it is how an operator learns to ignore red. */
.member.idle { border-left: 3px solid var(--panel-edge); color: var(--ink-dim); }
.member.silent { border-left: 3px solid var(--bad); }
.ready.yes { border-left: 3px solid var(--ok); }
.ready.no { border-left: 3px solid var(--warn); }

/* AutoOps. The worker line and the per-network facts are deliberately
   separate blocks: one is about a process on this machine, the other about a
   switch an operator set, and a single badge for both would be reassuring in
   precisely the case where nothing is running. */
.worker {
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--panel-edge);
  background: #0f131c;
  margin: 0 0 14px;
}
.worker-running { border-left: 3px solid var(--ok); }
.worker-degraded { border-left: 3px solid var(--warn); color: var(--warn); }
.worker-stopped { border-left: 3px solid var(--ink-dim); color: var(--ink-dim); }

.escalation {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  background: #1b1710;
}
.escalation h3 { margin: 0 0 6px; font-size: 14px; color: var(--warn); }
.escalation p { margin: 0 0 8px; font-size: 14px; }

.history { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 6px; }
.entry {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--panel-edge);
  background: #0f131c;
  font-size: 13px;
  color: var(--ink-dim);
  word-break: break-word;
}
.entry-acted { border-left: 3px solid var(--accent); color: var(--ink); }
.entry-looked { border-left: 3px solid var(--panel-edge); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.actions .primary { margin-top: 0; }
/* An action with nothing to do does not present as the thing to do next. The
   rule about what the command does lives in `mirco`; this is only the button
   declining to claim otherwise. */
button:disabled,
button:disabled:hover {
  background: transparent;
  border-color: var(--panel-edge);
  color: var(--observe);
  cursor: default;
}

/* The last thing automation DID: what it was, how it went, when. Stacked so the
   action reads first and the verification and the age read as its footnote. */
.last-action { display: flex; flex-direction: column; gap: 2px; }
.last-action-what { color: var(--ink); }
.last-action-how { color: var(--ink-dim); font-size: 12px; }

.output {
  margin-top: 14px;
  padding: 12px;
  background: #0b0e15;
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  color: var(--ink-dim);
}

.register { margin-top: 26px; border-top: 1px solid var(--panel-edge); padding-top: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 14px; }
.small { font-size: 12px; margin-top: 4px; }
.checkbox { display: flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--ink); }
.checkbox input { width: auto; }
.register summary { cursor: pointer; font-weight: 600; }

/* ------------------------------------------------------------------ dialog */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 11, 0.72);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 10;
}

.dialog {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 22px;
  max-width: 520px;
  width: 100%;
}

.dialog h2 { margin-top: 0; text-transform: none; letter-spacing: 0; font-size: 18px; color: var(--ink); }

[hidden] { display: none !important; }

@media (max-width: 560px) {
  .row { grid-template-columns: 1fr; grid-template-areas: "name" "tag" "genesis"; }
  .facts { grid-template-columns: 1fr; }
  .facts dt { margin-top: 8px; }
}

/* Economics. A table and not a fact list, because every value here has TWO
   readings -- what was asked for and what the chain answers -- and a list
   that showed one of them would be showing whichever the page happened to
   have, which is exactly the confusion this section exists to remove. */
fieldset#create-economics {
  margin: 18px 0 0;
  padding: 4px 14px 14px;
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
}
fieldset#create-economics legend {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-dim);
  padding: 0 6px;
}
.decided { margin-top: 14px; }
.decided summary { cursor: pointer; font-size: 13px; color: var(--ink-dim); }

table.economics {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 10px;
}
table.economics th, table.economics td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--panel-edge);
  vertical-align: top;
}
table.economics thead th {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-dim);
  font-weight: 500;
}
table.economics tbody th { font-weight: 500; color: var(--ink-dim); }
/* An asset id is the row's identity, so it is the thing you click. */
#assets-rows button.ghost {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  padding: 4px 8px;
}
#asset-detail { border-color: var(--panel-edge); background: #0f131c; }
#asset-detail h3 { margin: 0 0 4px; }
#asset-detail h4 { margin: 18px 0 4px; font-size: 13px; }
/* A command is something you copy, so it keeps its line breaks. */
#asset-actions dd { white-space: pre-wrap; font-size: 12px; }
table.economics td:nth-child(2), table.economics td:nth-child(3) {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}

/* VERIFIED is the only one that gets the good colour. Everything else is
   either a difference worth looking at or an absence of evidence, and an
   absence of evidence that rendered green would be the defect itself. */
.economics-verified { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.economics-mismatch { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.economics-unobserved { color: var(--ink-dim); }
.economics-not_observable { color: var(--ink-dim); }
.verdict-verified { border-left: 3px solid var(--ok); }
.verdict-mismatch { border-left: 3px solid var(--bad); color: var(--bad); }
.verdict-launched { border-left: 3px solid var(--ink-dim); color: var(--ink-dim); }
.verdict-unavailable { border-left: 3px solid var(--ink-dim); color: var(--ink-dim); }
