/* ==========================================================================
   Base — what every page of the panel shares.

   The design tokens, the reset and base elements, panels, lamps, buttons and the guarded
   control, notices and toasts, and the sign-in page. Sign-in and the error page load only
   this; the console pages load console.css after it.
   ========================================================================== */

:root {
  /* Chassis */
  --steel-950: #101316;
  --steel-900: #15181b;
  --steel-850: #191d21;
  --steel-825: #1b2024;
  --steel-800: #1e2226;
  --steel-750: #23282d;
  --steel-700: #282e33;
  --steel-650: #2f353b;
  --steel-600: #373e45;
  --steel-500: #454e56;
  --steel-450: #525c65;

  /* The edge of a control a hand can operate — field, radio, switch track, chip. The recessed
     well is about 1.1:1 against the panel, so this edge is the only sign the control exists:
     3.06:1 on steel-700 up to 3.96:1 on steel-900, where steel-450 managed 2.2-2.6:1. Dividers
     and panel borders keep the steel steps; hover and focus only ever brighten past this. */
  --edge-control: #6e7882;

  /* Ink */
  --ink-bright: #f0f4f6;
  --ink: #ced5da;
  --ink-muted: #a3adb5;
  --ink-dim: #8b959d;

  /* State roles */
  --signal: #4cc487;
  --signal-ink: #82e2b0;
  --signal-deep: #1c3a2b;

  --amber: #e2a63c;
  --amber-ink: #f2c065;
  --amber-deep: #43320f;

  --crimson: #d9483f;
  --crimson-ink: #ff8e84;
  --crimson-deep: #401815;
  /* Console colours the palette has no role for: ANSI black, blue, magenta and cyan. */
  --ansi-black: #8b959d;
  --ansi-blue: #8fb8ff;
  --ansi-magenta: #d9a6ff;
  --ansi-cyan: #7fdce8;
  /* Chart series: the data-viz categorical slots in their fixed order, stepped for the dark
     chart well (steel-900) and validated together against it: OKLCH lightness 0.48 to 0.67,
     chroma of at least 0.10, neighbours apart under protanopia and deuteranopia (worst 8.4) and
     to full colour vision (worst 19.3), and 3:1 against the well. Slot 0 is "Other". */
  --chart-series-0: #6e7882;
  --chart-series-1: #3987e5;
  --chart-series-2: #d95926;
  --chart-series-3: #199e70;
  --chart-series-4: #c98500;
  --chart-series-5: #d55181;
  --chart-series-6: #008300;

  /* Control faces. These hold the exact values the faces were tuned to, including the
     near-duplicate stops, so naming them changes nothing on screen. The label inks are the
     DESIGN.md button-text colours, measured against the dark end of each face. */
  --chassis-glow: #22282e;
  --button-primary-text: #241a05;
  --button-danger-text: #190604;
  --amber-face-hi: #eeb352;
  --amber-hover-hi: #f5be62;
  --amber-hover-lo: #e7ad46;
  --amber-lever-hi: #efb655;
  --amber-well-hi: #3f2f0e;
  --amber-well-lo: #35270c;
  --amber-mark-lo: #9a6d18;
  --crimson-face-hi: #e05a50;
  --crimson-hover-hi: #e96a60;
  --crimson-hover-lo: #d64f45;

  /* Type */
  --sans: ui-sans-serif, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono:
    ui-monospace, 'Cascadia Mono', SFMono-Regular, 'SF Mono', Consolas, 'Liberation Mono', monospace;

  /* Geometry. --radius-sm is DESIGN.md's indicator corner: tags, chips, switch levers. */
  --radius-sm: 2px;
  --radius: 3px;
  --radius-md: 4px;
  --radius-lg: 5px;
  --rail-width: 236px;
  --shell-max: 1440px;
  --masthead-height: calc(56px + env(safe-area-inset-top, 0px));

  /* Spacing, DESIGN.md's scale by the same names. --space-xl is the 22px vertical rhythm views
     keep between sections; tight inside one instrument, wider when the task changes. */
  --space-xs: 6px;
  --space-sm: 10px;
  --space-md: 14px;
  --space-lg: 18px;
  --space-xl: 22px;
  --space-2xl: 26px;

  /* Depth. The alpha steps every shadow and wash is built from, then DESIGN.md's four shadow
     layers by name and the lift an overlay needs over the page. Nothing outside :root writes
     an rgba() of its own. */
  --light-faint: rgba(255, 255, 255, 0.03);
  --light-edge: rgba(255, 255, 255, 0.055);
  --light-raised: rgba(255, 255, 255, 0.09);
  --light-strong: rgba(255, 255, 255, 0.14);
  --light-glint: rgba(255, 255, 255, 0.3);
  --shade-seam: rgba(0, 0, 0, 0.35);
  --shade-contact: rgba(0, 0, 0, 0.4);
  --shade-well: rgba(0, 0, 0, 0.45);
  --shade-strong: rgba(0, 0, 0, 0.55);
  --shade-deep: rgba(0, 0, 0, 0.85);
  --shade-drop: rgba(0, 0, 0, 0.9);
  --shadow-inset-panel: inset 0 1px 0 var(--light-edge), inset 0 -1px 0 var(--shade-seam);
  --shadow-contact: 0 2px 5px var(--shade-contact);
  --shadow-ambient: 0 10px 24px -14px var(--shade-deep);
  --shadow-recessed: inset 0 2px 4px var(--shade-well);
  --shadow-overlay: 0 18px 48px -20px var(--shade-deep);

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --fast: 120ms;
  --medium: 260ms;
  --cover: 620ms;
  --travel: 420ms;
}

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

/* Focus and reveal scrolling stop short of the sticky masthead instead of leaving the target
   under it (WCAG 2.4.11). Per-target scroll-margin adds to this, so reveals only add the
   breathing room they want beyond it. */
html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--masthead-height) + 16px);
}

/* The same at the bottom while a sticky action bar is on the page: the clean staff footer,
   the staff change bar and the presence change bar, each measured plus 16px. */
html:has(.staff-rack__footer) {
  scroll-padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
}

html:has(.staff-changebar),
html:has(.presence-bar),
html:has(.module-bar:not([hidden])) {
  scroll-padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(120% 80% at 50% -10%, var(--chassis-glow) 0%, transparent 62%), var(--steel-850);
  color: var(--ink);
  font-family: var(--sans);
  /* 15px at the default size, and it follows the reader's own default like the rest of the
     scale; a fixed 15px left body copy behind when controls grew. */
  font-size: 0.9375rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  color: var(--ink-bright);
  font-weight: 600;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

h1 {
  font-size: clamp(1.5rem, 1.2rem + 1.1vw, 2rem);
}
h2 {
  font-size: 1.125rem;
}
h3 {
  font-size: 0.9375rem;
}

p {
  margin: 0;
}

a {
  color: var(--amber-ink);
  text-decoration-color: color-mix(in srgb, var(--amber-ink) 40%, transparent);
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-color: currentColor;
}

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

/* Zero specificity: the corner is for links and bare targets. At (0,1,0) it beat the type-only
   select and textarea rules, so a field changed from 3px to 2px corners on keyboard focus. */
:where(:focus-visible) {
  border-radius: var(--radius-sm);
}

/* These controls fill an ancestor that clips its overflow edge to edge — the rail, the
   scrolling grids and tab shelf, the review and reset disclosures, the picker chip — so a ring
   drawn outside them was cut to fragments, or to nothing on a closed review summary. The ring
   is drawn inside instead; the global rule above still supplies its colour and weight. */
.rail__link:focus-visible,
.rail__scroll:focus-visible,
tbody tr.row--selectable:focus-visible,
.staff-review-role > summary:focus-visible,
.staff-review__body:focus-visible,
.case-action > summary:focus-visible,
.settings-reset-review__section > summary:focus-visible,
.search-picker__remove:focus-visible {
  outline-offset: -2px;
}

::selection {
  background: color-mix(in srgb, var(--amber) 35%, transparent);
  color: var(--ink-bright);
}

/* Native radio circles look like foreign browser chrome in this hardware surface. Keep the
   native input and its keyboard behavior, but render it as the same square contact used by
   the console's other selectors. */
input[type='radio'] {
  --choice-accent: var(--amber);
  --choice-deep: var(--amber-deep);
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  margin: 0;
  border: 1px solid var(--edge-control);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--steel-900) 0%, var(--steel-850) 100%);
  box-shadow: inset 0 2px 4px var(--shade-strong);
  cursor: pointer;
  transition:
    border-color var(--fast) ease,
    background var(--fast) ease,
    box-shadow var(--fast) ease;
}

input[type='radio']:hover:not(:disabled) {
  border-color: var(--ink-dim);
}

input[type='radio']:checked {
  border-color: color-mix(in srgb, var(--choice-accent) 62%, transparent);
  background:
    linear-gradient(var(--choice-accent), var(--choice-accent)) center / 8px 8px no-repeat,
    linear-gradient(
      180deg,
      color-mix(in srgb, var(--choice-deep) 82%, white) 0%,
      var(--choice-deep) 100%
    );
  box-shadow:
    inset 0 1px 0 var(--light-raised),
    0 1px 2px var(--shade-contact);
}

input[type='radio']:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

input[type='radio']:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

/* A native checkbox ignores border-color, so the field focus rule left it only a faint 28%
   halo. Outranking `input:focus` here, rather than rescoping that rule with :not(), keeps the
   field rule at a specificity that component focus styles can still override. */
input[type='checkbox']:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Primitives
   -------------------------------------------------------------------------- */

.data {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'zero' 1;
  letter-spacing: -0.01em;
}

.hidden,
[hidden] {
  display: none !important;
}

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

/* A skip link that stays clipped while focused is a first Tab that appears to land on
   nothing. When it takes focus it becomes a real control on the chassis. */
a.visually-hidden:focus {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 80;
  width: auto;
  height: auto;
  margin: 0;
  padding: 9px 14px;
  overflow: visible;
  clip-path: none;
  border: 1px solid var(--amber);
  border-radius: var(--radius);
  background: var(--steel-800);
  box-shadow: 0 6px 18px -6px var(--shade-drop);
  color: var(--ink-bright);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
}

/* Panels sit into the chassis: dark seam below, work light catching the top edge. */
.panel {
  position: relative;
  background: linear-gradient(180deg, var(--steel-750) 0%, var(--steel-800) 100%);
  border: 1px solid var(--steel-600);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-inset-panel), var(--shadow-contact), var(--shadow-ambient);
}

/* The meta drops under the title when one row cannot hold both, rather than squeezing the
   stamped title beside a search field or a pair of long buttons on a small phone. */
.panel__strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 18px;
  background: linear-gradient(180deg, var(--steel-700) 0%, var(--steel-750) 100%);
  border-bottom: 1px solid var(--steel-600);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.panel__strip h2,
.panel__strip h3,
.panel__strip-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.panel__strip-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-inline-start: auto;
}

.panel__body {
  padding: 20px 18px;
}

.panel__body--flush {
  padding: 0;
}

/* --------------------------------------------------------------------------
   Readouts and indicators
   -------------------------------------------------------------------------- */

.readout {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.readout__label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.readout__value {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.0625rem;
  color: var(--ink-bright);
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}

.readout__value--lg {
  font-size: 1.5rem;
}
.readout__value--sm {
  font-size: 0.875rem;
}
.readout__note {
  font-size: 0.75rem;
  color: var(--ink-dim);
}

.readout--nominal .readout__value {
  color: var(--signal-ink);
}
.readout--attention .readout__value {
  color: var(--amber-ink);
}
.readout--fault .readout__value {
  color: var(--crimson-ink);
}

.readouts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 22px 26px;
}

/* An LED never carries meaning alone — it always sits beside its label. */
.led {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--ink-muted);
  white-space: nowrap;
}

.led::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--steel-500);
  box-shadow: inset 0 0 0 1px var(--shade-strong);
  flex: none;
}

.led--nominal::before {
  background: var(--signal);
  box-shadow:
    inset 0 0 0 1px var(--shade-well),
    0 0 7px color-mix(in srgb, var(--signal) 60%, transparent);
}

.led--attention::before {
  background: var(--amber);
  box-shadow:
    inset 0 0 0 1px var(--shade-well),
    0 0 7px color-mix(in srgb, var(--amber) 60%, transparent);
}

.led--fault::before {
  background: var(--crimson);
  box-shadow:
    inset 0 0 0 1px var(--shade-well),
    0 0 7px color-mix(in srgb, var(--crimson) 65%, transparent);
}

.led--live::before {
  animation: pulse 1.9s var(--ease-out) infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border: 1px solid var(--steel-500);
  border-radius: var(--radius-sm);
  background: var(--steel-800);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  white-space: nowrap;
}

/* Attention is the amber state of the three lamps — pending, partial, quarantined, stale — so
   it is stamped like the other two states rather than left as grey metadata beside them. */
.tag--primary,
.tag--attention {
  border-color: color-mix(in srgb, var(--amber) 55%, transparent);
  background: var(--amber-deep);
  color: var(--amber-ink);
}

.tag--owner {
  border-color: var(--steel-450);
  background: var(--steel-700);
  color: var(--ink-bright);
}

.tag--fault {
  border-color: color-mix(in srgb, var(--crimson) 55%, transparent);
  background: var(--crimson-deep);
  color: var(--crimson-ink);
}

.tag--nominal {
  border-color: color-mix(in srgb, var(--signal) 45%, transparent);
  background: var(--signal-deep);
  color: var(--signal-ink);
}

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

.button {
  --busy-ink: var(--ink-bright);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  padding: 8px 14px;
  /* A control's edge, 3:1 or better against every chassis step (steel-500 was 1.89:1). */
  border: 1px solid var(--edge-control);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--steel-650) 0%, var(--steel-700) 100%);
  box-shadow:
    inset 0 1px 0 var(--light-raised),
    0 1px 2px var(--shade-contact);
  color: var(--ink-bright);
  font-family: var(--sans);
  font-size: 0.8125rem;
  font-weight: 600;
  /* A <button> gets `normal` from the browser while <a class="button"> inherited the body's
     1.55, which made link buttons 3px taller than the buttons beside them. */
  line-height: normal;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition:
    background var(--fast) ease,
    border-color var(--fast) ease,
    transform var(--fast) ease;
}

.button:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--steel-600) 0%, var(--steel-650) 100%);
  /* Brighter than the resting --edge-control, as hover and focus only ever are. */
  border-color: var(--ink-dim);
}

.button:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: inset 0 2px 4px var(--shade-strong);
}

.button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.button--primary {
  --busy-ink: var(--button-primary-text);
  border-color: color-mix(in srgb, var(--amber) 70%, black);
  background: linear-gradient(180deg, var(--amber-face-hi) 0%, var(--amber) 100%);
  color: var(--button-primary-text);
  box-shadow:
    inset 0 1px 0 var(--light-glint),
    0 1px 3px var(--shade-well);
}

.button--primary:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--amber-hover-hi) 0%, var(--amber-hover-lo) 100%);
  border-color: color-mix(in srgb, var(--amber) 85%, black);
}

/* The label is measured against the dark end of its own gradient, not the light end: at
   #2a0d0b on flat crimson it read 4.26:1, so the bottom half of the most consequential
   label in the product sat below AA. */
.button--danger {
  --busy-ink: var(--button-danger-text);
  border-color: color-mix(in srgb, var(--crimson) 65%, black);
  background: linear-gradient(
    180deg,
    var(--crimson-face-hi) 0%,
    color-mix(in srgb, var(--crimson) 92%, white) 100%
  );
  color: var(--button-danger-text);
  box-shadow:
    inset 0 1px 0 var(--light-glint),
    0 1px 3px var(--shade-well);
}

.button--danger:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--crimson-hover-hi) 0%, var(--crimson-hover-lo) 100%);
}

.button--danger-quiet {
  border-color: color-mix(in srgb, var(--crimson) 42%, var(--steel-600));
  background: color-mix(in srgb, var(--crimson-deep) 52%, var(--steel-800));
  box-shadow: none;
  color: var(--crimson-ink);
}

.button--danger-quiet:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--crimson) 68%, var(--steel-500));
  background: color-mix(in srgb, var(--crimson-deep) 76%, var(--steel-750));
}

.button--quiet {
  background: transparent;
  border-color: transparent;
  color: var(--ink-muted);
  box-shadow: none;
}

.button--quiet:hover:not(:disabled) {
  background: var(--steel-750);
  border-color: var(--steel-600);
  color: var(--ink-bright);
}

.button--sm {
  min-height: 34px;
  padding: 5px 10px;
  font-size: 0.75rem;
}

.button[aria-busy='true'] {
  color: transparent;
  position: relative;
  pointer-events: none;
}

/* busy() disables the control too, and the disabled fade stacked on the hidden label left a
   blank, faded face indistinguishable from an unavailable button. A busy button keeps full
   strength; pointer-events already refuses a second press. */
.button[aria-busy='true']:disabled {
  opacity: 1;
}

/* The arc is drawn in each variant's own label ink: ink-bright on the amber face read 1.95:1. */
.button[aria-busy='true']::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 13px;
  height: 13px;
  border: 2px solid color-mix(in srgb, var(--busy-ink) 28%, transparent);
  border-top-color: var(--busy-ink);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Throw switch: a lever that physically travels across a lit track. */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

/* The real checkbox stays in the accessibility tree and keeps keyboard focus; the lever is
   what a sighted operator sees move. */
.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.switch__track {
  position: relative;
  width: 52px;
  height: 26px;
  flex: none;
  border: 1px solid var(--edge-control);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--steel-900) 0%, var(--steel-850) 100%);
  box-shadow: inset 0 2px 4px var(--shade-strong);
  transition:
    background var(--fast) ease,
    border-color var(--fast) ease;
}

.switch__track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 20px;
  border: 1px solid var(--steel-500);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--steel-600) 0%, var(--steel-700) 100%);
  box-shadow:
    inset 0 1px 0 var(--light-strong),
    0 1px 3px var(--shade-strong);
  transition:
    transform var(--medium) var(--ease-out),
    background var(--fast) ease;
}

.switch input:checked + .switch__track {
  background: linear-gradient(180deg, var(--amber-deep) 0%, var(--amber-well-lo) 100%);
  border-color: color-mix(in srgb, var(--amber) 45%, var(--steel-600));
}

.switch input:checked + .switch__track::after {
  transform: translateX(24px);
  background: linear-gradient(180deg, var(--amber-lever-hi) 0%, var(--amber) 100%);
  border-color: color-mix(in srgb, var(--amber) 70%, black);
}

.switch input:focus-visible + .switch__track {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.switch input:disabled + .switch__track {
  opacity: 0.42;
  cursor: not-allowed;
}

.switch__label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-dim);
  min-width: 3.5em;
}

.switch input:checked ~ .switch__label {
  color: var(--amber-ink);
}

/* Guarded control: the cover must be lifted before the control underneath is live.
   This is the panel's one authored motion, and it mirrors the bot's own two-step
   confirmation rather than decorating over it. */
.guard {
  padding: 14px;
  border: 1px solid var(--steel-600);
  border-radius: var(--radius);
  background: var(--steel-850);
  box-shadow: inset 0 2px 6px var(--shade-well);
}

/* The consequence sits above the cover and stays readable at rest. Hiding the explanation
   behind the lid that the explanation justifies is the one thing this control must not do. */
.guard__brief {
  margin-bottom: 13px;
  max-width: 58ch;
  font-size: 0.75rem;
  color: var(--ink-muted);
}

/* Only the control is covered. */
.guard__stage {
  position: relative;
  padding: 5px 0;
  perspective: 900px;
}

/* The stage is a programmatic focus target rather than a control, so a mouse operator who
   lifts the cover should not be handed a ring. A keyboard operator must be: focus lands
   here and not on the trigger, and without a marker the console would go quiet at exactly
   the moment the most consequential control in the product became live. */
.guard__stage:focus {
  outline: none;
}

.guard__stage:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.guard__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  opacity: 0.25;
  filter: saturate(0.2);
  transition:
    opacity var(--medium) var(--ease-out) 160ms,
    filter var(--medium) var(--ease-out) 160ms;
}

.guard__cover {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid color-mix(in srgb, var(--crimson) 40%, var(--steel-500));
  border-radius: var(--radius);
  background:
    repeating-linear-gradient(
      -45deg,
      color-mix(in srgb, var(--crimson) 16%, transparent) 0 10px,
      transparent 10px 20px
    ),
    linear-gradient(180deg, var(--steel-700) 0%, var(--steel-800) 100%);
  box-shadow:
    inset 0 1px 0 var(--light-raised),
    0 4px 12px -4px var(--shade-deep);
  color: var(--crimson-ink);
  font-family: var(--sans);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  cursor: pointer;
  transform-origin: top center;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  /* Closing reveals the lid immediately while it is still edge-on. Opening overrides the
     opacity delay below so the face remains visible for the complete trip to 90 degrees.
     Linear travel avoids an ease-out tail that makes the lid look parked before the cutoff. */
  transition:
    transform var(--cover) linear,
    opacity 0s linear;
}

.guard__cover:hover {
  border-color: color-mix(in srgb, var(--crimson) 70%, var(--steel-500));
}

/* A cover that cannot be lifted at all: the control is not yours, so it reads as inert
   metal rather than as something you failed to operate. */
.guard__cover--disabled {
  background: linear-gradient(180deg, var(--steel-750) 0%, var(--steel-800) 100%);
  border-color: var(--steel-600);
  color: var(--ink-dim);
  cursor: not-allowed;
}

.guard__cover--disabled:hover {
  border-color: var(--steel-600);
}

/* The restoring direction. Still a cover — everyone in the server feels it either way —
   but it does not wear hazard stripes, because putting the lights back on is not the same
   act as turning them off. */
.guard__cover--safe {
  background: linear-gradient(180deg, var(--steel-700) 0%, var(--steel-800) 100%);
  border-color: color-mix(in srgb, var(--signal) 35%, var(--steel-500));
  color: var(--signal-ink);
}

.guard__cover--safe:hover {
  border-color: color-mix(in srgb, var(--signal) 60%, var(--steel-500));
}

.guard--open .guard__cover {
  transform: rotateX(-90deg);
  opacity: 0;
  /* At 90 degrees the lid has no visible face, making this discrete cutoff seamless.
     Stopping there also guarantees that the back face can never read as upside down. */
  transition-delay: 0s, var(--cover);
  pointer-events: none;
}

.guard--open .guard__inner {
  opacity: 1;
  filter: none;
}

/* --------------------------------------------------------------------------
   Feedback: empty, error, loading, toast
   -------------------------------------------------------------------------- */

.empty {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 52px 24px;
  text-align: center;
}

.empty__title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--ink-bright);
}

.empty__body {
  font-size: 0.875rem;
  color: var(--ink-muted);
  max-width: 46ch;
}

/* The message is a flex item whose minimum is its longest unbreakable run, so a URL, hash or
   long server message widened the page at phone widths. Breaking anywhere lowers that minimum. */
.notice {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 12px 15px;
  border: 1px solid var(--steel-600);
  border-radius: var(--radius);
  background: var(--steel-850);
  font-size: 0.8125rem;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.notice > * {
  min-width: 0;
}

/* The sign-in page's server-rendered error is the same fault notice, at its own padding. */
.notice--fault,
.login-error {
  border-color: color-mix(in srgb, var(--crimson) 45%, transparent);
  background: var(--crimson-deep);
  color: var(--crimson-ink);
}

.notice--attention {
  border-color: color-mix(in srgb, var(--amber) 45%, transparent);
  background: var(--amber-deep);
  color: var(--amber-ink);
}

.notice--nominal {
  border-color: color-mix(in srgb, var(--signal) 40%, transparent);
  background: var(--signal-deep);
  color: var(--signal-ink);
}

.skeleton {
  display: grid;
  gap: 10px;
  padding: 20px 18px;
}

.skeleton--compact {
  gap: 8px;
  padding: 12px 14px;
}

.skeleton--compact .skeleton__bar {
  height: 10px;
}

.skeleton__bar {
  height: 12px;
  border-radius: var(--radius-sm);
  background: linear-gradient(
    90deg,
    var(--steel-750) 0%,
    var(--steel-700) 50%,
    var(--steel-750) 100%
  );
  background-size: 200% 100%;
  animation: sweep 1.4s linear infinite;
}

.skeleton__bar:nth-child(1) {
  width: 40%;
}
.skeleton__bar:nth-child(2) {
  width: 76%;
}
.skeleton__bar:nth-child(3) {
  width: 58%;
}

@keyframes sweep {
  from {
    background-position: 160% 0;
  }
  to {
    background-position: -60% 0;
  }
}

/* Faults accumulate rather than expiring, so the tray is bounded and scrolls instead of
   growing up the screen and covering the console it is reporting on. It is auto-height and
   anchored to the bottom, so it needs no end alignment; that alignment only acted once the
   tray overflowed, and then it pushed the oldest faults into space no scroll could reach. */
/* --dock-clearance is the height of a docked action bar while one is on the page, published by
   trackDockClearance() in components.mjs. The tray stands on the bar rather than covering its
   Save and Review buttons, and gives up that much height, so a tall phone bar cannot push the
   tray up under the masthead. The first max-height is for engines without dvh units. */
.toast-tray {
  position: fixed;
  right: max(clamp(12px, 3vw, 28px), env(safe-area-inset-right, 0px));
  bottom: calc(
    max(clamp(12px, 3vw, 28px), env(safe-area-inset-bottom, 0px)) + var(--dock-clearance, 0px)
  );
  z-index: 60;
  display: grid;
  gap: 9px;
  width: min(360px, calc(100vw - 24px));
  max-height: min(60vh, 520px);
  max-height: min(
    60dvh,
    520px,
    calc(100dvh - var(--masthead-height) - var(--dock-clearance, 0px) - 40px)
  );
  overflow-y: auto;
  scrollbar-width: thin;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--steel-500);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--steel-700) 0%, var(--steel-750) 100%);
  box-shadow: 0 8px 22px -10px var(--shade-drop);
  font-size: 0.8125rem;
  color: var(--ink);
  animation: toast-in var(--medium) var(--ease-out);
}

.toast--fault {
  border-color: color-mix(in srgb, var(--crimson) 55%, transparent);
  color: var(--crimson-ink);
}
.toast--nominal {
  border-color: color-mix(in srgb, var(--signal) 45%, transparent);
  color: var(--signal-ink);
}
.toast--attention {
  border-color: color-mix(in srgb, var(--amber) 50%, transparent);
  color: var(--amber-ink);
}

.toast__message {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* A toast that carries its way forward, such as Sign in again, stacks it under the message:
   beside it, on a phone-width tray, the link squeezed the sentence into a column of words. */
.toast__body {
  display: grid;
  flex: 1;
  gap: 9px;
  justify-items: start;
  min-width: 0;
}

/* Faults stay until they are dismissed, so they need a way out. */
.toast__close {
  flex: none;
  width: 22px;
  height: 22px;
  margin: -2px -3px 0 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition:
    background var(--fast) ease,
    border-color var(--fast) ease;
}

.toast__close:hover {
  border-color: currentColor;
  background: color-mix(in srgb, var(--steel-900) 72%, transparent);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* --------------------------------------------------------------------------
   Login
   -------------------------------------------------------------------------- */

/* Centred in the visible viewport: 100vh is the large viewport in mobile Safari, so with the
   toolbar showing the panel sat low and the page scrolled. 100vh stays as the fallback. */
.login {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 32px 20px;
}

.login__panel {
  width: min(430px, 100%);
}

.login__body {
  display: grid;
  gap: 18px;
  padding: 30px 28px 28px;
}

.login__title {
  font-size: clamp(1.5rem, 1.2rem + 1.1vw, 2rem);
}

.login__lead {
  color: var(--ink-muted);
  font-size: 0.875rem;
  max-width: 46ch;
}

.login__form {
  display: grid;
  gap: 10px;
}

/* Its colours come from .notice--fault. Width and style only, because a border shorthand
   here, later in the file, would reset that border colour to the text colour. */
.login-error {
  padding: 10px 13px;
  border-width: 1px;
  border-style: solid;
  border-radius: var(--radius);
  font-size: 0.8125rem;
}

/* --ink-dim is tuned for the chassis from steel-950 to steel-700. On the deep state wells and
   the raised steel-650 it fell to about 4.05:1, so anything dim inside one reads in the muted
   ink instead (4.5:1 or better). */
.tag--primary,
.tag--attention,
.tag--fault,
.tag--nominal,
.notice--fault,
.notice--attention,
.notice--nominal,
.login-error {
  --ink-dim: var(--ink-muted);
}

@media (max-width: 620px) {
  .panel__body {
    padding: 16px 14px;
  }
}

@media (pointer: coarse) {
  /* Every page's own controls reach 44px on a touch screen. The console's further controls
     are listed in console.css. */
  .button,
  .button--sm,
  .switch,
  .toast__close {
    min-height: 44px;
  }

  input[type='text'],
  input[type='number'],
  input[type='search'],
  input[type='url'],
  input[type='password'],
  input[type='datetime-local'],
  input:not([type]),
  select,
  textarea {
    min-height: 44px;
  }

  .button--sm {
    padding-inline: 12px;
  }

  .switch {
    padding-block: 9px;
  }

  .toast__close {
    width: 44px;
    height: 44px;
    margin: -10px -10px -10px 0;
  }
}

@media (forced-colors: active) {
  /* A lamp's dot is its background and halo, both of which forced colours remove; it keeps its
     own colours here so the lamp still lights beside its word. */
  .led::before {
    forced-color-adjust: none;
  }

  /* The square radio draws its checked dot with a gradient; the native control draws its own
     state in system colours, including in the destructive scope choice. */
  input[type='radio'] {
    appearance: auto;
  }

  /* A focused field's ring is a border colour and a halo; forced colours keep neither. */
  input:focus,
  select:focus,
  textarea:focus {
    outline: 2px solid Highlight;
    outline-offset: 1px;
  }
}

@media (prefers-reduced-motion: reduce) {
  /* Delays have to go with the durations. The cover's opacity waits for its travel to
     finish, so collapsing only the duration would leave the lid stalled before vanishing. */
  *,
  *::before,
  *::after {
    animation-delay: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-delay: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .guard--open .guard__cover {
    transform: none;
    opacity: 0;
  }
}
