/* ============================================================
   AERL Nexus: Modbus TCP Protocol, multi-page layout
   Same A4 card shell and table utilities as the SRX RS485 protocol page;
   adds the field-map table columns. Tokens imported transitively via the HTML's link to tokens.css.

   Print contract (see DESIGN_NOTES.md and the @media print block at the
   end): the screen card IS the printed page. doc.css flattens
   article.page to auto height / zero padding under print, so this file
   re-asserts the fixed A4 card with matching specificity, later in the
   cascade. Every .page child is flex-shrink: 0 so an over-full page
   overflows honestly (and trips overflow-check.js) instead of squashing
   its children into each other.
   ============================================================ */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  font-size: var(--fs-14);
  line-height: var(--lh-normal);
  color: var(--fg-1);
  background: var(--gray-200);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- A4 page sheet ---------- */
.sheet {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 32px 16px 64px;
}

.page {
  width: 794px;            /* A4 paper @ 96dpi */
  height: 1123px;          /* hard-cap at A4; not min-height */
  overflow: hidden;        /* clip overflow so authors SEE pages that don't fit */
  background: var(--bg-surface);
  box-shadow: var(--shadow-lg);
  padding: 68px 60px 92px; /* 18mm / 16mm / reserved .pf band — matches DESIGN_NOTES */
  position: relative;
  display: flex;
  flex-direction: column;
}
/* Over-full pages must overflow, never shrink their children into overlap. */
.page > * { flex-shrink: 0; }

/* ---------- Page header ---------- */
.ph {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--gray-900);
  margin-bottom: 22px;
}
.ph__brand { display: flex; align-items: center; gap: 14px; }
.ph__logo  { height: 28px; width: auto; display: block; }
.ph__rule  { width: 1px; height: 22px; background: var(--border-strong); }
.ph__product {
  font-size: var(--fs-14);
  font-weight: 600;
  color: var(--fg-1);
  letter-spacing: -0.01em;
}
.ph__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}
.ph__meta .dot {
  width: 3px; height: 3px;
  background: var(--gray-300);
  border-radius: 50%;
}

/* ---------- Cover ---------- */
.cover { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.cover__hero {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 28px;
  align-items: center;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 22px;
}
.cover__copy { min-width: 0; }
.eyebrow {
  font-size: 11px; font-weight: 600;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--fg-accent);
  margin-bottom: 10px;
}
.cover__title {
  font-size: 40px; line-height: 1.05;
  letter-spacing: -0.025em;
  font-weight: 800;
  margin: 0 0 4px;
  color: var(--fg-1);
}
.cover__subtitle {
  font-size: 18px; font-weight: 400;
  color: var(--fg-2);
  margin: 0 0 12px;
  letter-spacing: -0.01em;
}
.cover__model {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 12px; font-weight: 600;
  letter-spacing: var(--tracking-wide);
  color: var(--fg-accent);
  background: var(--primary-50);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  margin-bottom: 12px;
}
.cover__lede {
  font-size: 13px; line-height: 1.55;
  color: var(--fg-2);
  margin: 0 0 16px;
  max-width: 44ch;
  text-wrap: pretty;
}

/* Cover "spec marquee" — drop-in for the product image on a protocol cover */
.cover__marquee {
  margin: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding: 18px 20px;
  background: linear-gradient(180deg, var(--gray-50) 0%, var(--white) 100%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}
.cover__marquee__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  border-bottom: 1px dashed var(--border-subtle);
}
.cover__marquee__row:last-child { border-bottom: 0; }
.cover__marquee__k {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--fg-3);
}
.cover__marquee__v {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--fg-1);
  text-align: right;
}

/* Document meta block */
.docmeta {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-top: 1px solid var(--border-subtle);
  border-left: 1px solid var(--border-subtle);
  margin-bottom: 22px;
}
.docmeta__cell {
  padding: 9px 12px;
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  display: flex; flex-direction: column; gap: 2px;
}
.docmeta__k {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--fg-3);
}
.docmeta__v {
  font-size: 12.5px; font-weight: 600;
  color: var(--fg-1);
}

/* ---------- Section title ---------- */
.sec-title {
  font-size: 11px; font-weight: 700;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--fg-2);
  margin: 0 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; gap: 10px;
}
.sec-title::before {
  content: "";
  width: 12px; height: 2px;
  background: var(--primary-500);
}

/* Big chapter heading (used at the top of body sections) */
.chapter {
  font-size: 26px; font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0 0 4px;
  padding: 0;
  border: 0;
  color: var(--fg-1);
}
.chapter__num {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--fg-accent);
  margin-bottom: 2px;
}
.chapter__rule {
  height: 2px; width: 48px;
  background: var(--primary-500);
  margin: 8px 0 12px;
}

/* H3 / H4 inside chapters */
.h3 {
  font-size: 14.5px; font-weight: 700;
  line-height: 1.3;
  margin: 16px 0 6px;
  color: var(--fg-1);
  letter-spacing: -0.01em;
}
.h3:first-of-type { margin-top: 10px; }
.h4 {
  font-size: 11.5px; font-weight: 700;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--fg-2);
  margin: 10px 0 5px;
}

p { margin: 0 0 7px; font-size: 12px; line-height: 1.5; color: var(--fg-2); }
p strong { color: var(--fg-1); font-weight: 600; }
p.small { font-size: 11px; color: var(--fg-3); }

ul, ol { margin: 0 0 9px; padding-left: 20px; }
li { font-size: 12px; line-height: 1.5; color: var(--fg-2); }
li + li { margin-top: 2px; }
li strong { color: var(--fg-1); font-weight: 600; }

.mono {
  font-family: var(--font-mono);
  font-size: 0.93em;
  background: var(--bg-sunken);
  padding: 0.05em 0.35em;
  border-radius: var(--radius-sm);
  color: var(--fg-1);
}

/* ---------- TOC ---------- */
.toc {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 24px;
  border-top: 1px solid var(--border-subtle);
}
.toc__entry {
  display: grid;
  grid-template-columns: 28px 1fr 36px;
  gap: 8px;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px;
}
.toc__num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-accent);
  font-weight: 600;
}
.toc__name { color: var(--fg-1); font-weight: 500; }
.toc__name small {
  display: block;
  font-size: 10.5px; font-weight: 400;
  color: var(--fg-3);
  margin-top: 2px;
}
.toc__page {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
  text-align: right;
}

/* ---------- Callouts ---------- */
.callout {
  border-left: 4px solid var(--primary-500);
  background: var(--primary-50);
  padding: 9px 13px;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin: 8px 0;
  box-shadow: none;
}
.callout__label {
  display: block;
  font-size: 10.5px; font-weight: 700;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  margin-bottom: 2px;
}
.callout__body p {
  margin: 0 0 4px;
  font-size: 11.5px; line-height: 1.45;
  color: var(--fg-1);
}
.callout__body p:last-child { margin-bottom: 0; }
.callout--important {
  border-left-color: var(--status-info);
  background: var(--status-info-bg);
}
.callout--important .callout__label { color: var(--status-info); }
.callout--note {
  border-left-color: var(--gray-700);
  background: var(--gray-50);
}
.callout--note .callout__label { color: var(--fg-2); }

/* ---------- Generic spec / small tables ---------- */
table.spec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  margin: 6px 0 10px;
  background: transparent;
}
table.spec-table th,
table.spec-table td {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}
table.spec-table thead th {
  background: var(--gray-900);
  color: var(--white);
  font-weight: 600;
  font-size: 10.5px;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  padding: 7px 10px;
  border-bottom: 0;
}
table.spec-table tbody tr:nth-child(even) td { background: var(--gray-50); }
table.spec-table td:first-child { font-weight: 500; color: var(--fg-1); }
table.spec-table td.mono,
table.spec-table td.num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-1);
  background: transparent;
  padding: 6px 10px;
  border-radius: 0;
}
table.spec-table td.desc { color: var(--fg-2); }

/* ---------- Two-column grid ---------- */
.col2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 22px;
  align-items: start;
}

/* ---------- Pinout / bus settings small key-value cards ---------- */
.kv-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-top: 1px solid var(--border-subtle);
  border-left: 1px solid var(--border-subtle);
  margin: 6px 0 12px;
}
.kv-card__cell {
  padding: 8px 12px;
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  display: flex; flex-direction: column; gap: 2px;
}
.kv-card__cell--wide { grid-column: span 2; }
.kv-card__k {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--fg-3);
}
.kv-card__v {
  font-size: 12.5px; font-weight: 600;
  color: var(--fg-1);
  font-family: var(--font-mono);
}
.kv-card__v .dim { color: var(--fg-3); font-weight: 400; }
.kv-card__cell--accent { background: var(--primary-50); }
.kv-card__cell--accent .kv-card__v { color: var(--fg-accent); }

/* ---------- Modbus register table ---------- */
table.modbus-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
  line-height: 1.3;
  margin: 4px 0 10px;
  table-layout: fixed;
  background: transparent;
}
table.modbus-table th,
table.modbus-table td {
  text-align: left;
  padding: 3px 6px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
/* snake_case field names break only after an underscore (<wbr>), never mid-word */
table.field-table td.desc { overflow-wrap: normal; word-break: normal; }
table.modbus-table thead th {
  background: var(--gray-900);
  color: var(--white);
  font-weight: 600;
  font-size: 9px;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  padding: 6px 6px;
  border-bottom: 0;
}
table.modbus-table tbody tr:nth-child(even) td { background: var(--gray-50); }
table.modbus-table .col-off  { width: 52px; }
table.modbus-table .col-addr { width: 60px; }
table.modbus-table .col-desc { width: auto; }
table.modbus-table .col-type { width: 88px; }
table.modbus-table .col-comment { width: 144px; }
table.modbus-table td.addr,
table.modbus-table td.off,
table.modbus-table td.type {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--fg-1);
}
table.modbus-table td.addr { font-weight: 600; color: var(--fg-accent); }
table.modbus-table td.off  { color: var(--fg-3); }
table.modbus-table td.type { color: var(--fg-2); }
table.modbus-table td.desc { color: var(--fg-1); }
table.modbus-table td.desc strong { font-weight: 600; }
table.modbus-table td.desc-cont { color: var(--fg-3); font-style: italic; }
table.modbus-table td.comment {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--fg-2);
}
table.modbus-table td.muted { color: var(--fg-3); }
table.modbus-table tbody tr.row-group td { border-top: 2px solid var(--primary-200); }
table.modbus-table tbody tr.row-group td:first-child { border-top-color: var(--primary-500); }

/* ---------- Bit-field table (status flags) ---------- */
table.bitfield-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
  line-height: 1.3;
  margin: 4px 0 10px;
  table-layout: fixed;
  background: transparent;
}
table.bitfield-table th,
table.bitfield-table td {
  text-align: left;
  padding: 4px 7px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
  word-wrap: break-word;
}
table.bitfield-table thead th {
  background: var(--gray-900);
  color: var(--white);
  font-weight: 600;
  font-size: 9px;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  border-bottom: 0;
}
table.bitfield-table tbody tr:nth-child(even) td { background: var(--gray-50); }
table.bitfield-table .col-bit  { width: 34px; }
table.bitfield-table .col-name { width: 138px; }
table.bitfield-table .col-desc { width: auto; }
table.bitfield-table td.bit {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--fg-accent);
  font-weight: 600;
}
table.bitfield-table td.name { font-weight: 600; color: var(--fg-1); }
table.bitfield-table td.desc { color: var(--fg-2); }
table.bitfield-table td.retired { color: var(--fg-3); font-style: italic; }
table.bitfield-table td + td.bit { border-left: 1px solid var(--border-subtle); }

/* ---------- Function-code / exception tables (wider) ---------- */
table.fc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  line-height: 1.4;
  margin: 6px 0 10px;
  background: transparent;
}
table.fc-table th,
table.fc-table td {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}
table.fc-table thead th {
  background: var(--gray-900);
  color: var(--white);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  border-bottom: 0;
}
table.fc-table td.code {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-accent);
  width: 96px;
  white-space: nowrap;
}
table.fc-table td.name { font-weight: 600; color: var(--fg-1); width: 190px; }
table.fc-table td.desc { color: var(--fg-2); }
table.fc-table tbody tr:nth-child(even) td { background: var(--gray-50); }

/* ---------- Byte-layout table (event counter response, worked example) ---------- */
table.bytes-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  line-height: 1.4;
  margin: 6px 0 10px;
  background: transparent;
  table-layout: fixed;
}
table.bytes-table th,
table.bytes-table td {
  text-align: left;
  padding: 5px 10px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
  word-wrap: break-word;
}
table.bytes-table thead th {
  background: var(--gray-900);
  color: var(--white);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  border-bottom: 0;
}
table.bytes-table .col-k { width: 92px; }
table.bytes-table .col-hex { width: 236px; }
table.bytes-table td.k {
  font-weight: 600; color: var(--fg-1);
}
table.bytes-table td.hex {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--fg-accent);
  font-weight: 600;
  letter-spacing: 0.02em;
}
table.bytes-table td.desc { color: var(--fg-2); }
table.bytes-table tbody tr:nth-child(even) td { background: var(--gray-50); }

/* ---------- Topology diagram ---------- */
.topology {
  background: var(--gray-50);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin: 8px 0 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-1);
}
.topology__row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 12px;
  align-items: center;
  padding: 4px 0;
}
.topology__row + .topology__row { border-top: 1px dashed var(--border-subtle); }
.topology__lbl {
  font-size: 10px;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--fg-accent);
  font-weight: 600;
}
.topology__bus {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.topology__node {
  padding: 4px 10px;
  background: var(--white);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--fg-1);
}
.topology__node--master {
  background: var(--gray-900);
  color: var(--white);
  border-color: var(--gray-900);
}
.topology__node--term {
  background: var(--primary-500);
  color: var(--gray-950);
  border-color: var(--primary-500);
  font-family: var(--font-mono);
}
.topology__wire {
  flex: 1;
  height: 2px;
  background: var(--gray-900);
  min-width: 12px;
}

/* ---------- Register notes list ---------- */
ul.regnotes { padding-left: 0; list-style: none; margin: 4px 0 8px; }
ul.regnotes li {
  font-size: 11.5px; line-height: 1.45;
  padding: 5px 0 5px 12px;
  border-left: 2px solid var(--primary-200);
  margin: 0 0 4px;
}
ul.regnotes li strong { color: var(--fg-1); }

/* ---------- Revision history table ---------- */
table.revhist {
  width: 100%;
  border-collapse: collapse;
  font-size: 10.5px;
  line-height: 1.35;
  margin: 6px 0 10px;
  background: transparent;
}
table.revhist th,
table.revhist td {
  text-align: left;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}
table.revhist thead th {
  background: var(--gray-900);
  color: var(--white);
  font-weight: 600;
  font-size: 9.5px;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  border-bottom: 0;
}
table.revhist td.rev {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-accent);
  font-weight: 600;
  width: 52px;
}
table.revhist td.date {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-2);
  width: 74px;
}
table.revhist td.officer { color: var(--fg-2); font-size: 10px; width: 118px; }
table.revhist td.change { color: var(--fg-1); }
table.revhist tbody tr:nth-child(even) td { background: var(--gray-50); }


/* ---------- Function-code head (CoolPro protocol pattern) ---------- */
.fn-head {
  display: flex; align-items: baseline; gap: 10px;
  margin: 10px 0 4px;
}
.fn-head__code {
  font-family: var(--font-mono);
  font-size: 12px; font-weight: 700;
  color: var(--fg-accent);
  background: var(--primary-50);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}
.fn-head__name {
  font-size: 13.5px; font-weight: 700;
  color: var(--fg-1);
  letter-spacing: -0.01em;
}

/* ---------- Figure box (images) ---------- */
.figbox {
  margin: 6px 0 10px;
  padding: 10px;
  background: var(--gray-50);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  text-align: center;
}
.figbox img { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.figbox figcaption {
  margin-top: 6px;
  font-size: 10px;
  color: var(--fg-3);
  line-height: 1.4;
  text-align: center;
}
.figbox--rj45 img { max-height: 132px; }
.figbox--topology img { max-height: 330px; }
.col2--wide-left { grid-template-columns: 1.25fr 1fr; }

/* ---------- Frame / field-format box ---------- */
.fmt {
  font-family: var(--font-mono);
  font-size: 9.5px;
  line-height: 1.5;
  color: var(--fg-1);
  background: var(--gray-50);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--primary-500);
  padding: 7px 12px;
  border-radius: var(--radius-md);
  margin: 3px 0 6px;
  overflow-wrap: anywhere;
}
.fmt__k {
  display: block;
  font-size: 9px;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--fg-accent);
  margin-bottom: 2px;
}
.fmt__k + .fmt__line { margin-bottom: 5px; display: block; }
.fmt__line:last-child { margin-bottom: 0; }

/* ---------- Wire / byte-sequence table ---------- */
table.wire-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  line-height: 1.4;
  margin: 4px 0 10px;
  table-layout: fixed;
  background: transparent;
}
table.wire-table th,
table.wire-table td {
  text-align: left;
  padding: 4px 7px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
table.wire-table thead th {
  background: var(--gray-900);
  color: var(--white);
  font-weight: 600;
  font-size: 9px;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  border-bottom: 0;
}
table.wire-table .col-dir   { width: 78px; }
table.wire-table .col-bytes { width: 220px; }
table.wire-table .col-note  { width: auto; }
table.wire-table td.dir {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--fg-accent);
}
table.wire-table td.dir.dir--rsp { color: var(--fg-2); }
table.wire-table td.bytes {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--fg-1);
  letter-spacing: 0.02em;
}
table.wire-table td.note { font-size: 10.5px; color: var(--fg-2); }
table.wire-table tbody tr:nth-child(even) td { background: var(--gray-50); }

/* ---------- Register map: one row per field ---------- */
table.modbus-table .col-range { width: 92px; }
table.modbus-table .col-offs  { width: 52px; }
table.modbus-table .col-regs  { width: 46px; }
table.modbus-table .col-notes { width: auto; }
table.modbus-table td.notes { color: var(--fg-2); }

/* ---------- Flags table: bit + input address + flag + description, two columns ---------- */
table.bitfield-table .col-iaddr { width: 46px; }
table.bitfield-table td.iaddr {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--fg-3);
}
table.bitfield-table td.name { font-size: 9.5px; }
table.bitfield-table td.desc { font-size: 9.5px; }

/* ---------- Field map: one row per field (value, quality and age addresses) ---------- */
table.field-table th, table.field-table td { padding-left: 5px; padding-right: 5px; }
table.field-table .col-id     { width: 26px; }
table.field-table .col-rec    { width: 46px; }
table.field-table .col-q      { width: 58px; }
table.field-table .col-kind   { width: 58px; }
table.field-table .col-scale  { width: 48px; }
table.field-table .col-unit   { width: 44px; }
table.field-table .col-src    { width: 100px; }
table.field-table--values .col-src { width: 60px; }
table.field-table--values .col-values { width: 128px; }
table.field-table--values td.desc { font-size: 9px; letter-spacing: -0.01em; }
table.field-table td.desc { font-family: var(--font-mono); font-size: 9.5px; }

/* Denser key/value table for the long descriptor list */
table.spec-table--tight th, table.spec-table--tight td { padding: 4px 10px; }
table.spec-table--tight { font-size: 11px; }

.h3--cont { margin-top: 0 !important; color: var(--fg-2); }
ol li { margin-bottom: 3px; }


/* ---------- Page footer ----------
   Reserved band per DESIGN_NOTES.md: absolutely positioned within .page;
   do NOT use margin-top:auto.
   --------------------------------------------------------------- */
.pf {
  position: absolute;
  left: 60px;
  right: 60px;
  bottom: 24px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--fg-3);
}
.pf__folio b { color: var(--fg-accent); font-weight: 700; }

/* ---------- Print ----------
   The screen card is the printed page. doc.css flattens .page/article.page
   to auto height and zero padding (with !important), so this block wins
   by matching the article.page specificity later in the cascade. The
   in-page .ph/.pf carry the running header and footer, so the @page
   margin is zero and Chromium's own header/footer stays off
   (build script passes --no-pdf-header-footer).
   --------------------------------------------------------------- */
@media print {
  @page { size: A4; margin: 0; }

  html, body { background: #fff !important; }
  body { font-size: var(--fs-14); }

  .sheet {
    display: block !important;
    padding: 0 !important; margin: 0 !important; gap: 0 !important;
    background: transparent !important;
  }

  article.page {
    width: 210mm !important;
    height: 297mm !important;
    padding: 68px 60px 92px !important;   /* mirrors the screen card */
    margin: 0 !important;
    background: #fff !important;
    overflow: hidden !important;
    box-shadow: none !important;
    border: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    break-after: page; page-break-after: always;
    break-inside: avoid; page-break-inside: avoid;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  article.page:last-child { break-after: auto; page-break-after: auto; }

  /* every tinted surface must keep its ink */
  thead th, .callout, .kv-card__cell--accent, .cover__model, .cover__marquee,
  .topology, .topology__node, .topology__wire, .chapter__rule, .sec-title::before,
  .mono, tbody tr:nth-child(even) td, .ph, .pf, .figbox, .fmt, .fn-head__code {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Defensive: hide the dev tweaks panel + no-print anchors. */
  .no-print, #tweaks-root, tweaks-panel, .overflow-banner { display: none !important; }
}
