:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #dfe4ec;
  --line-strong: #c5ccd8;
  --ink: #17202e;
  --ink-2: #4a5568;
  --ink-3: #7a8598;
  --brand: #24386b;
  --brand-ink: #ffffff;
  --brand-soft: #e9edf6;
  --accent: #03999c;
  --accent-soft: #e2f4f4;
  --ok: #1a7f4b;
  --ok-soft: #e2f4ea;
  --warn: #a15c00;
  --warn-soft: #fdf0d9;
  --bad: #b3261e;
  --bad-soft: #fbe6e4;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(23, 32, 46, .06), 0 4px 16px rgba(23, 32, 46, .05);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: "Cascadia Mono", Consolas, ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); }
h1, h2, h3 { margin: 0; font-weight: 600; text-wrap: balance; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
.muted { color: var(--ink-3); }
.mono { font-family: var(--mono); font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

/* ── buttons & inputs ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--ink);
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .tab:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: #1b2b54; }
.btn.danger { color: var(--bad); border-color: #e3b5b1; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-weight: 600; margin-bottom: 5px; font-size: 13px; }
label.field small { display: block; color: var(--ink-3); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=file], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface);
}
input[readonly] { background: var(--surface-2); color: var(--ink-2); }
textarea { min-height: 110px; resize: vertical; }
.form-error { background: var(--bad-soft); color: var(--bad); border-radius: 8px; padding: 9px 12px; margin-bottom: 14px; }

/* ── login ── */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 30px; }
.login-card h1 { font-size: 20px; }
.login-card p { margin: 4px 0 22px; color: var(--ink-2); }
.brand-mark { width: 40px; height: 40px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; letter-spacing: .5px; margin-bottom: 16px; }

/* ── shell ── */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); border-top: 3px solid var(--accent); position: sticky; top: 0; z-index: 5; }
.topbar-inner { max-width: 1400px; margin: 0 auto; padding: 0 24px; display: flex; align-items: center; gap: 24px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; white-space: nowrap; cursor: pointer; }
.brand .brand-mark { width: 30px; height: 30px; border-radius: 8px; font-size: 12px; margin: 0; }
.tabs { display: flex; gap: 2px; height: 100%; flex: 1; overflow-x: auto; }
.tab { border: 0; background: none; padding: 0 14px; height: 100%; cursor: pointer; color: var(--ink-2); font-weight: 600; border-bottom: 2px solid transparent; display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand); border-bottom-color: var(--accent); }
.count { background: var(--brand); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.count.zero { background: var(--line); color: var(--ink-2); }
.who { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.who-name { text-align: right; line-height: 1.25; }
.who-name b { display: block; }
.who-name span { color: var(--ink-3); font-size: 12px; }
.page { max-width: 1400px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; }
.page-head p { margin: 2px 0 0; color: var(--ink-2); }

/* ── cards & tables ── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }
.doc-title { font-weight: 600; max-width: 420px; }
.doc-sub { color: var(--ink-3); font-size: 12px; }
.empty { padding: 44px 20px; text-align: center; color: var(--ink-2); }
.empty b { display: block; color: var(--ink); margin-bottom: 4px; font-size: 15px; }

.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--line); color: var(--ink-2); }
.badge.review { background: var(--brand-soft); color: var(--brand); }
.badge.returned { background: var(--bad-soft); color: var(--bad); }
.badge.effective { background: var(--ok-soft); color: var(--ok); }
.badge.due { background: var(--warn-soft); color: var(--warn); }
.tag { display: inline-block; border: 1px solid var(--line-strong); border-radius: 6px; padding: 1px 7px; font-size: 12px; font-weight: 600; color: var(--ink-2); background: var(--surface-2); }

/* ── stepper ── */
.stepper { display: flex; align-items: center; gap: 0; }
.stepper .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-strong); background: var(--surface); display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--ink-3); flex: none; }
.stepper .bar { width: 18px; height: 2px; background: var(--line-strong); flex: none; }
.stepper .dot.done { background: var(--ok); border-color: var(--ok); color: #fff; }
.stepper .bar.done { background: var(--ok); }
.stepper .dot.current { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.stepper .dot.returned { border-color: var(--bad); color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }

/* ── document page ── */
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 20px; align-items: start; }
.viewer { position: sticky; top: 76px; height: calc(100vh - 100px); overflow: hidden; display: flex; flex-direction: column; }
.viewer-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.viewer-bar .left { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.viewer-bar .right { display: flex; gap: 8px; align-items: center; }
.viewer-bar select { width: auto; padding: 5px 8px; }
.viewer iframe { flex: 1; width: 100%; border: 0; background: #525659; }
.side { display: flex; flex-direction: column; gap: 16px; }
.panel { padding: 16px 18px; }
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); margin-bottom: 12px; }
.meta { display: grid; grid-template-columns: 130px 1fr; gap: 7px 12px; margin: 0; }
.meta dt { color: var(--ink-3); }
.meta dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.doc-head h1 { font-size: 17px; line-height: 1.35; overflow-wrap: anywhere; }
.doc-head .stp { font-family: var(--mono); color: var(--brand); font-weight: 700; margin-bottom: 4px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: grid; grid-template-columns: 28px 1fr; gap: 12px; position: relative; padding-bottom: 14px; }
.steps li:last-child { padding-bottom: 0; }
.steps li:not(:last-child)::before { content: ""; position: absolute; left: 13px; top: 28px; bottom: 0; width: 2px; background: var(--line-strong); }
.steps li.done:not(:last-child)::before { background: var(--ok); }
.steps .dot { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line-strong); display: grid; place-items: center; font-weight: 700; font-size: 12px; color: var(--ink-3); background: var(--surface); position: relative; }
.steps li.done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.steps li.current .dot { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.steps li.returned .dot { border-color: var(--bad); color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.steps .s-label { font-weight: 600; }
.steps .s-sub { color: var(--ink-3); font-size: 13px; }

.action-panel { border-color: var(--brand); }
.action-panel.returned { border-color: var(--bad); }
.action-panel p { margin: 0 0 12px; color: var(--ink-2); }
.action-row { display: flex; gap: 8px; flex-wrap: wrap; }
.action-row .btn { flex: 1; }

.comment { border: 1px solid var(--line); border-left: 3px solid var(--bad); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; background: var(--surface-2); }
.comment:last-child { margin-bottom: 0; }
.comment.old { border-left-color: var(--line-strong); }
.comment-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--ink-3); margin-bottom: 4px; flex-wrap: wrap; }
.comment-head b { color: var(--ink); font-size: 13px; }
.comment-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.note { font-size: 12px; color: var(--ink-3); margin-top: 10px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.timeline li:last-child { border-bottom: 0; }
.timeline time { color: var(--ink-3); font-size: 12px; display: block; }

/* ── library ── */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters select, .filters input[type=text] { width: auto; min-width: 170px; }
.filters label.check { display: flex; align-items: center; gap: 6px; color: var(--ink-2); }
.group-title { display: flex; align-items: baseline; gap: 10px; margin: 22px 0 10px; }
.group-title:first-of-type { margin-top: 0; }
.group-title h2 { font-size: 16px; }

/* ── modal & toast ── */
.overlay { position: fixed; inset: 0; background: rgba(23, 32, 46, .45); display: grid; place-items: center; padding: 20px; z-index: 20; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 480px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); max-height: calc(100vh - 40px); overflow: auto; }
.modal-head { padding: 18px 22px 0; }
.modal-head h2 { font-size: 17px; }
.modal-head p { margin: 4px 0 0; color: var(--ink-2); }
.modal-body { padding: 18px 22px; }
.modal-foot { padding: 0 22px 20px; display: flex; justify-content: flex-end; gap: 8px; }
.busy { display: flex; align-items: center; gap: 10px; color: var(--ink-2); padding: 4px 0 14px; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--brand); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; max-width: 90vw; }
#toast.show { opacity: 1; }

@media (max-width: 1000px) {
  .doc-layout { grid-template-columns: 1fr; }
  .viewer { position: static; height: 70vh; }
  .topbar-inner { padding: 0 16px; gap: 12px; }
  .page { padding: 16px; }
  .who-name { display: none; }
}

/* ── added: drafts, tracking, folders, editor ── */
.badge.draft { background: #ece9f6; color: #4b3f8f; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
textarea.short { min-height: 64px; }
.modal.wide { max-width: 680px; }
.modal.xl { max-width: 1100px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-section { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 600; margin: 4px 0 10px; }
.choices { display: grid; gap: 10px; }
.choice { text-align: left; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; padding: 14px 16px; cursor: pointer; display: grid; gap: 3px; }
.choice:hover, .choice:focus-visible { border-color: var(--brand); background: var(--brand-soft); outline: none; }
.choice b { font-size: 15px; }
.choice span { color: var(--ink-2); }
.preview-frame { width: 100%; height: 72vh; border: 1px solid var(--line); border-radius: 8px; background: #525659; }

/* tracking */
.stage-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.stage-card { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; cursor: pointer; display: block; }
.stage-card:hover { border-color: var(--line-strong); }
.stage-card.selected { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft), var(--shadow); }
.stage-card:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.stage-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 22px; }
.stage-label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 600; }
.stage-role { font-weight: 700; font-size: 16px; margin-top: 2px; }
.stage-count { font-size: 40px; font-weight: 700; line-height: 1.15; margin-top: 8px; color: var(--brand); }
.stage-detail { color: var(--ink-2); font-size: 13px; }
.stage-people { list-style: none; margin: 12px 0 0; padding: 10px 0 0; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
.stage-people li { display: flex; justify-content: space-between; gap: 8px; padding: 1px 0; }
.stage-people b { color: var(--ink); }

/* library folders */
.lib-layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 20px; align-items: start; }
.folders { padding: 8px; display: grid; gap: 1px; position: sticky; top: 76px; max-height: calc(100vh - 100px); overflow: auto; }
.folder { display: flex; justify-content: space-between; align-items: center; gap: 8px; border: 0; background: none; text-align: left; padding: 7px 10px; border-radius: 7px; cursor: pointer; font-weight: 600; width: 100%; }
.folder.sub { padding-left: 26px; font-weight: 400; color: var(--ink-2); font-size: 13px; }
.folder:hover { background: var(--surface-2); }
.folder.selected { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.folder:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.folder-count { font-size: 12px; background: var(--line); color: var(--ink-2); border-radius: 999px; padding: 0 7px; font-weight: 600; }
.folder-count.zero { background: none; color: var(--ink-3); }
.filters .crumb { font-size: 16px; }
.filters .spacer { flex: 1; }

/* editor */
.editor { min-width: 0; }
.editor-bar { border-radius: var(--radius) var(--radius) 0 0; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; position: sticky; top: 56px; background: var(--surface); z-index: 3; }
.editor-bar .left, .editor-bar .right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.save-status { color: var(--ink-3); font-size: 13px; }
.paper { padding: 22px 26px 28px; }
.paper .sec { font-size: 14px; margin: 24px 0 10px; letter-spacing: .02em; }
.paper table { border-collapse: collapse; width: 100%; }
.paper table th, .paper table td { border: 1px solid var(--ink-3); padding: 5px 8px; vertical-align: middle; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--ink); white-space: normal; }
.sheet-head th { width: 210px; text-align: center; font-weight: 700; background: var(--surface-2); }
.sheet-head tr.labels th { width: 25%; }
.sheet-head tr.values td { text-align: center; font-weight: 600; }
.sheet-info th { width: 240px; text-align: left; font-weight: 700; background: var(--surface-2); }
.sheet-rev th { background: var(--surface-2); text-align: center; font-weight: 700; }
.sheet-rev td:nth-child(-n+3) { width: 120px; }
.sheet-rev td:last-child, .sheet-rev th:last-child { width: 40px; border: 0; background: none; }
.paper input[type=text], .paper input[type=date], .paper textarea { border-color: transparent; background: #fbfcfe; border-radius: 5px; padding: 5px 7px; }
.paper input:hover, .paper textarea:hover { border-color: var(--line-strong); }
.paper input:focus, .paper textarea:focus { border-color: var(--brand); background: var(--surface); }
.pair { display: grid; gap: 4px; }
.pair label { display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 6px; }
.toolbar-wrap { position: sticky; top: 112px; z-index: 2; margin-top: 22px; }
.toolbar { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 8px; padding: 5px; }
.tool { min-width: 32px; height: 30px; border: 1px solid transparent; background: none; border-radius: 6px; cursor: pointer; padding: 0 8px; font-size: 13px; }
.tool:hover { background: var(--surface); border-color: var(--line-strong); }
.tool.bold { font-weight: 700; } .tool.italic { font-style: italic; } .tool.underline { text-decoration: underline; }
.toolbar .sep { width: 1px; height: 20px; background: var(--line-strong); margin: 0 4px; }
.rte { min-height: 120px; border: 1px dashed var(--line-strong); border-radius: 8px; padding: 12px 14px; font-family: Arial, sans-serif; font-size: 14px; line-height: 1.45; }
.rte:focus { outline: none; border: 1px solid var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.rte p { margin: 0 0 8px; }
.rte table { margin: 6px 0 10px; }
.rte th { background: var(--surface-2); text-align: center; font-weight: 700; }
.rte td, .rte th { min-width: 40px; height: 28px; vertical-align: top; }
.rte ul, .rte ol { margin: 0 0 8px; padding-left: 26px; }

@media (max-width: 1000px) {
  .stage-grid { grid-template-columns: 1fr 1fr; }
  .lib-layout { grid-template-columns: 1fr; }
  .folders { position: static; max-height: none; }
  .form-grid { grid-template-columns: 1fr; }
  .editor-bar, .toolbar-wrap { position: static; }
  .paper { padding: 16px; }
  .sheet-head th, .sheet-info th { width: auto; }
}
@media (max-width: 560px) { .stage-grid { grid-template-columns: 1fr; } }
.doc-layout:has(.editor) { grid-template-columns: minmax(0, 1fr) 330px; }
.editor-bar .btn { padding: 6px 12px; font-size: 13px; }
@media (max-width: 1000px) { .doc-layout:has(.editor) { grid-template-columns: 1fr; } }
.paper input, .paper textarea { min-width: 0; }
@media (max-width: 1000px) { .paper { overflow-x: auto; } .pair label { grid-template-columns: 1fr; } }

/* ── editor laid out like the printed STP page ── */
.toolbar-wrap { position: sticky; top: 107px; z-index: 2; margin: 0; padding: 6px 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
.toolbar-wrap .toolbar { border: 0; padding: 0; background: none; }
.sheet-scroll { padding: 22px; background: #e6eaf0; overflow-x: auto; border-radius: 0 0 var(--radius) var(--radius); }
.sheet { background: #fff; max-width: 840px; min-width: 640px; margin: 0 auto; border: 4px double #111; padding: 24px 26px 20px; font-family: Arial, Helvetica, sans-serif; color: #000; font-size: 14px; box-shadow: 0 2px 12px rgba(0, 0, 0, .14); }
.sheet .restricted { text-align: center; font-weight: 700; font-size: 11px; line-height: 1.3; }
.sheet table { border-collapse: collapse; width: 100%; table-layout: fixed; }
.sheet th, .sheet td { border: 1px solid #000; padding: 3px 7px; font-size: 14px; color: #000; text-transform: none; letter-spacing: 0; white-space: normal; vertical-align: middle; font-family: inherit; overflow-wrap: anywhere; }
.sheet-head th { font-weight: 700; text-align: center; }
.sheet-head .left { text-align: left; }
.sheet-head td.logo { text-align: center; padding: 4px; }
.sheet-head td.logo img { height: 42px; max-width: 100%; display: block; margin: 0 auto; }
.sheet td.fill, .sheet-info td, .sheet-rev tbody td { background: #eef5ff; padding: 0; }
.sheet input[type=text], .sheet input[type=date], .sheet textarea { width: 100%; min-width: 0; border: 0; border-radius: 0; background: transparent; font: inherit; color: #000; padding: 6px 7px; display: block; }
.sheet td.fill input { font-weight: 700; text-align: center; }
.sheet td.fill.left input { text-align: left; }
.sheet input:focus, .sheet textarea:focus { outline: 2px solid var(--brand); outline-offset: -2px; background: #fff; }
.sheet-note { font-family: var(--font); font-size: 12px; color: var(--ink-3); margin: 6px 0 0; }
.sheet .sec { font-size: 14px; font-weight: 700; margin: 30px 0 10px; display: flex; gap: 36px; letter-spacing: 0; }
.sheet table.sheet-info { width: 88%; margin-left: 8%; }
.sheet-info th { width: 38%; text-align: left; font-weight: 700; }
.sheet-info textarea { resize: vertical; min-height: 52px; }
.sheet .pair { display: grid; gap: 0; }
.sheet .pair label { display: grid; grid-template-columns: auto 1fr; align-items: center; padding-left: 7px; }
.sheet .pair label span { white-space: nowrap; }
.sheet .rte { border: 1px dashed #8c9bb0; border-radius: 0; background: #f7faff; font-size: 14px; min-height: 130px; }
.sheet .rte:focus { border: 1px solid var(--brand); background: #fff; }
.sheet .rte th { background: none; }
.sheet .rte table { table-layout: auto; }
.sheet table.sheet-rev { width: 90%; margin-left: 5%; }
.sheet-rev th { font-weight: 700; text-align: center; }
.sheet-rev th:nth-child(1), .sheet-rev th:nth-child(2) { width: 13%; }
.sheet-rev th:nth-child(3) { width: 18%; }
.sheet-rev input { text-align: center; }
.sheet .sheet-rev th:last-child, .sheet .sheet-rev tbody td:last-child { border: 0; background: none; width: 36px; padding: 0 0 0 4px; }
.sheet .end-of-stp { text-align: center; font-weight: 700; margin: 22px 0 44px; }
.sheet-foot th { font-weight: 700; text-align: center; }
.sheet-foot th:first-child { text-align: left; width: 22%; }
.sheet-foot td { text-align: center; height: 30px; }
@media (max-width: 1000px) { .toolbar-wrap { position: static; } .sheet-scroll { padding: 12px; } }

/* ── pages in the editor ── */
.page-wrap { max-width: 840px; min-width: 640px; margin: 0 auto 22px; }
.page-tag { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; margin: 0 2px 6px; color: var(--ink-2); }
.page-tag b { color: var(--ink); }
.page-wrap .sheet { max-width: none; min-width: 0; }
.sheet .sec.first { margin-top: 26px; }
.sheet .sheet-gap { height: 150px; }
.sheet > .rte { margin: 16px 0 22px; min-height: 420px; }
.sheet .rte img { max-width: 100%; height: auto; }
.sheet .rte h3 { font-size: 14px; font-weight: 700; margin: 4px 0 10px; }
.sheet.tail { border-style: dashed; border-width: 1px; box-shadow: none; }
.sheet .sec input.sec-no { width: 54px; font-weight: 700; background: #eef5ff; padding: 3px 6px; text-align: center; }
.add-page { display: grid; justify-items: center; gap: 2px; width: 100%; max-width: 840px; min-width: 640px; margin: 0 auto 22px; padding: 18px; border: 2px dashed #8c9bb0; border-radius: 10px; background: rgba(255, 255, 255, .55); cursor: pointer; color: var(--ink-2); }
.add-page:hover, .add-page:focus-visible { border-color: var(--brand); background: #fff; color: var(--ink); outline: none; }
.add-page .plus { width: 38px; height: 38px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 26px; line-height: 36px; text-align: center; }
.add-page b { font-size: 15px; color: var(--ink); }
.sheet-note.center { text-align: center; max-width: 840px; margin: 0 auto; }
.tool.wide.bold { font-weight: 700; }

/* ── signature pictures ── */
.sign-box { display: inline-flex; align-items: center; justify-content: center; width: 150px; height: 34px; background: #fff; border: 1px solid var(--line-strong); border-radius: 4px; padding: 3px 6px; vertical-align: middle; }
.sign-box img { max-width: 100%; max-height: 100%; display: block; }
.sign-box.large { width: 100%; max-width: 330px; height: 64px; display: flex; }
.sign-box.empty { border-style: dashed; color: var(--brand); font-weight: 600; font-size: 13px; }
.sign-cell { border: 0; background: none; padding: 0; cursor: pointer; border-radius: 4px; }
.sign-cell:hover .sign-box { border-color: var(--brand); }
.sign-cell:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.sign-note { display: grid; gap: 6px; margin-bottom: 14px; color: var(--ink-2); font-size: 13px; }
div.field > span { display: block; font-weight: 600; margin-bottom: 5px; font-size: 13px; }
div.field small { display: block; color: var(--ink-3); margin-top: 4px; }
div.field { margin-bottom: 14px; }

/* superseded revisions: kept, but visibly secondary to the revision above them */
tr.superseded td { color: var(--ink-3); background: var(--surface-2); }
tr.superseded .doc-title { font-weight: 400; }
tr.superseded td:first-child { padding-left: 30px; }

/* ── master library ── */
.lib-controls { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 18px; }
.lib-controls .field { margin-bottom: 0; }
.lib-controls .grow { flex: 1 1 220px; max-width: 320px; }
.lib-controls .grow2 { flex: 2 1 320px; }
.search-row { display: flex; gap: 8px; }
.search-row input { flex: 1; }
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.folder-card { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; cursor: pointer; display: grid; gap: 10px; align-content: start; }
.folder-card:hover { border-color: var(--brand); }
.folder-card:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.folder-card[hidden] { display: none; }
.folder-card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.folder-card-top b { font-size: 16px; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font-size: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; color: var(--ink-2); }
.badges { display: inline-flex; gap: 5px; flex-wrap: wrap; vertical-align: middle; }
.doc-sub { overflow-wrap: anywhere; }

/* where the searched words were found inside a document */
.hit { margin-top: 5px; font-size: 13px; color: var(--ink-2); max-width: 560px; overflow-wrap: anywhere; }
.hit-page { display: inline-block; font-size: 11px; font-weight: 700; color: var(--brand); background: var(--brand-soft); border-radius: 4px; padding: 0 6px; margin-right: 6px; }
.hit mark { background: #ffe58a; color: inherit; padding: 0 1px; border-radius: 2px; }
.result-group { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 18px 0 8px; }
.result-group:first-of-type { margin-top: 4px; }
.result-group b { font-size: 15px; }
.lib-controls { align-items: flex-start; }
.lib-controls > .btn { margin-top: 23px; }

/* printing */
.print-frame { position: fixed; right: 0; bottom: 0; width: 2px; height: 2px; border: 0; opacity: 0; pointer-events: none; }
.viewer-note { padding: 7px 14px; font-size: 12px; color: var(--ink-3); border-top: 1px solid var(--line); background: var(--surface); }
.lib-controls input[type=search] { width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); }

/* viewer accounts: folder tick-boxes */
.folder-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 14px; border: 1px solid var(--line); border-radius: 8px; padding: 12px; max-height: 240px; overflow: auto; }
.folder-picks .check { display: flex; align-items: center; gap: 7px; font-weight: 400; }
[hidden] { display: none !important; }

/* ── Valence branding ── */
.brand-logo { height: 38px; width: auto; display: block; }
.brand-name { padding-left: 14px; border-left: 1px solid var(--line-strong); color: var(--brand); font-size: 15px; line-height: 1.2; }
.brand-name small { display: block; font-weight: 400; color: var(--ink-3); font-size: 11.5px; letter-spacing: .02em; }
.login-card { text-align: left; border-top: 4px solid var(--accent); }
.login-logo { height: 56px; width: auto; display: block; margin-bottom: 18px; }
.login-card h1 { color: var(--brand); }
@media (max-width: 820px) { .brand-name { display: none; } .brand-logo { height: 32px; } }

/* ── add a document ── */
.add-step { margin-bottom: 20px; }
.add-step > .step-title { display: flex; align-items: center; gap: 9px; font-weight: 600; margin-bottom: 9px; }
.step-no { width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice { position: relative; display: block; border: 1.5px solid var(--line-strong); border-radius: 10px; padding: 12px 14px 12px 40px; cursor: pointer; background: var(--surface); }
.choice:hover { background: var(--surface-2); }
.choice input { position: absolute; left: 14px; top: 15px; margin: 0; accent-color: var(--brand); }
.choice b { display: block; }
.choice span { display: block; color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.choice:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.dropzone { display: flex; align-items: center; gap: 14px; border: 1.5px dashed var(--line-strong); border-radius: 10px; padding: 16px; cursor: pointer; background: var(--surface-2); }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone:focus-within { outline: 2px solid var(--brand); outline-offset: 2px; }
.dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; padding: 0; border: 0; }
.dropzone .dz-text { flex: 1; min-width: 0; }
.dropzone .dz-text b { display: block; overflow-wrap: anywhere; }
.dropzone .dz-text span { color: var(--ink-3); font-size: 13px; }
.dropzone.has-file { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }
.add-step label.field:last-child, .add-step .field:last-child { margin-bottom: 0; }
.add-summary { border-radius: 10px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); margin-bottom: 14px; }
.add-summary.ready { background: var(--ok-soft); border-color: #bfe3cd; color: var(--ink); }
.add-summary b { font-weight: 600; }
@media (max-width: 560px) { .choices { grid-template-columns: 1fr; } }

/* ── access requests ── */
.login-alt { margin: 16px 0 0; text-align: center; color: var(--ink-2); }
.link-btn { border: 0; background: none; padding: 0; color: var(--brand); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.requests-card { margin-bottom: 8px; border-left: 4px solid var(--accent); }
.requests-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 4px; }
.note-cell { max-width: 320px; color: var(--ink-2); }
@media (max-width: 760px) { .choices[style] { grid-template-columns: 1fr !important; } }
