/* Folio style kit.
 *
 * Tokens first, then base type, then the primitives page views compose: layout shell,
 * sidebar nav, tabs, forms, buttons, tables, callouts, badges. Print rules at the end.
 * Document text (.doc) is set in a serif at a reading measure; the application chrome
 * around it is sans. One accent colour; everything else is neutral.
 */

/* ---------- Tokens ---------- */

:root {
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* Minor-third scale */
  --step--2: 0.694rem;
  --step--1: 0.833rem;
  --step-0: 1rem;
  --step-1: 1.2rem;
  --step-2: 1.44rem;
  --step-3: 1.728rem;
  --step-4: 2.074rem;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;

  --radius-s: 3px;
  --radius-m: 6px;
  --radius-l: 10px;

  --measure: 68ch;
  --content-max: 76rem;
  --sidebar-width: 15rem;

  --paper: #fbfaf7;
  --surface: #ffffff;
  --sunken: #f3f1ec;
  --ink: #1d1f22;
  --ink-2: #4a4e55;
  --ink-3: #767b83;
  --rule: #e3e0d8;
  --rule-strong: #cbc7bd;

  --accent: #2c5a85;
  --accent-ink: #ffffff;
  --accent-soft: #e6eef6;
  --focus: #2c5a85;

  --info: #2c5a85;
  --info-soft: #e9f0f7;
  --ok: #2f6b46;
  --ok-soft: #e8f2eb;
  --warn: #8a5a0b;
  --warn-soft: #fbf1dc;
  --risk: #a2332a;
  --risk-soft: #f9e6e3;

  /* Chart series in fixed order, checked for colour-blind separation on --surface. */
  --chart-1: #2f6db0;
  --chart-2: #c47a1e;
  --chart-3: #1f9a7f;
  --chart-4: #8a6fc4;
  --chart-5: #c2566e;
  --highlight: #fff3c4;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16181b;
    --surface: #1c1f23;
    --sunken: #121417;
    --ink: #e7e5e0;
    --ink-2: #b4b2ad;
    --ink-3: #8a8985;
    --rule: #2d3136;
    --rule-strong: #41464d;

    --accent: #8cb4dc;
    --accent-ink: #10161c;
    --accent-soft: #1f2b37;
    --focus: #8cb4dc;

    --info: #8cb4dc;
    --info-soft: #1d2833;
    --ok: #86c39b;
    --ok-soft: #1b2a21;
    --warn: #e0b766;
    --warn-soft: #2e2617;
    --risk: #ec9087;
    --risk-soft: #331f1d;

    --chart-1: #5b93cf;
    --chart-2: #c98a35;
    --chart-3: #2fa587;
    --chart-4: #9a82d6;
    --chart-5: #dc6f86;
    --highlight: #3a3220;
  }
}

/* ---------- Base ---------- */

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-kerning: normal;
}

h1,
h2,
h3,
h4 {
  margin: 0 0 var(--space-3);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h1 { font-size: var(--step-3); }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }
h4 { font-size: var(--step-0); }

p,
ul,
ol,
dl,
figure,
table {
  margin: 0 0 var(--space-4);
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-thickness: 2px;
}

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

code,
kbd,
pre,
.mono {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

code {
  padding: 0.1em 0.3em;
  border-radius: var(--radius-s);
  background: var(--sunken);
}

pre {
  overflow-x: auto;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--rule);
  border-radius: var(--radius-m);
  background: var(--sunken);
  line-height: 1.45;
}

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

hr {
  margin: var(--space-6) 0;
  border: 0;
  border-top: 1px solid var(--rule);
}

.muted { color: var(--ink-2); }
.small { font-size: var(--step--1); }
.nowrap { white-space: nowrap; }
.eyebrow {
  margin-bottom: var(--space-2);
  color: var(--ink-3);
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.lead {
  color: var(--ink-2);
  font-size: var(--step-0);
}
.truncate {
  display: inline-block;
  max-width: 28ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip-link {
  position: absolute;
  left: var(--space-3);
  top: -3rem;
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-m);
}
.skip-link:focus { top: var(--space-3); z-index: 10; }

/* ---------- Document typography ----------
 * Long-form pages: serif, reading measure, quiet rhythm. Block renderers put their output
 * inside .doc; anything wider than the measure (tables, charts) opts out with .doc-wide.
 */

.doc {
  max-width: var(--measure);
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  line-height: 1.65;
  hyphens: auto;
}

.doc h1,
.doc h2,
.doc h3 {
  font-family: var(--font-sans);
  hyphens: manual;
}

.doc h1 { margin-top: var(--space-6); }
.doc h2 { margin-top: var(--space-6); }
.doc h3 { margin-top: var(--space-5); }
.doc > :first-child { margin-top: 0; }

.doc ul,
.doc ol { padding-left: 1.4em; }
.doc li + li { margin-top: var(--space-1); }

.doc blockquote {
  margin: 0 0 var(--space-4);
  padding-left: var(--space-4);
  border-left: 3px solid var(--rule-strong);
  color: var(--ink-2);
}

.doc-wide {
  max-width: none;
}

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

.topbar {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
}

.brand,
.auth-brand {
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: var(--step-1);
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.topnav {
  display: flex;
  gap: var(--space-4);
}

.topnav a {
  color: var(--ink-2);
  font-size: var(--step--1);
  font-weight: 500;
  text-decoration: none;
}

.topnav a:hover,
.topnav a[aria-current="page"] {
  color: var(--ink);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: auto;
  font-size: var(--step--1);
}

.topbar-user form { margin: 0; }
.topbar-name { color: var(--ink-2); }

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  max-width: var(--content-max);
  margin: 0 auto;
}

.shell:has(> .sidebar) {
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.main {
  min-width: 0;
  padding: var(--space-6) var(--space-5) var(--space-8);
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-3) var(--space-5);
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--rule);
}

.page-header h1 { margin: 0; }
.page-header .actions { margin-left: auto; display: flex; gap: var(--space-2); }

.section + .section { margin-top: var(--space-7); }

.empty-state {
  max-width: 36rem;
  padding: var(--space-7) 0;
}

.empty-state h2 { font-size: var(--step-1); }

.details {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: var(--space-2) var(--space-6);
}

.details dt { color: var(--ink-2); }
.details dd { margin: 0; }

@media (max-width: 52rem) {
  .shell:has(> .sidebar) { grid-template-columns: minmax(0, 1fr); }
  .topbar { flex-wrap: wrap; gap: var(--space-3); padding: var(--space-3) var(--space-4); }
  .main { padding: var(--space-5) var(--space-4) var(--space-7); }
  .details { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .details dd { margin-bottom: var(--space-3); }
}

/* ---------- Sidebar nav ----------
 * <aside class="sidebar"><nav class="nav-list"><p class="nav-heading">..</p><a>..</a></nav></aside>
 * Nested lists indent; aria-current="page" marks the open item.
 */

.sidebar {
  padding: var(--space-6) var(--space-4);
  border-right: 1px solid var(--rule);
  font-size: var(--step--1);
}

.nav-list,
.nav-list ul {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-list ul { padding-left: var(--space-3); }

.nav-heading {
  margin: var(--space-5) 0 var(--space-2);
  color: var(--ink-3);
  font-size: var(--step--2);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-heading:first-child { margin-top: 0; }

.nav-list a {
  display: block;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-s);
  color: var(--ink-2);
  text-decoration: none;
}

.nav-list a:hover { background: var(--sunken); color: var(--ink); }

.nav-list a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--ink);
  font-weight: 600;
}

@media (max-width: 52rem) {
  .sidebar { padding: var(--space-4); border-right: 0; border-bottom: 1px solid var(--rule); }
}

/* ---------- Tabs ----------
 * <nav class="tabs"><a aria-current="page">Overview</a><a>Detail</a></nav>
 */

.tabs {
  display: flex;
  gap: var(--space-5);
  margin-bottom: var(--space-5);
  overflow-x: auto;
  border-bottom: 1px solid var(--rule);
  scrollbar-width: thin;
}

.tabs a {
  margin-bottom: -1px;
  padding: var(--space-2) 0;
  border-bottom: 2px solid transparent;
  color: var(--ink-2);
  font-size: var(--step--1);
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
}

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

.tabs a[aria-current="page"] {
  border-bottom-color: var(--accent);
  color: var(--ink);
}

/* ---------- Forms ---------- */

.form { margin: 0; }

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
}

.field label,
.label {
  font-size: var(--step--1);
  font-weight: 600;
}

.field .hint {
  color: var(--ink-3);
  font-size: var(--step--1);
}

.field .error {
  color: var(--risk);
  font-size: var(--step--1);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="date"],
input:not([type]),
select,
textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-m);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  line-height: 1.4;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 0;
  border-color: var(--focus);
}

input[aria-invalid="true"] { border-color: var(--risk); }

.input-code {
  font-family: var(--font-mono);
  font-size: var(--step-2);
  letter-spacing: 0.3em;
  text-align: center;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.5rem 0.95rem;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-m);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: var(--step--1);
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover { background: var(--sunken); }

.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

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

.btn-quiet {
  border-color: transparent;
  background: transparent;
  color: var(--ink-2);
}

.btn-quiet:hover { color: var(--ink); }

.btn-danger { color: var(--risk); }
.btn-danger:hover { border-color: var(--risk); background: var(--risk-soft); }

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

.btn-small { padding: 0.25rem 0.6rem; }
.btn-block { width: 100%; padding-block: 0.65rem; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Tables ----------
 * Wrap in .table-wrap so a wide table scrolls on its own instead of the page.
 * td.num right-aligns figures with tabular digits.
 */

.table-wrap {
  margin-bottom: var(--space-4);
  overflow-x: auto;
}

.table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  font-size: var(--step--1);
  font-variant-numeric: tabular-nums;
}

.table caption {
  padding-bottom: var(--space-2);
  color: var(--ink-2);
  font-weight: 600;
  text-align: left;
}

.table th,
.table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

.table th:first-child,
.table td:first-child { padding-left: 0; }

.table th:last-child,
.table td:last-child { padding-right: 0; }

.table thead th {
  border-bottom: 1px solid var(--rule-strong);
  color: var(--ink-2);
  font-weight: 600;
  white-space: nowrap;
}

.table tbody tr:hover { background: color-mix(in srgb, var(--sunken) 60%, transparent); }

.table .num { text-align: right; }

.table .actions {
  width: 1%;
  text-align: right;
  white-space: nowrap;
}

.table .actions form { display: inline; margin: 0; }

.table .badge { margin-left: var(--space-2); }

/* ---------- Callouts ----------
 * Tones match the callout block: .callout-info, -ok, -warn, -risk.
 */

.callout {
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-left: 3px solid var(--info);
  border-radius: 0 var(--radius-m) var(--radius-m) 0;
  background: var(--info-soft);
  font-family: var(--font-sans);
  font-size: var(--step--1);
}

.callout > :last-child { margin-bottom: 0; }

.callout-title {
  margin-bottom: var(--space-1);
  font-weight: 600;
}

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

/* ---------- Badges ---------- */

.badge {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-size: var(--step--2);
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.6;
  white-space: nowrap;
  vertical-align: 0.1em;
}

.badge-accent { border-color: transparent; background: var(--accent-soft); color: var(--accent); }
.badge-ok { border-color: transparent; background: var(--ok-soft); color: var(--ok); }
.badge-warn { border-color: transparent; background: var(--warn-soft); color: var(--warn); }
.badge-risk { border-color: transparent; background: var(--risk-soft); color: var(--risk); }

/* ---------- Pages and blocks ----------
 * A page is <div class="doc doc-page"> holding one <section class="block block-<type>"> per block.
 * Prose blocks keep the reading measure; tables, charts and graphs (.doc-wide) use the full width.
 */

.doc-page { max-width: none; }
.doc-page > .block { max-width: var(--measure); }
.doc-page > .block.doc-wide { max-width: none; }
.doc-page > .block + .block { margin-top: var(--space-4); }

.block > :last-child,
.block .prose > :last-child { margin-bottom: 0; }

.doc h4 { margin-top: var(--space-5); font-family: var(--font-sans); }

.doc table:not(.table) {
  border-collapse: collapse;
  font-family: var(--font-sans);
  font-size: var(--step--1);
  font-variant-numeric: tabular-nums;
}

.doc table:not(.table) th,
.doc table:not(.table) td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--rule);
  text-align: left;
}

.doc table:not(.table) thead th { border-bottom-color: var(--rule-strong); color: var(--ink-2); }

.doc img { max-width: 100%; height: auto; }

.block figure { margin: 0; }

.block figcaption {
  margin-bottom: var(--space-2);
  font-family: var(--font-sans);
  font-size: var(--step--1);
  font-weight: 600;
}

.table-block .table-wrap { margin-bottom: var(--space-2); }
.doc .table { font-family: var(--font-sans); }

.table-tools {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
  font-family: var(--font-sans);
}

.table-tools .table-filter { max-width: 16rem; padding: 0.3rem 0.6rem; font-size: var(--step--1); }

.table-note { margin: 0; font-family: var(--font-sans); }

.table th .sort-button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.table th .sort-button::after {
  content: "";
  display: inline-block;
  width: 0.9em;
  color: var(--ink-3);
}

.table th[aria-sort="ascending"] .sort-button::after { content: " \2191"; }
.table th[aria-sort="descending"] .sort-button::after { content: " \2193"; }

.table td[data-sort],
.table td.num { white-space: nowrap; }

.stat {
  padding: var(--space-4) 0;
  font-family: var(--font-sans);
}

.stat-value {
  margin: 0;
  font-size: var(--step-4);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.stat-unit {
  margin-left: 0.25em;
  color: var(--ink-2);
  font-size: var(--step-1);
  font-weight: 500;
}

.stat-label { margin: var(--space-1) 0 0; color: var(--ink-2); font-size: var(--step--1); }

.chart-canvas {
  width: 100%;
  height: 20rem;
}

.chart-graph .chart-canvas { height: 24rem; }

.chart-canvas svg { max-width: 100%; }

.block-error { max-width: var(--measure); }

/* Live refresh: a block that just changed glows briefly and names its author. */
.block { position: relative; border-radius: var(--radius-m); }

.block-changed { animation: block-glow 2.4s ease-out; }

@keyframes block-glow {
  from { background-color: var(--highlight); box-shadow: 0 0 0 0.5rem var(--highlight); }
  to { background-color: transparent; box-shadow: 0 0 0 0.5rem transparent; }
}

.edit-chip {
  position: absolute;
  top: 0;
  right: 0;
  transform: translateY(-100%);
  z-index: 1;
  padding: 0.05rem 0.5rem;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-size: var(--step--2);
  font-weight: 600;
  pointer-events: none;
  animation: chip-fade 3.2s ease-in forwards;
}

@keyframes chip-fade {
  0%, 70% { opacity: 1; }
  100% { opacity: 0; }
}

.live-status {
  position: fixed;
  right: var(--space-4);
  bottom: var(--space-4);
  z-index: 5;
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--step--1);
}

@media (prefers-reduced-motion: reduce) {
  .block-changed { animation: none; outline: 2px solid var(--highlight); }
  .edit-chip { animation: none; }
}

/* ---------- Lists, filters, paging ---------- */

.card-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
  gap: var(--space-4);
  padding: 0;
  list-style: none;
}

.card {
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--rule);
  border-radius: var(--radius-l);
  background: var(--surface);
}

.card > :last-child { margin-bottom: 0; }
.card-title { margin-bottom: var(--space-2); font-size: var(--step-1); }
.card-title a { color: var(--ink); text-decoration: none; }
.card-title a:hover { text-decoration: underline; }

.tree-list { padding: 0; list-style: none; }
.tree-list li { padding: var(--space-1) 0; }

.nav-depth-1 { padding-left: var(--space-3); }
.nav-depth-2 { padding-left: var(--space-5); }
.nav-depth-3 { padding-left: var(--space-6); }
.nav-depth-4 { padding-left: var(--space-7); }

.badges { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.badges .badge { margin: 0; }

.dataset-table .sort-link { color: inherit; text-decoration: none; }
.dataset-table .sort-link:hover { text-decoration: underline; }
.dataset-table th[aria-sort="ascending"] .sort-link::after { content: " \2191"; }
.dataset-table th[aria-sort="descending"] .sort-link::after { content: " \2193"; }

.column-type {
  display: block;
  color: var(--ink-3);
  font-size: var(--step--2);
  font-weight: 400;
}

.pager {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0 var(--space-4);
  margin-bottom: var(--space-4);
}

.filters .field { min-width: 12rem; }
.filters-actions { flex-direction: row; min-width: 0; }

.snapshot-banner { max-width: var(--measure); margin-bottom: var(--space-6); }
.snapshot-header { margin-bottom: var(--space-5); padding-bottom: var(--space-4); border-bottom: 1px solid var(--rule); }
.snapshot-header h1 { margin-bottom: var(--space-1); }

.print-page { padding: 0; }
.print-header { margin-bottom: var(--space-5); padding-bottom: var(--space-3); border-bottom: 1px solid var(--rule); }

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

.auth {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 12vh var(--space-4) var(--space-6);
}

.auth-panel {
  width: 100%;
  max-width: 24rem;
}

.auth-brand {
  display: block;
  margin-bottom: var(--space-6);
  font-size: var(--step-2);
}

.auth h1 { font-size: var(--step-2); }

.auth-footer {
  width: 100%;
  max-width: 24rem;
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--rule);
  font-size: var(--step--1);
}

.qr {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
  margin: var(--space-5) 0;
}

.qr svg {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius-m);
  background: #ffffff;
}

.qr figcaption {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  font-size: var(--step--1);
}

.secret {
  padding: var(--space-2) var(--space-3);
  font-size: var(--step-0);
  letter-spacing: 0.06em;
  word-spacing: 0.3em;
  user-select: all;
}

/* ---------- Print ----------
 * What a client receives: the document alone, black on white, no application chrome.
 */

@media print {
  :root {
    --paper: #ffffff;
    --surface: #ffffff;
    --sunken: #f4f4f4;
    --ink: #000000;
    --ink-2: #333333;
    --ink-3: #555555;
    --rule: #cccccc;
    --rule-strong: #999999;
    --accent: #1f3f5e;
  }

  @page {
    size: A4;
    margin: 18mm 16mm 20mm;
  }

  body {
    background: #ffffff;
    font-size: 10.5pt;
  }

  .topbar,
  .sidebar,
  .skip-link,
  .tabs,
  .page-header .actions,
  .table .actions,
  .no-print,
  form {
    display: none !important;
  }

  .shell,
  .shell:has(> .sidebar) {
    display: block;
    max-width: none;
  }

  .main { padding: 0; }

  .doc-page > .block { max-width: none; }
  .table-tools,
  .edit-chip,
  .live-status { display: none !important; }
  .block-changed { animation: none; }
  .chart-canvas { height: 18rem; }
  .chart-graph .chart-canvas { height: 22rem; }
  .stat-value { font-size: 20pt; }

  .doc {
    max-width: none;
    font-size: 11pt;
    line-height: 1.5;
  }

  h1,
  h2,
  h3,
  h4 {
    break-after: avoid;
  }

  table,
  figure,
  .callout,
  pre {
    break-inside: avoid;
  }

  thead { display: table-header-group; }
  tr { break-inside: avoid; }

  .table-wrap { overflow: visible; }

  .table tbody tr:hover { background: none; }

  a {
    color: inherit;
    text-decoration: none;
  }

  .doc a[href^="http"]::after {
    content: " (" attr(href) ")";
    color: var(--ink-3);
    font-size: 0.85em;
  }

  .callout,
  .badge {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}
