/* HTO1 Stack Monitor
   The content here is equipment tags, so the interface borrows from panel
   schedules and engraved nameplates: monospace for anything that is a code,
   a cool drawing-sheet ground, and saturated colour reserved entirely for
   device state. Okabe-Ito palette per the design spec -- red/green is the
   worst possible pairing for colour vision deficiency, and state is never
   carried by hue alone. */

:root {
  --ground: #e8ecf0;
  --sheet: #ffffff;
  --ink: #11161c;
  --muted: #5c6874;
  --rule: #ccd4dc;
  --rule-strong: #9aa7b4;

  --waiting: #0072b2;
  --up: #009e73;
  --down: #d55e00;
  --unknown: #8b949e;

  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --tick: 4px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

/* ---- masthead ---------------------------------------------------------- */

.masthead {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--ink);
  color: #eef2f6;
  position: sticky;
  top: 0;
  z-index: 10;
}

.mark { text-decoration: none; color: inherit; display: flex; gap: 10px; align-items: baseline; }
.mark-code {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.14em;
  border: 1px solid #4a5561;
  padding: 2px 7px;
}
.mark-name { font-size: 13px; color: #9fadbb; letter-spacing: 0.04em; }

.masthead nav { display: flex; gap: 18px; align-items: baseline; }
.masthead nav a, .linkish {
  color: #cfd8e2;
  text-decoration: none;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.masthead nav a:hover, .linkish:hover { color: #fff; }
.linkish { background: none; border: 0; padding: 0; cursor: pointer; font-family: inherit; }
.masthead form { display: inline; }

/* Hamburger. Hidden above the breakpoint, where the nav sits inline. */
.nav-button { display: none; }
.nav-toggle { display: none; }

/* ---- sheet ------------------------------------------------------------- */

main.sheet { max-width: 1080px; margin: 0 auto; padding: 24px 20px 64px; }
main.narrow { max-width: 420px; margin: 0 auto; padding: 56px 20px; }

h1 {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 18px;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-transform: uppercase;
}

/* ---- overall progress -------------------------------------------------- */

.tally {
  background: var(--sheet);
  border: 1px solid var(--rule);
  padding: 20px 22px;
  margin-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  align-items: flex-end;
}
.tally .figure {
  font-family: var(--mono);
  font-size: 40px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
}
.tally .figure span { color: var(--rule-strong); }
.tally dl { margin: 0; display: flex; gap: 22px; }
.tally dt { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.tally dd { margin: 2px 0 0; font-family: var(--mono); font-size: 19px; font-weight: 600; }

/* ---- banner ------------------------------------------------------------ */

.banner {
  border-left: var(--tick) solid var(--unknown);
  background: var(--sheet);
  border-top: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 14px;
}
.banner strong { text-transform: uppercase; letter-spacing: 0.08em; font-size: 12px; }
.banner.warn { border-left-color: var(--down); }
/* Nothing is wrong and nothing needs doing -- said plainly, so an empty
   result reads as an answer rather than as a fault. */
.banner.ok { border-left-color: var(--up); }

/* ---- stack list -------------------------------------------------------- */
/* Vertical, in CRIT/MNR order. The alias is the identifier people actually
   speak, so it leads; the raw code sits under it for cross-referencing
   against the drawings. */

.stack-list { background: var(--sheet); border: 1px solid var(--rule); }

.stack-row {
  display: grid;
  grid-template-columns: var(--tick) 104px 1fr auto;
  grid-template-areas:
    "rail alias ticks fraction"
    "rail code  ticks fraction";
  align-items: center;
  gap: 0 16px;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
  color: inherit;
}
.stack-row .rail { grid-area: rail; }
.stack-row .alias { grid-area: alias; padding-left: 16px; align-self: end; }
.stack-row .code { grid-area: code; padding-left: 16px; align-self: start; }
.stack-row .ticks { grid-area: ticks; }
.stack-row .fraction { grid-area: fraction; }
.stack-row:last-child { border-bottom: 0; }
.stack-row:hover { background: #f6f8fa; }

.stack-row .rail { align-self: stretch; background: var(--rule-strong); }
.stack-row.complete .rail { background: var(--up); }
.stack-row.started .rail { background: var(--waiting); }
.stack-row.faulted .rail { background: var(--down); }
.stack-row.blind .rail { background: var(--unknown); }

.stack-row .alias {
  display: block;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.04em;
  padding-top: 12px;
  white-space: nowrap;
}
.stack-row .code {
  display: block;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
  padding-bottom: 12px;
}
.stack-row .fraction {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--muted);
  padding: 12px 16px 12px 0;
  white-space: nowrap;
}
.stack-row .fraction b { color: var(--ink); font-weight: 600; font-size: 17px; }

/* one tick per device, in port order -- reads like a panel schedule */
.ticks { display: flex; gap: 2px; flex-wrap: wrap; padding: 12px 0; }
.ticks i { width: 6px; height: 15px; background: var(--rule); display: block; }
.ticks i.up { background: var(--up); }
.ticks i.down { background: var(--down); }
/* Waiting is a neutral empty slot, not a colour.
   Up and waiting were previously both saturated fills differing mainly by
   hue, which is the channel that fails first at 6px on a phone. Outlining
   them separated the two but read as harsh at that size -- a 1.5px border
   on a 6px tick is a quarter of its width.
   Draining the colour instead means anything coloured on the strip is
   something that happened: green turned up, vermillion went down. The rest
   is simply not done yet. */
.ticks i.waiting { background: #e6eaee; }
/* Unknown never appears alongside the others -- when the collector is
   blind, every tick is unknown -- so a slightly deeper grey distinguishes
   a stale board from an untouched one without competing. */
.ticks i.unknown { background: #d5dbe1; }

/* ---- device list ------------------------------------------------------- */

.stack-head {
  background: var(--sheet);
  border: 1px solid var(--rule);
  padding: 18px 20px;
  margin-bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
}
.stack-head .code { font-family: var(--mono); font-size: 28px; font-weight: 700; letter-spacing: 0.05em; }
.stack-head .fraction { font-family: var(--mono); font-size: 28px; font-weight: 600; }
.stack-head .fraction span { color: var(--rule-strong); }

select.stack-picker {
  font-family: var(--mono);
  font-size: 15px;
  padding: 9px 10px;
  border: 1px solid var(--rule-strong);
  background: var(--sheet);
  color: var(--ink);
  width: 100%;
  max-width: 320px;
}

.rows { background: var(--sheet); border: 1px solid var(--rule); }

.row {
  display: grid;
  /* rail | port | body | state */
  grid-template-columns: var(--tick) auto 1fr auto;
  align-items: center;
  gap: 0 14px;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
  color: inherit;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: #f6f8fa; }
.row .rail { align-self: stretch; background: var(--rule); }
.row.up .rail { background: var(--up); }
.row.down .rail { background: var(--down); }
.row.waiting .rail { background: var(--waiting); }
.row.unknown .rail { background: var(--unknown); }

.row .body { padding: 11px 0 11px 14px; min-width: 0; }
.row .tag {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
}
.row .meta { font-size: 12px; color: var(--muted); font-family: var(--mono); margin-top: 2px; }

/* What is wrong with this row, on its own line under the device name
   rather than wrapping out of the address. A sentence that begins halfway
   along a line of identifiers reads as more of the identifier. */
.row .problem {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  font-family: var(--mono);
  color: var(--down);
  overflow-wrap: anywhere;
}
.row .state { padding: 11px 14px 11px 0; text-align: right; white-space: nowrap; }

/* Fixed-width state chips: filled with the state colour, white text.
   Same footprint whatever the state, so the right-hand column stays a clean
   vertical line down the list rather than ragging in and out.
   Colour never carries the meaning alone -- each chip keeps its glyph. */

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 104px;
  padding: 5px 0;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #fff;
  border: 1px solid transparent;
}
.chip.up { background: var(--up); }
.chip.down { background: var(--down); }
.chip.waiting { background: var(--waiting); }
.chip.unknown { background: var(--unknown); }
/* Asserted, not observed: hollow says the state was entered rather than
   measured. Solid on the tick strip, where it counts simply as progress. */
.chip.passive {
  background: transparent;
  color: #007052;
  border-color: var(--up);
}
.chip .glyph { font-size: 11px; }

.stamp { font-size: 11px; color: var(--muted); font-family: var(--mono); margin-top: 3px; }

/* ---- tables and diffs -------------------------------------------------- */

table { width: 100%; border-collapse: collapse; background: var(--sheet); border: 1px solid var(--rule); }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--rule); font-size: 13px; vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); font-weight: 600; }
td.mono, th.mono { font-family: var(--mono); }
tr:last-child td { border-bottom: 0; }

.panel { background: var(--sheet); border: 1px solid var(--rule); padding: 20px 22px; margin-bottom: 18px; }
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.12em; margin: 0 0 14px; color: var(--muted); }

.count-line { font-family: var(--mono); font-size: 15px; margin: 0 0 6px; }
.count-line b { font-size: 19px; }
.risk { border-left: var(--tick) solid var(--down); padding-left: 14px; margin: 14px 0; }

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

label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin: 14px 0 5px; }
input[type=text], input[type=email], input[type=password], input[type=file] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--rule-strong);
  background: var(--sheet);
  font-family: var(--sans);
  font-size: 15px;
  color: var(--ink);
}
button.primary {
  margin-top: 18px;
  padding: 11px 20px;
  border: 0;
  background: var(--ink);
  color: #fff;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}
button.primary:hover { background: #2a3541; }
button.ghost {
  margin-top: 18px;
  padding: 11px 20px;
  border: 1px solid var(--rule-strong);
  background: transparent;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form label { margin-top: 0; }
.inline-form button { margin-top: 0; }

.error { border-left: var(--tick) solid var(--down); padding: 10px 14px; background: var(--sheet); font-size: 14px; margin-top: 14px; }
.note { font-size: 13px; color: var(--muted); }
.secret { font-family: var(--mono); font-size: 13px; word-break: break-all; background: #f2f5f8; border: 1px dashed var(--rule-strong); padding: 12px; }

a.plain { color: var(--ink); }

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

@media (max-width: 760px) {
  .masthead { padding: 12px 14px; position: relative; }
  .mark-name { display: none; }

  .nav-button {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    margin: -10px -8px -10px 0;
    padding: 0 8px;
    cursor: pointer;
    align-items: flex-end;
  }
  .nav-button span {
    display: block;
    width: 22px;
    height: 2px;
    background: #cfd8e2;
  }

  /* Collapsed by default; the checkbox opens it. */
  .masthead nav {
    display: none;
    order: 3;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin-top: 12px;
    border-top: 1px solid #2f3a46;
  }
  .nav-toggle:checked ~ nav { display: flex; }
  .masthead nav a, .masthead nav .linkish {
    padding: 13px 2px;
    border-bottom: 1px solid #2f3a46;
    font-size: 14px;
    text-align: left;
  }
  .masthead nav form { display: block; width: 100%; }
  .masthead nav .linkish { display: block; width: 100%; }

  main.sheet { padding: 16px 14px 56px; }
  .tally { gap: 18px; padding: 16px; }
  .tally .figure { font-size: 32px; }
  .stack-head .code, .stack-head .fraction { font-size: 22px; }
  .chip { width: 92px; font-size: 10px; }
  /* Alias and tick strip share the top line; code and count share the
     second. The name column is auto-width so it cannot force a wrap. */
  .stack-row {
    grid-template-columns: var(--tick) auto 1fr;
    grid-template-areas:
      "rail alias ticks"
      "rail code  fraction";
    align-items: center;
    gap: 2px 10px;
  }
  .stack-row .alias { padding: 10px 0 0 12px; font-size: 14px; }
  .stack-row .code { padding: 0 0 10px 12px; }
  .stack-row .fraction {
    padding: 0 12px 10px 0;
    font-size: 13px;
    text-align: right;
    justify-self: end;
  }
  .stack-row .fraction b { font-size: 15px; }
  .stack-row .ticks {
    padding: 10px 12px 0 0;
    gap: 2px;
    justify-content: flex-end;
    flex-wrap: nowrap;
    overflow: hidden;
  }
  .ticks i { width: 6px; height: 14px; flex: 0 0 auto; }
}

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

/* ---- admin row actions ------------------------------------------------- */

/* A <td> must stay a table cell: making it a flex container detaches it
   from the row's height, which leaves the links floating and the borders
   misaligned. Flex goes on an inner wrapper instead. */
.row-actions { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.row-actions form { display: inline; margin: 0; }
.linkish.dark { color: var(--ink); text-transform: none; letter-spacing: 0; font-size: 13px; text-decoration: underline; }
.linkish.dark:hover { color: var(--waiting); }
.linkish.danger { color: #a34800; text-transform: none; letter-spacing: 0; font-size: 13px; text-decoration: underline; }
.linkish.danger:hover { color: var(--down); }

/* ---- day toggle -------------------------------------------------------- */

.panel-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}
.panel-head h2 { text-transform: uppercase; letter-spacing: 0.12em; font-size: 13px; color: var(--muted); }

.toggle { display: inline-flex; border: 1px solid var(--rule-strong); }
.toggle a {
  padding: 7px 14px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--muted);
  border-right: 1px solid var(--rule-strong);
}
.toggle a:last-child { border-right: 0; }
.toggle a.on { background: var(--ink); color: #fff; }
.toggle a:hover:not(.on) { background: #f0f3f6; color: var(--ink); }

.role-form { display: inline; }
.role-select {
  font-family: var(--mono);
  font-size: 12px;
  padding: 4px 6px;
  border: 1px solid var(--rule-strong);
  background: var(--sheet);
  color: var(--ink);
}

.flag { color: #a34800; font-weight: 600; }

/* ---- view-as banner ---------------------------------------------------- */
/* Deliberately loud: the failure mode is forgetting it is on and concluding
   the export is broken. */

.view-as-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  background: var(--waiting);
  color: #fff;
  padding: 9px 20px;
  font-size: 13px;
}
.view-as-bar b { letter-spacing: 0.04em; }
.view-as-bar button {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.55);
  color: #fff;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 5px 12px;
  cursor: pointer;
}
.view-as-bar button:hover { background: rgba(255, 255, 255, 0.28); }

@media (max-width: 760px) { .view-as-bar { padding: 9px 14px; } }

/* ---- switch state ------------------------------------------------------ */
/* A small circle, deliberately unlike the square device ticks and the left
   rail: it reports the switch, not the devices beneath it. */

.sw-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 7px;
  vertical-align: baseline;
  background: var(--rule-strong);
}
.sw-dot.up { background: var(--up); }
.sw-dot.down { background: var(--down); }
.sw-dot.waiting { background: var(--waiting); }
.sw-dot.unknown { background: var(--unknown); }

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

.switch-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0; }
.ip-input {
  font-family: var(--mono);
  font-size: 13px;
  padding: 4px 7px;
  width: 130px;
  border: 1px solid var(--rule-strong);
  background: var(--sheet);
  color: var(--ink);
}
.poll-toggle {
  margin: 0;
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

/* The whole block is the link, matching how a device row behaves. */
a.switch-status,
.switch-status {
  display: inline-block;
  margin: 8px 0 0;
  padding: 4px 8px 4px 0;
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
  letter-spacing: 0.02em;
  text-decoration: none;
}
.switch-status b { color: var(--ink); text-transform: uppercase; }
a.switch-status:hover { color: var(--ink); }
a.switch-status:hover b { text-decoration: underline; }

/* ---- destructive actions ----------------------------------------------- */
/* Collapsed by default and visually separated: resetting a device destroys
   the record this system exists to produce. */

.danger-zone {
  border: 1px solid var(--rule);
  border-left: var(--tick) solid var(--down);
  background: var(--sheet);
  margin-top: 28px;
}
.danger-zone summary {
  cursor: pointer;
  padding: 12px 16px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #a34800;
  font-weight: 600;
}
.danger-body { padding: 0 16px 18px; max-width: 620px; }
.danger-body .note { margin: 0 0 8px; }
.danger-body input[type=text] { max-width: 240px; font-family: var(--mono); }

/* ---- Net plan view ------------------------------------------------------ */
/* The building in plan, north at the top: MDF at the north end, IDFs
   running north to south down each side. Two columns fit a 360px phone
   with room to spare once the H- prefix is dropped. */

.plan { max-width: 620px; }
/* The MDF sits at the north end of the building, so it is centred above the
   two columns rather than aligned to one side. Constrained to a single
   column's width so it reads as a closet rather than a banner. */
.plan-north {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
/* Room 114 holds the MDF and an IDF; they stack, centred over the two
   columns, rather than sitting side by side like the east/west pairs. */
.plan-north .closet {
  grid-column: 1 / -1;
  justify-self: center;
  width: calc(50% - 4px);
}


.plan-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.plan-col { display: flex; flex-direction: column; gap: 8px; }
.plan-label {
  margin: 0 0 2px;
  min-height: 1em;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.closet {
  display: block;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-left: var(--tick) solid var(--rule-strong);
  padding: 10px;
  text-decoration: none;
  color: inherit;
}
.closet:hover { border-color: var(--rule-strong); }
.closet.up { border-left-color: var(--up); }
.closet.down { border-left-color: var(--down); }
.closet.waiting { border-left-color: var(--waiting); }
.closet.unknown { border-left-color: var(--unknown); }

.closet-name {
  display: block;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.closet-name .sw-dot { margin-right: 7px; }
.closet-meta {
  display: block;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}

@media (max-width: 760px) {
  .plan-sides { gap: 6px; }
  .closet { padding: 9px 8px; }
  .closet-name { font-size: 13px; }
  .closet-meta { font-size: 11px; }
}

/* A details element styled as a panel: the summary carries the heading and
   the body is what unfolds. */
.detail-panel summary {
  cursor: pointer;
  list-style: revert;
}
.detail-panel summary h2 { margin: 0; }
.detail-panel[open] summary { margin-bottom: 4px; }

/* ---- port view ---------------------------------------------------------- */
/* Two independent signals per row: the port dot says whether anything is
   plugged in, the state chip says whether the expected device answers. */

.row .port-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 58px;
  padding-left: 12px;
  font-family: var(--mono);
}
.port-num { font-size: 12px; color: var(--muted); }

/* State classes are namespaced: a bare .error here collided with the form
   error style and inflated the dot into an orange lozenge. */
.port-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--rule-strong);
}
.port-dot.pd-connected { background: var(--up); }
.port-dot.pd-idle { background: var(--waiting); }
/* Hollow rather than a pale fill: no reading at all should not look like
   a faint version of a reading. */
.port-dot.pd-unknown {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--rule-strong);
}
/* A downward triangle, so a fault differs in shape as well as colour. */
.port-dot.pd-error {
  width: 0;
  height: 0;
  background: transparent;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 10px solid var(--down);
  border-radius: 0;
}

.port-head {
  display: grid;
  grid-template-columns: var(--tick) auto 1fr auto;
  gap: 0 14px;
  padding: 0 0 6px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--rule);
}
.port-head .h-port { min-width: 58px; padding-left: 12px; }
.port-head .h-state { text-align: right; padding-right: 12px; }

/* The device type pages name a switch as well as a port, so that column
   is wider. Set on both the header and the rows from one place: an inline
   width on the row alone leaves the header behind, which is exactly what
   it did. */
.port-head.wide .h-port,
.rows.wide .port-cell { min-width: 196px; }

@media (max-width: 760px) {
  .row .port-cell { min-width: 46px; padding-left: 10px; gap: 5px; }
  .port-num { font-size: 11px; }
  .port-head { grid-template-columns: var(--tick) auto 1fr auto; gap: 0 10px; }
  .port-head .h-port { min-width: 46px; padding-left: 10px; }
  /* Narrow screens: the switch name wraps under the port rather than
     forcing the device column off the edge. */
  .port-head.wide .h-port,
  .rows.wide .port-cell { min-width: 124px; }
}

/* A device reached through the one above it, not through a port of its
   own. Indented so the relationship reads at a glance. */
.row.behind .body { padding-left: 10px; }
.behind-mark {
  font-family: var(--mono);
  color: var(--rule-strong);
  padding-left: 18px;
}

/* Switch lines in a device's history: same table, visibly not the device. */
tr.switch-line td { background: #f4f7fa; color: var(--muted); }

/* ---- shielded values ---------------------------------------------------- */
/* Switch management addresses outside /admin are covered until deliberately
   revealed, so a demo does not put them on a projector by accident.
   Cosmetic only: the value is in the page source, and the admin check on
   the server is the actual boundary. Re-covers when the pointer leaves. */

.shielded {
  position: relative;
  display: inline-block;
  font-family: var(--mono);
  cursor: pointer;
  border-radius: 2px;
}
.shielded > span {
  filter: blur(5px);
  opacity: 0.85;
  transition: filter 90ms linear, opacity 90ms linear;
  user-select: none;
}
.shielded::after {
  content: "reveal";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.55);
  pointer-events: none;
  transition: opacity 90ms linear;
}
.shielded:hover > span,
.shielded:focus > span,
.shielded.revealed > span {
  filter: none;
  opacity: 1;
  user-select: text;
}
.shielded:hover::after,
.shielded:focus::after,
.shielded.revealed::after {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .shielded > span,
  .shielded::after { transition: none; }
}

/* The switch disagrees with the schedule for this device. The row already
   links to it, so the mark only has to be findable. */
.alarm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--down);
  color: #fff;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
  cursor: help;
}

/* ---- busy overlay ------------------------------------------------------- */
/* A 30 MB upload plus parse is long enough that a tab spinner is not
   enough to tell somebody the page is working rather than stuck. */

#busy {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 26, 33, 0.55);
}
#busy[hidden] { display: none; }

.busy-card {
  background: var(--sheet);
  border: 1px solid var(--rule-strong);
  border-top: var(--tick) solid var(--waiting);
  padding: 26px 30px;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(20, 26, 33, 0.25);
}
.busy-text {
  margin: 16px 0 6px;
  font-size: 14px;
  color: var(--ink);
}
.busy-card .note { margin: 0; }

.busy-spinner {
  width: 30px;
  height: 30px;
  margin: 0 auto;
  border: 3px solid var(--rule);
  border-top-color: var(--waiting);
  border-radius: 50%;
  animation: busy-spin 800ms linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .busy-spinner { animation-duration: 2.4s; }
}

/* A rule where the switch changes, so a long findings list reads as
   groups of ports rather than one undifferentiated run. */
tr.group-start td { border-top: 2px solid var(--rule-strong); }


/* What is wrong with a port, on its own line beneath the address rather
   than running on from it: a sentence squeezed after an IP reads as more
   of the same field. */
.problem {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--down);
}

/* Which switch the ports below belong to. Closets have two or three, each
   numbering from 1, so the list needs saying where one ends. */
.switch-head {
  margin: 18px 0 6px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.switch-head .stamp { margin-left: 8px; }
.switch-head:first-of-type { margin-top: 0; }

/* ---- PFPT reports -------------------------------------------------------- */

/* Several plans side by side outgrow a phone; the table scrolls inside its
   panel rather than pushing the page sideways. */
.pfpt-scroll { overflow-x: auto; }
.pfpt-table td, .pfpt-table th { white-space: nowrap; }
/* The pink Todd's sheets use for a failing requirement, so the report reads
   the same as what it replaces. */
.pfpt-table td.req.fail { background: #f2c4c4; color: #7a2400; font-weight: 600; }
.pfpt-table td.verdict.go, .verdict-tag.go { color: #007a5a; font-weight: 600; }
.pfpt-table td.verdict.nogo { background: #f2c4c4; color: #7a2400; font-weight: 600; }
.pfpt-table td.verdict.na, .verdict-tag.na { color: var(--muted); }
.verdict-tag.nogo { color: #b03a00; font-weight: 600; }
.pfpt-table td.state-unknown { color: var(--muted); }
.pfpt-table td.state-down, .pfpt-table td.state-waiting { color: #b03a00; }
label.pfpt-item {
  display: inline; margin: 0; font-size: 13px; text-transform: none;
  letter-spacing: 0; color: var(--ink); font-family: var(--mono); cursor: pointer;
}
a.ghost.pdf-link {
  display: inline-block; padding: 9px 16px; border: 1px solid var(--rule-strong);
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em;
  text-transform: uppercase; text-decoration: none; color: var(--ink);
}
