/* Order ops console.
 *
 * Styled after a kitchen display system rather than a dashboard: high
 * contrast, hard edges, colour-coded by version, legible across a room.
 * Version colour is information, not decoration — red is reserved
 * exclusively for trouble so a version's identity can never imply its
 * health. */

:root {
  /* Espresso-dark ground, warm rather than a tinted black. */
  --ground: #1a1614;
  --panel: #241e1a;
  --panel-raised: #2c2521;
  --rule: #3a312b;
  --rule-bright: #50443c;

  --ink: #f2eae1;
  --ink-dim: #b3a69b;
  --ink-faint: #7d7168;

  /* Version identities. No red, no true green: those carry state. */
  --v1: #5ba8d0;
  --v2: #7fd4c1;
  --v3: #e3b23c;
  --v4: #b48ce0;
  --v5: #e88a3c;

  /* State. */
  --trouble: #e5484d;
  --good: #58c98a;

  --gap: 14px;
  --radius: 2px;

  --sans: "Barlow", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --cond: "Barlow Condensed", "Barlow", ui-sans-serif, system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  padding: 0 0 48px;
  background: var(--ground);
  color: var(--ink);
  font: 400 15px/1.45 var(--sans);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

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

.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-bottom: 1px solid var(--rule);
  background: var(--panel);
}

.brand { display: flex; align-items: center; gap: 10px; }

/* Five bands: the versions, and the reason this is called a rainbow deploy. */
.brand-mark {
  width: 10px;
  height: 30px;
  background: linear-gradient(
    var(--v1) 0 20%, var(--v2) 20% 40%, var(--v3) 40% 60%,
    var(--v4) 60% 80%, var(--v5) 80% 100%);
}

.brand-name {
  font: 600 25px/1 var(--cond);
  letter-spacing: 0.01em;
}

.readouts { display: flex; gap: 26px; flex-wrap: wrap; margin-left: auto; }

.readout { display: flex; align-items: baseline; gap: 7px; }

.readout-value {
  font: 700 30px/0.9 var(--cond);
  font-variant-numeric: tabular-nums;
}

.readout-unit { color: var(--ink-dim); font-size: 13px; }

.readout-trouble .readout-value { color: var(--trouble); }

.link-status {
  display: flex; align-items: center; gap: 7px;
  color: var(--ink-faint); font-size: 13px;
}

.link-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink-faint);
}

.link-dot[data-state="live"] { background: var(--good); }
.link-dot[data-state="lost"] { background: var(--trouble); }

/* --- Hero: the traffic split ------------------------------------------- */

.split { padding: 22px 20px 18px; border-bottom: 1px solid var(--rule); }

.split-row + .split-row { margin-top: 18px; }

.split-label {
  margin: 0 0 7px;
  color: var(--ink-dim);
  font-size: 13px;
}

.split-bar {
  display: flex;
  height: 46px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--rule);
}

.split-bar-inflight { height: 26px; }

.split-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  color: #17120f;
  font: 600 15px/1 var(--cond);
  white-space: nowrap;
  /* The one piece of motion that matters: watching this move is the demo. */
  transition: flex-grow 600ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.split-seg-name { font-size: 19px; font-weight: 700; }

.split-bar-inflight .split-seg { font-size: 13px; }
.split-bar-inflight .split-seg-name { font-size: 14px; }

.split-empty {
  display: flex; align-items: center; padding-left: 12px;
  color: var(--ink-faint); font-size: 13px;
}

.split-note { margin: 7px 0 0; color: var(--ink-faint); font-size: 12.5px; }
.split-note em { color: var(--ink-dim); font-style: italic; }

/* --- Panels ------------------------------------------------------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: var(--gap);
  padding: var(--gap) 20px 0;
  align-items: start;
}

.panel {
  padding: 15px 16px 17px;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

.panel-heading {
  margin: 0 0 13px;
  font: 600 19px/1 var(--cond);
  letter-spacing: 0.02em;
  color: var(--ink);
}

.field-caption { margin: 0 0 8px; color: var(--ink-dim); font-size: 13px; }

.empty { margin: 0; color: var(--ink-faint); font-size: 14px; }

/* --- Controls ----------------------------------------------------------- */

.btn {
  padding: 8px 15px;
  border: 1px solid var(--rule-bright);
  border-radius: var(--radius);
  background: var(--panel-raised);
  color: var(--ink);
  font: 500 14px/1 var(--sans);
  cursor: pointer;
}

.btn:hover { border-color: var(--ink-faint); }

.btn:focus-visible,
.chip:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--v1);
  outline-offset: 2px;
}

.btn-primary { background: var(--ink); border-color: var(--ink); color: #17120f; font-weight: 600; }
.btn-primary:hover { background: #fff; }

.btn-danger { background: var(--trouble); border-color: var(--trouble); color: #fff; font-weight: 600; }
.btn-danger:hover { background: #f05a5f; }

.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  padding: 6px 12px;
  border: 1px solid var(--rule-bright);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink-dim);
  font: 500 14px/1 var(--sans);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.chip:hover { color: var(--ink); border-color: var(--ink-faint); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #17120f; }
.chip-spike:hover { border-color: var(--v5); color: var(--v5); }

input[type="number"], select {
  padding: 7px 9px;
  border: 1px solid var(--rule-bright);
  border-radius: var(--radius);
  background: var(--ground);
  color: var(--ink);
  font: 500 15px/1 var(--sans);
  font-variant-numeric: tabular-nums;
}

select { width: 100%; }

.rate { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 11px; }

.rate-field { display: flex; flex-direction: column; gap: 5px; }
.rate-caption { color: var(--ink-dim); font-size: 13px; }

.rate-input-wrap { position: relative; display: inline-flex; align-items: center; }
.rate-input-wrap input { width: 108px; padding-right: 42px; }
.rate-suffix {
  position: absolute; right: 9px;
  color: var(--ink-faint); font-size: 13px; pointer-events: none;
}

.spike { margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--rule); }

/* --- Capacity ----------------------------------------------------------- */

.gauges { display: grid; gap: 13px; }

.gauge { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: 0 11px; align-items: baseline; }

.gauge-value { grid-row: 1 / 3; font: 700 32px/0.85 var(--cond); font-variant-numeric: tabular-nums; }
.gauge-name { color: var(--ink-dim); font-size: 13px; align-self: end; }

.spark { width: 100%; height: 28px; align-self: start; }
.spark-line { fill: none; stroke: var(--v1); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.spark-area { fill: color-mix(in srgb, var(--v1) 18%, transparent); }

/* Sync match is the signal Temporal actually scales workers on, so it is set
   apart from the three descriptive gauges above it. */
.gauge-primary { padding-top: 13px; border-top: 1px solid var(--rule); }
.gauge-primary .gauge-value { font-size: 38px; }

.gauge-unavailable .gauge-value { color: var(--ink-faint); }

.capacity-note { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--rule); color: var(--ink-faint); font-size: 12.5px; }

/* --- Rollout ------------------------------------------------------------ */

.rollout-head { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; margin-bottom: 12px; }
.rollout-target { font: 700 26px/1 var(--cond); }
.rollout-phase {
  padding: 3px 9px;
  border: 1px solid currentColor;
  border-radius: var(--radius);
  font: 600 13px/1.25 var(--sans);
}

.phase-ramping, .phase-promoting { color: var(--v3); }
.phase-gating { color: var(--v1); }
.phase-paused { color: var(--ink-dim); }
.phase-completed { color: var(--good); }
.phase-rolledback, .phase-gatefailed, .phase-aborted { color: var(--trouble); }

/* The stage plan is a real sequence, so it is drawn as one. */
.stages { display: flex; align-items: stretch; margin-bottom: 13px; }

.stage {
  flex: 1;
  min-width: 0;
  padding: 7px 4px 6px;
  border-top: 3px solid var(--rule);
  color: var(--ink-faint);
  text-align: center;
  font: 600 14px/1 var(--cond);
}

.stage-done { border-top-color: var(--ink-faint); color: var(--ink-dim); }
.stage-live { border-top-color: var(--v3); color: var(--v3); }
.stage-gate { flex: 0 0 62px; }

.stage-sub { display: block; margin-top: 3px; font: 400 11px/1 var(--sans); }

.rollout-message { margin: 0 0 12px; font-size: 14px; color: var(--ink-dim); }
.rollout-message-bad { color: var(--trouble); }

.rollout-stats { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 13px; }
.rollout-stat { display: flex; align-items: baseline; gap: 6px; }
.rollout-stat-value { font: 700 21px/1 var(--cond); }
.rollout-stat-name { color: var(--ink-dim); font-size: 12.5px; }
.rollout-stat-bad .rollout-stat-value { color: var(--trouble); }

.rollout-actions { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.rollout-jump { display: flex; gap: 6px; align-items: center; }
.rollout-jump input { width: 74px; }

.manual-flag { margin: 11px 0 0; color: var(--v3); font-size: 12.5px; }

/* --- Fault injection ---------------------------------------------------- */

.fault-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 9px; margin-bottom: 12px; }
.fault-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.fault-field-narrow { max-width: 118px; }
.fault-caption { color: var(--ink-dim); font-size: 12.5px; }
.fault-actions { display: flex; gap: 7px; }
.fault-active { margin: 11px 0 0; color: var(--trouble); font-size: 13px; font-weight: 500; }

/* --- Version rail ------------------------------------------------------- */

.rail { padding: var(--gap) 20px 0; }
.rail-heading { margin-bottom: 11px; }

.stations {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(212px, 1fr));
  gap: var(--gap);
}

.station {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  /* The version's identity, stated once and boldly. */
  border-top: 4px solid var(--version-color);
}

.station-trouble { border-color: var(--trouble); }

.station-head { padding: 12px 13px 10px; }

.station-name-row { display: flex; align-items: baseline; gap: 9px; }

.station-name {
  font: 700 27px/1 var(--cond);
  color: var(--version-color);
}

.station-role { font: 600 12.5px/1.3 var(--sans); color: var(--ink-dim); }
.station-role-current { color: var(--ink); }
.station-role-ramping { color: var(--v3); }
.station-role-draining { color: var(--ink-faint); }

.station-share { display: flex; align-items: baseline; gap: 6px; margin-top: 9px; }
.station-share-value { font: 700 23px/1 var(--cond); }
.station-share-name { color: var(--ink-dim); font-size: 12.5px; }

.station-counts { display: flex; gap: 14px; margin-top: 8px; font-size: 12.5px; color: var(--ink-dim); }
.station-counts b { color: var(--ink); font-weight: 600; }
.station-stuck { color: var(--trouble); }
.station-stuck b { color: var(--trouble); }

/* The pipeline as a ladder: rung count makes the shape difference obvious. */
.ladder { list-style: none; margin: 0; padding: 11px 13px 12px; border-top: 1px solid var(--rule); }

.rung {
  position: relative;
  padding: 0 0 0 16px;
  color: var(--ink-dim);
  font-size: 13px;
  line-height: 1.75;
}

.rung::before {
  content: "";
  position: absolute;
  left: 3px; top: 9px;
  width: 6px; height: 6px;
  background: var(--version-color);
}

/* Steps this version added relative to the current one. */
.rung-new { color: var(--ink); font-weight: 600; }
.rung-new::before { width: 8px; height: 8px; left: 2px; top: 8px; }

.station-foot { margin-top: auto; padding: 11px 13px 13px; border-top: 1px solid var(--rule); display: flex; flex-wrap: wrap; gap: 6px; }

/* --- Order tickets ------------------------------------------------------ */

.tickets-section { padding: var(--gap) 20px 0; }
.tickets-count { margin-left: 9px; color: var(--ink-faint); font: 400 13px/1 var(--sans); }

.tickets { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 8px; }

.ticket {
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--version-color);
  border-radius: var(--radius);
}

.ticket-stuck { border-color: var(--trouble); border-left-color: var(--trouble); }
.ticket-done { opacity: 0.55; }

.ticket-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.ticket-id { font-size: 12.5px; color: var(--ink-dim); }
.ticket-version { font: 700 15px/1 var(--cond); color: var(--version-color); }
.ticket-step { margin-top: 3px; font-size: 13.5px; font-weight: 500; }
.ticket-stuck .ticket-step { color: var(--trouble); }
.ticket-age { margin-top: 2px; font-size: 12px; color: var(--ink-faint); }

/* --- Toasts ------------------------------------------------------------- */

.toasts {
  position: fixed;
  bottom: 16px; right: 16px;
  display: flex; flex-direction: column; gap: 8px;
  max-width: min(420px, calc(100vw - 32px));
  z-index: 10;
}

.toast {
  padding: 10px 13px;
  background: var(--panel-raised);
  border: 1px solid var(--rule-bright);
  border-left: 3px solid var(--good);
  border-radius: var(--radius);
  font-size: 13.5px;
}

.toast-error { border-left-color: var(--trouble); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@media (max-width: 640px) {
  .topbar { gap: 14px; }
  .readouts { gap: 18px; width: 100%; margin-left: 0; }
  .split, .grid, .rail, .tickets-section { padding-left: 16px; padding-right: 16px; }
  .readout-value { font-size: 25px; }
}
