:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1d2430;
  --muted: #667085;
  --border: #e3e6ea;
  --accent: #1f4e79;
  --accent-hover: #173b5c;
  --ok-bg: #e6f4ea;
  --ok-text: #1e6b34;
  --bad-bg: #fbe9e7;
  --bad-text: #a1301f;
  --warn-bg: #fff4e0;
  --warn-text: #8a5300;
}

* { box-sizing: border-box; }
/* The hidden attribute must win over any display rule (e.g. .row { display: flex }). */
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-size: 0.9em; background: #eef1f4; padding: 1px 5px; border-radius: 4px; }
h1 { font-size: 24px; margin: 0 0 8px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ── Layout ─────────────────────────────────────────── */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px;
  padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-link { display: flex; flex-direction: column; line-height: 1.15; color: var(--text); }
.brand-link:hover { text-decoration: none; }
.brand-name { font-weight: 700; }
.brand-org { font-size: 12px; color: var(--muted); }
.env-badge { font-size: 11px; font-weight: 700; background: var(--warn-bg); color: var(--warn-text); padding: 2px 6px; border-radius: 4px; }
.mainnav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
.mainnav a { padding: 6px 10px; border-radius: 6px; color: var(--muted); }
.mainnav a.active, .mainnav a:hover { background: #eef1f4; color: var(--text); text-decoration: none; }
.user { display: flex; align-items: center; gap: 10px; }
.user-name { font-weight: 600; }
.role-chip { font-size: 12px; text-transform: capitalize; background: #eef1f4; padding: 2px 8px; border-radius: 10px; }
.container { max-width: 1100px; margin: 0 auto; padding: 24px; }
.footer { display: flex; gap: 8px; justify-content: center; padding: 24px; font-size: 12px; color: var(--muted); }

/* ── Components ─────────────────────────────────────── */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 20px; margin: 16px 0; }
.panel.narrow { max-width: 560px; margin: 60px auto; }
.panel.center { text-align: center; }
.btn {
  display: inline-block; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer;
}
.btn:hover { background: #eef1f4; text-decoration: none; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.inline-form { display: inline; margin: 0; }
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; background: #e8f0fb; }
.flash.error { background: var(--bad-bg); color: var(--bad-text); }
.flash.success { background: var(--ok-bg); color: var(--ok-text); }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 10px; }
.pill.ok { background: var(--ok-bg); color: var(--ok-text); }
.pill.bad { background: var(--bad-bg); color: var(--bad-text); }
table.kv { border-collapse: collapse; width: 100%; }
table.kv th { text-align: left; width: 220px; color: var(--muted); font-weight: 500; }
table.kv th, table.kv td { padding: 8px 0; border-top: 1px solid var(--border); vertical-align: top; }
.stack { overflow: auto; background: #f4f6f9; padding: 12px; border-radius: 8px; font-size: 12px; }

/* ── Login ──────────────────────────────────────────── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 32px; }
.login-form { display: flex; flex-direction: column; gap: 14px; margin: 20px 0; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
.login-form input { height: 42px; border: 1px solid var(--border); border-radius: 6px; padding: 0 12px; font: inherit; }
.login-form .btn { height: 44px; }

@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .container { padding: 16px; }
  table.kv th { width: 130px; }
}

/* ── Dashboard tests ────────────────────────────────── */
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-head h2 { margin: 0; }
.pill.warn { background: var(--warn-bg); color: var(--warn-text); }
.btn[disabled] { opacity: 0.6; cursor: default; }
table.grid { border-collapse: collapse; width: 100%; margin-top: 8px; }
table.grid th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13px; }
table.grid th, table.grid td { padding: 6px 8px 6px 0; border-top: 1px solid var(--border); vertical-align: top; }
table.grid .num { text-align: right; padding-right: 16px; }
@media (max-width: 700px) { .panel-head { flex-wrap: wrap; } table.grid { font-size: 13px; } }

/* ── Catalog tree ───────────────────────────────────── */
.tree details { border-top: 1px solid var(--border); padding: 6px 0; }
.tree summary { cursor: pointer; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tree-title { font-weight: 600; }
.tree details table.grid { margin: 6px 0 4px 18px; width: calc(100% - 18px); }
.tree-empty { margin: 6px 0 4px 18px; }
.type-col { width: 110px; text-transform: capitalize; }

/* ── Policies & runs ────────────────────────────────── */
.policy-form fieldset { border: 0; padding: 0; margin: 0; }
.field { display: inline-flex; flex-direction: column; gap: 4px; margin: 0 16px 12px 0; font-size: 13px; font-weight: 600; }
.field input, .field select { height: 36px; border: 1px solid var(--border); border-radius: 6px; padding: 0 10px; font: inherit; font-weight: 400; min-width: 140px; }
.field input[type=text] { min-width: 260px; }
.row { display: flex; flex-wrap: wrap; align-items: flex-end; }
.check { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 2px 16px; margin-bottom: 8px; }
.radios { margin-bottom: 12px; }
.pick-list { max-height: 320px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; margin-bottom: 12px; }
.pick-list.short { max-height: 160px; }
.inline-search { height: 28px; border: 1px solid var(--border); border-radius: 6px; padding: 0 8px; margin: 0 6px; }
.progress { height: 8px; background: #eef1f4; border-radius: 4px; overflow: hidden; margin: 8px 0; }
.progress .bar { height: 100%; background: var(--accent); transition: width 0.5s ease; }
.danger-zone { margin: 24px 0; }
@media (max-width: 700px) { .field input[type=text] { min-width: 0; width: 100%; } .field { display: flex; margin-right: 0; } }

/* ── Snapshots ──────────────────────────────────────── */
.inline-search.wide { width: 280px; height: 36px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.tabs a { padding: 6px 12px; border-radius: 6px 6px 0 0; color: var(--muted); }
.tabs a.active { background: #eef1f4; color: var(--text); text-decoration: none; font-weight: 600; }
.preview-frame { width: 100%; height: 70vh; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.snippet { margin-top: 2px; }
.snippet mark { background: #fff2b3; padding: 0 1px; }
.raw { max-height: 480px; overflow: auto; background: #f4f6f9; padding: 12px; border-radius: 8px; font-size: 12px; white-space: pre-wrap; word-break: break-word; }
.questions > li { margin-bottom: 14px; }
.options { list-style: none; padding-left: 8px; }
.options li.correct { color: var(--ok-text); font-weight: 600; }
.scroll-x { overflow-x: auto; }
h2.section { margin-top: 20px; }
@media (max-width: 700px) { .inline-search.wide { width: 100%; } .preview-frame { height: 60vh; } }

/* ── Retention ──────────────────────────────────────── */
.retention-box { padding: 12px 20px; }
.actions { display: flex; gap: 6px; align-items: flex-start; flex-wrap: wrap; }
.inline-details { display: inline-block; }
.inline-details summary { list-style: none; }
.inline-details summary::-webkit-details-marker { display: none; }
.hold-form { display: flex; gap: 6px; margin-top: 6px; }
.hold-form input { height: 30px; border: 1px solid var(--border); border-radius: 6px; padding: 0 8px; min-width: 220px; }
.gc-form { display: flex; gap: 8px; align-items: center; }
h3 { font-size: 15px; margin: 16px 0 4px; }

/* ── Documentation ──────────────────────────────────── */
.docs { display: grid; grid-template-columns: 220px 1fr; gap: 28px; align-items: start; }
.docs-nav { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.docs-nav a { padding: 5px 10px; border-radius: 6px; color: var(--muted); }
.docs-nav a.active, .docs-nav a:hover { background: #eef1f4; color: var(--text); text-decoration: none; }
.docs-nav .docs-home { font-weight: 600; color: var(--text); margin-bottom: 6px; }
.docs-nav-section { margin: 12px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.docs-body { min-width: 0; max-width: 860px; }
.docs-body h1 { font-size: 28px; }
.docs-body h2 { font-size: 20px; margin: 32px 0 10px; padding-top: 8px; border-top: 1px solid var(--border); }
.docs-body h3 { font-size: 16px; margin: 22px 0 8px; }
.docs-body p, .docs-body li { line-height: 1.65; }
.docs-body .lead { font-size: 17px; color: var(--muted); margin-bottom: 20px; }
.docs-crumb { margin: 0 0 4px; color: var(--muted); }
.docs-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.docs-card { display: flex; flex-direction: column; gap: 4px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); }
.docs-card:hover { border-color: var(--accent); text-decoration: none; }
.docs-card span { font-size: 13px; color: var(--muted); line-height: 1.5; }
.docs-pager { display: flex; justify-content: space-between; margin: 40px 0 8px; padding-top: 16px; border-top: 1px solid var(--border); }
.note, .warn-box, .tip { border-radius: 8px; padding: 12px 14px; margin: 14px 0; font-size: 14px; line-height: 1.6; }
.note { background: #e8f0fb; }
.tip { background: var(--ok-bg); }
.warn-box { background: var(--warn-bg); }
.steps { counter-reset: step; list-style: none; padding-left: 0; }
.steps > li { counter-increment: step; position: relative; padding-left: 38px; margin-bottom: 12px; }
.steps > li::before { content: counter(step); position: absolute; left: 0; top: 1px; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; }
table.doc-table { border-collapse: collapse; width: 100%; margin: 10px 0 16px; font-size: 14px; }
table.doc-table th, table.doc-table td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; vertical-align: top; }
table.doc-table th { background: #f4f6f9; font-weight: 600; }
.yes { color: var(--ok-text); font-weight: 700; }
.no { color: var(--muted); }
kbd { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; background: #f4f6f9; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; }
pre.code { background: #1d2430; color: #e6edf3; padding: 12px 14px; border-radius: 8px; overflow-x: auto; font-size: 13px; line-height: 1.5; }

/* Diagrams */
.diagram { margin: 18px 0; }
.diagram svg { width: 100%; height: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.diagram figcaption { font-size: 13px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.dg-box { fill: #ffffff; stroke: #c9d1db; stroke-width: 1.5; }
.dg-accent { fill: #e8f0fb; stroke: var(--accent); }
.dg-group { fill: #f6f7f9; stroke: #c9d1db; stroke-dasharray: 5 4; }
.dg-title { font: 600 14px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; fill: var(--text); }
.dg-text { font: 13px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; fill: var(--text); }
.dg-muted { font: 12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; fill: var(--muted); }
.dg-small { font: 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; fill: var(--muted); }
.dg-label { font: 700 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; fill: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.dg-line { stroke: #8a96a6; stroke-width: 1.5; fill: none; }
.dg-strong { stroke: var(--accent); stroke-width: 2.5; }
.dg-dashed { stroke-dasharray: 5 4; }
.dg-arrowhead { fill: #8a96a6; }
.dg-axis { stroke: #c9d1db; stroke-width: 2; }
.dg-dot-keep { fill: var(--accent); }
.dg-dot-gone { fill: #d5d9de; }
.dg-dot-pin { fill: #c77700; }

/* Annotated screen replicas */
.mock { border: 1px solid #c9d1db; border-radius: 10px; overflow: hidden; margin: 16px 0 8px; background: var(--bg); box-shadow: 0 2px 10px rgba(29, 36, 48, .06); font-size: 13px; }
.mock-bar { display: flex; align-items: center; gap: 6px; padding: 7px 10px; background: #eef1f4; border-bottom: 1px solid #d5d9de; }
.mock-bar i { width: 10px; height: 10px; border-radius: 50%; background: #c9d1db; display: inline-block; }
.mock-url { margin-left: 10px; font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); background: #fff; border-radius: 4px; padding: 1px 8px; }
.mock-body { padding: 14px; }
.mock .panel { margin: 0 0 10px; padding: 12px; }
.mock h4 { margin: 0 0 8px; font-size: 14px; }
.mock .field input, .mock .field select { height: 30px; min-width: 110px; }
.mock .btn { padding: 4px 10px; }
.mock-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 6px 0; }
.mock-input { display: inline-block; min-width: 120px; padding: 5px 9px; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--text); }
.co { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; background: #c77700; color: #fff; font: 700 11px -apple-system, BlinkMacSystemFont, sans-serif; vertical-align: middle; margin: 0 4px; flex: none; }
.co-legend { list-style: none; padding: 0; margin: 4px 0 18px; }
/* Block layout, not flex: a flex <li> would turn every <em>/<strong>/<code> into its own column. */
.co-legend li { position: relative; padding-left: 30px; margin: 6px 0; line-height: 1.55; }
.co-legend li > .co:first-child { position: absolute; left: 0; top: 2px; margin: 0; }

@media (max-width: 800px) {
  .docs { grid-template-columns: 1fr; }
  .docs-nav { position: static; flex-direction: row; flex-wrap: wrap; }
  .docs-nav-section { width: 100%; margin: 6px 0 0; }
}

/* ── Compare ────────────────────────────────────────── */
.text-diff { white-space: pre-wrap; line-height: 1.7; font-size: 14px; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; max-height: 70vh; overflow: auto; }
.text-diff ins { background: var(--ok-bg); color: var(--ok-text); text-decoration: none; border-radius: 3px; }
.text-diff del { background: var(--bad-bg); color: var(--bad-text); border-radius: 3px; }
.text-diff .gap { display: block; color: var(--muted); font-style: italic; font-size: 12px; margin: 6px 0; }
.diff-fields .del-cell { background: #fdf3f1; word-break: break-word; }
.diff-fields .add-cell { background: #eef8f1; word-break: break-word; }

/* ── Guided restore ─────────────────────────────────── */
.quote { margin: 6px 0; padding: 8px 12px; border-left: 3px solid var(--border); background: #f6f7f9; border-radius: 4px; font-size: 14px; white-space: pre-wrap; }
.step-status { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.step-status .field { flex: 1; min-width: 240px; margin-bottom: 0; }
.step-status .field input { width: 100%; }
.steps-table td { vertical-align: middle; }

/* ── People records & org restore ───────────────────── */
.rel-list { columns: 2; column-gap: 24px; margin: 0; padding-left: 18px; }
.exec-form { display: inline-flex; gap: 6px; align-items: center; }
.exec-form input { height: 32px; border: 1px solid var(--border); border-radius: 6px; padding: 0 8px; width: 140px; }
@media (max-width: 700px) { .rel-list { columns: 1; } }

/* ── Settings & alerts ──────────────────────────────── */
.settings-tabs { margin-bottom: 16px; }
.textarea { width: 100%; border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font: inherit; font-weight: 400; }
.alert-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }

/* ── Library (reader) ───────────────────────────────── */
.lib-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 16px; }
.lib-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14px; }
.lib-crumbs > a:first-child { font-weight: 600; }
.lib-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.lib-search input { height: 34px; width: 260px; border: 1px solid var(--border); border-radius: 6px; padding: 0 10px; font: inherit; background: var(--surface); }
.lib-asof { display: flex; align-items: center; gap: 6px; }
.lib-asof select { height: 34px; border: 1px solid var(--border); border-radius: 6px; padding: 0 8px; font: inherit; background: var(--surface); max-width: 260px; }
.lib-older { background: var(--warn-bg); color: var(--warn-text); border-radius: 8px; padding: 8px 12px; margin: -4px 0 16px; }
.lib-hero { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.lib-hero p { margin: 0; }
.lib-filter { height: 36px; width: 260px; border: 1px solid var(--border); border-radius: 6px; padding: 0 10px; font: inherit; background: var(--surface); }
.lib-section { margin-top: 24px; }
.lib-section-title { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.lib-card { display: flex; gap: 12px; align-items: flex-start; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; color: var(--text); min-width: 0; }
.lib-card:hover { border-color: var(--accent); text-decoration: none; box-shadow: 0 2px 8px rgba(29, 36, 48, .06); }
.lib-card-sm { padding: 10px 12px; }
.lib-card-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.lib-card-title { font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.lib-desc { font-size: 13px; color: var(--muted); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lib-emoji { flex: none; width: 36px; height: 36px; border-radius: 8px; background: #eef1f4; display: flex; align-items: center; justify-content: center; font-size: 20px; line-height: 1; }
.lib-emoji.lg { width: 56px; height: 56px; font-size: 30px; border-radius: 12px; }
.lib-subject-head { display: flex; gap: 16px; align-items: flex-start; }
.lib-subject-text { flex: 1; min-width: 0; }
.lib-subject-text p { margin: 4px 0; }
.lib-contents { margin: 0; padding-left: 22px; }
.lib-contents > li { padding: 8px 0; border-top: 1px solid var(--border); }
.lib-contents > li:first-child { border-top: 0; }
.lib-contents-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.lib-pages { margin: 4px 0 0 26px; }
.lib-pages summary { cursor: pointer; }
.lib-pages ol { margin: 4px 0; font-size: 14px; }
.lib-results { list-style: none; padding: 0; margin: 0; }
.lib-results li { padding: 10px 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.lib-results li:first-child { border-top: 0; }

.reader { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 24px; align-items: start; }
.reader-toc { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px; font-size: 14px; }
.reader-toc-title { display: block; font-weight: 700; color: var(--text); padding: 4px 6px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.reader-toc ol { list-style: none; margin: 0; padding: 0; }
.reader-toc li > a { display: block; padding: 5px 6px; border-radius: 6px; color: var(--text); line-height: 1.35; }
.reader-toc li > a:hover { background: #eef1f4; text-decoration: none; }
.reader-toc li.current > a { font-weight: 600; background: #eef1f4; }
.reader-toc-pages { margin: 2px 0 6px 14px !important; border-left: 2px solid var(--border); }
.reader-toc-pages a { color: var(--muted) !important; font-size: 13px; padding: 4px 8px !important; }
.reader-toc-pages a.here { color: var(--accent) !important; font-weight: 600; background: #e8f0fb; }
.reader-main { min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 20px 24px; }
.reader-kicker { margin: 0 0 4px; }
.reader-title { font-size: 26px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.reader-desc { color: var(--muted); font-size: 16px; }
.reader-frame { display: block; width: 100%; height: calc(100vh - 260px); min-height: 460px; border: 0; border-top: 1px solid var(--border); margin-top: 8px; background: #fff; }
.reader-main .panel { border: 0; padding: 0; }
.reader-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.reader-step { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.reader-step:hover { border-color: var(--accent); text-decoration: none; }
.reader-step.next { text-align: right; grid-column: 2; }
.reader-progress { height: 4px; margin: 12px 0 4px; }
.reader-foot { margin: 8px 0 0; }
.reader-quiz .mark-ok { display: none; }
.reader-quiz:not(:has(#reveal-answers:checked)) .options li.correct { color: inherit; font-weight: inherit; }
.reader-quiz:has(#reveal-answers:checked) li.correct .mark-ok { display: inline; }
.reader-quiz:has(#reveal-answers:checked) li.correct .mark-opt { display: none; }

@media (max-width: 860px) {
  .reader { grid-template-columns: 1fr; }
  .reader-toc { position: static; max-height: 320px; order: 2; }
  .reader-main { padding: 16px; }
  .reader-frame { height: 70vh; }
  .lib-search input, .lib-filter { width: 100%; }
  .lib-tools, .lib-search { width: 100%; }
  .lib-subject-head { flex-wrap: wrap; }
}

/* ── Audit log ──────────────────────────────────────── */
/* Fixed columns so long emails, snapshot ids and details wrap inside the panel instead of widening it. */
.audit-table { table-layout: fixed; min-width: 760px; }
.audit-table col.c-when { width: 118px; }
.audit-table col.c-who { width: 22%; }
.audit-table col.c-action { width: 17%; }
.audit-table col.c-target { width: 22%; }
.audit-table td { overflow-wrap: anywhere; }
.audit-table code { white-space: normal; overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
.audit-detail { margin: 0; }
.audit-detail div { margin-bottom: 2px; }
.audit-detail dt { display: inline; color: var(--muted); }
.audit-detail dd { display: inline; margin: 0; }

/* Library list layout */
.lib-hero-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--surface); }
.seg a { padding: 6px 12px; font-size: 14px; color: var(--muted); }
.seg a + a { border-left: 1px solid var(--border); }
.seg a:hover { background: #eef1f4; text-decoration: none; }
.seg a.active { background: #eef1f4; color: var(--text); font-weight: 600; }
@media (max-width: 860px) { .lib-hero-tools { width: 100%; } .lib-hero-tools .lib-filter { flex: 1; width: auto; } }

/* Library toolbar (View by / Sort / filter / layout) */
.lib-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 12px 0 16px; }
.lib-choices { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.lib-select { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 6px 0 14px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); font-size: 14px; }
.lib-select select { border: 0; background: transparent; font: inherit; color: var(--text); height: 32px; cursor: pointer; padding-right: 4px; }
.lib-select select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Library list layout, modelled on Trainual's content list */
.tl { display: flex; flex-direction: column; gap: 10px; }
.tl-head, .tl-header { display: grid; grid-template-columns: 36px 36px minmax(0, 1fr) 96px 120px 130px; align-items: center; gap: 12px; }
.tl-header { padding: 0 18px; color: var(--muted); font-weight: 600; }
.tl-header > span:first-child { grid-column: 1 / 4; }
.tl-row { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.tl-row[open] { background: #f9fafb; }
.tl-head { padding: 14px 18px; list-style: none; cursor: pointer; }
div.tl-head { cursor: default; }
.tl-head::-webkit-details-marker, .tl-child-row::-webkit-details-marker { display: none; }
.tl-row[open] > .tl-head { border-bottom: 1px solid var(--border); background: var(--surface); border-radius: 12px 12px 0 0; }
.tl-chev { width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.tl-chev::before { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s ease; margin-left: -3px; }
details[open] > summary .tl-chev::before { transform: rotate(45deg); margin: -4px 0 0; }
.tl-head:hover .tl-chev, .tl-child-row:hover .tl-chev { background: #eef1f4; color: var(--text); }
.tl-chev-space { width: 32px; }
.tl-icon { display: inline-flex; align-items: center; justify-content: center; width: 28px; font-size: 18px; line-height: 1; }
.tl-icon.lg { font-size: 22px; width: 36px; }
.tl-name { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tl-title { color: var(--text); font-weight: 600; font-size: 16px; overflow-wrap: anywhere; }
.tl-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.tl-tag { background: #eef1f4; color: var(--text); border-radius: 4px; padding: 0 6px; }
.tl-tag.warn { background: var(--warn-bg); color: var(--warn-text); }
.tl-dot { color: #b8bec6; }
.tl-items { font-size: 14px; }
.type-pill { display: inline-block; font-size: 12px; font-weight: 500; padding: 1px 10px; border: 1px solid #b8bec6; border-radius: 10px; }
.tl-cat { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.cat-icon { width: 14px; height: 17px; border-radius: 2px 6px 2px 2px; flex: none; position: relative; }
.cat-icon::after { content: ""; position: absolute; left: 3px; right: 3px; top: 7px; height: 5px; border-top: 1.5px solid rgba(0, 0, 0, .35); border-bottom: 1.5px solid rgba(0, 0, 0, .35); }
.cat-company { background: #f5c242; }
.cat-policy { background: #f075c0; }
.cat-process { background: #5aa7f0; }
.tl-children { padding: 10px 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.tl-loading { margin: 4px 8px; }
.tl-child { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.tl-child-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; list-style: none; flex-wrap: wrap; }
summary.tl-child-row { cursor: pointer; }
.tl-child-title { flex: 1; min-width: 180px; color: var(--text); font-size: 15px; overflow-wrap: anywhere; }
.tl-fact { color: var(--muted); font-size: 14px; white-space: nowrap; }
.tl-status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px; border: 1px solid var(--border); border-radius: 16px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.tl-status i { width: 9px; height: 9px; border-radius: 50%; background: #c9d1db; }
.tl-status.ok i { background: #3fbf94; }
.tl-status.warn i { background: #f0a020; }
.tl-pages { margin: 0; padding: 4px 16px 12px 94px; font-size: 14px; border-top: 1px solid var(--border); }
.tl-pages li { padding: 3px 0; }
@media (max-width: 860px) {
  .tl-head { grid-template-columns: 32px 32px minmax(0, 1fr); }
  .tl-header, .tl-items, .tl-type, .tl-cat { display: none; }
  .tl-head { padding: 12px; }
  .tl-pages { padding-left: 40px; }
  .lib-toolbar { flex-direction: column; align-items: stretch; }
}

/* ── Backup runs: Backup now + live progress ───────── */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.backup-now { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0; }
.backup-now select { height: 36px; border: 1px solid var(--border); border-radius: 6px; padding: 0 10px; font: inherit; background: var(--surface); max-width: 280px; }
.live { border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; margin: 12px 0; background: var(--surface); }
#run-live .live { border: 0; padding: 0; margin: 0 0 16px; }
.live-idle { margin: 4px 0; }
.live-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.live-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 16px; margin-bottom: 2px; }
.live-pulse { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 1px; animation: live-pulse 1.4s ease-in-out infinite; }
@keyframes live-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .live-pulse { animation: none; } }
.live-note { background: #e8f0fb; border-radius: 8px; padding: 10px 12px; font-size: 14px; margin: 8px 0 12px; }
.live-note.warn { background: var(--warn-bg); color: var(--warn-text); }
.live-steps { list-style: none; padding: 0; margin: 0 0 16px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.live-step { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: #f9fafb; min-width: 0; }
.live-step-mark { flex: none; width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; background: #e3e6ea; color: var(--muted); }
.live-step-text { display: flex; flex-direction: column; min-width: 0; font-size: 14px; font-weight: 600; line-height: 1.3; }
.live-step-text .small { font-weight: 400; }
.live-step.done .live-step-mark { background: var(--ok-bg); color: var(--ok-text); }
.live-step.active { border-color: var(--accent); background: #e8f0fb; }
.live-step.active .live-step-mark { background: var(--accent); color: #fff; }
.live-step.stopped .live-step-mark { background: var(--bad-bg); color: var(--bad-text); }
.live-step.pending { opacity: .7; }
.live-doing { margin: 4px 0 8px; }
.live-main { margin: 4px 0 12px; }
.live-main-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; font-size: 14px; }
.live-bar { height: 12px; border-radius: 6px; margin-top: 6px; }
.live-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 12px 0; }
.live-tiles > div { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px; color: var(--muted); line-height: 1.35; }
.live-tiles > div span { display: block; font-size: 20px; font-weight: 700; color: var(--text); }
.live-tiles > div.bad span { color: var(--bad-text); }
.live-types th, .live-types td { padding-top: 5px; padding-bottom: 5px; }
.live-types-bar { width: 22%; }
.live-types .progress { margin: 6px 0 0; height: 6px; }
.bad-text { color: var(--bad-text); font-weight: 600; }
.live-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 12px; }
.live-cols h3 { margin: 0 0 6px; font-size: 14px; }
.live-items { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.live-items li { display: flex; align-items: baseline; gap: 6px; padding: 4px 0; border-top: 1px solid var(--border); min-width: 0; }
.live-items li:first-child { border-top: 0; }
.live-item-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-items .pill { flex: none; }
.live-scope { margin: 12px 0 0; line-height: 1.6; }
@media (max-width: 860px) {
  .live-steps { grid-template-columns: 1fr 1fr; }
  .live-cols { grid-template-columns: 1fr; }
  .live-types-bar { display: none; }
}

/* Dashboard: backup-running banner */
.run-banner { position: relative; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; padding: 12px 16px 14px; margin: 12px 0; border-radius: 10px; background: #e8f0fb; border: 1px solid #c7d8ef; color: var(--text); overflow: hidden; }
.run-banner:hover { text-decoration: none; border-color: var(--accent); }
.run-banner.queued { background: var(--warn-bg); border-color: #f0dcb4; }
.run-banner strong { color: var(--accent); }
.run-banner.queued strong { color: var(--warn-text); }
.run-banner .live-pulse { color: inherit; }
.run-banner-link { font-weight: 600; color: var(--accent); white-space: nowrap; }
.run-banner-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(31, 78, 121, .12); }
.run-banner-bar span { display: block; height: 100%; background: var(--accent); transition: width .5s ease; }
