:root {
  --ink: #182230;
  --muted: #5d6978;
  --line: #dbe2ea;
  --panel: #f6f8fb;
  --brand: #65236f;
  --brand-dark: #43164b;
  --brand-soft: #f3eaf5;
  --accent: #f0b429;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --ok: #147a56;
  --ok-soft: #eaf8f2;
  --info: #1c5d99;
  --info-soft: #edf6ff;
  --shadow: 0 14px 38px rgba(24, 34, 48, 0.09);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  background: #eef1f5;
}

body {
  margin: 0;
  color: var(--ink);
  background: #eef1f5;
  font: 15px/1.65 Inter, "Segoe UI", Arial, sans-serif;
}

a { color: var(--info); }
a:hover { color: var(--brand); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 58px;
  padding: 8px max(24px, calc((100vw - 1180px) / 2));
  color: #fff;
  background: rgba(67, 22, 75, 0.97);
  box-shadow: 0 3px 18px rgba(16, 24, 40, 0.2);
}

.brand {
  color: #fff;
  font-weight: 750;
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 2px;
}

.nav a {
  padding: 6px 9px;
  color: rgba(255, 255, 255, 0.82);
  border-radius: 6px;
  font-size: 12px;
  text-decoration: none;
}

.nav a:hover,
.nav a[aria-current="page"] {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
}

.page {
  width: min(1180px, calc(100% - 40px));
  margin: 30px auto 64px;
  padding: 46px clamp(24px, 5vw, 72px) 64px;
  background: #fff;
  border: 1px solid #e0e5ec;
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.doc-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 26px;
  align-items: start;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1, h2, h3 { color: #17202d; line-height: 1.25; }
h1 { margin: 0 0 10px; font-size: clamp(30px, 5vw, 48px); letter-spacing: -0.035em; }
h2 { margin: 44px 0 14px; font-size: 25px; letter-spacing: -0.015em; }
h3 { margin: 27px 0 10px; font-size: 18px; }
p { margin: 8px 0 14px; }

.lede {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 17px;
}

.doc-meta {
  min-width: 220px;
  padding: 14px 16px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 12px;
}

.doc-meta strong { color: var(--ink); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  color: var(--brand-dark);
  background: var(--brand-soft);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge.warn { color: #7a4d00; background: #fff2cc; }
.badge.ok { color: var(--ok); background: var(--ok-soft); }

.hero-grid,
.grid-2,
.grid-3 {
  display: grid;
  gap: 20px;
}

.hero-grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); margin-top: 30px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.product-image {
  display: block;
  width: 100%;
  max-height: 430px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.product-figure { min-width: 0; margin: 0; }
.product-figure figcaption { margin-top: 8px; color: var(--muted); font-size: 12px; }

.card {
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.card h2,
.card h3 { margin-top: 0; }
.card p:last-child { margin-bottom: 0; }

.architecture-diagram {
  margin: 18px 0 24px;
  padding: 18px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.arch-canvas {
  display: grid;
  grid-template-columns: minmax(170px, 0.65fr) minmax(120px, 0.42fr) minmax(340px, 1.55fr);
  gap: 14px;
  align-items: stretch;
}

.arch-zone {
  padding: 14px;
  border: 1px solid #cfd8e3;
  border-radius: 10px;
  background: #fff;
}

.arch-zone.module {
  border-color: #cbaed0;
  background: #fcf9fd;
}

.arch-zone-label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.arch-box {
  padding: 10px 11px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
}

.arch-box + .arch-box { margin-top: 10px; }
.arch-box strong { display: block; color: #2d1832; }
.arch-box small { display: block; margin-top: 3px; color: var(--muted); line-height: 1.45; }
.arch-box.preferred { border-color: #73b99f; background: var(--ok-soft); }

.arch-interface {
  display: grid;
  gap: 7px;
  align-content: center;
  padding: 12px 10px;
  color: #344054;
  background: #edf2f7;
  border: 1px dashed #aab7c6;
  border-radius: 10px;
  font-size: 12px;
  text-align: center;
}

.arch-interface strong { color: var(--brand-dark); font-size: 13px; }
.arch-interface span { display: block; padding: 2px 0; }

.arch-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.arch-arrow {
  padding: 4px 0;
  color: var(--brand);
  font-size: 12px;
  font-weight: 750;
  text-align: center;
}

.arch-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
}

.arch-tags span {
  padding: 3px 7px;
  color: #344054;
  background: #eef2f6;
  border-radius: 999px;
  font-size: 11px;
}

.architecture-diagram figcaption {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.stat {
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.stat b { display: block; font-size: 19px; }
.stat span { color: var(--muted); font-size: 12px; }

.callout {
  margin: 20px 0;
  padding: 16px 18px;
  border-left: 4px solid var(--info);
  border-radius: 8px;
  background: var(--info-soft);
}

.callout.todo {
  border-left-color: var(--accent);
  background: #fff8df;
}

/* Unified marker for information that is not yet available or approved. */
.callout.missing-info {
  border: 2px dashed #d97706;
  border-left-width: 6px;
  background: #fff7ed;
  color: #7c2d12;
}

.callout.missing-info strong:first-child { color: #9a3412; }

.callout.internal-note {
  border: 2px dashed #c88719;
  border-left-width: 6px;
  background: #fff7d6;
}

.callout.internal-note strong:first-child { color: #704700; }

.callout.danger {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}

.callout.ok {
  border-left-color: var(--ok);
  background: var(--ok-soft);
}

.callout strong:first-child {
  display: block;
  margin-bottom: 4px;
}

.todo-inline {
  display: inline;
  padding: 1px 5px;
  color: #704700;
  background: #fff0b3;
  border-radius: 4px;
  font-weight: 700;
}

.missing-inline {
  display: inline-block;
  padding: 2px 7px;
  color: #9a3412;
  background: #ffedd5;
  border: 1px dashed #d97706;
  border-radius: 4px;
  font-weight: 750;
}

.missing-table {
  border: 2px dashed #d97706;
  background: #fffaf3;
}

.missing-table th { background: #ffedd5; color: #7c2d12; }
.missing-table td { background: #fffaf3; }
.missing-cell { color: #9a3412; background: #fff7ed !important; font-weight: 650; }

.table-wrap {
  width: 100%;
  margin: 16px 0 24px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

table {
  width: 100%;
  min-width: 650px;
  border-collapse: collapse;
  background: #fff;
}

th, td {
  padding: 11px 13px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

th {
  color: #344054;
  background: #f2f5f8;
  font-size: 12px;
  letter-spacing: 0.02em;
}

tr:last-child td { border-bottom: 0; }
td code { white-space: nowrap; }

.antenna-matrix { min-width: 760px; }
.antenna-matrix caption,
.measurement-table caption {
  padding: 10px 13px;
  color: var(--muted);
  background: var(--panel);
  text-align: left;
  font-size: 13px;
}
.antenna-matrix td:nth-child(n+3),
.antenna-matrix th:nth-child(n+3),
.measurement-table .numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.antenna-matrix th[scope="row"] { white-space: nowrap; }
.antenna-matrix sup,
.measurement-table sup { color: #9a3412; }

code, pre {
  font-family: "Cascadia Code", Consolas, monospace;
}

code {
  padding: 1px 5px;
  color: #4a2250;
  background: #f4eef5;
  border-radius: 4px;
  font-size: 0.92em;
}

pre {
  margin: 16px 0 24px;
  padding: 18px;
  overflow-x: auto;
  color: #e6edf3;
  background: #17202a;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.55;
}

pre code { padding: 0; color: inherit; background: none; }

ul, ol { padding-left: 22px; }
li { margin: 5px 0; }

.toc {
  margin: 26px 0;
  padding: 18px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.toc strong { display: block; margin-bottom: 6px; }
.toc ol { columns: 2; margin: 0; }

.status-list {
  display: grid;
  gap: 12px;
  margin: 18px 0;
}

.status-row {
  display: grid;
  grid-template-columns: minmax(200px, 0.8fr) 110px minmax(0, 1.6fr);
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.status-row a { font-weight: 750; text-decoration: none; }
.status-row small { color: var(--muted); }

.checklist {
  list-style: none;
  padding: 0;
}
.checklist li { position: relative; padding-left: 26px; }
.checklist li::before {
  position: absolute;
  left: 0;
  top: 1px;
  color: var(--ok);
  content: "✓";
  font-weight: 900;
}
.checklist li.todo-item::before,
.checklist li.missing-item::before { color: #a46900; content: "□"; }
.checklist li.missing-item { color: #7c2d12; background: #fffaf3; border-radius: 5px; }

.doc-footer {
  margin-top: 54px;
  padding-top: 20px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.button {
  display: inline-block;
  padding: 9px 14px;
  color: #fff;
  background: var(--brand);
  border-radius: 7px;
  font-weight: 700;
  text-decoration: none;
}
.button.secondary { color: var(--brand); background: var(--brand-soft); }
.button:hover { color: #fff; background: var(--brand-dark); }
.button.secondary:hover { color: var(--brand-dark); background: #ead9ed; }

@media (max-width: 880px) {
  .topbar { align-items: flex-start; flex-direction: column; gap: 4px; position: static; }
  .nav { justify-content: flex-start; }
  .doc-header, .hero-grid, .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .doc-meta { min-width: 0; }
  .toc ol { columns: 1; }
  .status-row { grid-template-columns: 1fr; gap: 5px; }
  .arch-canvas { grid-template-columns: 1fr; }
  .arch-interface { text-align: left; }
  .arch-interface span { display: inline-block; margin-right: 10px; }
}

@media (max-width: 560px) {
  .page { width: 100%; margin: 0; padding: 28px 18px 48px; border: 0; border-radius: 0; }
  .topbar { padding: 10px 14px; }
  h1 { font-size: 32px; }
  .arch-split { grid-template-columns: 1fr; }
  #read-distance-reference, #i2c-addresses, #antenna-read-distance { min-width: 0; }
  #read-distance-reference th, #read-distance-reference td,
  #i2c-addresses th, #i2c-addresses td,
  #antenna-read-distance th, #antenna-read-distance td { padding: 8px; font-size: 13px; }
}

@media print {
  html, body { background: #fff; }
  .topbar { display: none; }
  .page { width: 100%; margin: 0; padding: 15mm; border: 0; box-shadow: none; }
  a { color: inherit; text-decoration: none; }
  .callout, .card, .table-wrap { break-inside: avoid; }
}
