/* iR3 Unit Maintenance
   Cool slate workshop palette. Livery yellow and blue appear only in the check strip under
   the header; status colours are reserved for unit state (lamps, pills). */

:root {
  --ink: #18222e;
  --ink-soft: #4d5b6b;
  --paper: #e9edf1;
  --panel: #ffffff;
  --rule: #cdd5de;
  --bar: #1f2d3b;
  --bar-ink: #e6ecf2;
  --action: #1f4fa3;
  --action-ink: #ffffff;
  --livery-yellow: #f2c200;
  --livery-blue: #1f4fa3;
  --lamp-on: #29b33f;
  --lamp-off: #c3ccd6;
  --ok: #1d7a33;
  --ok-bg: #e2f3e5;
  --warn: #8a5a00;
  --warn-bg: #fdf1d3;
  --bad: #a42424;
  --bad-bg: #fbe4e4;
  --focus: #f2c200;

  --font-display: Bahnschrift, "DIN Alternate", "Roboto Condensed", "Arial Narrow", sans-serif;
  --font-body: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: Consolas, "Cascadia Mono", ui-monospace, monospace;

  --radius: 6px;
  --gutter: 24px;
  color-scheme: light;
}
/* Older browsers (before iOS 13.4) don't understand clamp() and would drop the gutter altogether. */
@supports (width: clamp(1px, 2px, 3px)) {
  :root { --gutter: clamp(16px, 3vw, 32px); }
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e3e9ef;
    --ink-soft: #9aa8b6;
    --paper: #111820;
    --panel: #1a232d;
    --rule: #2f3b48;
    --bar: #0b1118;
    --action: #5b8de0;
    --lamp-off: #3a4653;
    --ok: #7fd18f;
    --ok-bg: #173323;
    --warn: #f0c060;
    --warn-bg: #3a2e10;
    --bad: #f08a8a;
    --bad-bg: #3d1a1a;
    color-scheme: dark;
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 var(--font-body);
}

h1, h2 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  margin: 0 0 0.5em;
}
h1 { font-size: 1.9rem; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; }

a { color: var(--action); }
a:hover { text-decoration-thickness: 2px; }

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

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Header ---------- */

.topbar { background: var(--bar); color: var(--bar-ink); }

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--gutter);
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
}

.wordmark {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--livery-yellow);
  text-decoration: none;
  white-space: nowrap;
}
.wordmark span { color: var(--bar-ink); font-weight: 400; }

.nav { display: flex; gap: 4px; flex-wrap: wrap; }

.nav-link {
  color: var(--bar-ink);
  text-decoration: none;
  padding: 16px 12px 13px;
  border-bottom: 3px solid transparent;
}
.nav-link:hover { border-bottom-color: #4d6075; }
.nav-link.is-current { border-bottom-color: var(--livery-yellow); }

.signout { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.signout .user { opacity: 0.75; }
.signout .btn-link { color: var(--bar-ink); }

/* Battenburg-style livery strip: the one decorative element on the site. */
.livery {
  height: 12px;
  /* Two rows of linear gradients for older browsers (conic-gradient needs iOS 12.2). */
  background:
    linear-gradient(90deg, var(--livery-yellow) 50%, var(--livery-blue) 50%) 0 0 / 48px 6px repeat-x,
    linear-gradient(90deg, var(--livery-blue) 50%, var(--livery-yellow) 50%) 0 6px / 48px 6px repeat-x;
}
@supports (background: conic-gradient(red, blue)) {
  .livery {
    background:
      conic-gradient(var(--livery-yellow) 25%, var(--livery-blue) 0 50%, var(--livery-yellow) 0 75%, var(--livery-blue) 0)
      0 0 / 48px 12px;
  }
}

/* ---------- Layout ---------- */

.page {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px var(--gutter) 48px;
}

.footer {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 12px var(--gutter) 20px;
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-head h1 { margin: 0; }

.panel {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.panel-head h2 { margin: 0; }

.lede { color: var(--ink-soft); margin: 0 0 20px; max-width: 60ch; }
.empty { color: var(--ink-soft); margin: 0; max-width: 70ch; }

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

input {
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid #9eabb9;
  border-radius: var(--radius);
  padding: 9px 11px;
  min-width: 0;
}
input:focus-visible { outline-offset: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  padding: 10px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--rule);
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--ink-soft); }

.btn-primary {
  background: var(--action);
  border-color: var(--action);
  color: var(--action-ink);
}
.btn-primary:hover { filter: brightness(1.1); border-color: var(--action); }

.btn-link {
  font: inherit;
  background: none;
  border: 0;
  padding: 0;
  color: var(--action);
  text-decoration: underline;
  cursor: pointer;
}

.stack { display: grid; gap: 16px; }

.field { display: grid; gap: 6px; }
.field span { font-weight: 600; }

.alert {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 0 0 20px;
  border-left: 4px solid;
  max-width: 80ch;
}
.alert-error { background: var(--bad-bg); color: var(--bad); }
.alert-ok { background: var(--ok-bg); color: var(--ok); }

/* ---------- Sign in ---------- */

.signin {
  max-width: 380px;
  margin: 6vh auto 0;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 28px;
}
.signin .btn { width: 100%; }

/* ---------- Open a unit ---------- */

.hero { max-width: 720px; padding-top: 4vh; }

.imei-form { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }

.imei-input {
  flex: 1 1 260px;
  font-family: var(--font-display);
  font-size: 1.6rem;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
  padding: 10px 14px;
}
.imei-form .btn { font-size: 1.05rem; padding: 0 22px; min-height: 52px; }

/* ---------- Unit ---------- */

.unit-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.imei {
  font-size: 2.2rem;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  margin: 0;
}

.unit-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 32px;
  padding: 14px 20px;
  margin-bottom: 20px;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

.status-item { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.status-label { font-weight: 600; margin-right: 2px; }

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}
.pill-on { background: var(--ok-bg); color: var(--ok); }
.pill-off { background: var(--bad-bg); color: var(--bad); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-unknown { background: var(--paper); color: var(--ink-soft); }

.readings {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 18px 24px;
  margin: 0;
}
.readings div { min-width: 0; }
.readings .span2 { grid-column: span 2; }
/* Let shorter readings fill the gaps left beside the wide ones. */
.readings { grid-auto-flow: row dense; }
.show-sm { display: none; }
.readings dt { color: var(--ink-soft); font-size: 0.85rem; }
.readings dd {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.readings .is-guessed { font-style: italic; }
.readings .is-warn { color: var(--warn); }

/* Indicator lamps: the I/O state of a vehicle input. */
.lamp {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--lamp-off);
  vertical-align: -3px;
  margin-right: 6px;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.12);
}
.lamp-on {
  background: var(--lamp-on);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.15), 0 0 0 3px rgba(41, 179, 63, 0.22);
}
.io-grid .lamp { margin: 0; }

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}
.segmented a {
  padding: 6px 12px;
  text-decoration: none;
  color: var(--ink);
  border-left: 1px solid var(--rule);
}
.segmented a:first-child { border-left: 0; }
.segmented a.is-current { background: var(--bar); color: var(--bar-ink); }

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

.table-wrap { overflow-x: auto; }
.panel.table-wrap { padding: 0; }

.grid { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.grid th, .grid td { padding: 9px 14px; text-align: left; border-bottom: 1px solid var(--rule); }
.grid th { font-size: 0.85rem; color: var(--ink-soft); font-weight: 600; vertical-align: bottom; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover { background: var(--paper); }
@supports (color: color-mix(in srgb, red, blue)) {
  .grid tbody tr:hover { background: color-mix(in srgb, var(--paper) 55%, transparent); }
}
.grid .c { text-align: center; }

.nowrap { white-space: nowrap; }
.mono { font-family: var(--font-mono); }
.tick { color: var(--ok); font-weight: 700; }

.filter { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.pager { display: flex; align-items: center; gap: 12px; justify-content: flex-end; }

/* ---------- System check ---------- */

.checks { list-style: none; margin: 0; padding: 0; }
.checks li {
  display: grid;
  grid-template-columns: 24px minmax(160px, 240px) 1fr;
  gap: 4px 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
  align-items: start;
}
.checks li:last-child { border-bottom: 0; }
.checks li span:last-child { word-wrap: break-word; overflow-wrap: anywhere; color: var(--ink-soft); }
.checks li.fail span:last-child { color: var(--bad); }
.check-mark { width: 18px; height: 18px; border-radius: 50%; margin-top: 2px; }
.checks .ok .check-mark { background: var(--lamp-on); }
.checks .fail .check-mark { background: var(--bad); }

@media (max-width: 640px) {
  h1 { font-size: 1.5rem; }
  .checks li { grid-template-columns: 24px 1fr; }
  .checks li span:last-child { grid-column: 2; }
  .signout { margin-left: 0; width: 100%; padding-bottom: 10px; }
  .nav-link { padding: 10px 10px 7px; }
}

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

/* ---------- Astra additions ---------- */

.alert-warn { background: var(--warn-bg); color: var(--warn); }

.pill-neutral { background: var(--paper); color: var(--ink); border: 1px solid var(--rule); }
.pill-live { background: var(--bar); color: var(--livery-yellow); }

.unit-model { margin: 4px 0 0; color: var(--ink-soft); font-family: var(--font-display); font-size: 1.05rem; }

/* Configuration items sit side by side at their natural width and wrap only when the row is full. */
.config-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 32px;
  margin: 0;
}
.config-grid > div { min-width: 0; }
.config-grid dt { color: var(--ink-soft); font-size: 0.85rem; margin-bottom: 4px; }
.config-grid dd { margin: 0; display: flex; gap: 6px; flex-wrap: wrap; }
.config-note { margin: 14px 0 0; color: var(--ink-soft); font-size: 0.9rem; }

.lede-tight { color: var(--ink-soft); margin: 4px 0 0; }

.readings .is-bad, .grid .is-bad { color: var(--bad); font-weight: 600; }
.grid .is-guessed { font-style: italic; }

/* ---------- Tablets and phones ---------- */

/* 16px stops iOS zooming into a field when it's tapped. */
input { font-size: 16px; }

/* Touch screens: bigger targets. */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .segmented a { padding: 10px 14px; }
  .nav-link { padding-top: 14px; padding-bottom: 11px; }
}

/* Tablet portrait and smaller */
@media (max-width: 820px) {
  .page { padding: 18px 16px 32px; }
  .panel { padding: 16px; margin-bottom: 14px; }
  .unit-head { margin-bottom: 14px; align-items: flex-start; }
  .status-row, .alert { margin-bottom: 14px; }
  .readings { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 14px 18px; }
  .grid th, .grid td { padding: 8px 10px; }
}

/* Phones */
@media (max-width: 560px) {
  .topbar-inner { gap: 4px 16px; min-height: 48px; padding: 0 16px; }
  .wordmark { font-size: 1.15rem; }
  .wordmark-rest, .signout .user { display: none; }
  .signout { margin-left: auto; width: auto; padding-bottom: 0; }
  .nav-link { padding: 12px 8px 9px; }

  h1 { font-size: 1.4rem; }
  h2 { font-size: 1.05rem; }
  .imei { font-size: 1.55rem; letter-spacing: 0.02em; }
  .unit-model { font-size: 0.95rem; }

  /* Unit actions become one row of equal buttons. */
  .unit-actions { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; gap: 6px; }
  .unit-actions .btn { padding: 8px 6px; font-size: 0.85rem; white-space: normal; text-align: center; }

  .panel { padding: 14px 12px; }
  .config-grid { gap: 10px 20px; }
  .readings { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
  .readings dd { font-size: 1.05rem; }

  /* Tables: drop today's date, tighten cells, hide secondary columns. */
  .when.is-today .when-date { display: none; }
  .grid th { font-size: 0.75rem; }
  .grid th, .grid td { padding: 7px 6px; }
  .grid td { font-size: 0.9rem; }
  .io-grid th.c { white-space: normal; min-width: 3.5em; }
  .io-grid .lamp { width: 16px; height: 16px; }
  .hide-sm { display: none; }
  .show-sm { display: block; }
  .when-driver { font-size: 0.75rem; color: var(--ink-soft); }

  .segmented { width: 100%; }
  .segmented a { flex: 1 1 auto; text-align: center; }

  .imei-input { font-size: 1.3rem; }
  .imei-form .btn { width: 100%; }
}

/* ---------- Configuration actions ---------- */

.config-grid dd { align-items: center; }
.inline-form { display: inline; margin: 0; }

.btn-sm { padding: 4px 12px; font-size: 0.85rem; min-height: 30px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn-cancel { color: var(--bad); border-color: currentColor; }
/* Activation is one-way, so it looks different from the other actions. */
.btn-activate { background: var(--bar); border-color: var(--bar); color: var(--livery-yellow); }
.btn-activate:hover { filter: brightness(1.2); border-color: var(--bar); }

.config-notice { color: var(--ink); }

.panel-confirm { border: 2px solid var(--action); }
.panel-confirm p { max-width: 70ch; }
.confirm-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

.orientation-form { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: flex-end; }
.orientation-form .confirm-actions { width: 100%; margin-top: 4px; }
select {
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid #9eabb9;
  border-radius: var(--radius);
  padding: 9px 11px;
  min-width: 11em;
}
.check { display: flex; align-items: center; gap: 8px; padding-bottom: 10px; }
.check input { width: 20px; height: 20px; }

.live-status { color: var(--ink-soft); font-size: 0.85rem; margin: -6px 0 12px; min-height: 1.5em; }
.live-status.alert { font-size: 0.95rem; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 14px; }
/* Updates have stopped: grey the details so it's obvious they may be out of date. */
#live.is-stale { opacity: 0.55; filter: grayscale(0.6); }

@media (pointer: coarse) {
  .btn-sm { min-height: 40px; padding: 6px 14px; }
}
@media (max-width: 560px) {
  .orientation-form .field, .orientation-form select { width: 100%; }
}

/* ---------- IMEI search ---------- */

.imei-combo { position: relative; flex: 1 1 260px; min-width: 0; }
.imei-combo .imei-input { width: 100%; }

.imei-suggest {
  position: absolute;
  z-index: 10;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  max-height: 440px;
  max-height: min(60vh, 440px);
  overflow-y: auto;
}
.imei-suggest a {
  display: block;
  padding: 10px 14px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}
.imei-suggest li.is-active a, .imei-suggest a:hover { background: var(--paper); }
.imei-suggest mark, .match-list mark {
  background: var(--warn-bg);
  color: inherit;
  font-weight: 700;
  border-radius: 3px;
  padding: 0 1px;
}
.imei-suggest-note { padding: 8px 14px; color: var(--ink-soft); font-size: 0.9rem; }

.match-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; max-width: 420px; }
.match-list a {
  display: block;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}
.match-list a:hover { border-color: var(--ink-soft); }

@media (pointer: coarse) {
  .imei-suggest a { padding: 13px 14px; }
}

/* Model, firmware and tag, under the IMEI. */
.unit-meta { display: flex; flex-wrap: wrap; gap: 6px 28px; margin: -6px 0 16px; }
.unit-meta div { display: flex; align-items: center; gap: 8px; }
.unit-meta dt { color: var(--ink-soft); font-size: 0.85rem; }
.unit-meta dd { margin: 0; font-family: var(--font-display); font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
@media (max-width: 560px) {
  .unit-meta { gap: 4px 18px; margin-top: -2px; }
  .unit-meta dd { font-size: 1rem; }
}

/* ---------- Older tablets ----------
   Old iPads (iOS 9 and 10, in Safari or Chrome) have no CSS Grid, and iOS before 14.5 has no
   gap between flexbox items. Without these rules the location readings stack one per line and
   items in a row touch. Newer browsers skip all of this. */

/* No CSS Grid (before iOS 10.3): rows of fixed-share boxes instead. */
@supports not (display: grid) {
  .stack, .field, .match-list { display: block; }
  .stack > * + * { margin-top: 16px; }
  .field > * { display: block; width: 100%; }
  .field > * + * { margin-top: 6px; }
  .match-list li + li { margin-top: 6px; }

  /* Readings: 5 across, 4 on a portrait tablet, 2 on a phone, as the grid gives at those sizes. */
  /* Widths are whole percentages with the gap as padding, so a row always adds up to exactly
     100% and rounding can't push the last box onto the next line. */
  .readings { display: flex; flex-wrap: wrap; gap: 0; margin: 0 -24px -18px 0; }
  .readings > div { width: 20%; padding: 0 24px 18px 0; }
  .readings > .span2 { width: 40%; }

  .checks li { display: flex; flex-wrap: wrap; gap: 0; align-items: flex-start; }
  .checks li > :first-child { flex: 0 0 auto; margin-right: 18px; }
  .checks li > :nth-child(2) { flex: 0 0 auto; width: 200px; margin-right: 12px; }
  .checks li > :last-child { flex: 1 1 0; min-width: 0; }
}
@media (max-width: 820px) {
  @supports not (display: grid) {
    .readings { gap: 0; margin: 0 -18px -14px 0; }
    .readings > div { width: 25%; padding: 0 18px 14px 0; }
    .readings > .span2 { width: 50%; }
  }
}
@media (max-width: 640px) {
  @supports not (display: grid) {
    .checks li > :last-child { flex: 0 0 auto; width: calc(100% - 36px); margin-left: 36px; }
  }
}
@media (max-width: 560px) {
  @supports not (display: grid) {
    .readings { gap: 0; margin: 0 -14px -12px 0; }
    .readings > div { width: 50%; padding: 0 14px 12px 0; }
    .readings > .span2 { width: 100%; }
    .unit-actions { display: flex; flex-wrap: nowrap; gap: 0; }
    .unit-actions > .btn { flex: 1 1 0; }
    .unit-actions > * + * { margin-left: 6px; }
  }
}

/* No gap in flexbox (before iOS 14.5): compat.js adds "no-flexgap" to the
   page when the browser can't do it, and margins stand in for the gaps. */
.no-flexgap .topbar-inner > *, .no-flexgap .page-head > *, .no-flexgap .panel-head > *,
.no-flexgap .unit-head > *, .no-flexgap .imei-form > *, .no-flexgap .confirm-actions > *,
.no-flexgap .filter > *, .no-flexgap .pager > *, .no-flexgap .unit-actions > *,
.no-flexgap .nav > *, .no-flexgap .signout > *, .no-flexgap .status-item > *,
.no-flexgap .check > *, .no-flexgap .unit-meta div > *, .no-flexgap .unit-meta dd > *,
.no-flexgap .config-grid dd > * { margin-right: 10px; }
.no-flexgap .topbar-inner > * { margin-right: 28px; }
.no-flexgap .page-head > *, .no-flexgap .unit-head > * { margin-right: 16px; }
.no-flexgap .nav > * { margin-right: 4px; }
.no-flexgap .unit-actions > *, .no-flexgap .filter > *, .no-flexgap .status-item > *,
.no-flexgap .check > *, .no-flexgap .unit-meta div > *, .no-flexgap .unit-meta dd > * { margin-right: 8px; }
.no-flexgap .config-grid dd > * { margin-right: 6px; }
.no-flexgap .signout > *, .no-flexgap .pager > * { margin-right: 12px; }
.no-flexgap .topbar-inner > :last-child, .no-flexgap .page-head > :last-child,
.no-flexgap .panel-head > :last-child, .no-flexgap .unit-head > :last-child,
.no-flexgap .imei-form > :last-child, .no-flexgap .confirm-actions > :last-child,
.no-flexgap .filter > :last-child, .no-flexgap .pager > :last-child,
.no-flexgap .unit-actions > :last-child, .no-flexgap .nav > :last-child,
.no-flexgap .signout > :last-child, .no-flexgap .status-item > :last-child,
.no-flexgap .check > :last-child, .no-flexgap .unit-meta div > :last-child,
.no-flexgap .unit-meta dd > :last-child, .no-flexgap .config-grid dd > :last-child { margin-right: 0; }
/* Buttons that wrap onto a second line need space above them too. */
.no-flexgap .unit-actions > *, .no-flexgap .confirm-actions > *, .no-flexgap .imei-form > * { margin-bottom: 8px; }
.no-flexgap .unit-actions, .no-flexgap .confirm-actions { margin-bottom: -8px; }
.no-flexgap .imei-form { margin-bottom: 8px; }

/* Rows that often wrap: space below each item, taken back off the row's own margin. */
.no-flexgap .config-grid > *, .no-flexgap .status-row > * { margin: 0 32px 12px 0; }
.no-flexgap .config-grid { margin-bottom: -12px; }
.no-flexgap .status-row { padding-bottom: 2px; }
.no-flexgap .unit-meta > * { margin: 0 28px 6px 0; }
.no-flexgap .unit-meta { margin-bottom: 10px; }
.no-flexgap .orientation-form > * { margin: 0 24px 14px 0; }
.no-flexgap .orientation-form { margin-bottom: -14px; }
.no-flexgap .orientation-form > .confirm-actions { margin-right: 0; }
.no-flexgap .live-status.alert > * + * { margin-left: 12px; }
@media (max-width: 560px) {
  .no-flexgap .topbar-inner > * { margin-right: 16px; }
  .no-flexgap .config-grid > * { margin: 0 20px 10px 0; }
  .no-flexgap .config-grid { margin-bottom: -10px; }
  .no-flexgap .unit-meta > * { margin: 0 18px 4px 0; }
  .no-flexgap .unit-meta { margin-bottom: 12px; }
  /* On phones with grid, the unit actions are a grid with its own gaps. */
  @supports (display: grid) {
    .no-flexgap .unit-actions > * { margin: 0; }
    .no-flexgap .unit-actions { margin-bottom: 0; }
  }
}
