/* 2A Laboratory · Module 2 document control preview.
   Brand colours sampled from the supplied logo: cyan rings #22a3de, deep-blue drop #2154a3.
   The controlled page uses the document format from Module 2 (Arial 11, line 1.15, 6 pt spacing). */
:root {
  --ink: #142132;
  --ink-2: #3c4b5e;
  --muted: #5b6b7e;
  --line: #d3dce6;
  --line-2: #e6ecf2;
  --canvas: #eef2f6;
  --surface: #ffffff;
  --brand: #1f56a3;
  --brand-ink: #173f78;
  --brand-tint: #e7effa;
  --cyan: #1d9bd6;
  --cyan-tint: #e3f4fb;
  --en: #193b85;
  --focus: #1d9bd6;
  --ok: #17703f; --ok-bg: #e2f3e9;
  --review: #8a5300; --review-bg: #fff0d4;
  --approved: #0b6873; --approved-bg: #dcf2f4;
  --draft: #46536a; --draft-bg: #eceff4;
  --bad: #9b2c3a; --bad-bg: #fbe5e8;
  --demo: #5a3d9e; --demo-bg: #eee8fa;
  --radius: 6px;
  --rail: 240px;
  --font: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --doc: Arial, 'Liberation Sans', Helvetica, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--ink); background: var(--canvas); }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; font-weight: 600; }
a { color: var(--brand); }
a:hover { color: var(--brand-ink); }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.hint { display: block; color: var(--muted); font-size: 0.85rem; margin-top: 4px; }
.code { font-variant-numeric: tabular-nums; font-weight: 600; letter-spacing: 0.01em; color: var(--ink); white-space: nowrap; }
.code.small { font-size: 0.8rem; font-weight: 500; }
.noscript { padding: 24px; }

/* Buttons */
button, .button { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; font-weight: 500; font-size: 0.92rem; line-height: 1.2; }
button:hover:not(:disabled), .button:hover { border-color: #aebccc; background: #f7f9fb; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary, .button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover:not(:disabled), .button.primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); color: #fff; }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
button.danger:hover:not(:disabled) { background: #7e2230; color: #fff; }
button.danger-outline { color: var(--bad); border-color: #e3b2b9; }
button.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
button.ghost:hover:not(:disabled) { background: rgba(20, 33, 50, 0.06); }
button.ghost.danger { color: var(--bad); }
button.link { border: 0; background: none; padding: 0; min-height: 0; color: var(--brand); text-decoration: underline; font-weight: 500; }
.icon-btn { min-height: 30px; min-width: 30px; padding: 2px 6px; justify-content: center; }
button.icon-btn.danger { color: var(--bad); background: var(--surface); border-color: var(--line); font-weight: 600; }
button.icon-btn.danger:hover:not(:disabled) { background: var(--bad-bg); color: var(--bad); border-color: #e3b2b9; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Shell */
.topbar { display: none; }
.rail { position: fixed; inset: 0 auto 0 0; width: var(--rail); background: var(--surface); border-right: 1px solid var(--line); padding: 20px 16px; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; z-index: 30; }
.brand img { display: block; width: 168px; height: auto; }
.rail-module { margin: -6px 0 0; color: var(--muted); font-size: 0.85rem; }
#nav { display: flex; flex-direction: column; gap: 2px; }
#nav a { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; border-radius: var(--radius); color: var(--ink-2); text-decoration: none; font-weight: 500; border-left: 3px solid transparent; }
#nav a:hover { background: var(--canvas); color: var(--ink); }
#nav a.on { background: var(--brand-tint); color: var(--brand-ink); border-left-color: var(--cyan); }
.badge { background: var(--review); color: #fff; border-radius: 999px; font-size: 0.75rem; min-width: 22px; padding: 1px 7px; text-align: center; }
.rail-role { margin-top: auto; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: #f8fafc; }
.rail-role label { font-weight: 600; font-size: 0.85rem; display: block; margin-bottom: 6px; }
.rail-role select { width: 100%; min-height: 38px; border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 8px; background: var(--surface); }
.rail-role p, .rail-note { margin: 8px 0 0; font-size: 0.8rem; color: var(--muted); }
.rail-note { margin: 0; }
main { margin-left: var(--rail); min-height: 100vh; outline: none; }
.view { padding: 28px 32px 96px; max-width: 1520px; }
.view-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; }
.lede { margin: 6px 0 0; color: var(--ink-2); max-width: 70ch; }
.scrim { display: none; }

/* Forms */
.f-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.f-row > label, .f-label { font-weight: 500; font-size: 0.88rem; color: var(--ink-2); }
input[type=text], input[type=search], input[type=date], input:not([type]), select, textarea { width: 100%; min-height: 38px; border: 1px solid #b9c6d4; border-radius: var(--radius); padding: 7px 10px; background: var(--surface); }
textarea { resize: vertical; line-height: 1.45; }
input:hover, select:hover, textarea:hover { border-color: #8fa1b5; }
[aria-invalid=true] { border-color: var(--bad) !important; box-shadow: 0 0 0 1px var(--bad); }
.f-error { color: var(--bad); font-size: 0.85rem; font-weight: 500; }
.req { color: var(--bad); }
.radios { display: flex; flex-direction: column; gap: 6px; }
.radios label { display: flex; gap: 8px; align-items: center; font-size: 0.92rem; }
.radios.stack { margin: 12px 0; }
.f-inline { display: flex; gap: 8px; }
.f-inline select { flex: 1; min-width: 0; }

/* Chips and status */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.s-effective { background: var(--ok-bg); color: var(--ok); }
.s-review { background: var(--review-bg); color: var(--review); }
.s-approved { background: var(--approved-bg); color: var(--approved); }
.s-draft { background: var(--draft-bg); color: var(--draft); }
.s-obsolete { background: var(--bad-bg); color: var(--bad); }
.level { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 0.78rem; font-weight: 600; background: var(--cyan-tint); color: #0c5d84; white-space: nowrap; }
.demo-badge { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 0.75rem; font-weight: 600; background: var(--demo-bg); color: var(--demo); }
.assume { display: inline-block; padding: 0 6px; border-radius: 4px; font-size: 0.72rem; font-weight: 600; background: var(--review-bg); color: var(--review); vertical-align: 1px; }
.type-code { font-weight: 600; }

/* Banners */
.banner { border: 1px solid var(--line); border-left-width: 4px; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 10px; background: var(--surface); }
.banner ul { margin: 6px 0 0; padding-left: 20px; }
.banner.info { border-left-color: var(--cyan); }
.banner.warn { border-left-color: var(--review); background: #fffaf0; }
.banner.error { border-left-color: var(--bad); background: #fff6f7; }
.banner.review { border-left-color: var(--review); }
.banner.approved { border-left-color: var(--approved); }
.banner.obsolete { border-left-color: var(--bad); background: #fff6f7; }
.banner.demo { border-left-color: var(--demo); background: #faf8ff; font-size: 0.9rem; }
.banner li.w { color: var(--review); }
details.banner summary { cursor: pointer; }
.note { font-size: 0.88rem; padding: 6px 10px; border-radius: var(--radius); background: var(--canvas); margin: 8px 0; }
.note.warn { background: var(--review-bg); color: #5f3a00; }
.note.sim { background: var(--demo-bg); color: #40287a; }

/* Register */
.register-layout { display: grid; grid-template-columns: 228px minmax(0, 1fr); gap: 20px; align-items: start; }
.tree { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 10px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
.panel-title { font-size: 0.95rem; padding: 0 6px 8px; }
.tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul ul { margin-left: 12px; }
.tree-item { width: 100%; justify-content: flex-start; border: 0; background: none; min-height: 32px; padding: 5px 8px; font-weight: 400; text-align: left; gap: 8px; }
.tree-item:hover:not(:disabled) { background: var(--canvas); }
.tree-item.on { background: var(--brand-tint); color: var(--brand-ink); font-weight: 600; }
.t-code { font-weight: 600; font-size: 0.82rem; min-width: 48px; }
.tree-item.child .t-code { min-width: 54px; }
.t-name { flex: 1; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-count { font-size: 0.78rem; color: var(--muted); }
.register-main { min-width: 0; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: none; min-height: 40px; padding: 8px 12px; color: var(--ink-2); white-space: nowrap; }
.tabs button[aria-selected=true] { border-bottom-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.tabs .n { font-size: 0.75rem; background: var(--canvas); color: var(--muted); border-radius: 999px; padding: 0 7px; margin-left: 2px; }
.tabs button[aria-selected=true] .n { background: var(--brand-tint); color: var(--brand-ink); }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; align-items: end; margin-bottom: 10px; }
.f-search { grid-column: span 2; }
.filters > button { align-self: end; }
.f-field { display: flex; flex-direction: column; gap: 3px; font-size: 0.8rem; color: var(--muted); font-weight: 500; min-width: 0; }
.result-line { color: var(--muted); font-size: 0.88rem; margin: 6px 0 10px; }
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table.register { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.register th { text-align: left; font-weight: 600; font-size: 0.8rem; color: var(--ink-2); padding: 10px; border-bottom: 1px solid var(--line); background: #f8fafc; white-space: nowrap; }
.register td { padding: 10px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.register tr:last-child td { border-bottom: 0; }
.register tr:hover td { background: #fafcfe; }
.register tr.is-selected td { background: var(--brand-tint); }
.c-check { width: 36px; }
.c-check input, .doc-card input { width: 18px; height: 18px; accent-color: var(--brand); }
.c-code a { text-decoration: none; }
.c-code .legacy { display: block; color: var(--muted); font-size: 0.8rem; }
.c-code .sub-line { display: flex; gap: 6px; align-items: center; margin-top: 3px; font-size: 0.82rem; }
.c-code .code { font-size: 0.86rem; }
.c-title { min-width: 220px; }
.title-link { font-weight: 600; color: var(--ink); text-decoration: none; }
.title-link:hover { text-decoration: underline; color: var(--brand); }
.c-title .en, .doc-card .en { display: block; color: var(--muted); font-size: 0.85rem; }
.c-title .demo-badge { margin-top: 4px; }
.c-status { display: flex; flex-wrap: wrap; gap: 4px; min-width: 150px; }
td.c-status { display: table-cell; }
td.c-status .chip { margin: 0 4px 4px 0; }
.c-route { font-size: 0.85rem; min-width: 130px; }
.c-date, .c-type { white-space: nowrap; }
.cards { display: none; list-style: none; margin: 0; padding: 0; }
.empty { background: var(--surface); border: 1px dashed #b9c6d4; border-radius: var(--radius); padding: 40px 24px; text-align: center; }
.empty h2 { margin-bottom: 8px; }
.empty p { color: var(--ink-2); max-width: 60ch; margin: 0 auto 16px; }
.empty .row-actions { justify-content: center; }
.empty.error { border-color: var(--bad); }
.skeleton { display: grid; gap: 8px; }
.sk-row { height: 48px; border-radius: var(--radius); background: linear-gradient(90deg, #e3e9ef, #f2f5f8, #e3e9ef); background-size: 200% 100%; animation: sk 1.4s infinite; }
@keyframes sk { to { background-position: -200% 0; } }
.bulk-bar { position: fixed; left: calc(var(--rail) + 24px); right: 24px; bottom: 18px; z-index: 20; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 14px; background: var(--ink); color: #fff; border-radius: 10px; box-shadow: 0 10px 30px rgba(20, 33, 50, 0.25); }
.bulk-bar strong { margin-right: 6px; }
.bulk-bar button { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.25); color: #fff; }
.bulk-bar button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.2); }
.bulk-bar button.danger { background: #c2414f; border-color: #c2414f; }
.bulk-bar button.ghost { border-color: transparent; }

/* Detail and editor */
.crumbs { display: flex; gap: 8px; font-size: 0.88rem; color: var(--muted); margin-bottom: 10px; flex-wrap: wrap; }
.doc-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 24px; align-items: flex-end; margin-bottom: 14px; }
.doc-title .en { color: var(--muted); margin: 2px 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 0.9rem; }
.version-switch { display: flex; gap: 4px; flex-wrap: wrap; }
.version-switch a { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-decoration: none; color: var(--ink-2); font-weight: 500; font-size: 0.88rem; }
.version-switch a.on { border-color: var(--brand); color: var(--brand-ink); box-shadow: inset 0 0 0 1px var(--brand); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: currentColor; }
.dot.s-effective { background: var(--ok); } .dot.s-review { background: var(--review); } .dot.s-approved { background: var(--approved); } .dot.s-draft { background: #8794a8; } .dot.s-obsolete { background: var(--bad); }
.action-bar { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 0 16px; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start; }
.side-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 14px 16px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
.tabs.small { flex-wrap: wrap; }
.tabs.small button { padding: 8px 7px; font-size: 0.84rem; min-height: 36px; }
.tab-panel { font-size: 0.9rem; }
.kv-list { margin: 0; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line-2); }
.kv dt { color: var(--muted); font-size: 0.83rem; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.runs, .versions, .log, .refs, .decisions, .inbox, .snapshots { list-style: none; margin: 0; padding: 0; }
.run { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin: 10px 0; }
.run-head { display: flex; justify-content: space-between; gap: 8px; }
.run-approved { border-left: 4px solid var(--ok); } .run-returned { border-left: 4px solid var(--bad); } .run-open { border-left: 4px solid var(--review); } .run-cancelled { opacity: 0.7; }
.decisions li { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; padding: 4px 0; }
.decisions li > span:last-of-type { color: var(--muted); font-size: 0.85rem; }
.decisions .dot { background: #b4bfcc; } .decisions .approve .dot { background: var(--ok); } .decisions .return .dot { background: var(--bad); }
.decisions q { display: block; width: 100%; color: var(--ink-2); font-style: italic; padding-left: 16px; }
.versions li { padding: 10px 0; border-bottom: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 3px; }
.versions li.current { background: var(--brand-tint); margin: 0 -14px; padding: 10px 14px; }
.versions a { text-decoration: none; display: flex; gap: 8px; align-items: center; }
.versions .reason { font-size: 0.85rem; color: var(--ink-2); }
.versions button.link { align-self: flex-start; }
.sub { font-size: 0.92rem; margin: 14px 0 6px; }
.refs li { padding: 6px 0; border-bottom: 1px solid var(--line-2); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.refs .note { width: 100%; margin: 4px 0 0; }
.log li { padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.log .when { display: block; color: var(--muted); font-size: 0.8rem; }
.log p { margin: 2px 0 0; color: var(--ink-2); }

.editor-toolbar { position: sticky; top: 0; z-index: 15; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; padding: 10px 0; background: var(--canvas); border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.segmented button { border: 0; border-radius: 0; min-height: 36px; }
.segmented button[aria-pressed=true] { background: var(--ink); color: #fff; }
.save { font-size: 0.88rem; color: var(--muted); }
.save.s-saved { color: var(--ok); }
.save.s-saving { color: var(--review); }
.save.s-error { color: var(--bad); font-weight: 600; }
.editor-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 24px; align-items: start; }
.mode-preview .editor-layout { grid-template-columns: minmax(0, 1fr); }
.form-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 16px 10px; position: sticky; top: 70px; max-height: calc(100vh - 86px); overflow-y: auto; }
fieldset { border: 0; border-bottom: 1px solid var(--line-2); margin: 0; padding: 14px 0 6px; }
fieldset:last-child { border-bottom: 0; }
legend { font-weight: 600; padding: 0; margin-bottom: 10px; float: left; width: 100%; }
legend + * { clear: both; }
.code-preview { background: var(--canvas); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 2px; }
.code-preview .code { font-size: 1.02rem; white-space: normal; overflow-wrap: anywhere; }
.mode-note { font-size: 0.86rem; color: var(--muted); margin: 0 0 8px; }

/* The controlled document page */
.paper-wrap { min-width: 0; }
.paper { background: #fff; width: 100%; max-width: 860px; margin: 0 auto; padding: 36px 40px 28px; box-shadow: 0 1px 2px rgba(20, 33, 50, 0.08), 0 6px 22px rgba(20, 33, 50, 0.08); border: 1px solid #cfd8e2; font-family: var(--doc); font-size: 11pt; line-height: 1.15; color: #000; }
.paper.is-edit { outline: 2px dashed #9cc9e6; outline-offset: -8px; }
.c-header { display: grid; grid-template-columns: 1.15fr 1.05fr 1.5fr 1fr; grid-template-areas: "logo check check level" "logo num title resp" "logo old title appr" "logo ver users appr" "eff eff page page"; border: 1px solid #000; font-size: 7.5pt; line-height: 1.25; margin-bottom: 14pt; }
.h-cell { border: 0.5px solid #000; padding: 3px 5px; display: flex; flex-direction: column; justify-content: flex-start; min-width: 0; overflow-wrap: anywhere; }
.h-label { color: #333; }
.h-value { font-weight: 700; font-size: 8pt; }
.h-logo { grid-area: logo; align-items: center; justify-content: center; padding: 8px; }
.h-logo img { width: 100%; max-width: 150px; height: auto; display: block; }
.h-check { grid-area: check; font-size: 7.5pt; }
.h-level { grid-area: level; position: relative; padding-right: 34px; }
.h-num { grid-area: num; } .h-title { grid-area: title; align-items: center; justify-content: center; text-align: center; gap: 2px; }
.h-resp { grid-area: resp; } .h-old { grid-area: old; } .h-appr { grid-area: appr; } .h-ver { grid-area: ver; } .h-users { grid-area: users; } .h-eff { grid-area: eff; } .h-page { grid-area: page; }
.t-en, .t-vi { font-weight: 700; font-size: 9pt; }
.pyramid { position: absolute; right: 4px; top: 6px; width: 26px; height: 25px; }
.pyramid polygon { fill: #fff; stroke: #000; stroke-width: 0.8; }
.pyramid polygon.on { fill: #1f56a3; }
.d-section { margin: 0 0 4pt; }
.d-section h3 { font-size: 11pt; font-weight: 700; margin: 10pt 0 6pt; text-transform: uppercase; }
.d-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.d-pair p, .d-full { margin: 6pt 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.d-pair p[lang=en], .d-full span[lang=en], .paper textarea.en { color: var(--en); }
.d-table { width: 100%; border-collapse: collapse; margin: 6pt 0; font-size: 10pt; }
.d-table th, .d-table td { border: 0.5px solid #555; padding: 4px 6px; text-align: left; vertical-align: top; white-space: pre-wrap; }
.d-table th { font-weight: 700; background: #f3f5f7; }
.d-foot { margin-top: 28pt; border-top: 0.5px solid #000; padding-top: 4pt; font-size: 7pt; }
.d-foot p { margin: 1pt 0; }
.d-foot p:first-child { font-weight: 700; }
.paper.is-demo .d-foot p:last-child { color: var(--demo); font-weight: 700; }

/* Edit mode inside the page */
.paper textarea.ed { display: block; width: 100%; min-height: 0; border: 1px solid transparent; border-radius: 3px; background: #f5f9fd; padding: 3px 5px; resize: none; overflow: hidden; font: inherit; line-height: 1.15; color: inherit; }
.paper textarea.ed:hover { border-color: #b9d6ea; }
.paper textarea.ed:focus { background: #fff; border-color: var(--cyan); outline: 2px solid rgba(29, 155, 214, 0.35); outline-offset: 0; }
.paper textarea.ed::placeholder { color: #8a97a6; font-style: italic; }
.paper .h-title textarea.ed { text-align: center; font-weight: 700; font-size: 9pt; }
.s-head { display: flex; align-items: flex-start; gap: 6px; margin: 12pt 0 6pt; padding-top: 6px; border-top: 1px dashed #d6e2ec; }
.s-num { font-weight: 700; padding-top: 4px; }
.s-head textarea.ed-h { font-weight: 700; text-transform: uppercase; flex: 1; }
.slash { padding-top: 4px; color: #777; }
.s-tools { display: flex; gap: 2px; font-family: var(--font); }
.b-edit { position: relative; margin: 4px 0 8px; padding: 6px 0 0; }
.b-tools { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; justify-content: flex-end; font-family: var(--font); font-size: 0.78rem; margin-bottom: 4px; }
.b-tools button { min-height: 26px; padding: 2px 8px; font-size: 0.78rem; }
.b-kind { margin-right: auto; color: var(--muted); }
.d-full-edit { display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px; align-items: start; }
.table-scroll { overflow-x: auto; }
.d-table.editing td { padding: 2px; }
.d-table.editing textarea.ed { background: #fff; }
.d-table.editing textarea.ed-th { font-weight: 700; }
.s-add { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-family: var(--font); font-size: 0.8rem; color: var(--muted); padding: 4px 0 6px; }
.s-add button, .add-section button { min-height: 28px; padding: 2px 10px; font-size: 0.8rem; border-style: dashed; }
.add-section { margin: 14px 0; font-family: var(--font); }

/* Inbox, data, about */
.inbox-view section, .data-view section, .about-view section { margin-bottom: 28px; }
.inbox-view h2 { margin-bottom: 10px; }
.inbox-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; display: grid; gap: 6px; }
.inbox-item > a:first-child { text-decoration: none; color: var(--ink); }
.inbox-item .button { justify-self: start; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 0.85rem; }
.progress { display: flex; flex-wrap: wrap; gap: 6px; }
.step { font-size: 0.8rem; padding: 2px 8px; border-radius: 4px; background: var(--canvas); color: var(--muted); }
.step.done { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.empty-line { color: var(--muted); }
.prose { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px; max-width: 1100px; }
.prose p, .prose li { max-width: 78ch; }
.prose h2 { margin: 4px 0 8px; }
.prose ul { padding-left: 20px; }
.prose.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.stats { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0 0; }
.stats div { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 14px; min-width: 140px; }
.stats dt { color: var(--muted); font-size: 0.82rem; }
.stats dd { margin: 0; font-size: 1.3rem; font-weight: 600; }
table.plain { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.plain th, table.plain td { border-bottom: 1px solid var(--line-2); padding: 8px 10px; text-align: left; vertical-align: top; }
table.plain th { background: #f8fafc; font-weight: 600; }
table.questions td:first-child { width: 55%; }

/* Dialog and toast */
dialog { border: 0; border-radius: 10px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 20px 60px rgba(20, 33, 50, 0.35); color: var(--ink); }
dialog.wide { width: min(900px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(20, 33, 50, 0.45); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px 0; }
.dialog-body { padding: 10px 20px 20px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.issues { padding-left: 20px; }
.copy-box { width: 100%; font-family: var(--doc); font-size: 0.9rem; }
.diff { list-style: none; margin: 10px 0 0; padding: 0; font-family: var(--doc); font-size: 0.9rem; max-height: 60vh; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.diff li { padding: 3px 10px; white-space: pre-wrap; border-left: 4px solid transparent; }
.diff li.add, .legend .add { background: #e4f5ea; border-left-color: var(--ok); }
.diff li.del, .legend .del { background: #fbe9eb; border-left-color: var(--bad); text-decoration: line-through; }
.legend span { padding: 1px 6px; border-radius: 3px; font-size: 0.8rem; }
.snapshots li { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 1000; max-width: min(640px, calc(100vw - 32px)); padding: 11px 16px; border-radius: 8px; background: var(--ink); color: #fff; box-shadow: 0 10px 30px rgba(20, 33, 50, 0.3); font-size: 0.92rem; }
.toast[data-tone=success] { background: #12553a; }
.toast[data-tone=error] { background: #8a2331; }

/* Narrow screens */
@media (max-width: 1500px) { .c-owner { display: none; } }
@media (max-width: 1280px) {
  .detail-layout { grid-template-columns: minmax(0, 1fr) 330px; }
}
@media (max-width: 1100px) {
  .register-layout { grid-template-columns: 1fr; }
  .tree { position: static; max-height: 220px; }
  .detail-layout, .editor-layout { grid-template-columns: 1fr; }
  .side-panel, .form-panel { position: static; max-height: none; }
}
@media (max-width: 860px) {
  :root { --rail: 0px; }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 25; background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px 12px; }
  .topbar-logo img { width: 88px; height: auto; display: block; }
  .topbar-title { font-weight: 600; font-size: 0.95rem; }
  .rail { width: 280px; transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: none; }
  body.nav-open .rail { transform: none; box-shadow: 0 0 40px rgba(20, 33, 50, 0.3); }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(20, 33, 50, 0.4); z-index: 28; }
  main { margin-left: 0; }
  .view { padding: 16px 16px 110px; }
  .action-bar button { min-height: 34px; padding: 4px 10px; font-size: 0.88rem; }
  h1 { font-size: 1.35rem; }
  .table-wrap { display: none; }
  .cards { display: grid; gap: 8px; }
  .doc-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; grid-template-columns: 26px 1fr; gap: 4px 8px; }
  .doc-card.is-selected { border-color: var(--brand); background: var(--brand-tint); }
  .doc-card a { text-decoration: none; color: var(--ink); display: flex; flex-direction: column; }
  .doc-card .card-meta { grid-column: 2; }
  .filters { grid-template-columns: 1fr 1fr; }
  .f-search { grid-column: 1 / -1; }
  .bulk-bar { left: 12px; right: 12px; bottom: 12px; }
  .editor-toolbar { top: 53px; }
  .prose.two-col { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 110px 1fr; }
  .paper { padding: 16px 12px; font-size: 10.5pt; }
  .c-header { grid-template-columns: 1fr 1fr; grid-template-areas: "logo level" "check check" "title title" "num resp" "old appr" "ver users" "eff page"; }
  .h-logo img { max-width: 120px; }
  .d-pair, .d-full-edit { grid-template-columns: 1fr; }
  .d-full-edit .slash { display: none; }
  .s-head { flex-wrap: wrap; }
  .s-head textarea.ed-h { flex-basis: 70%; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Print: only the controlled page */
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  .rail, .topbar, .crumbs, .doc-head, .action-bar, .side-panel, .banner, .editor-toolbar, .form-panel, .mode-note, .toast, .bulk-bar, .skip, .scrim, .add-section, .s-add, .b-tools, .s-tools { display: none !important; }
  main { margin: 0; } .view { padding: 0; max-width: none; }
  .detail-layout, .editor-layout { display: block; }
  .paper { box-shadow: none; border: 0; padding: 0; max-width: none; outline: 0; }
  .d-pair { grid-template-columns: 1fr 1fr !important; }
  .c-header { grid-template-columns: 1.15fr 1.05fr 1.5fr 1fr !important; grid-template-areas: "logo check check level" "logo num title resp" "logo old title appr" "logo ver users appr" "eff eff page page" !important; }
}
