/* paasd operator console.
   One stylesheet, no build step, no external asset: the CSP is
   default-src 'self' and a console that needs a CDN is a console that goes
   blank the day the CDN does. */

:root {
  --bg: #0b0e13;
  --surface: #121720;
  --sunken: #0d1118;
  --line: #222a37;
  --line-soft: #1a212c;
  --text: #e8edf5;
  --dim: #92a0b5;
  --faint: #626f82;
  --accent: #8fb4e4;
  --ok: #5ec98d;
  --warn: #e2b053;
  --bad: #f2717d;
  --busy: #7fa8e8;

  color-scheme: dark;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  font-size: 0.875rem;
  line-height: 1.45;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* -------------------------------------------------------------------------
   The login gate keeps the centred single panel. Everything below it is the
   signed-in shell.
   ------------------------------------------------------------------------- */

.shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 2rem;
}

.panel {
  width: min(100%, 31rem);
  padding: 2.5rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--surface);
  box-shadow: 0 1.5rem 4rem rgb(0 0 0 / 35%);
}

.login-panel h1 {
  margin: 0.25rem 0 0.5rem;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  letter-spacing: -0.04em;
}

.eyebrow {
  margin: 0;
  color: #8ea1bb;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.muted {
  margin: 0 0 2rem;
  color: var(--dim);
}

/* -------------------------------------------------------------------------
   Shell: a fixed rail, a thin top bar, and everything else in the stage.
   ------------------------------------------------------------------------- */

body.app {
  display: grid;
  grid-template-areas: "rail top" "rail stage";
  grid-template-columns: 12.5rem minmax(0, 1fr);
  grid-template-rows: 2.6rem minmax(0, 1fr);
}

.rail {
  display: flex;
  position: sticky;
  top: 0;
  flex-direction: column;
  grid-area: rail;
  gap: 0.1rem;
  height: 100vh;
  padding: 0.75rem 0.6rem;
  border-right: 1px solid var(--line);
  background: #0a0d12;
}

.brand {
  display: block;
  margin-bottom: 1rem;
  padding: 0.35rem 0.55rem;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 750;
  letter-spacing: -0.03em;
}

.brand:hover {
  text-decoration: none;
}

.brand span {
  display: block;
  color: var(--faint);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.nav {
  padding: 0.4rem 0.55rem;
  border-radius: 0.35rem;
  color: var(--dim);
  font-weight: 600;
}

.nav:hover {
  background: #141a24;
  color: var(--text);
  text-decoration: none;
}

.nav.on {
  background: #18202c;
  box-shadow: inset 2px 0 0 var(--accent);
  color: var(--text);
}

.nav.accent {
  margin-top: auto;
  color: var(--accent);
}

.topbar {
  display: flex;
  position: sticky;
  z-index: 5;
  top: 0;
  align-items: center;
  grid-area: top;
  gap: 0.75rem;
  padding: 0 1.1rem;
  border-bottom: 1px solid var(--line);
  background: rgb(11 14 19 / 92%);
}

.crumb {
  flex: 1;
  color: var(--dim);
  font-size: 0.8125rem;
}

.tz {
  color: var(--faint);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.who {
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 650;
}

.stage {
  grid-area: stage;
  min-width: 0;
  padding: 1.1rem 1.25rem 3rem;
}

/* -------------------------------------------------------------------------
   Headings and blocks
   ------------------------------------------------------------------------- */

h1.page {
  margin: 0 0 0.9rem;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}

.head h1.page {
  margin: 0;
}

.head .button {
  margin-left: auto;
}

h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.55rem;
  color: var(--dim);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h2 .more {
  margin-left: auto;
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  text-transform: none;
}

.count {
  padding: 0.05rem 0.35rem;
  border-radius: 0.25rem;
  background: #1a212c;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.panel-block {
  margin-bottom: 1.1rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
}

.panel-block.failure {
  border-color: #5b2a31;
  background: #161215;
}

.split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(21rem, 1fr));
  gap: 1.1rem;
  align-items: start;
}

.split > .panel-block {
  margin-bottom: 0;
}

/* -------------------------------------------------------------------------
   Cards
   ------------------------------------------------------------------------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13.5rem, 1fr));
  gap: 0.7rem;
  margin-bottom: 1.1rem;
}

.card {
  display: block;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--text);
}

a.card:hover {
  border-color: #38455a;
  text-decoration: none;
}

.card .k {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--dim);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.card.stat .n {
  display: block;
  font-size: 2.4rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.05;
}

.card.stat .sub {
  color: var(--faint);
  font-size: 0.75rem;
}

.card.bad {
  border-color: #6a2f38;
  background: #171216;
}

.card.bad .n {
  color: var(--bad);
}

ul.mini {
  margin: 0;
  padding: 0;
  list-style: none;
}

ul.mini a {
  display: flex;
  justify-content: space-between;
  padding: 0.15rem 0;
  border-bottom: 1px solid var(--line-soft);
  color: var(--dim);
}

ul.mini li:last-child a {
  border-bottom: 0;
}

ul.mini a:hover {
  color: var(--text);
  text-decoration: none;
}

ul.mini b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------------------
   Tables
   ------------------------------------------------------------------------- */

table.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

table.grid th {
  position: sticky;
  top: 2.6rem;
  padding: 0.35rem 0.55rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: var(--faint);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

table.grid td {
  padding: 0.35rem 0.55rem;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}

table.grid tbody tr:last-child td {
  border-bottom: 0;
}

table.grid.rows tbody tr:hover td {
  background: #151b25;
}

table.grid th.num,
table.grid td.num {
  text-align: right;
  white-space: nowrap;
}

table.grid tr.drifted td {
  background: #191507;
}

table.grid tr.follow td {
  padding-top: 0;
  border-bottom: 1px solid var(--line-soft);
  color: var(--dim);
  font-size: 0.75rem;
}

table.grid.journal td {
  vertical-align: top;
}

table.grid tr.j-failed td,
table.grid tr.j-undo_failed td {
  background: #1a1114;
}

/* -------------------------------------------------------------------------
   Pills, tags and state colour
   ------------------------------------------------------------------------- */

.pill {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  border: 1px solid #2c3543;
  border-radius: 0.7rem;
  background: #171e29;
  color: var(--dim);
  font-size: 0.6875rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.pill.s-succeeded,
.pill.l-active,
.pill.i-serving,
.pill.h-active,
.pill.v-verified,
.pill.j-done {
  border-color: #26543c;
  background: #10201a;
  color: var(--ok);
}

.pill.s-running,
.pill.j-running,
.pill.i-starting,
.pill.l-provisioning,
.pill.l-trial {
  border-color: #2c4468;
  background: #101827;
  color: var(--busy);
}

.pill.s-compensating,
.pill.s-rolled_back,
.pill.s-stuck,
.pill.s-stale,
.pill.s-config_drift,
.pill.l-suspended,
.pill.l-past_due,
.pill.i-draining,
.pill.h-draining,
.pill.j-undone,
.pill.sev-medium {
  border-color: #5c4620;
  background: #1d1708;
  color: var(--warn);
}

.pill.s-failed,
.pill.s-needs_attention,
.pill.l-destroyed,
.pill.i-failed,
.pill.v-failed,
.pill.j-failed,
.pill.j-undo_failed,
.pill.sev-critical,
.pill.sev-high {
  border-color: #5f2a33;
  background: #1e1114;
  color: var(--bad);
}

.tag {
  display: inline-block;
  padding: 0.02rem 0.35rem;
  border: 1px solid #4a3b22;
  border-radius: 0.25rem;
  color: var(--warn);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tag.dim {
  border-color: var(--line);
  color: var(--faint);
}

/* -------------------------------------------------------------------------
   Filters
   ------------------------------------------------------------------------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.8rem;
}

.chip {
  padding: 0.15rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  background: var(--surface);
  color: var(--dim);
  font-size: 0.75rem;
}

.chip:hover {
  border-color: #38455a;
  color: var(--text);
  text-decoration: none;
}

.chip.on {
  border-color: var(--accent);
  background: #16202e;
  color: var(--text);
}

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

dl.facts {
  display: grid;
  grid-template-columns: minmax(7rem, auto) minmax(0, 1fr);
  gap: 0 0.8rem;
  margin: 0;
  font-size: 0.8125rem;
}

dl.facts dt {
  padding: 0.2rem 0;
  border-bottom: 1px solid var(--line-soft);
  color: var(--faint);
}

dl.facts dd {
  overflow-wrap: anywhere;
  margin: 0;
  padding: 0.2rem 0;
  border-bottom: 1px solid var(--line-soft);
}

dl.facts.derived {
  margin: 0.3rem 0 0.5rem;
  padding: 0.4rem 0.6rem;
  border: 1px dashed var(--line);
  border-radius: 0.4rem;
  background: var(--sunken);
}

.redacted {
  color: var(--warn);
  letter-spacing: 0.2em;
}

/* -------------------------------------------------------------------------
   Forms
   ------------------------------------------------------------------------- */

form {
  display: grid;
  gap: 0.75rem;
}

form.inline {
  display: inline;
}

label {
  margin-top: 0.35rem;
  color: #c8d1dc;
  font-size: 0.875rem;
  font-weight: 650;
}

input,
select {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid #374151;
  border-radius: 0.35rem;
  outline: none;
  background: var(--sunken);
  color: #f5f7fa;
  font: inherit;
}

.login-panel input {
  padding: 0.8rem 0.9rem;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(122 162 214 / 18%);
}

button,
.button {
  display: inline-block;
  justify-self: start;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--accent);
  border-radius: 0.35rem;
  background: var(--accent);
  color: #08111d;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.login-panel button {
  margin-top: 0.75rem;
  padding: 0.8rem 1rem;
}

button:hover,
.button:hover {
  background: #a4c5ed;
  text-decoration: none;
}

button.secondary,
button.ghost {
  border-color: #465266;
  background: transparent;
  color: #d6deea;
}

button.ghost:hover {
  border-color: #6a7889;
  background: #18202c;
}

button.destructive {
  border-color: #7d333b;
  background: #7d333b;
  color: #ffe7e9;
}

button.destructive:hover {
  background: #94404a;
}

button[disabled] {
  border-color: var(--line);
  background: transparent;
  color: var(--faint);
  cursor: not-allowed;
}

.field {
  display: grid;
  gap: 0.2rem;
  max-width: 34rem;
}

.field label {
  margin: 0;
}

form.stack {
  max-width: 40rem;
  gap: 0.85rem;
}

form.picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
}

form.picker label {
  margin: 0;
}

form.picker select {
  width: auto;
  min-width: 18rem;
}

form.picker .note {
  flex-basis: 100%;
}

form.action {
  gap: 0.3rem;
  margin-bottom: 0.9rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--line-soft);
}

form.action:last-of-type {
  border-bottom: 0;
}

form.action.danger {
  padding: 0.7rem;
  border: 1px solid #4a2830;
  border-radius: 0.4rem;
  background: #150f12;
}

form.action.danger input {
  max-width: 24rem;
}

.action.off {
  display: grid;
  gap: 0.3rem;
  opacity: 0.65;
}

/* -------------------------------------------------------------------------
   Text utilities
   ------------------------------------------------------------------------- */

.mono,
code,
pre {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
  font-variant-numeric: tabular-nums;
}

.strong {
  color: var(--text);
  font-weight: 650;
}

.dim {
  color: var(--dim);
}

.ok {
  color: var(--ok);
}

.warn {
  color: var(--warn);
}

.bad {
  color: var(--bad);
}

.busy {
  color: var(--busy);
}

.note {
  display: block;
  color: var(--faint);
  font-size: 0.75rem;
}

ul.reasons {
  margin: 0.2rem 0 0;
  padding-left: 1.1rem;
}

.empty {
  margin: 0.2rem 0;
  color: var(--faint);
  font-size: 0.8125rem;
}

.empty.ok {
  color: var(--ok);
}

.error {
  margin: 0 0 0.9rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid #7d333b;
  border-radius: 0.4rem;
  background: #2b171b;
  color: #ffb7bd;
}

pre {
  overflow-x: auto;
  margin: 0.2rem 0;
  padding: 0.4rem 0.55rem;
  border-radius: 0.3rem;
  background: var(--sunken);
  color: #cfdaea;
}

pre.wrap {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

code {
  padding: 0.05rem 0.3rem;
  border-radius: 0.25rem;
  background: var(--sunken);
  color: #cfdaea;
}

details summary {
  color: var(--faint);
  cursor: pointer;
  font-size: 0.75rem;
}

details[open] summary {
  color: var(--dim);
}
