/* ============================================================================
   LoopOS — application shell and components

   Hand-written. No Bootstrap: on a three-day build it would have cost more time
   fighting the brand than it saved. Hairlines only, at var(--color-line) —
   never heavier, never coloured. Status colour is the one exception and it earns
   its place by carrying meaning.
   ========================================================================= */

/* ------------------------------------------------------------------- shell */

.shell {
  display: grid;
  grid-template-columns: var(--shell-nav) 1fr;
  min-height: 100vh;
}

.shell-nav {
  border-inline-end: 1px solid var(--color-line);
  padding: 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.shell-main {
  min-width: 0;               /* or a wide table pushes the whole page sideways */
  display: flex;
  flex-direction: column;
}

.shell-header {
  border-bottom: 1px solid var(--color-line);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.shell-body { padding: 2rem; flex: 1; }

/* ------------------------------------------------- the menu on a small screen

   Below this width the sidebar becomes a drawer. The old rule simply dropped it
   above the content, which on a phone is four screens of links before the page
   starts — technically a layout, but not one anybody could use.

   The breakpoint is 62rem rather than a device width: it is where twenty nav links
   and a page of content stop both fitting, which is a fact about this layout and
   not about anybody's tablet. */

.nav-toggle {
  display: none;
  width: 2.5rem;
  height: 2.5rem;
  flex: none;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: var(--color-body);
  cursor: pointer;
}

.nav-toggle:hover { background: var(--hover); }
.nav-toggle:focus-visible { outline: 2px solid var(--color-signal); outline-offset: 2px; }

/* Three lines that become a cross. Drawn with borders rather than three elements,
   because it is a button, not a component. */
.nav-toggle-bars,
.nav-toggle-bars::before,
.nav-toggle-bars::after {
  display: block;
  width: 1.125rem;
  height: 1px;
  background: currentColor;
  transition: transform .18s ease, opacity .18s ease;
}

.nav-toggle-bars::before,
.nav-toggle-bars::after {
  content: "";
  position: absolute;
}

.nav-toggle-bars { position: relative; }
.nav-toggle-bars::before { transform: translateY(-5px); }
.nav-toggle-bars::after { transform: translateY(5px); }

.nav-toggle[aria-expanded="true"] .nav-toggle-bars { background: transparent; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars::before { transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars::after { transform: rotate(-45deg); }

.nav-scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(0, 0, 0, .5);
}

@media (max-width: 62rem) {
  .shell { grid-template-columns: 1fr; }



  .nav-toggle { display: inline-flex; }
  /* [hidden] is display:none, and a bare display:block here beat it — so the scrim
     sat over the page at full width whether the menu was open or not, and its own
     inset:0 then stretched to whatever the page had already overflowed to. */
  .nav-scrim:not([hidden]) { display: block; }

  .shell-nav {
    position: fixed;
    top: 0;
    inset-inline-start: 0;
    z-index: 80;
    width: min(19rem, 82vw);
    height: 100vh;
    background: var(--color-page);
    border-inline-end: 1px solid var(--color-line);

    /* Off to the left, not hidden: a drawer that is display:none cannot animate, and
       one that is only transparent is still in the tab order. visibility does both. */
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform .22s ease, visibility 0s linear .22s;
  }

  body.nav-open .shell-nav {
    transform: none;
    visibility: visible;
    transition: transform .22s ease, visibility 0s;
  }

  .shell-body, .shell-header { padding: 1rem; }
  .shell-header { gap: .75rem; }
  .page-title { font-size: 1.5rem; }

  /* A screen held to one viewport has nowhere to put a drawer, and on a phone the
     figures want the page scroll back anyway. */
  body.shell-fixed { overflow: auto; }
  body.shell-fixed .shell,
  body.shell-fixed .shell-body { height: auto; overflow: visible; }

  /* Last, so it wins over the rule above on the one screen that has both. A page
     that scrolls behind an open drawer loses the reader's place while they are
     looking at a menu. */
  body.nav-open,
  body.nav-open.shell-fixed { overflow: hidden; }
}

@media (max-width: 62rem) and (prefers-reduced-motion: reduce) {
  .shell-nav { transition: none; }
}

/* The header wraps rather than squeezing on a phone: the tower picker and the page
   actions are both things you press, and a 30px-wide button is not one. */
@media (max-width: 40rem) {
  .shell-header { flex-wrap: wrap; }
  .shell-header > .row { width: 100%; }
  .tower-pick { width: 100%; }
}

/* --------------------------------------------------------------------- nav */

.nav-brand { padding: 0 1.25rem 0.25rem; }
.nav-version { display: block; margin-top: 0.25rem; }

.nav-group { display: flex; flex-direction: column; }

.nav-group > .eyebrow { padding: 0 1.25rem 0.5rem; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 1.25rem;
  color: var(--color-muted);
  text-decoration: none;
  border-inline-start: 2px solid transparent;
  transition: color 0.15s ease, background 0.15s ease;
}

.nav-link:hover { color: var(--color-body); background: var(--color-raised); }

.nav-link[aria-current="page"] {
  color: var(--color-body);
  border-inline-start-color: var(--color-signal);
  background: var(--color-raised);
}

.nav-link svg { width: 1rem; height: 1rem; flex: none; opacity: 0.75; }

.nav-foot { margin-top: auto; padding: 1rem 1.25rem 0; border-top: 1px solid var(--color-line); }

/* ----------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius);
  background: transparent;
  color: var(--color-body);
  cursor: pointer;
  text-decoration: none;
  font-size: 0.875rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn:hover { background: var(--color-raised); border-color: var(--color-body); }

.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:disabled:hover { background: transparent; border-color: var(--color-line-strong); }
.btn-primary:disabled:hover { background: var(--color-signal); border-color: transparent; }

/* Signal (#4F46E5) is the fill on both grounds and carries white text. Brand-coloured TEXT uses --color-accent. */
.btn-primary {
  background: var(--color-signal);
  border-color: var(--color-signal);
  color: #fff;
}

.btn-primary:hover { filter: brightness(1.08); }

.btn-sm { padding: 0.3125rem 0.625rem; font-size: 0.8125rem; }
.btn-danger { color: var(--color-breach); border-color: var(--color-breach); }
.btn-danger:hover { background: var(--color-breach-bg); border-color: var(--color-breach); }

/* ------------------------------------------------------------------- cards */

.card {
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  padding: 1.25rem;
  background: transparent;
}

.card-raised { background: var(--color-raised); }

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); }

/* --------------------------------------------------------------- KPI tiles */

.kpi {
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  padding: 1rem 1.125rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

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

.kpi-value {
  font-family: var(--font-display);
  font-size: 2rem;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.kpi-note { font-size: 0.75rem; color: var(--color-faint); }
.kpi-value.is-signal { color: var(--color-accent); }
.kpi-value.is-breach { color: var(--color-breach); }
.kpi-value.is-ok { color: var(--color-ok); }

/* ------------------------------------------------------- the period picker */

.period {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: nowrap;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-line);
}

.period-tabs { display: flex; gap: 0; flex-wrap: nowrap; flex: 0 1 auto; min-width: 0; }

/* The dates take what is left and push to the right. min-width:0 so they give way
   before the presets do — a preset that has wrapped is unreadable, a date input that
   has narrowed is still a date input. */
.period-dates {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-inline-start: auto;
  min-width: 0;
}

.period-dates .input { width: auto; min-width: 0; }

.period-tab {
  background: transparent;
  border: 1px solid var(--color-line-strong);
  border-inline-end-width: 0;
  color: var(--color-muted);
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  cursor: pointer;
}

.period-tab:first-child { border-start-start-radius: var(--radius); border-start-end-radius: 0; border-end-end-radius: 0; border-end-start-radius: var(--radius); }
.period-tab:last-child { border-inline-end-width: 1px; border-start-start-radius: 0; border-start-end-radius: var(--radius); border-end-end-radius: var(--radius); border-end-start-radius: 0; }
.period-tab:hover { background: var(--color-raised); color: var(--color-body); }

@media (max-width: 64rem) {
  .period { flex-wrap: wrap; }
  .period-dates { margin-inline-start: 0; width: 100%; }
  .period-dates .input { flex: 1; }
}

/* Below this the five presets cannot sit on one line at any font size that is still
   a button. They wrap, and each one grows to fill its row rather than leaving a
   ragged edge. */
@media (max-width: 30rem) {
  .period-tabs { flex-wrap: wrap; width: 100%; }
  .period-tab { flex: 1 0 auto; text-align: center; }
  .period-tab:first-child { border-start-start-radius: var(--radius); border-start-end-radius: 0; border-end-end-radius: 0; border-end-start-radius: 0; }
  .period-tab:last-child { border-start-start-radius: 0; border-start-end-radius: 0; border-end-end-radius: var(--radius); border-end-start-radius: 0; border-inline-end-width: 1px; }
}

.period-tab.is-on {
  background: var(--color-signal);
  border-color: var(--color-signal);
  color: #fff;
}

.period-title {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

/* ------------------------------------------------------- dashboard rhythm */

/* The sections space themselves. Inheriting the page stack put a heading exactly
   as far from the row above it as from its own boxes, so every heading read as the
   caption of the wrong section. */
.dash {
  display: flex;
  flex-direction: column;
  gap: 3rem;
}

.dash-section { display: flex; flex-direction: column; gap: 1rem; }

/* A section that also carries .grid means it, and two single-class selectors would
   otherwise be decided by which one came last in this file — which is how two charts
   asking to sit beside each other ended up stacked full width. */
.dash-section.grid { display: grid; }

/* Label, a hairline across the gap, then a note. The rule is what makes a screen
   full of boxes read as a system rather than a pile. */
.section-head {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.section-rule {
  flex: 1;
  height: 1px;
  background: var(--color-line);
}

.section-note {
  font-size: 0.75rem;
  color: var(--color-faint);
  white-space: nowrap;
}

@media (max-width: 700px) {
  .dash { gap: 2.25rem; }
  .section-note { display: none; }
}

/* ------------------------------------------------------- the headline strip */

/* The five figures somebody wants before deciding whether to read the rest, in one
   line, divided by hairlines. Nothing here is not also below — it is a summary, not
   a separate set of numbers to reconcile against. */
.headline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  overflow: hidden;
}

.headline-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.25rem 1.5rem;
  border-inline-end: 1px solid var(--color-line);
}

.headline-item:last-child { border-inline-end: 0; }

@media (max-width: 900px) {
  .headline-item { border-inline-end: 0; border-bottom: 1px solid var(--color-line); }
  .headline-item:last-child { border-bottom: 0; }
}

.headline-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-faint);
  line-height: 1.4;
}

.headline-value {
  font-family: var(--font-display);
  font-size: 2.75rem;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.headline-value.is-breach { color: var(--color-breach); }
.headline-value.is-ok { color: var(--color-ok); }
.headline-value .of {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  letter-spacing: 0;
  color: var(--color-faint);
}

/* --------------------------------------------------------------- the boxes */

/* Simple boxes, one number each, large enough to read from across a room. This is
   shown to the client on a screen, not studied on a laptop. */
.box {
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  padding: 1.125rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 7.5rem;
  transition: border-color 0.15s ease;
}

.box:hover { border-color: var(--color-line-strong); }

/* A thin bar on the left when a number means something is wrong. Colour alone in the
   figure is easy to miss on a screen somebody is glancing at from across a room. */
.box:has(.box-value.is-breach) { border-inline-start: 2px solid var(--color-breach); }
.box:has(.box-value.is-warn) { border-inline-start: 2px solid var(--color-warn); }

.box-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-faint);
  line-height: 1.4;
}

.box-value {
  font-family: var(--font-display);
  font-size: 2.25rem;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin-top: auto;
}

.box-value.is-ok { color: var(--color-ok); }
.box-value.is-warn { color: var(--color-warn); }
.box-value.is-breach { color: var(--color-breach); }

.box-note { font-size: 0.6875rem; color: var(--color-faint); line-height: 1.45; }

/* A box that does something. Same shape as the others so it sits in the row, with
   a signal border so it does not read as a number. */
.box-action {
  cursor: pointer;
  border-color: var(--color-signal);
  color: var(--color-accent);
}

.box-action:hover { background: var(--color-raised); }
.box-action .box-value { color: var(--color-accent); }

/* ------------------------------------------------------------ camera hero */

.camera-hero {
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  padding: 1.75rem 2rem;
  display: grid;
  grid-template-columns: minmax(18rem, 1fr) minmax(0, 1fr);
  gap: 2rem;
}

@media (max-width: 900px) {
  .camera-hero { grid-template-columns: 1fr; padding: 1.25rem; gap: 1.25rem; }
}

.camera-figure {
  font-family: var(--font-display);
  font-size: clamp(3rem, 8vw, 5rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--color-ok);
  margin-top: 0.5rem;
}

.camera-of {
  font-family: var(--font-sans);
  font-size: 1rem;
  letter-spacing: 0;
  color: var(--color-faint);
}

/* --------------------------------------------------------------- bar rows */

.bar-row {
  display: grid;
  grid-template-columns: minmax(9rem, 14rem) 1fr 3rem;
  gap: 0.875rem;
  align-items: center;
  padding: 0.375rem 0;
}

.bar-label { font-size: 0.8125rem; color: var(--color-muted); }
.bar-track { height: 0.5rem; background: var(--color-raised-2); border-radius: 2px; }
.bar-fill { display: block; height: 100%; background: var(--color-signal); border-radius: 2px; }
.bar-count { font-size: 0.8125rem; text-align: end; font-variant-numeric: tabular-nums; }

@media (max-width: 600px) {
  .bar-row { grid-template-columns: 1fr 2.5rem; }
  .bar-track { grid-column: 1 / -1; }
}

/* --------------------------------------------------------------- the hero */

/* One number, large. The contract is about a costed figure on the client's desk
   by 09:30, so that figure gets the top of the screen and everything else
   arranges itself underneath it. */
.hero {
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  padding: 1.75rem 2rem;
  display: grid;
  grid-template-columns: minmax(16rem, 1fr) minmax(0, 1.4fr);
  gap: 2rem;
  align-items: center;
}

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; padding: 1.25rem; gap: 1.25rem; }
}

.hero-figure {
  font-family: var(--font-display);
  font-size: clamp(2.75rem, 7vw, 4.5rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--color-accent);
}

.hero-unit {
  font-size: 0.875rem;
  letter-spacing: 0.08em;
  color: var(--color-faint);
  font-family: var(--font-sans);
}

.hero-side { display: flex; flex-direction: column; gap: 0.75rem; min-width: 0; }

.hero-side-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-line);
}

.hero-side-row:last-of-type { border-bottom: 0; padding-bottom: 0; }

.hero-side-value { font-variant-numeric: tabular-nums; font-size: 1.125rem; }

/* --------------------------------------------------------------- the meter */

/* A ratio you can read without doing arithmetic. Used for claimed-against-verified
   and for uptime against its SLA, which are the two places a number alone hides
   whether it is good. */
.meter {
  height: 4px;
  background: var(--color-raised-2);
  border-radius: 999px;
  overflow: hidden;
  display: flex;
}

.meter > span { display: block; height: 100%; }
.meter .is-signal { background: var(--color-signal); }
.meter .is-ok { background: var(--color-ok); }
.meter .is-warn { background: var(--color-warn); }
.meter .is-breach { background: var(--color-breach); }

/* The SLA target line sits on the bar, so "99.15% against 99.00%" is one glance
   rather than two numbers and a subtraction. */
.meter-target { position: relative; }
.meter-target::after {
  content: "";
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 1px;
  background: var(--color-body);
  inset-inline-start: var(--target, 99%);
  opacity: 0.5;
}

.stat-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.8125rem;
  padding: 0.375rem 0;
}

.stat-line + .stat-line { border-top: 1px solid var(--color-line); }
.stat-line .num { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------- needs attention */

/* One list of everything waiting on a person, ordered by how much it costs to
   ignore. Three separate lists on one screen means the third never gets read. */
.attention-item {
  display: grid;
  grid-template-columns: 5.5rem 1fr auto;
  gap: 0.875rem;
  align-items: baseline;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--color-line);
}

.attention-item:last-child { border-bottom: 0; }

@media (max-width: 700px) {
  .attention-item { grid-template-columns: 1fr; gap: 0.25rem; }
}

.attention-body { min-width: 0; font-size: 0.8125rem; }
.attention-meta { font-size: 0.75rem; color: var(--color-faint); }

.sparkline { height: 2.25rem; }
.sparkline svg { display: block; }

/* The day read out as sentences. A dot carries the tone so the eye can scan for
   what went wrong without the text having to shout. */
.story-line {
  display: grid;
  grid-template-columns: 0.5rem 1fr;
  gap: 0.875rem;
  align-items: start;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--color-line);
}

.story-line:last-child { border-bottom: 0; }
.story-line p { font-size: 0.9375rem; line-height: 1.6; max-width: 62rem; }

.story-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  margin-top: 0.5rem;
  background: var(--color-faint);
}

.story-dot.is-ok { background: var(--color-ok); }
.story-dot.is-warn { background: var(--color-warn); }
.story-dot.is-breach { background: var(--color-breach); }

/* ------------------------------------------------------------------ tables */

/* A register is 20 columns wide on a 1280px screen. It scrolls inside its own
   box; the page never scrolls sideways. The wrapper needs min-width:0 on its
   grid parent or min-width:auto passes the width straight back out. */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  min-width: 0;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  white-space: nowrap;
}

table.data th {
  text-align: start;
  font-weight: 500;
  color: var(--color-faint);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--color-line);
  background: var(--color-raised);
  position: sticky;
  top: 0;
  z-index: 1;
}

table.data td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--color-line);
  vertical-align: top;
}

table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--color-raised); }

table.data .num, table.data th.num { text-align: end; font-variant-numeric: tabular-nums; }

/* A computed cell is not editable and should not look editable. */
table.data td.computed { color: var(--color-muted); background: var(--color-raised); }

table.data tfoot td {
  border-top: 1px solid var(--color-line-strong);
  border-bottom: 0;
  font-weight: 500;
  padding: 0.625rem 0.75rem;
}

/* Editable grid. Inputs inside a table drop their border so the grid reads as a
   sheet rather than a wall of boxes; the border returns on focus. */
table.data td .input {
  border-color: transparent;
  background: transparent;
  padding: 0.25rem 0.375rem;
  min-width: 4rem;
  font-size: 0.8125rem;
}

table.data td .input:hover { border-color: var(--color-line); }
table.data td .input:focus { border-color: var(--color-signal); background: var(--color-page); }

/* A row you have changed says so, and keeps saying so until it saves. */
table.data tr.is-dirty td { background: var(--color-warn-bg); }
table.data tr.is-dirty td.computed { opacity: 0.5; }

/* The blank line at the bottom that adds a row. */
table.data tr.row-new td { background: var(--color-raised); border-top: 1px solid var(--color-line-strong); }

table.data td input[type="checkbox"] { width: 1rem; height: 1rem; accent-color: var(--color-signal); }

/* ------------------------------------------------------------------ status */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-ok { color: var(--color-ok); background: var(--color-ok-bg); border-color: var(--color-ok); }
.badge-warn { color: var(--color-warn); background: var(--color-warn-bg); border-color: var(--color-warn); }
.badge-breach { color: var(--color-breach); background: var(--color-breach-bg); border-color: var(--color-breach); }
.badge-neutral { color: var(--color-faint); border-color: var(--color-line-strong); }

.text-ok { color: var(--color-ok); }
.text-warn { color: var(--color-warn); }
.text-breach { color: var(--color-breach); }

/* ------------------------------------------------------------------- forms */

.field { display: flex; flex-direction: column; gap: 0.375rem; margin-bottom: 1rem; }

.field label { font-size: 0.8125rem; color: var(--color-muted); }

.input, select.input, textarea.input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: transparent;
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius);
  color: var(--color-body);
}

.input:focus { border-color: var(--color-signal); }
.input::placeholder { color: var(--color-faint); }

select.input option { background: var(--color-page); color: var(--color-body); }

.field-error { color: var(--color-breach); font-size: 0.75rem; }
.input.is-invalid { border-color: var(--color-breach); }

/* -------------------------------------------------------------------- misc */

.hr { border: 0; border-top: 1px solid var(--color-line); margin: 1.5rem 0; }

.row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.row-between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 1.5rem; }

.empty {
  border: 1px dashed var(--color-line-strong);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--color-faint);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
}

.theme-toggle:hover { background: var(--color-raised); }
.theme-toggle svg { width: 1rem; height: 1rem; }
:root:not([data-theme="light"]) .theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: none; }

.notification-centre { position: relative; }
.notification-bell {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem; border: 1px solid var(--color-line-strong);
  border-radius: var(--radius); background: transparent; color: var(--color-body); cursor: pointer;
}
.notification-bell:hover, .notification-bell[aria-expanded="true"] { background: var(--color-raised); }
.notification-bell svg { width: 1.125rem; height: 1.125rem; display: block; }
.notification-count {
  position: absolute; top: -.45rem; inset-inline-end: -.45rem; min-width: 1.15rem; height: 1.15rem;
  padding: 0 .2rem; border: 2px solid var(--color-page); border-radius: 1rem;
  background: #dc2626; color: #fff; font-size: .6rem; line-height: .95rem;
  font-variant-numeric: tabular-nums; text-align: center;
}
.notification-panel {
  position: absolute; z-index: 90; top: calc(100% + .65rem); inset-inline-end: 0;
  width: min(24rem, calc(100vw - 2rem)); max-height: min(34rem, calc(100vh - 6rem));
  border: 1px solid var(--color-line-strong); background: var(--color-page);
  box-shadow: 0 1rem 2.5rem rgba(0,0,0,.32); overflow: hidden;
}
.notification-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1rem; border-bottom: 1px solid var(--color-line); }
.notification-list { max-height: min(29rem, calc(100vh - 10rem)); overflow-y: auto; }
.notification-item { display: grid; grid-template-columns: minmax(0, 1fr) 1.75rem; align-items: center; border-bottom: 1px solid var(--color-line); }
.notification-item:hover { background: var(--color-raised); }
.notification-open { min-width: 0; display: grid; grid-template-columns: .35rem minmax(0, 1fr); gap: .65rem; padding-block: .7rem .7rem; padding-inline: .85rem .25rem; color: var(--color-body); text-decoration: none; }
.notification-signal { width: .35rem; height: .35rem; margin-top: .35rem; border-radius: 50%; background: var(--color-signal); }
.notification-item.tone-critical .notification-signal { background: var(--color-breach); }
.notification-copy { min-width: 0; display: flex; flex-direction: column; gap: .15rem; font-size: .75rem; color: var(--color-muted); overflow: hidden; }
.notification-copy strong, .notification-detail { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notification-copy strong { color: var(--color-body); font-size: .8125rem; font-weight: 500; }
.notification-meta { color: var(--color-faint); font-size: .6875rem; text-transform: uppercase; }
.notification-dismiss { width: 1.75rem; height: 1.75rem; display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--color-faint); font-size: 1.15rem; line-height: 1; cursor: pointer; }
.notification-dismiss:hover { color: var(--color-body); background: var(--color-raised-2); }
.notification-dismiss:focus-visible { outline: 2px solid var(--color-signal); outline-offset: -2px; }
.notification-empty { padding: 2rem 1rem; color: var(--color-faint); text-align: center; font-size: .8125rem; }
.data tr.notification-target > td { background: var(--color-signal-bg); }
.data tr.notification-target > td:first-child { box-shadow: inset 2px 0 0 var(--color-signal); }

/* A wheel or touch gesture belongs to the scroll surface under the pointer. At the
   first/last item it stops there instead of moving the page behind the popup. */
.notification-list,
.modal-overlay,
.tower-panel,
.tw-detail,
.tw-detail.is-floating,
.fm-tree,
.site-day-list {
  overscroll-behavior: contain;
}
@media (max-width: 40rem) {
  .notification-centre { margin-inline-start: auto; }
  .notification-panel { position: fixed; top: 4.5rem; inset-inline-end: 1rem; inset-inline-start: 1rem; width: auto; }
}

/* Day status banner. The one place a large tinted area is allowed, because the
   whole point is that you cannot miss which state the day is in. */
.status-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-line);
  border-inline-start-width: 3px;
  border-radius: var(--radius);
  background: var(--color-raised);
}

.status-banner.is-draft { border-inline-start-color: var(--color-signal); }
.status-banner.is-submitted { border-inline-start-color: var(--color-warn); }
.status-banner.is-approved, .status-banner.is-locked { border-inline-start-color: var(--color-ok); }

/* ------------------------------------------------------------------- login */

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

.login-card { width: 100%; max-width: 24rem; }
.login-card .brand { margin-bottom: 2.5rem; }

/* One line at the top of the day: what state it is in and what can be done to it.
   The paragraphs that used to be here were read once and then read past. */
.day-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  background: var(--color-raised);
}

/* --------------------------------------------------------- the register */

/* A short table you can read, and one line at a time opened into a form you can
   fill without dragging the page sideways. Twenty columns in one table was
   faithful to the spreadsheet and unusable: by the time you reached the last
   column you could no longer see which row you were on. */

.reg-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.75rem;
}

table.data.reg { white-space: normal; min-width: 0; }
table.data.reg th, table.data.reg td { padding: 0.625rem 0.75rem; }
table.data.reg tr.is-open { background: var(--color-raised); }
table.data.reg tr.is-open td { border-bottom-color: transparent; }

.reg-actions { text-align: end; white-space: nowrap; }

.reg-panel > td { padding: 0 !important; background: var(--color-raised); }
.reg-panel-box { padding: 1rem 1.25rem 1.25rem; }

.reg-new {
  border: 1px solid var(--color-signal);
  border-radius: var(--radius);
  padding: 1rem 1.25rem 1.25rem;
  margin-bottom: 1rem;
  background: var(--color-raised);
}

.reg-editor.is-dirty { position: relative; }

/* Fields wrap across the width. Nothing is ever off the side of the screen. */
.reg-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.75rem 1rem;
  margin: 0.75rem 0 1rem;
}

.reg-field { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }

.reg-field > span {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-faint);
  line-height: 1.3;
}

.reg-field .input { padding: 0.375rem 0.5rem; font-size: 0.8125rem; }
.reg-field.is-wide { grid-column: span 2; }

@media (max-width: 700px) {
  .reg-field.is-wide { grid-column: auto; }
}

.reg-hint { font-size: 0.625rem; color: var(--color-faint); font-style: normal; line-height: 1.4; }
/* Q1d: quick add, saved rows, declarations, the summary before sending. */
.ny-late { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem 0.75rem; padding: 0.625rem 0.875rem; margin-bottom: 0.75rem; border: 1px solid var(--color-breach, #e5484d); }
.ny-late a { font-weight: 500; }
.qa-head { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: baseline; margin-bottom: 0.625rem; }
.qa-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: 0.5rem 0.75rem; }
.qa-actions { gap: 0.5rem; margin-top: 0.75rem; flex-wrap: wrap; }
.qa-templates { display: flex; flex-wrap: wrap; gap: 0.375rem 0.5rem; align-items: center; margin-top: 0.625rem; }
.qa-chip { display: inline-flex; align-items: center; gap: 0.125rem; }
.qa-chip-x { background: none; border: 0; color: var(--color-faint); cursor: pointer; font-size: 1rem; padding: 0 0.375rem; min-height: 2rem; }
.qa-chip-x:hover { color: var(--color-breach, #e5484d); }
.qa-decl { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.375rem; }
.qa-decl li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.75rem; }
.qa-decl-main { font-weight: 500; }
.qa-sum { display: grid; grid-template-columns: max-content 1fr; gap: 0.375rem 1rem; margin: 0; }
.qa-sum dt { color: var(--color-faint); font-size: 0.8125rem; }
.qa-sum dd { margin: 0; font-variant-numeric: tabular-nums; }
.qa-warnings { margin: 0.375rem 0 0; padding-inline-start: 1.25rem; }
.qa-warnings li { margin-bottom: 0.25rem; }
@media (max-width: 600px) {
  .qa-fields { grid-template-columns: 1fr 1fr; }
  .qa-field .input { min-height: 2.5rem; }
}

.reg-check { display: flex; align-items: center; height: 2rem; }
.reg-check input { width: 1rem; height: 1rem; accent-color: var(--color-signal); }

/* What the server worked out, shown but not typed. */
.reg-computed {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.75rem;
  padding: 0.625rem 0.875rem;
  margin: 0.375rem 0 1rem;
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
}

.reg-out { display: flex; flex-direction: column; gap: 0.125rem; }
.reg-out span { font-size: 0.625rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--color-faint); }
.reg-out strong { font-weight: 400; font-size: 0.9375rem; font-variant-numeric: tabular-nums; }

.reg-foot { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.reg-state { min-height: 1rem; }

/* Totals under the table, not squeezed into a footer row. */
.reg-totals {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 2rem;
  padding: 0.875rem 1rem;
  margin-top: 0.75rem;
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  background: var(--color-raised);
}

.reg-total { display: flex; flex-direction: column; gap: 0.125rem; }
.reg-total span { font-size: 0.625rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--color-faint); }
.reg-total strong { font-weight: 400; font-size: 1.125rem; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------ evidence uploader */

/* One block per file. A two-hour recording and a still of a gate do not share a
   start time, so they do not share a form either. */
.up-rows { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1.25rem; }

.up-row {
  display: grid;
  grid-template-columns: minmax(11rem, 1fr) minmax(0, 2.4fr) 10rem auto;
  gap: 1rem;
  align-items: start;
  padding: 0.875rem 1rem;
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
}

.up-row.is-sending { border-color: var(--color-signal); }
.up-row.is-done { border-inline-start: 2px solid var(--color-ok); opacity: 0.75; }

@media (max-width: 900px) {
  .up-row { grid-template-columns: 1fr; }
}

.up-file { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }

.up-name {
  font-size: 0.8125rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.up-size { font-size: 0.6875rem; }

.up-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
.up-field { display: flex; flex-direction: column; gap: 0.1875rem; min-width: 0; }
.up-field > span { font-size: 0.625rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--color-faint); }
.up-field .input { padding: 0.3125rem 0.5rem; font-size: 0.8125rem; }
.up-wide { grid-column: 1 / -1; }

.up-status { display: flex; flex-direction: column; gap: 0.375rem; }

.up-bar { height: 4px; background: var(--color-raised-2); border-radius: 2px; overflow: hidden; }
.up-bar span { display: block; height: 100%; width: 0; background: var(--color-signal); transition: width 0.2s ease; }
.up-state { font-size: 0.6875rem; line-height: 1.4; }

.up-remove { align-self: start; }

/* --------------------------------------------------------------- tags */

.tag {
  display: inline-block;
  padding: 0.0625rem 0.4375rem;
  margin-block: 0.125rem 0.125rem; margin-inline: 0 0.1875rem;
  border: 1px solid var(--color-line-strong);
  border-radius: 999px;
  font-size: 0.6875rem;
  color: var(--color-muted);
  white-space: nowrap;
}

.tag.is-kind { border-color: var(--color-signal); color: var(--color-accent); }

/* ---------------------------------------------------------- file manager */

/* Laid out like every file manager anybody has used: spaces and a folder tree down
   the left, a breadcrumb trail along the top, a list in the middle. Nobody has to be
   taught that, and anything more inventive would have to be. */
.fm {
  display: grid;
  grid-template-columns: 16rem 1fr;
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  min-height: 32rem;
  overflow: hidden;
}

@media (max-width: 860px) {
  .fm { grid-template-columns: 1fr; }
  .fm-side { border-inline-end: 0; border-bottom: 1px solid var(--color-line); }
  .fm-tree { max-height: 12rem; }
}

.fm-side {
  border-inline-end: 1px solid var(--color-line);
  display: flex;
  flex-direction: column;
  background: var(--color-raised);
}

.fm-spaces { display: flex; flex-direction: column; padding: 0.75rem; gap: 0.25rem; }

.fm-space {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--color-muted);
  font-size: 0.8125rem;
  border-inline-start: 2px solid transparent;
}

.fm-space:hover { background: var(--color-raised-2); color: var(--color-body); }

.fm-space.is-on {
  background: var(--color-raised-2);
  color: var(--color-body);
  border-inline-start-color: var(--color-signal);
}

.fm-space-count { font-size: 0.6875rem; color: var(--color-faint); font-variant-numeric: tabular-nums; }

.fm-tree-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--color-line);
}

.fm-tree { flex: 1; overflow-y: auto; padding: 0 0.5rem 0.75rem; }

.fm-branch {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  background: none;
  border: 0;
  padding: 0.3125rem 0.5rem;
  color: var(--color-muted);
  font-size: 0.8125rem;
  text-align: start;
  cursor: pointer;
  border-radius: var(--radius);
}

.fm-branch:hover { background: var(--color-raised-2); color: var(--color-body); }
.fm-branch.is-on { background: var(--color-raised-2); color: var(--color-body); }

.fm-storage {
  padding: 0.75rem;
  border-top: 1px solid var(--color-line);
  font-size: 0.6875rem;
}

.fm-main { display: flex; flex-direction: column; min-width: 0; }

.fm-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-line);
}

.fm-crumbs { display: flex; align-items: center; gap: 0.375rem; flex-wrap: wrap; min-width: 0; }

.fm-crumb {
  background: none;
  border: 0;
  padding: 0.25rem 0.375rem;
  color: var(--color-accent);
  font-size: 0.8125rem;
  cursor: pointer;
  border-radius: var(--radius);
}

.fm-crumb:hover { background: var(--color-raised); }
.fm-crumb.is-here { color: var(--color-body); cursor: default; }
.fm-crumb.is-here:hover { background: none; }
.fm-sep { color: var(--color-faint); font-size: 0.8125rem; }

.fm-body { flex: 1; overflow-x: auto; }

/* One grid for the header and every row, so the columns cannot drift apart. */
.fm-head,
.fm-row {
  display: grid;
  grid-template-columns: minmax(14rem, 2.2fr) 7rem 9rem 11rem minmax(16rem, auto);
  gap: 1rem;
  align-items: center;
  padding: 0.5rem 1rem;
  min-width: 60rem;
}

.fm-head {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-faint);
  border-bottom: 1px solid var(--color-line);
  background: var(--color-raised);
  position: sticky;
  top: 0;
  z-index: 1;
}

.fm-row { border-bottom: 1px solid var(--color-line); font-size: 0.8125rem; }
.fm-row:hover { background: var(--color-raised); }
.fm-cell { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.fm-name { display: flex; align-items: center; gap: 0.625rem; min-width: 0; cursor: default; }
.fm-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.fm-icon { width: 1.125rem; height: 1.125rem; flex: none; color: var(--color-faint); }
.fm-icon.is-folder { color: var(--color-accent); }

.fm-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--color-line);
  background: var(--color-raised);
}

/* ------------------------------------------------------------------ modals */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgb(0 0 0 / 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 3rem 1.25rem;
  overflow-y: auto;
}

:root[data-theme="light"] .modal-overlay { background: rgb(20 18 15 / 0.4); }

.modal-panel {
  background: var(--color-page);
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius);
  width: 100%;
  max-width: 44rem;
  animation: modal-in 0.14s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(-0.5rem); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--color-line);
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.modal-close {
  background: none;
  border: 0;
  color: var(--color-faint);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
}

.modal-close:hover { color: var(--color-body); }

.modal-body { padding: 1.5rem; }

.modal-intro {
  font-size: 0.875rem;
  color: var(--color-muted);
  margin-bottom: 1.5rem;
  max-width: 40rem;
  line-height: 1.6;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-line);
  background: var(--color-raised);
}

/* Every field says what it is for, under the field. If it needs a manual, the
   field is wrong. */
.field-help {
  font-size: 0.75rem;
  color: var(--color-faint);
  line-height: 1.5;
}

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

.field-error:empty { display: none; }

@media (max-width: 640px) {
  .modal-overlay { padding: 1rem 0.75rem; }
  .modal-body, .modal-head, .modal-foot { padding: 1rem; }
}

/* ----------------------------------------------------------- table toolbar */

.toolbar {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding-bottom: 0.25rem;
}

.toolbar .field { margin-bottom: 0; }
.toolbar .field label { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--color-faint); }
.toolbar .input { min-width: 9rem; }
.toolbar-grow { flex: 1 1 12rem; min-width: 0; }
.toolbar-spacer { flex: 1 1 auto; }

.toolbar-count {
  font-size: 0.75rem;
  color: var(--color-faint);
  padding-bottom: 0.5rem;
}

/* ------------------------------------------------------------------ guides */

/* A short line at the top of every screen saying what it is for and who uses it.
   Written for somebody who has never seen the system, because on a site that is
   most of the people who will open it. */
.guide {
  border: 1px solid var(--color-line);
  border-inline-start: 3px solid var(--color-signal);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  background: var(--color-raised);
}

.guide p { font-size: 0.875rem; line-height: 1.65; max-width: 62rem; }
.guide p + p { margin-top: 0.625rem; color: var(--color-muted); font-size: 0.8125rem; }

.guide summary {
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--color-accent);
  margin-top: 0.625rem;
}

.guide ul { margin-block: 0.625rem 0; margin-inline: 1.125rem 0; font-size: 0.8125rem; color: var(--color-muted); }
.guide li { margin-bottom: 0.375rem; line-height: 1.6; }

/* ------------------------------------------------------------------- toast */

.toasts {
  position: fixed;
  inset-inline-end: 1.25rem;
  bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 60;
  max-width: 22rem;
}

.toast {
  border: 1px solid var(--color-line-strong);
  border-inline-start-width: 3px;
  border-radius: var(--radius);
  background: var(--color-page);
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  animation: toast-in 0.2s ease;
}

.toast.is-ok { border-inline-start-color: var(--color-ok); }
.toast.is-error { border-inline-start-color: var(--color-breach); }

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


/* --------------------------------------------------------- the tower picker

   The one control that changes what the whole screen is about, so it reads as a
   decision rather than as another filter: its own compartment at the left of the
   header, separated by a hairline, with the tower name set larger than the page
   actions beside it.

   Built by hand rather than as a <select> — see tower-picker.js for why. That
   means the panel is ours to style, so it follows the house rules the native
   popup could not: hairlines only, no shadow, and the selected row marked with a
   dot rather than tinted. */

.tower-pick {
    display: flex;
    align-items: center;
    gap: .625rem;
    padding-inline-end: 1rem;
    margin-inline-end: .25rem;
    border-inline-end: 1px solid var(--color-line);
}

.tower-pick-label {
    font-size: .625rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--color-faint);
    white-space: nowrap;
}

.tower-menu { position: relative; }

.tower-button {
    display: flex;
    align-items: center;
    gap: .625rem;
    min-width: 11rem;
    padding-block: .4375rem .4375rem; padding-inline: .75rem .625rem;
    background: transparent;
    color: var(--color-body);
    border: 1px solid var(--color-line);
    border-radius: 2px;
    font: inherit;
    font-size: .875rem;
    cursor: pointer;
    transition: border-color .15s ease;
}

.tower-button:hover { border-color: var(--color-faint); }

.tower-button:focus-visible {
    outline: 2px solid var(--color-signal);
    outline-offset: 2px;
}

.tower-current { flex: 1; text-align: start; }

.tower-caret {
    width: 1rem;
    height: 1rem;
    flex: none;
    color: var(--color-faint);
    transition: transform .15s ease;
}

.tower-button[aria-expanded="true"] {
    border-color: var(--color-faint);
}

.tower-button[aria-expanded="true"] .tower-caret { transform: rotate(180deg); }

/* Solid, not translucent. A panel that lets the page show through is unreadable
   over a table, and a blur panel is on the list of things this project does not
   do. The hairline does the separating that a shadow would. */
.tower-panel {
    position: absolute;
    top: calc(100% + .375rem);
    inset-inline-end: 0;
    z-index: 40;
    min-width: 13rem;
    max-height: 24rem;
    overflow-y: auto;
    padding: .3125rem 0;
    background: var(--color-page);
    border: 1px solid var(--color-line);
    border-radius: 2px;
}

.tower-group {
    padding: .625rem .875rem .25rem;
    font-size: .625rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--color-faint);
}

.tower-group:first-child { padding-top: .25rem; }

.tower-option {
    display: flex;
    align-items: center;
    gap: .5rem;
    width: 100%;
    padding: .4375rem .875rem;
    background: transparent;
    color: var(--color-muted);
    border: 0;
    font: inherit;
    font-size: .875rem;
    text-align: start;
    cursor: pointer;
}

.tower-option:hover,
.tower-option:focus-visible {
    background: var(--color-raised);
    color: var(--color-body);
    outline: 0;
}

.tower-option.is-on { color: var(--color-body); }

.tower-tick {
    width: .5rem;
    flex: none;
    color: var(--color-accent);
    font-size: 1.125rem;
    line-height: 1;
}

.tower-rule {
    height: 1px;
    margin: .3125rem 0;
    background: var(--color-line);
}

/* One tower and nothing to choose. It still says which, because "which tower am
   I looking at" is the question, and a missing answer is worse than a fixed one. */
.tower-fixed {
    font-size: .9375rem;
    font-weight: 500;
    color: var(--color-body);
}

.tower-none {
    font-size: .8125rem;
    color: var(--color-faint);
}

@media (max-width: 48rem) {
    .tower-pick {
        border-inline-end: 0;
        padding-inline-end: 0;
        width: 100%;
        order: -1;
    }
    .tower-menu { flex: 1; min-width: 0; }
    /* The 11rem minimum pushed the button past a 390 px screen once it shared its row (PR-004). */
    .tower-button { width: 100%; min-width: 0; }
    .tower-panel { inset-inline-start: 0; inset-inline-end: auto; }
}

/* ------------------------------------------------------------- the tower

   An elevation, drawn in SVG. One colour and one signal: floors run from faint
   to solid as they progress, so a floor further along reads as MORE rather than
   as DIFFERENT — which is what is actually true, and it keeps a forty-storey
   drawing from turning into a chart with six hues up its side. */

.tw-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 2rem;
    flex-wrap: wrap;
    margin-bottom: 1.75rem;
}

.tw-title {
    font-size: 1.5rem;
    font-weight: 400;
    letter-spacing: -.01em;
    margin: .375rem 0 0;
}

.tw-totals { display: flex; gap: 2.25rem; flex-wrap: wrap; }

.tw-stat { display: flex; flex-direction: column; gap: .25rem; }

.tw-stat-value {
    font-size: 1.375rem;
    font-variant-numeric: tabular-nums;
    color: var(--color-body);
}

.tw-stat-label {
    font-size: .6875rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--color-faint);
}

.tw-body {
    display: grid;
    grid-template-columns: minmax(0, 26rem) minmax(0, 24rem);
    justify-content: start;
    gap: 3rem;
    align-items: start;
}

.tw-stage { max-width: 26rem; }

.tw-canvas {
    width: 100%;
    height: 100%;
    flex: 1;
    min-height: 0;
    display: block;
    cursor: grab;
    touch-action: pan-y;
}

.tw-canvas.is-held { cursor: grabbing; }

.tw-hint {
    flex: none;
    font-size: .6875rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--color-faint);
    text-align: center;
    margin: .375rem 0 0;
}

/* ---- the panel beside it */

.tw-detail { padding-top: .25rem; }

.tw-detail-head {
    display: flex;
    align-items: baseline;
    gap: .75rem;
    flex-wrap: wrap;
}

.tw-detail-floor {
    font-size: 1.75rem;
    font-variant-numeric: tabular-nums;
    color: var(--color-body);
}

.tw-detail-stage { font-size: .9375rem; color: var(--color-muted); }

.tw-source {
    font-size: .75rem;
    color: var(--color-faint);
    margin: .375rem 0 1.25rem;
}

.tw-facts {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: .5rem 1.25rem;
    margin: 0;
    font-size: .875rem;
}

.tw-facts dt {
    color: var(--color-faint);
    font-size: .75rem;
    padding-top: .125rem;
}

.tw-facts dd { margin: 0; color: var(--color-body); }

/* ---- the legend */

.tw-legend {
    display: flex;
    gap: .375rem .875rem;
    flex-wrap: wrap;
    margin-top: .875rem;
    padding-top: .75rem;
    border-top: 1px solid var(--color-line);
}

.tw-key {
    display: inline-flex;
    align-items: center;
    gap: .4375rem;
    font-size: .75rem;
    color: var(--color-faint);
}

.tw-swatch {
    width: .875rem;
    height: .625rem;
    background: var(--color-body);
    flex: none;
}

@media (max-width: 60rem) {
    .tw-body { grid-template-columns: 1fr; gap: 1.75rem; }
    .tw-stage { max-width: 100%; }
}

/* ------------------------------------------------------- the level grid

   Forty levels as a grid rather than a list, because setting up a tower means
   scanning for the few that need saying something about, not reading all of
   them. A level whose stage was set by hand carries a signal edge — the whole
   point of opening this screen is to see which ones somebody has spoken for. */

.floor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
    gap: .375rem;
    margin-top: 1.25rem;
}

.floor-chip {
    display: flex;
    flex-direction: column;
    gap: .125rem;
    padding: .5rem .625rem;
    background: transparent;
    border: 1px solid var(--color-line);
    border-radius: 999px;
    font: inherit;
    text-align: start;
    cursor: pointer;
    transition: border-color .12s ease;
}

.floor-chip:hover { border-color: var(--color-faint); }

.floor-chip:focus-visible {
    outline: 2px solid var(--color-signal);
    outline-offset: 2px;
}

.floor-chip.is-set { border-inline-start: 2px solid var(--color-signal); }

.floor-chip.is-parking { background: var(--color-raised); }

.floor-chip-name {
    font-size: .875rem;
    color: var(--color-body);
    font-variant-numeric: tabular-nums;
}

.floor-chip-stage {
    font-size: .6875rem;
    color: var(--color-faint);
}

.floor-chip.is-set .floor-chip-stage { color: var(--color-muted); }

/* ------------------------------------------------- the work on a level

   Twenty rows of "how far has this got". Each one is a name, a track, a
   number. The track is the thing you read across at a glance; the number is
   the thing you change. A finished row goes solid and loses its emphasis,
   because what matters on this screen is what is NOT finished. */

.work-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 2rem 0 .875rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--color-line);
}

.work-list { display: flex; flex-direction: column; }

.work-row {
    display: grid;
    grid-template-columns: minmax(9rem, 14rem) minmax(0, 1fr) 4.5rem auto minmax(0, 7rem);
    align-items: center;
    gap: .875rem;
    padding: .4375rem 0;
    border-bottom: 1px solid var(--color-line);
}

.work-name { font-size: .875rem; color: var(--color-body); }

.work-track {
    height: .375rem;
    background: var(--color-raised);
    border-radius: 1px;
    overflow: hidden;
}

.work-fill {
    display: block;
    height: 100%;
    background: var(--color-body);
    opacity: .55;
    transition: width .12s ease;
}

.work-row.is-done .work-fill { opacity: 1; }
.work-row.is-done .work-name { color: var(--color-muted); }

.work-percent {
    width: 100%;
    text-align: end;
    font-variant-numeric: tabular-nums;
    padding: .3125rem .5rem;
}

.work-unit { font-size: .75rem; color: var(--color-faint); }

.work-by {
    font-size: .6875rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 52rem) {
    .work-row {
        grid-template-columns: minmax(0, 1fr) 4.5rem auto;
        row-gap: .375rem;
    }
    .work-track { grid-column: 1 / -1; order: 3; }
    .work-by { display: none; }
}

/* A level chip carries its own progress bar, so the grid reads as the building
   rather than as a list of names. */
.floor-chip-bar {
    display: block;
    height: 2px;
    margin-top: .375rem;
    background: var(--color-raised);
}

.floor-chip-bar span {
    display: block;
    height: 100%;
    background: var(--color-signal);
}

/* --------------------------------------------- the dashboard, split in two

   Twelve columns: eight of figures, four of building. The tower is not another
   section in the list — it is what every number to its left is about — so it
   gets a column and sticks while the figures scroll past it.

   Below the breakpoint the tower goes first. On a phone the building is the
   thing worth seeing without scrolling; the numbers are the detail. */

.dash-split {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 2.5rem;
    align-items: start;
}



/* The whole building on one screen, or it is not a picture of a building.

   A fixed canvas height meant a thirty-seven level tower ran off the bottom of
   the column and had to be scrolled — at which point the dashboard has stopped
   being a dashboard. The column is exactly one viewport tall, the header and the
   legend take what they need, and the drawing takes everything that is left. */
.dash-tower {
    grid-column: span 4;
    min-width: 0;
    position: sticky;
    top: 1.5rem;
    height: calc(100vh - 3rem);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overscroll-behavior: contain;
    padding: 1.25rem 1.25rem 1rem;
    border: 1px solid var(--color-line);
    border-radius: 2px;
}

/* The drawing takes whatever the header and the legend leave. min-height:0 is what
   lets a flex child shrink below its content — without it the canvas would insist on
   its natural size and push the legend off the bottom again. */
.dash-tower .tw-head { flex: none; }
.dash-tower .tw-legend { flex: none; }
.dash-tower .tw-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.dash-tower .tw-stage { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* The card only ever floats now. Resting under a drawing that fills the column would
   put it off the bottom of the screen, which is the thing this is fixing. */
.dash-tower .tw-detail:not(.is-floating) { display: none; }

/* In its own column the tower reads top to bottom, not side by side. */
/* Figures down one side, the key down the other, and the building between them
   using the whole height of the column. Stacking them above and below was spending
   the one thing a thirty-seven level tower has none of. */
.dash-tower .tw-body {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: .625rem;
}

.dash-tower .tw-stage { flex: 1; min-width: 0; max-width: 100%; }

.dash-tower .tw-totals,
.dash-tower .tw-legend {
    flex: 0 0 5.25rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1.125rem;
    margin: 0;
    padding: 0;
    border: 0;
}

.dash-tower .tw-legend { gap: .625rem; }

.dash-tower .tw-stat { gap: .0625rem; }
.dash-tower .tw-stat-value { font-size: 1rem; }
.dash-tower .tw-stat-label { font-size: .5625rem; letter-spacing: .06em; line-height: 1.3; }

.dash-tower .tw-key { font-size: .625rem; gap: .3125rem; align-items: flex-start; }
.dash-tower .tw-swatch { width: .625rem; height: .5rem; margin-top: .1875rem; flex: none; }
.dash-tower .tw-hint { margin-top: .3125rem; font-size: .625rem; }

@media (max-width: 80rem) {
    .dash-split { grid-template-columns: minmax(0, 1fr); gap: 2rem; }

    .dash-tower { grid-column: 1 / -1; order: 1; position: static;
                  height: auto; overflow: visible; }
    .dash-tower .tw-canvas { height: 26rem; flex: none; }
    .dash-tower .tw-detail:not(.is-floating) { display: block; }
    .dash-tower .tw-head { flex-direction: row; }
}

/* ------------------------------------ the level panel beside the tower

   The number somebody remembers, then the facts, then every trade. The
   outstanding trades sort to the top: what is left is the question this panel
   is open to answer, and the finished ones are there to be scrolled past. */

.tw-progress { margin: 1rem 0 .75rem; }

.tw-progress-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .5rem;
}

.tw-progress-value {
    font-size: 2rem;
    font-variant-numeric: tabular-nums;
    color: var(--color-body);
    line-height: 1;
}

.tw-progress-left { font-size: .75rem; color: var(--color-faint); }

.tw-progress-track {
    display: block;
    height: .3125rem;
    background: var(--color-raised);
    border-radius: 1px;
    overflow: hidden;
}

.tw-progress-track span {
    display: block;
    height: 100%;
    background: var(--color-signal);
}

.tw-work-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin: 1.5rem 0 .625rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-line);
}

.tw-work { display: flex; flex-direction: column; gap: .375rem; }

.tw-work-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 4.5rem 2.5rem;
    align-items: center;
    gap: .625rem;
    font-size: .8125rem;
}

.tw-work-name {
    color: var(--color-body);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tw-work-track {
    height: .25rem;
    background: var(--color-raised);
    border-radius: 1px;
    overflow: hidden;
}

.tw-work-track span {
    display: block;
    height: 100%;
    background: var(--color-body);
    opacity: .5;
}

.tw-work-value {
    text-align: end;
    font-variant-numeric: tabular-nums;
    color: var(--color-muted);
    font-size: .75rem;
}

/* Finished recedes; nothing recorded recedes further. What is left stands out. */
.tw-work-row.is-done .tw-work-name { color: var(--color-faint); }
.tw-work-row.is-done .tw-work-track span { opacity: 1; }
.tw-work-row.is-untouched .tw-work-name { color: var(--color-faint); }
.tw-work-row.is-untouched .tw-work-value { color: var(--color-faint); }

/* A held level says so, so nobody wonders why the panel stopped following. */
.tw-stage.is-pinned .tw-hint::after { content: " · press it again to let go"; }

/* -------------------------------------------- the level card, floating

   One element, in two places. It sits under the drawing at rest and lifts out
   beside the floor under the pointer — so the full detail is where somebody is
   looking, and what is on it is never on the screen twice.

   Fixed, not absolute: the tower is in a column that scrolls on its own, and an
   absolutely positioned card would be clipped by it. */

.tw-detail.is-floating {
    position: fixed;
    z-index: 60;
    width: 23rem;
    max-height: 82vh;
    overflow-y: auto;
    padding: 1.25rem 1.375rem;

    /* Solid. A card you can read the dashboard through is one you read twice. */
    background: var(--color-page);
    border: 1px solid var(--color-line);
    border-inline-start: 2px solid var(--color-signal);
    border-radius: 2px;
}

/* The edge nearest the building is the signal one, so the eye goes back to the
   floor it belongs to rather than hunting for it. */
.tw-detail.is-floating .tw-facts { gap: .4375rem 1rem; }
.tw-detail.is-floating .tw-work { gap: .3125rem; }

.tw-detail.is-floating::-webkit-scrollbar { width: 5px; }
.tw-detail.is-floating::-webkit-scrollbar-thumb {
    background: var(--color-raised);
    border-radius: 3px;
}

/* Under a narrow viewport there is nowhere beside the tower to put it, so it
   stays where it is and the drawing keeps the screen to itself. */
@media (max-width: 60rem) {
    .tw-detail.is-floating {
        position: static;
        width: auto;
        max-height: none;
        padding: 0;
        background: transparent;
        border: 0;
    }
}

/* ------------------------------------------- the dashboard as one screen

   A dashboard you have to scroll to see is a report. On this one screen the page
   itself does not move: the figures scroll inside their own column and the tower
   is drawn whole, which is the only arrangement where a thirty-seven level
   building is a picture of a building rather than a thing to drag past.

   Scoped to the body class, so every other screen still scrolls the way a page
   should. min-height:0 appears at every level because a flex or grid child
   defaults to its content's size and would otherwise push the bottom off. */

body.shell-fixed { overflow: hidden; }

body.shell-fixed .shell { height: 100vh; min-height: 0; }
body.shell-fixed .shell-main { min-height: 0; }
body.shell-fixed .shell-header { flex: none; }
body.shell-fixed .shell-body {
    flex: 1;
    min-height: 0;
    overflow: hidden;

    /* Half the usual padding. On a screen that is exactly one viewport, every
       centimetre of chrome is a centimetre off the building. */
    padding: 1rem 1.25rem;
}

body.shell-fixed .shell-header { padding: .625rem 1.25rem; }
body.shell-fixed .page-title { font-size: 1.5rem; }

body.shell-fixed #dashboard { height: 100%; min-height: 0; }

/* The period tabs and the title stay put; only what is under them moves. */
body.shell-fixed #dash-split { flex: 1; min-height: 0; }

/* Full height of its own column, not of the viewport: the column starts below the
   period tabs, and sizing it against the viewport is what left the base of the
   tower hanging off the bottom of the screen. */
body.shell-fixed .dash-tower {
    position: static;
    height: 100%;
    min-height: 0;
}

@media (max-width: 80rem) {
    body.shell-fixed { overflow: auto; }
    body.shell-fixed .shell,
    body.shell-fixed .shell-body { height: auto; overflow: visible; }
    body.shell-fixed #dashboard { height: auto; }
    body.shell-fixed .dash-tower { height: auto; }
}

/* -------------------------------- the tower column, without a heading

   The building names itself on the drawing, the way a site hoarding does, so the
   card has no heading of its own — the same words twice were eating the height
   the tower needed. The totals sit under it as a footnote rather than over it as
   a headline: they are about the building, and the building is the thing. */



/* The period picker and the title belong to the figures, so they live in that
   column and the tower takes the full height of the screen beside them. */
.dash-left {
    grid-column: span 8;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

body.shell-fixed .dash-left { height: 100%; min-height: 0; }
body.shell-fixed .dash-left > .period,
body.shell-fixed .dash-left > .row { flex: none; }

body.shell-fixed .dash-left > .dash {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-inline-end: .75rem;
}

body.shell-fixed .dash-left > .dash::-webkit-scrollbar { width: 6px; }
body.shell-fixed .dash-left > .dash::-webkit-scrollbar-thumb {
    background: var(--color-raised);
    border-radius: 3px;
}

@media (max-width: 80rem) {
    .dash-left { grid-column: 1 / -1; order: 2; }
    body.shell-fixed .dash-left { height: auto; }
    body.shell-fixed .dash-left > .dash { overflow: visible; }
}


/* ------------------------------------- the tower column on a small screen

   On a phone the page scrolls, so height is not the scarce thing — width is. The
   figures and the key go back under the drawing and give it the whole width.

   These rules sit at the end of the file on purpose: a media query adds no
   specificity, so a narrow-screen rule written above a wide-screen one loses at
   every width. Order is the only thing that settles it. */

@media (max-width: 62rem) {
  .dash-tower .tw-body { flex-direction: column; }
  .dash-tower .tw-totals,
  .dash-tower .tw-legend {
    flex: none;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: .625rem 1.5rem;
  }
  .dash-tower .tw-canvas { height: 24rem; flex: none; }
}

/* ==========================================================================
   Camera state colour

   The one place in this application where colour carries meaning rather than
   decoration. Two hundred tiles cannot be scanned by shape, and the whole point
   of the panel is that a dead camera is findable in a second.

   Held to two hues, defined per ground because a green that reads on ink is a
   green that disappears on bone. Never the only signal: every tile also says
   what it is in words.
   ========================================================================== */

:root {
    --cam-up: #5FBF80;
    --cam-down: #E36A4B;
    --cam-working: #D9A441;
}

/* Darkened for the light ground, and only that: the hue does not move, so a
   camera does not look like a different state after somebody presses the
   switch. Every one of these clears 4.5:1 against the page it sits on —
   #3F8F5B was the obvious green and measures 3.58:1, which fails for the 11px
   state line under a tile. */
:root[data-theme="light"] {
    --cam-up: #27703F;
    --cam-down: #B33A22;
    --cam-working: #845A12;
}

/* ==========================================================================
   The camera panel

   Two hundred cameras as the building they are fixed to: floors down the page,
   the cameras on each floor across it. Green is working, red is not.
   ========================================================================== */

.cam-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1.25rem;
    padding: .625rem 0 .75rem;
    border-bottom: 1px solid var(--color-line);
}

.cam-stat { display: flex; flex-direction: column; gap: .125rem; }

.cam-stat-label {
    font-size: .6875rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--color-faint);
}

.cam-stat-value {
    font-size: 1.25rem;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    color: var(--color-body);
}

.cam-stat-value.is-up { color: var(--cam-up); }
.cam-stat-value.is-down { color: var(--cam-down); }

.cam-actions {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-inline-start: auto;
    flex-wrap: wrap;
    justify-content: flex-end;
    flex: 1 1 26rem;
}

.cam-filter {
    display: flex;
    align-items: center;
    gap: .4375rem;
    font-size: .8125rem;
    color: var(--color-muted);
    cursor: pointer;
}

/* ------------------------------------------------------------------ a tile

   Sized from the number, not from the mockup. Two hundred boxes have to be on
   one screen at once — that is the reason the floor headings went — so the box
   is what 200 divided by the space allows: about twelve across and seventeen
   down on a laptop, at seven rem wide and a shade over two rem tall.

   Two lines fit in that. The code, because that is what a camera is called on a
   report and over a radio, and where it is. Everything else — what it watches,
   why it is down, the ticket — is on the hover and in the dialog. A box that
   tried to carry all of it would carry none of it legibly. */

.cam-grid {
    display: grid;
    /* 5.25rem is the narrowest the longest code still reads at, once the prefix
       every tile shares has come off it: the box is 84px, the text well inside it
       is 66px, and the longest thing that has to sit in it is about 61px at 11px.
       Narrower and a code starts losing its tail, which is the one thing on the
       box that must never be guessed at. Fifteen columns at 1600. */
    grid-template-columns: repeat(auto-fill, minmax(5.25rem, 1fr));
    gap: .1875rem;
    margin-top: .625rem;
}

.cam-tile {
    display: block;
    padding: .25rem .375rem;
    background: transparent;
    border: 1px solid var(--color-line);
    border-radius: var(--radius);
    font: inherit;
    text-align: start;
    cursor: pointer;
    transition: border-color .12s ease;
    min-width: 0;
}

.cam-tile:hover { border-color: var(--color-faint); }

.cam-tile:focus-visible {
    outline: 2px solid var(--color-signal);
    outline-offset: 1px;
}

/* A critical camera carries a signal edge, the same as a level somebody has
   spoken for. The gate is not one more camera. */
.cam-tile.is-critical { border-inline-start: 2px solid var(--color-signal); }

/* The code gets the whole width of the box. It is the longest thing on the tile
   and the one thing that must never be read back wrong, so nothing shares its
   line — the dot went to the second row, next to the words it describes. */
.cam-code {
    display: block;
    font-size: .6875rem;
    line-height: 1.2;
    color: var(--color-body);
    font-variant-numeric: tabular-nums;
    letter-spacing: -.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cam-where {
    display: flex;
    align-items: center;
    gap: .25rem;
    min-height: .9375rem;
}

.cam-where-text {
    font-size: .625rem;
    line-height: 1.2;
    color: var(--color-faint);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cam-dot {
    width: .375rem;
    height: .375rem;
    border-radius: 50%;
    background: var(--cam-up);
    flex: none;
}

/* The five states. Anything not working is red on the dot and says so in
   words on the second line; the shades separate "it will come back" from
   "somebody has to go". */

.cam-tile.is-offline,
.cam-tile.is-damaged,
.cam-tile.is-underrepair,
.cam-tile.is-awaitingreplacement { border-color: color-mix(in srgb, var(--cam-down) 45%, transparent); }

.cam-tile.is-offline .cam-dot,
.cam-tile.is-damaged .cam-dot,
.cam-tile.is-awaitingreplacement .cam-dot { background: var(--cam-down); }

.cam-tile.is-underrepair .cam-dot { background: var(--cam-working); }

.cam-tile.is-offline .cam-where-text,
.cam-tile.is-damaged .cam-where-text,
.cam-tile.is-awaitingreplacement .cam-where-text { color: var(--cam-down); }

.cam-tile.is-underrepair .cam-where-text { color: var(--cam-working); }


/* The search box, which is how a camera is found once there are two hundred of
   them and no headings to scan. It takes the width the row has spare, because
   what people type into it is "27th floor lift lobby", not "F27". */
.cam-search {
    flex: 1 1 12rem;
    min-width: 8rem;
    max-width: 22rem;
    font-size: .8125rem;
    padding: .375rem .625rem;
}

/* Says how many of the two hundred are on screen. A filtered grid that looks
   like a short register is the one way this panel could lie about what is down. */
.cam-shown {
    font-size: .75rem;
    color: var(--color-faint);
    white-space: nowrap;
}

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

.cam-dialog { display: flex; flex-direction: column; gap: 1.25rem; }

.cam-now {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: .25rem .625rem;
    padding: .875rem 1rem;
    border: 1px solid var(--color-line);
    border-radius: var(--radius);
}

.cam-now .cam-dot,
.cam-log-item .cam-dot { width: .5rem; height: .5rem; }

.cam-now .cam-dot { margin-top: .375rem; grid-row: 1; }

.cam-now.is-offline,
.cam-now.is-damaged,
.cam-now.is-awaitingreplacement { border-color: color-mix(in srgb, var(--cam-down) 45%, transparent); }

.cam-now.is-offline .cam-dot,
.cam-now.is-damaged .cam-dot,
.cam-now.is-awaitingreplacement .cam-dot { background: var(--cam-down); }

.cam-now.is-underrepair .cam-dot { background: var(--cam-working); }

.cam-now-state { font-size: 1.125rem; color: var(--color-body); }
.cam-now-since { font-size: .8125rem; color: var(--color-faint); }

.cam-now-reason,
.cam-now-note,
.cam-now-by {
    grid-column: 2;
    font-size: .8125rem;
    color: var(--color-muted);
}

.cam-now-reason { display: flex; gap: .5rem; align-items: baseline; margin-top: .5rem; }
.cam-now-note { margin: .375rem 0 0; }
.cam-now-by { font-size: .75rem; color: var(--color-faint); margin-top: .375rem; }

.cam-month {
    display: flex;
    gap: 2.5rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--color-line);
}

.cam-month-value {
    display: block;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--color-body);
    font-variant-numeric: tabular-nums;
}

.cam-month-label {
    display: block;
    font-size: .6875rem;
    color: var(--color-faint);
    margin-top: .25rem;
}

.cam-facts {
    display: grid;
    grid-template-columns: 9rem 1fr;
    gap: .375rem 1rem;
    margin: 0;
    font-size: .8125rem;
}

.cam-facts dt { color: var(--color-faint); }
.cam-facts dd { margin: 0; color: var(--color-body); }

.cam-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--color-line);
}

/* ---------------------------------------------------------------- the log */

.cam-log { list-style: none; margin: 0; padding: 0; }

.cam-log-item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: .125rem .625rem;
    padding: .75rem 0;
    border-bottom: 1px solid var(--color-line);
}

.cam-log-item:last-child { border-bottom: 0; }
.cam-log-item .cam-dot { margin-top: .375rem; grid-row: 1; }

.cam-log-item.is-offline .cam-dot,
.cam-log-item.is-damaged .cam-dot,
.cam-log-item.is-awaitingreplacement .cam-dot { background: var(--cam-down); }

.cam-log-item.is-underrepair .cam-dot { background: var(--cam-working); }

.cam-log-state { font-size: .875rem; color: var(--color-body); }
.cam-log-note { font-size: .8125rem; color: var(--color-muted); margin: .25rem 0 0; }
.cam-log-when { font-size: .6875rem; color: var(--color-faint); margin-top: .25rem; }

/* A refusal that belongs to no field, shown where the eye already is rather
   than as a toast in a corner the dialog is covering. */
.modal-error {
    margin: 0 0 1rem;
    padding: .625rem .75rem;
    font-size: .8125rem;
    color: var(--color-body);
    border-inline-start: 2px solid var(--cam-down);
    background: var(--color-raised);
}

/* ------------------------------------------------------------- narrow screens

   Below the tablet break the tiles go one per row. Two columns of truncated
   location text is worse than one column that reads, and the location is how
   somebody finds the camera. */
@media (max-width: 40rem) {
    .cam-grid { grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr)); }
    .cam-summary { gap: 1.25rem; }
    .cam-actions { margin-inline-start: 0; width: 100%; }
    .cam-search { flex: 1 1 100%; max-width: none; }
    .cam-facts { grid-template-columns: 1fr; gap: 0; }
    .cam-facts dt { margin-top: .625rem; }
    .cam-month { gap: 1.5rem; }
}

/* ==========================================================================
   The site drawing on the dashboard

   A single tower is tall and narrow, so it lives in four columns beside the
   figures and uses the full height of the screen. Six buildings side by side
   are the opposite shape — wide and short — and four columns would draw them
   about forty pixels each, which is a bar chart with names on it.

   So on the all-towers total the split turns: the site takes the full width
   across the top and the figures scroll underneath it. Same one-screen shell,
   same sticky nothing, just the other way up.
   ========================================================================== */

.dash-split.is-site {
    grid-template-columns: minmax(0, 1fr);
    gap: 2rem;
}

/* First, explicitly. Both children span the full width, so without this the grid
   places them in source order and the figures end up above the drawing. */
.dash-split.is-site .dash-tower {
    grid-column: 1 / -1;
    order: -1;
    position: static;
    top: auto;

    /* The screen. The scale is height-bound — a site plan is wider than it is
       tall and the box is wider still — so every pixel this grows downwards is a
       pixel on every building. The figures are a scroll away, which is where a
       dashboard's second screen has always been. */
    /* Room for the line above it. Without this the card keeps its full height, the
       whole thing moves down, and the slider — which is the point of the screen —
       falls below the fold on arrival. */
    height: calc(100vh - 8.5rem);
    min-height: 26rem;
    padding: .875rem 1rem .5rem;
}

.dash-split.is-site .dash-left { grid-column: 1 / -1; min-height: 0; }

/* The wheel belongs to the page here.

   `.dash-tower` hides its overflow and contains its overscroll, which is right for
   the single-tower elevation: that one fills a sticky column and must not scroll
   the page out from under somebody who is turning it. On the site layout the card
   is an ordinary box on an ordinary page, and containing the scroll there only
   means a wheel over the drawing does nothing and the page has to be scrolled from
   the margin. */
.dash-split.is-site .dash-tower {
    overflow: visible;
    overscroll-behavior: auto;
}

/* Below the tablet break the split is already one column and everything stacks;
   the site just needs a height it can be seen at. */
@media (max-width: 62rem) {
    .dash-split.is-site .dash-tower { height: 26rem; }
}

/* Across the top, the four counts sit in a row above the drawing rather than in
   a column beside it. Width is the thing a site plan is short of, and four
   figures stacked down one side cost eighty pixels of it.

   Specific enough to beat ".dash-tower .tw-body", which is the row layout the
   single-tower elevation needs. Equal specificity settles on source order, and
   relying on order across two thousand lines is how this breaks the next time
   somebody appends a rule. */
.dash-tower .tw-body.is-site {
    display: block;
    position: relative;
    min-height: 0;
    height: 100%;
}

/* The drawing takes the whole card. Everything else sits over it. */
.dash-tower .tw-body.is-site .tw-stage {
    position: absolute;
    inset: 0;
    max-width: none;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ---------------------------------------------- the figures, over the drawing

   In the corners rather than in columns beside it. A site plan turning at a
   twenty degree tilt leaves its own corners empty at every angle, and nineteen
   rem of flanking columns was costing the buildings their height. */

/* At the BOTTOM, not the top. The drawing now fills the card, and the tallest
   roof reaches within forty pixels of the ceiling — which is where the names sit.
   The bottom of a site plan is the sea and the road, which is the one part of the
   picture with nothing in it to read. */
/* Down the left, not along the bottom.

   A turning site plan is wider than it is deep, so the buildings sit right of
   centre and the left third of the card is empty at every angle. The counts go
   there; the slider gets the bottom strip to itself instead of sharing it. */
.dash-tower .tw-body.is-site .tw-totals {
    position: absolute;
    inset-inline-start: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    flex-direction: column;
    gap: 1.75rem;
    margin: 0;
    padding: 0;
    border: 0;
    pointer-events: none;
}

.site-list {
    position: absolute;
    inset-inline-end: 0;
    top: 0;
    z-index: 2;
    width: 12rem;
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .375rem;
}

.site-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: .125rem .5rem;
    width: 100%;
    padding: .25rem .375rem;
    background: transparent;
    border: 0;
    border-radius: var(--radius);
    font: inherit;
    text-align: start;
    cursor: pointer;
}

.site-row:hover { background: var(--color-raised); }

.site-row:focus-visible {
    outline: 2px solid var(--color-signal);
    outline-offset: 1px;
}

.site-row-name {
    font-size: .75rem;
    color: var(--color-body);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.site-row-figure {
    font-size: .75rem;
    color: var(--color-faint);
    font-variant-numeric: tabular-nums;
}

.site-row-bar {
    grid-column: 1 / -1;
    height: 2px;
    background: var(--color-line);
    margin-top: .1875rem;
}

.site-row-bar > span {
    display: block;
    height: 100%;
    background: var(--color-signal);
}

/* The hint sits at the bottom of the drawing rather than pushing it up. */
.dash-tower .tw-body.is-site .tw-hint {
    position: absolute;
    inset-inline-start: 0;
    inset-inline-end: 0;
    bottom: 0;
    text-align: center;
    margin: 0;
    pointer-events: none;
}

@media (max-width: 62rem) {
    .dash-tower .tw-body.is-site .tw-totals {
        position: static;
        flex-wrap: wrap;
        gap: 1.25rem;
        margin-bottom: .5rem;
    }

    .site-list { position: static; width: 100%; margin-top: .75rem; }

    .dash-tower .tw-body.is-site { display: flex; flex-direction: column; }
    .dash-tower .tw-body.is-site .tw-stage { position: relative; inset: auto; flex: 1; }
}

/* ------------------------------------------------- what the shading means

   Bottom right, opposite the counts, in the corner a turning site plan leaves
   empty at every angle. Four steps of the same ramp the levels are drawn with,
   sampled from it rather than written out again, so the key cannot drift from
   the thing it describes. */

.site-key {
    position: absolute;
    inset-inline-end: 0;
    bottom: 1.5rem;
    z-index: 2;
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .3125rem;
    pointer-events: none;
}

.site-key li {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.site-key-swatch {
    width: .75rem;
    height: .75rem;
    flex: none;
    border: 1px solid var(--color-line);
    border-radius: 1px;
}

.site-key-swatch.is-signal {
    background: var(--color-signal);
    border-color: var(--color-signal);
    width: .5rem;
    height: .5rem;
    border-radius: 50%;
    margin: 0 .125rem;
}

.site-key-label {
    font-size: .6875rem;
    color: var(--color-faint);
    white-space: nowrap;
}

@media (max-width: 62rem) {
    .site-key {
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
        gap: .75rem;
        margin-top: .75rem;
    }
}

/* ------------------------------------------------- scrubbing through the months

   Under the drawing, across the middle, where the ground is. It is the one control
   on this screen and it should look like one — a handle, a date, and a button that
   plays it forward. */

.site-when {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 1.25rem;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: .75rem;
    width: min(34rem, 72%);
}

.site-play {
    flex: none;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    background: transparent;
    border: 1px solid var(--color-line);
    border-radius: 50%;
    color: var(--color-muted);
    font-size: .625rem;
    line-height: 1;
    cursor: pointer;
}

.site-play:hover { border-color: var(--color-faint); color: var(--color-body); }

.site-play:focus-visible {
    outline: 2px solid var(--color-signal);
    outline-offset: 2px;
}

.site-slider {
    flex: 1;
    min-width: 0;
    accent-color: var(--color-signal);
    cursor: pointer;
}

.site-when-date {
    flex: none;
    min-width: 6rem;
    font-size: .75rem;
    color: var(--color-faint);
    font-variant-numeric: tabular-nums;
}

/* Away from today, the date is the most important thing on the screen: everything
   else — the counts, the list, the cameras — is still about this morning. */
.site-when.is-past .site-when-date { color: var(--color-accent); }

@media (max-width: 62rem) {
    .site-when { position: static; transform: none; width: 100%; margin-top: .75rem; }
}

/* ---------------------------------------------------------- worth a look

   A list of things a person would have noticed if they had read every row. No
   badges, no colour: the moment one of these looks like an alarm, somebody
   starts arguing with it instead of looking. */

.attention-row {
    padding: .75rem 0;
    border-bottom: 1px solid var(--color-line);
}

.attention-row:last-child { border-bottom: 0; }

.attention-what { font-size: .9375rem; color: var(--color-body); }
.attention-where { font-size: .75rem; color: var(--color-faint); margin-top: .125rem; }
.attention-why { font-size: .8125rem; color: var(--color-muted); margin-top: .3125rem; }

/* A difference, not a feed. One line, above everything that says what is true now. */
.since {
    margin: 0 0 1rem;
    padding: .625rem .75rem;
    font-size: .8125rem;
    color: var(--color-muted);
    border-inline-start: 2px solid var(--color-signal);
    background: var(--color-raised);
}

.header-status {
    margin: .25rem 0 0;
    padding-block: 0 0; padding-inline: .5rem 0;
    max-width: 38rem;
    background: transparent;
    font-size: .6875rem;
    line-height: 1.35;
}

/* The coverage switch, under the key it belongs with. */
/* Under the key rather than over it. The key ends at the bottom right of the
   drawing, and the switch was landing on its last line. */
.site-coverage {
    position: absolute;
    inset-inline-end: 0;
    bottom: 9.25rem;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: .4375rem;
    font-size: .75rem;
    color: var(--color-muted);
    cursor: pointer;
}

@media (max-width: 62rem) {
    .site-coverage { position: static; margin-top: .75rem; }
}

/* ------------------------------------------------- the reach, worked out

   The one number on the sign-in setup screen that nobody types. It is shown
   large because it is the consequence of everything above it, and because it
   decides whether a shift can get into the system. */

.fence-reach {
    display: flex;
    align-items: baseline;
    gap: .625rem;
    margin-top: 1.25rem;
    padding: .875rem 1rem;
    border-inline-start: 2px solid var(--color-signal);
    background: var(--color-raised);
}

.fence-reach-value {
    font-size: 1.75rem;
    line-height: 1;
    color: var(--color-body);
    font-variant-numeric: tabular-nums;
}

.fence-reach-label {
    font-size: .8125rem;
    color: var(--color-muted);
}

/* A day nobody came to. Quieter than the days somebody did — an absence is read down
   a column, not one row at a time, and a wall of loud rows stops being read at all. */
.data tr.is-absent td { opacity: .72; }

/* A row that opens something when pressed. */
.data tr.is-pressable { cursor: pointer; }
.data tr.is-pressable:hover { background: var(--color-raised); }

/* ------------------------------------------------ the screen that was left

   A minute's warning before the session ends. Bottom right rather than a modal
   over the middle: somebody who IS working should be able to carry on typing
   and never look at it, and somebody who is not will find it where notices
   live. It is not a dialog to dismiss — moving the mouse is the answer. */

.idle-warning {
    position: fixed;
    inset-inline-end: 1.25rem;
    bottom: 1.25rem;
    z-index: 60;
    width: min(22rem, calc(100vw - 2.5rem));
    padding: 1rem 1.125rem;
    background: var(--color-page);
    border: 1px solid var(--color-signal);
    box-shadow: none;
}

.idle-warning-title {
    font-size: .9375rem;
    color: var(--color-body);
    margin: 0 0 .375rem;
}

.idle-warning-note {
    font-size: .8125rem;
    color: var(--color-muted);
    margin: 0 0 .875rem;
}

.idle-warning-note strong {
    color: var(--color-body);
    font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------- one day, hour by hour

   Beneath the drawing rather than on it. The canvas answers "how far has this got";
   this answers "what happened and in what order", and the second question is read as
   a list — a mark on a building says something happened there and cannot say what. */

/* The drawing and the day beneath it, as one column of the dashboard grid.

   The card keeps its own sticky full height inside this, so the buildings are drawn
   exactly as large as they were before the panel existed — it is the column that grows,
   not the drawing that shrinks. */
/* It only ever exists on the all-towers layout, where the split is one column and the
   drawing goes full width at the top with the figures a scroll below it. So the wrapper
   takes exactly the place the card used to take — full width, first — and the card keeps
   its own height rules inside it, which is why the buildings are drawn the same size
   they always were. */
.site-column {
    grid-column: 1 / -1;
    order: -1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.site-column .dash-tower { grid-column: auto; }

.site-day {
    flex: none;
    min-width: 0;
    border: 1px solid var(--color-line);
    padding: .875rem 1rem;
}

.site-day-head {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.site-day-play {
    flex: none;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    font-size: .625rem;
    line-height: 1;
    background: none;
    color: var(--color-body);
    border: 1px solid var(--color-line);
    cursor: pointer;
}

.site-day-play:hover { border-color: var(--color-signal); }

.site-day-slider { flex: 1 1 auto; min-width: 0; accent-color: var(--color-signal); }

.site-day-hour {
    flex: none;
    font-size: .75rem;
    color: var(--color-faint);
    font-variant-numeric: tabular-nums;
    min-width: 7.5rem;
    text-align: end;
}

.site-day-list {
    list-style: none;
    margin: .625rem 0 0;
    padding: 0;

    /* Four or five lines. It shares a card with the drawing, and the drawing is the
       thing somebody came to look at. */
    max-height: 9rem;
    overflow-y: auto;
}

.site-day-item {
    display: grid;
    grid-template-columns: 3rem 6.5rem minmax(0, 1fr) minmax(0, 10rem);
    gap: .75rem;
    padding: .3125rem 0;
    font-size: .75rem;
    color: var(--color-muted);
    border-bottom: 1px solid var(--color-line);
}

.site-day-at { color: var(--color-faint); font-variant-numeric: tabular-nums; }
.site-day-kind { color: var(--color-faint); }
.site-day-what { color: var(--color-body); overflow: hidden; text-overflow: ellipsis; }
.site-day-where { color: var(--color-faint); text-align: end; }

/* A P1 incident and a delivery both happened. Only one of them earns the mark. */
.site-day-item.is-weight-3 { border-inline-start: 2px solid var(--color-signal); padding-inline-start: .625rem; }
.site-day-item.is-weight-3 .site-day-kind { color: var(--color-body); }

.site-day-more {
    padding: .5rem 0 0;
    font-size: .75rem;
    color: var(--color-faint);
}

@media (max-width: 46rem) {
    .site-day-item { grid-template-columns: 3rem minmax(0, 1fr); }
    .site-day-kind, .site-day-where { display: none; }
}

/* --------------------------------------------- one photograph a day, in a row

   A strip rather than a grid. The point of these is the sequence — thirty days
   side by side is a building going up — and a grid breaks the sequence into
   rows the eye reads as unrelated. It scrolls sideways inside its own box, which
   is the one place on this system that is allowed to. */

.photo-strip {
    display: flex;
    gap: .5rem;
    margin-top: 1rem;
    padding-bottom: .5rem;
    overflow-x: auto;
}

.photo-thumb {
    flex: none;
    width: 6.5rem;
    text-decoration: none;
    color: var(--color-faint);
    font-size: .6875rem;
}

.photo-thumb img {
    display: block;
    width: 6.5rem;
    height: 8.125rem;    /* 4:5, the same portrait every other picture on this system uses */
    object-fit: cover;
    border: 1px solid var(--color-line);
    background: var(--color-raised);
}

.photo-thumb:hover img { border-color: var(--color-signal); }
.photo-thumb span { display: block; margin-top: .375rem; }

/* -------------------------------------------------- the cameras on a floor, playing

   Named live-* rather than cam-*, because the camera panel has owned .cam-tile
   since it was built and these are a different thing entirely — a wall of moving
   pictures against a grid of two hundred status boxes. Sharing the name made every
   box on the panel sixteen by nine and cut what fits on a screen from 210 to 75.

   Sixteen by nine, because that is what a camera produces and cropping it to
   something tidier throws away the edges of the frame — which on a wide-angle
   site camera is where most of what you want to see is. */

.live-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: .75rem;
    margin-top: 1rem;
}

.live-tile {
    position: relative;
    border: 1px solid var(--color-line);
    background: #000;
    min-width: 0;
}

.live-tile video {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background: #000;
}

.live-tile-dark {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 16 / 9;
    padding: 1rem;
    text-align: center;
    font-size: .75rem;
    color: var(--color-faint);
    background: var(--color-raised);
}

.live-tile-foot {
    display: flex;
    justify-content: space-between;
    gap: .5rem;
    padding: .4375rem .625rem;
    font-size: .6875rem;
    border-top: 1px solid var(--color-line);
}

.live-tile-code { color: var(--color-body); }

.live-tile-where {
    color: var(--color-faint);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* On the picture, not under it. Somebody screenshotting a tile for a slide has to
   take the word with them — which is the whole reason it is here rather than in a
   caption that crops off. */
.live-tile-sample {
    position: absolute;
    top: .375rem;
    inset-inline-start: .375rem;
    padding: .125rem .375rem;
    font-size: .625rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #fff;
    background: var(--color-signal);
}

/* The way out of the hover card and into the cameras on that floor.

   Near the top of the card, because a floor with a dozen trades on it makes the
   card taller than the screen and anything at the bottom of it cannot be seen. */
.tw-detail-cams {
    display: block;
    margin: .75rem 0 .25rem;
    text-align: center;
    text-decoration: none;
}

/* And the card itself never runs off the screen again. Its own scroll rather than
   the pages, so the drawing underneath does not move while somebody reads it. */
.tw-detail {
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
}

/* ------------------------------------------------- the floor card, held open

   It used to close the instant somebody moved towards it, which made everything
   on it unreachable — a card you cannot get to is a card with nothing on it.
   Now it survives the journey, and pressing a floor pins it until it is let go. */

.tw-detail-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
}

/* Only on a pinned card. On one that follows the pointer it would be a target
   nobody could hit, and a thing to have to explain. */
.tw-detail-close {
    display: none;
    flex: none;
    width: 1.375rem;
    height: 1.375rem;
    padding: 0;
    font-size: 1rem;
    line-height: 1;
    background: none;
    border: 0;
    color: var(--color-faint);
    cursor: pointer;
}

.tw-detail.is-pinned .tw-detail-close { display: block; }
.tw-detail-close:hover { color: var(--color-body); }

.tw-detail-close:focus-visible {
    outline: 1px solid var(--color-signal);
    outline-offset: 2px;
}

/* Pinned reads as pinned, or nobody knows why it stopped following them. */
.tw-detail.is-pinned { border-color: var(--color-signal); }

.tw-detail-open {
    display: block;
    margin-top: .375rem;
    font-size: .75rem;
    color: var(--color-accent);
}

/* Register screens added by the expanded roadmap (claims, commissioning, risk,
   land and legal, enquiries). One set of rules rather than five copies inlined
   into five views. */
/* minmax(0,1fr), not 1fr, and min-width:0 on the cells.

   A 1fr track will not shrink below its content, because a grid item's min-width
   defaults to auto — so one long figure widens its track, the row grows past the
   viewport, and the whole page scrolls sideways. It only shows once the data is
   real: this passed for weeks and then failed by 22px at 1024 the first time a
   booking on the register carried "PKR 29,000,000". The same note is written
   above .table-wrap, and it is the same mistake. */
.erp-kpis{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));border:1px solid var(--color-line)}
.erp-kpis div{padding:1rem;border-inline-end:1px solid var(--color-line);min-width:0}
.erp-kpis div:last-child{border-inline-end:0}
.erp-kpis strong{display:block;overflow-wrap:anywhere}
.erp-kpis .eyebrow{overflow-wrap:anywhere}
.erp-tabs{display:flex;gap:1rem;overflow:auto;border-bottom:1px solid var(--color-line);margin:1rem 0}
.erp-tabs button{border:0;background:none;color:var(--color-muted);padding:.7rem 0;white-space:nowrap;text-transform:capitalize}
.erp-tabs .active{color:var(--color-body);border-bottom:2px solid var(--color-accent)}
.erp-note{color:var(--color-faint);margin:.8rem 0 0}
.data td.warn{color:var(--color-warn)}
@media(max-width:900px){.erp-kpis{grid-template-columns:repeat(2,minmax(0,1fr))}.erp-kpis div{border-bottom:1px solid var(--color-line)}}
.btn-small{padding:.25rem .6rem;font-size:.8rem;margin-inline-end:.35rem}
.gantt-wrap{margin:0 0 1.5rem}
.gantt-scroll{overflow-x:auto;border:1px solid var(--color-line);border-radius:var(--radius)}
.gantt-scroll canvas{display:block;width:100%;min-width:640px}

/* ==========================================================================
   The command palette (Ctrl+K)

   One overlay, built by command-palette.js. Colours are the shared tokens only,
   so both themes follow without a rule of their own.
   ========================================================================== */

.cmdk-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 2rem;
  padding: 0 0.6rem;
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius);
  background: transparent;
  color: var(--color-muted);
  cursor: pointer;
}
.cmdk-btn:hover { background: var(--color-raised); }
.cmdk-btn svg { width: 1rem; height: 1rem; }
.cmdk-btn kbd {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--color-faint);
}

.cmdk { position: fixed; inset: 0; z-index: 120; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 1rem 1rem; }
.cmdk[hidden] { display: none; }
.cmdk-scrim { position: absolute; inset: 0; background: rgb(0 0 0 / 0.55); }
.cmdk-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 40rem;
  max-height: 72vh;
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius);
  background: var(--color-page);
  color: var(--color-body);
  box-shadow: 0 1.5rem 3rem rgb(0 0 0 / 0.4);
}
.cmdk-input {
  width: 100%;
  padding: 0.9rem 1rem;
  border: 0;
  border-bottom: 1px solid var(--color-line);
  background: transparent;
  color: var(--color-body);
  font-family: var(--font-sans);
  font-size: 1rem;
  outline: none;
}
.cmdk-input:focus-visible { box-shadow: inset 0 -2px 0 var(--color-accent); }
.cmdk-list { overflow-y: auto; overscroll-behavior: contain; padding: 0.25rem 0 0.5rem; }
.cmdk-group { padding: 0.6rem 1rem 0.25rem; }
.cmdk-item {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  cursor: pointer;
}
.cmdk-item.is-active { background: var(--color-raised-2); box-shadow: inset 2px 0 0 var(--color-accent); }
.cmdk-kind {
  flex: 0 0 6.5rem;
  font-size: 0.6875rem;
  color: var(--color-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cmdk-text { display: flex; flex-direction: column; min-width: 0; }
.cmdk-title, .cmdk-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-sub { font-size: 0.75rem; }
.cmdk-note { padding: 0.6rem 1rem; font-size: 0.8125rem; }
.cmdk-foot {
  display: flex;
  gap: 1rem;
  padding: 0.5rem 1rem;
  border-top: 1px solid var(--color-line);
  font-size: 0.6875rem;
}
body.cmdk-lock { overflow: hidden; }

@media (max-width: 40rem) {
  .cmdk { padding-top: 4rem; }
  .cmdk-btn kbd, .cmdk-foot { display: none; }
  .cmdk-kind { flex-basis: 4.5rem; }
}

/* ------------------------------------------------- saved views, empty states */

.sv-group { display: inline-flex; gap: 0.5rem; flex-wrap: wrap; }
.sv-bar { justify-content: flex-end; margin-top: 0.75rem; }
.sv-wrap { position: relative; display: inline-block; }
.sv-button { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sv-pop {
  position: absolute; inset-inline-end: 0; top: calc(100% + 0.25rem); z-index: 40;
  width: 22rem; max-width: calc(100vw - 2rem); max-height: 70vh; overflow: auto;
  padding: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem;
  background: var(--color-page); color: var(--color-body);
  border: 1px solid var(--color-line-strong); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.25);
}
.sv-pop[hidden] { display: none; }
.sv-title { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--color-faint); }
.sv-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.sv-item { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.25rem 0.75rem; padding: 0.25rem 0.375rem; border-radius: var(--radius); }
.sv-item.is-active { background: var(--color-raised); }
.sv-item .input { flex: 1 1 8rem; min-width: 0; }
.sv-none { padding: 0.25rem 0.375rem; font-size: 0.8125rem; }
.sv-name { background: none; border: 0; padding: 0; color: var(--color-body); font: inherit; cursor: pointer; text-align: start; overflow-wrap: anywhere; }
.sv-name:hover { color: var(--color-accent); }
.sv-tag { margin-inline-start: 0.5rem; font-size: 0.6875rem; color: var(--color-accent); }
.sv-acts { display: inline-flex; gap: 0.625rem; flex-wrap: wrap; }
.sv-link { background: none; border: 0; padding: 0; font: inherit; font-size: 0.75rem; color: var(--color-faint); cursor: pointer; text-decoration: underline; }
.sv-link:hover { color: var(--color-accent); }
.sv-reset { align-self: flex-start; }
.sv-save { display: flex; gap: 0.5rem; }
.sv-save .input { flex: 1 1 auto; min-width: 0; }
.sv-update { align-self: flex-start; white-space: normal; text-align: start; }
.sv-check { display: flex; gap: 0.5rem; align-items: center; cursor: pointer; font-size: 0.875rem; }

/* The row spans a table that may be wider than the screen; the block stays in view. */
.sv-empty-row > td { padding: 0.5rem; }
.empty-state { margin: 0; padding: 2rem 1rem; position: sticky; inset-inline-start: 0; box-sizing: border-box; width: min(100%, calc(100vw - 3rem)); }
.empty-state p { margin: 0; }
.empty-title { color: var(--color-body); font-weight: 500; }
.empty-state .empty-line { margin: 0.375rem auto 0; font-size: 0.875rem; max-width: 40rem; }
.empty-actions { justify-content: center; margin-top: 1rem; }

@media (max-width: 640px) {
  /* A popover anchored to a button near the screen edge runs off it; a sheet does not. */
  .sv-pop { position: fixed; inset-inline-start: 1rem; inset-inline-end: 1rem; top: auto; bottom: 1rem; width: auto; max-width: none; }
}

/* Linked media on RFI / snag / NCR rows (linked-media.js) */
.lm { display: flex; flex-wrap: wrap; gap: .25rem .6rem; margin-block-start: .25rem; font-size: .75rem; }
.lm-link { color: var(--color-accent); text-decoration: underline; }
.lm-photos { border: 0; background: none; padding: 0; color: var(--color-accent); text-decoration: underline; cursor: pointer; font-size: inherit; }
.lm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); gap: .5rem; }
.lm-thumb img { width: 100%; height: 6rem; object-fit: cover; border: 1px solid var(--color-line); display: block; }


/* ==========================================================================
   Create, drafts and export (docs/32 E1, E3, E12)
   create-menu.js, drafts.js, export-tools.js. Shared colour tokens only.
   ========================================================================== */

.create-group { display: inline-flex; gap: 0.375rem; align-items: center; }

.create-menu {
  position: fixed; z-index: 110; min-width: 14rem; max-width: calc(100vw - 1rem); max-height: 70vh; overflow-y: auto;
  padding: 0.25rem 0; border: 1px solid var(--color-line-strong); border-radius: var(--radius);
  background: var(--color-page); box-shadow: 0 1rem 2rem rgb(0 0 0 / 0.35);
}
.create-menu[hidden] { display: none; }
.create-menu-head { padding: 0.5rem 0.875rem 0.25rem; }
.create-item {
  display: block; width: 100%; padding: 0.5rem 0.875rem; border: 0; background: transparent;
  color: var(--color-body); font: inherit; text-align: start; cursor: pointer;
}
.create-item:hover, .create-item:focus-visible { background: var(--color-raised-2); outline: none; box-shadow: inset 2px 0 0 var(--color-accent); }
.create-none { padding: 0.5rem 0.875rem; margin: 0; font-size: 0.8125rem; }

.raise-where { margin: 0 0 0.75rem; font-size: 0.8125rem; }
.raise-list { display: grid; gap: 0.5rem; }
.raise-option {
  display: flex; flex-direction: column; gap: 0.125rem; width: 100%; padding: 0.625rem 0.875rem; text-align: start;
  border: 1px solid var(--color-line-strong); border-radius: var(--radius); background: transparent; color: var(--color-body);
  font: inherit; cursor: pointer;
}
.raise-option:hover, .raise-option:focus-visible { background: var(--color-raised-2); border-color: var(--color-accent); outline: none; }
.raise-option span { font-size: 0.8125rem; }

.draft-banner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem;
  margin: 0 0 0.75rem; padding: 0.5rem 0.75rem; border: 1px solid var(--color-warn); border-radius: var(--radius);
  background: var(--color-warn-bg); font-size: 0.8125rem;
}
.draft-actions { display: inline-flex; gap: 0.375rem; }

.export-bar { display: flex; justify-content: flex-end; gap: 0.375rem; margin: 0 0 0.375rem; }

/* One record on its own: the browser's print dialog is the "Save as PDF". */
@media print {
  body.print-one * { visibility: hidden !important; }
  body.print-one .print-one-target, body.print-one .print-one-target * { visibility: visible !important; }
  body.print-one .print-one-target { position: absolute; inset: 0 auto auto 0; width: 100%; margin: 0; }
  body.print-one .print-one-target .btn, body.print-one .print-one-target .export-bar { display: none !important; }
}

@media (max-width: 40rem) {
  .create-group { flex: 1 1 auto; }
}

/* QA UX-001 (11 Nov 2026): the shared line grid (Loop.lineGrid) for schedules of values and IPC lines. */
.line-grid { display: grid; gap: .5rem; margin: .5rem 0 }
.line-grid .table-wrap { overflow-x: auto }
.line-grid-table .input { width: 100%; min-width: 5rem }
.line-grid-total { margin: 0 }
.line-grid-total.line-grid-off { color: var(--color-danger, #b42318) }
.co-retired { margin-block-end: 1rem }
