:root {
  --creme: #F6F5EE; --grafite: #1E1E1E; --amora: #5E3574; --uva: #46163B;
  --bg: var(--creme); --surface: #FFFFFF; --sunk: #ECEBE3; --ink: var(--grafite); --muted: #5E5C56; --line: #DDDBD1;
  --accent: var(--amora); --accent-text: var(--amora); --accent-strong: var(--uva); --accent-ink: var(--creme); --accent-soft: #ECE5EF;
  --bar: var(--grafite); --bar-ink: var(--creme); --bar-muted: #B9B7AE; --bar-line: #34332F;
  --ok: #1F6B45; --ok-soft: #E2F0E6; --warn: #8A5600; --warn-soft: #F8EDD7; --bad: #A8281E; --bad-soft: #F9E4E1;
  --f-body: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-display: var(--f-body);
  --f-code: ui-monospace, "SF Mono", Menlo, monospace;
  --r: 6px;
  color-scheme: light;
  accent-color: var(--accent);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #2B2B28; --surface: #33332F; --sunk: #3A3A36; --ink: var(--creme); --muted: #B0AEA5; --line: #474641;
    --accent: var(--amora); --accent-text: #C9B3D6; --accent-strong: #7A4A93; --accent-ink: var(--creme); --accent-soft: #3A2C42;
    --bar: var(--grafite); --bar-line: #3A3936;
    --ok: #7FC79B; --ok-soft: #22352A; --warn: #E8B45E; --warn-soft: #3B3020; --bad: #F08A7E; --bad-soft: #42241F;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 400 14px/1.5 var(--f-body); -webkit-font-smoothing: antialiased; font-optical-sizing: auto; }
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
a { color: var(--accent-text); }
.wrap { padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right)); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.block { display: block; }
.code { font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.tag { font-family: var(--f-code); font-size: 12px; }
.sep { margin-left: 10px; }
.bad-text { color: var(--bad); }
.warn-text { color: var(--warn); }

.bar { position: sticky; top: 0; z-index: 5; background: var(--bar); color: var(--bar-ink); border-bottom: 1px solid var(--bar-line); }
.bar-row { display: flex; align-items: center; gap: 4px 18px; flex-wrap: wrap; padding-block: 6px; }
.brand { display: inline-flex; align-items: center; gap: 14px; color: var(--bar-ink); text-decoration: none; }
/* 150 px is the brand manual's smallest digital size. */
.brand img { display: block; width: 150px; height: 50px; }
.brand span { font-weight: 500; font-size: 15px; padding-left: 14px; border-left: 1px solid var(--bar-line); line-height: 28px; white-space: nowrap; }
nav[aria-label="Seções"] { display: flex; gap: 2px; flex-wrap: wrap; align-self: stretch; }
nav[aria-label="Seções"] a { display: flex; align-items: center; padding: 0 12px; min-height: 44px; color: var(--bar-muted); text-decoration: none; font-weight: 500; box-shadow: inset 0 -3px 0 transparent; }
nav[aria-label="Seções"] a:hover { color: var(--bar-ink); }
nav[aria-label="Seções"] a[aria-current="page"] { color: var(--bar-ink); box-shadow: inset 0 -3px 0 var(--amora); }
.bar-end { display: flex; gap: 10px; margin-left: auto; align-items: center; flex-wrap: wrap; min-width: 0; }
.bar select { background: var(--grafite); color: var(--bar-ink); border-color: var(--bar-line); }
.who { font-size: 12.5px; color: var(--bar-muted); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-link { display: inline-flex; align-items: center; gap: 7px; color: var(--bar-ink); text-decoration: none; font-weight: 500; font-size: 13px; padding: 6px 11px; border: 1px solid var(--bar-line); border-radius: var(--r); }
.settings-link svg { width: 16px; height: 16px; fill: currentColor; }
.settings-link:hover { border-color: var(--bar-muted); }
.settings-link[aria-current="page"] { background: var(--amora); border-color: var(--amora); }
.bar .btn.ghost { color: var(--bar-muted); }
.bar .btn.ghost:hover { color: var(--bar-ink); background: transparent; }
select, input[type="text"], input[type="url"], input[type="password"], input[type="email"], input[type="date"], input[type="search"], input:not([type]), textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 7px 10px; min-width: 0;
}
textarea { width: 100%; resize: vertical; line-height: 1.45; }
input[type="file"] { max-width: 100%; color: var(--muted); font-size: 13px; }
input[type="file"]::file-selector-button { font: inherit; font-weight: 500; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 12px; margin-right: 10px; cursor: pointer; }
input[type="file"]::file-selector-button:hover { background: var(--sunk); }

main.wrap { padding-block: 28px 56px; }
.view-head { margin-bottom: 22px; }
.view-head h1::before { content: ""; display: block; width: 20px; height: 4px; background: currentColor; margin-bottom: 14px; }
h1 { font-weight: 700; font-size: 30px; line-height: 1.1; margin: 0 0 6px; letter-spacing: -.015em; }
h2 { font-weight: 600; font-size: 16px; line-height: 1.3; margin: 0; }
h3 { font-weight: 600; font-size: 14px; line-height: 1.3; margin: 0 0 10px; }
.lede { color: var(--muted); margin: 0; max-width: 72ch; }

.btn { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 7px 13px; font-weight: 500; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; color: var(--ink); }
.btn:hover:not(:disabled) { background: var(--sunk); }
.btn.pri { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.pri:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.sm { padding: 3px 9px; font-size: 12.5px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn:disabled { opacity: .55; cursor: default; }
.pill { display: inline-flex; align-items: center; font-size: 12px; font-weight: 500; padding: 1px 8px; border-radius: 99px; background: var(--sunk); color: var(--muted); white-space: nowrap; }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.alert { background: var(--bad-soft); color: var(--bad); border-radius: var(--r); padding: 9px 12px; margin: 0 0 14px; }
.notice { background: var(--ok-soft); color: var(--ok); border-radius: var(--r); padding: 9px 12px; margin: 0 0 14px; }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--grafite); color: var(--creme); padding: 9px 15px; border-radius: var(--r); z-index: 40; font-size: 13px; }
.empty { padding: 48px 0; }
.empty-box { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r); padding: 22px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.empty-box p { margin: 0; color: var(--muted); max-width: 60ch; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.login { min-height: 100vh; background: var(--grafite); color: var(--creme); display: flex; align-items: center; position: relative; overflow: hidden; padding: 48px max(16px, 8vw); }
.login-card { position: relative; z-index: 1; width: min(420px, 100%); }
.login-card .brand img { width: 210px; height: 70px; margin: 0 0 36px -12px; }
.login h1 { font-size: 40px; color: var(--creme); margin-bottom: 12px; }
.login h1::before { content: ""; display: block; width: 24px; height: 5px; background: var(--creme); margin-bottom: 16px; }
.login .lede { color: #C9C7BE; margin-bottom: 30px; font-size: 15px; }
.login .muted { color: #A9A79F; }
.login .alert { background: #42241F; color: #F7B4AA; }
.supergraphic { position: absolute; top: 50%; height: max(104vh, 560px); width: auto; right: calc(max(104vh, 560px) * -0.53); transform: translateY(-50%); fill: var(--amora); }
@media (max-width: 760px) { .supergraphic { height: 340px; right: -180px; top: auto; bottom: -60px; transform: none; } .login { align-items: flex-start; padding-top: 56px; } }
.gbtn { min-height: 44px; margin-bottom: 12px; }

.today { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
@media (max-width: 900px) { .today { grid-template-columns: minmax(0, 1fr); } }
.group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 16px; overflow: hidden; }
.group > header { display: flex; align-items: baseline; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.count { font-weight: 600; font-size: 13px; color: var(--accent-text); background: var(--accent-soft); border-radius: 99px; padding: 0 8px; }
.group ul, ul.plain { list-style: none; margin: 0; padding: 0; }
.task { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; border-left: 3px solid var(--warn); }
.group li:last-child .task { border-bottom: 0; }
.task.late { border-left-color: var(--bad); }
.task:hover { background: var(--bg); }
.task-meta { grid-column: 1; font-size: 12.5px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.task .pill { grid-column: 2; grid-row: 1 / span 2; }
.side .box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 16px; }
.side h2 { margin-bottom: 8px; }
.link-row { width: 100%; display: flex; justify-content: space-between; gap: 8px; padding: 7px 0; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; }
.side li:last-child .link-row { border-bottom: 0; }
.link-row:hover { color: var(--accent-text); }
.date { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--muted); white-space: nowrap; }

.agency-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 16px; padding: 10px 14px 10px 10px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--r); }
.agency-banner p { margin: 0; flex: 1 1 160px; font-size: 16px; line-height: 1.3; }
.agency-logo { position: relative; flex: none; width: 64px; height: 64px; border-radius: var(--r); border: 1px solid var(--line); background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; font-weight: 700; font-size: 18px; overflow: hidden; }
.agency-logo.sm { width: 40px; height: 40px; font-size: 14px; }
.agency-chip { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.agency-chip p { margin: 0; line-height: 1.3; }
.agency-logo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 2px; background: #FFFFFF; }
.board-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 14px; }
.board-tools p { margin: 0; }
.search { position: relative; flex: 0 1 380px; min-width: 0; }
.search svg { position: absolute; left: 10px; top: 50%; width: 16px; height: 16px; margin-top: -8px; fill: var(--muted); pointer-events: none; }
.search input { width: 100%; min-height: 40px; padding-left: 34px; }
.search-empty { margin-bottom: 14px; }
.ext { display: inline-flex; align-items: center; gap: 5px; }
.ext svg { width: 13px; height: 13px; fill: currentColor; flex: none; }
.dh .ext { margin-top: 10px; }
.board { overflow-x: auto; padding-bottom: 10px; margin-inline: -4px; }
.cols { display: grid; grid-auto-flow: column; grid-auto-columns: 252px; gap: 12px; min-width: min-content; padding-inline: 4px; }
.col { background: var(--sunk); border-radius: var(--r); padding: 8px; display: flex; flex-direction: column; gap: 8px; min-height: 220px; }
.col > header { padding: 4px 6px 6px; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; }
.col > header .count { align-self: start; }
.col > header p { grid-column: 1 / -1; margin: 0; font-size: 11.5px; color: var(--muted); line-height: 1.35; }
.col.lost { opacity: .85; }
.col-empty { margin: 4px 6px; font-size: 12px; color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 10px; text-align: left; width: 100%; display: flex; flex-direction: column; gap: 7px; }
.card:hover { border-color: var(--accent-text); }
.card { cursor: grab; }
.card:active { cursor: grabbing; }
.card.lifted { opacity: .4; border-style: dashed; }
.col { transition: background-color .12s, box-shadow .12s; }
.col.over { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent-text); }
.col.lost.over { background: var(--bad-soft); box-shadow: inset 0 0 0 1.5px var(--bad); }
.col[data-drop="ACTIVATED"].over { background: var(--ok-soft); box-shadow: inset 0 0 0 1.5px var(--ok); }
.card.landed { animation: landed 1.4s ease-out; }
@keyframes landed { from { background: var(--accent-soft); border-color: var(--accent-text); } }
@media (prefers-reduced-motion: reduce) { .col { transition: none; } .card.landed { animation: none; } }
.card-meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.card-foot { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: space-between; }
.card-foot .pill.sig, .card-foot .pill.bad { margin-right: auto; }
.money { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--muted); }
.mini { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.mini i { height: 4px; border-radius: 2px; background: var(--line); }
.mini i.done { background: var(--accent); opacity: .45; }
.mini i.here { background: var(--accent); }
.mini.lost i.here, .mini.lost i.done { background: var(--muted); }

.scrim { position: fixed; inset: 0; background: rgba(30, 30, 30, .45); z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(600px, 100%); background: var(--bg); z-index: 21; overflow-y: auto; border-left: 1px solid var(--line);
  padding: 18px max(18px, env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) 20px; display: flex; flex-direction: column; gap: 14px; }
@media (prefers-reduced-motion: no-preference) { .drawer { animation: slide .18s ease-out; } @keyframes slide { from { transform: translateX(24px); opacity: .6; } } }
.dh { display: flex; gap: 10px; align-items: flex-start; }
.dh h2 { font-weight: 700; font-size: 22px; line-height: 1.15; letter-spacing: -.01em; }
.dh p { margin: 4px 0 0; }
.dh .x { margin-left: auto; font-size: 16px; }
.track { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); counter-reset: s; }
.track li { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding-top: 2px; }
.track li::before { content: ""; position: absolute; top: 15px; left: -50%; right: 50%; height: 3px; background: var(--line); z-index: 0; }
.track li:first-child::before { display: none; }
.track li.done::before, .track li.here::before { background: var(--accent); }
.track .n { position: relative; z-index: 1; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 13px; background: var(--surface); border: 2px solid var(--line); color: var(--muted); font-variant-numeric: tabular-nums; }
.track li.done .n { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.track li.here .n { border-color: var(--uva); background: var(--uva); color: var(--creme); box-shadow: 0 0 0 4px var(--accent-soft); }
.track .t { font-size: 11px; line-height: 1.2; color: var(--muted); max-width: 11ch; }
.track li.here .t { color: var(--ink); font-weight: 600; }
.track.lost li.done .n { background: var(--muted); border-color: var(--muted); }
.track.lost li.here .n { border-color: var(--bad); color: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); }
.track.lost li.done::before, .track.lost li.here::before { background: var(--muted); }
.lost-note { margin: -4px 0 0; font-size: 12.5px; color: var(--bad); }
@media (max-width: 480px) { .track .t { display: none; } .track li.here .t { display: block; position: absolute; top: 34px; white-space: nowrap; } .track { padding-bottom: 18px; } }
.next { background: var(--uva); color: var(--creme); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.next.done-box { background: var(--sunk); color: var(--ink); }
.next .btn { border-color: transparent; }
.next .btn.pri { background: var(--creme); color: var(--uva); border-color: var(--creme); }
.next .btn.pri:hover:not(:disabled) { background: #FFFFFF; border-color: #FFFFFF; }
.next .muted { color: #D7C9D3; }
.next input, .next select { border-color: transparent; background: #FFFFFF; color: var(--grafite); color-scheme: light; }
.next .btn.ghost { color: #E6DCE3; }
.next .btn.ghost:hover:not(:disabled) { background: rgba(246, 245, 238, .12); color: var(--creme); }
.next .bad-text { color: #FFB8AE; font-weight: 600; }
.next .warn-text { color: #F5D08A; font-weight: 600; }
.next.done-box .btn.ghost { color: var(--muted); }
.next-label { margin: 0; font-size: 12.5px; color: #D7C9D3; font-weight: 500; }
.next.done-box .next-label { color: var(--muted); }
.next-title { margin: 0; font-weight: 700; font-size: 19px; line-height: 1.25; letter-spacing: -.01em; }
.sec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
dl { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 6px 12px; margin: 0; font-size: 13px; }
dt { color: var(--muted); }
dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
dl.person + dl.person { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
@media (max-width: 460px) { dl { grid-template-columns: minmax(0, 1fr); } dt { margin-top: 4px; } }
.note-form { display: grid; gap: 8px; margin-bottom: 14px; }
.note-form .btn { justify-self: start; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.timeline li { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 10px; font-size: 13px; }
.timeline .when { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); padding-top: 1px; }
.timeline .by { display: block; font-size: 11.5px; color: var(--muted); }
.timeline li.note .what { background: var(--warn-soft); border-radius: 4px; padding: 4px 8px; }

.settings { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; align-items: start; }
@media (max-width: 820px) { .settings { grid-template-columns: minmax(0, 1fr); gap: 16px; } }
.settings-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 84px; }
@media (max-width: 820px) { .settings-nav { position: static; flex-direction: row; flex-wrap: wrap; } }
.settings-nav a { padding: 8px 12px; border-radius: var(--r); color: var(--muted); text-decoration: none; font-weight: 500; box-shadow: inset 3px 0 0 transparent; }
.settings-nav a:hover { background: var(--sunk); color: var(--ink); }
.settings-nav a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: inset 3px 0 0 var(--accent-text); }
.picker { display: grid; gap: 4px; font-size: 13px; color: var(--muted); max-width: 420px; }
.picker select { color: var(--ink); }
.detail { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.detail-head h2 { font-weight: 700; font-size: 22px; line-height: 1.2; letter-spacing: -.01em; }
.detail-head p { margin: 2px 0 0; }
.form { display: grid; gap: 10px; }
.detail .form { max-width: 560px; }
.form.inline { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.form label.check { display: flex; gap: 8px; align-items: center; color: var(--ink); }
.form .btn { justify-self: start; }
.form-title { margin: 0; font-weight: 600; }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 6px; }
legend { font-size: 13px; color: var(--muted); padding: 0; margin-bottom: 6px; }
.choice label { display: flex; gap: 8px; align-items: center; color: var(--ink); }
.partners .row { align-items: end; gap: 12px; }
.partners .grow { flex: 1; max-width: 420px; display: grid; gap: 4px; }
.partners-list { max-height: 360px; overflow: auto; margin-top: 10px; border: 1px solid var(--line); border-radius: var(--r); }
.partners-list table { width: 100%; border-collapse: collapse; font-size: 13px; }
.partners-list th { position: sticky; top: 0; background: var(--surface); text-align: left; font-weight: 500; color: var(--muted); }
.partners-list th, .partners-list td { padding: 6px 10px; border-bottom: 1px solid var(--line); }
.partners-list td:first-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.result { margin-top: 14px; display: grid; gap: 10px; }
.result p { margin: 0; }
.bad-box { border-left: 3px solid var(--bad); padding-left: 12px; }
.quote { font-style: italic; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; }

table.addenda td { vertical-align: middle; }
.pill.draft { background: var(--accent-soft); color: var(--accent-text); }

main.wrap.wide { padding-bottom: 0; }
.ws-head { display: grid; gap: 12px; margin-bottom: 18px; }
.ws-head .view-head { margin-bottom: 0; }
.ws-head .back { justify-self: start; margin-left: -9px; }
.ws-controls { display: flex; gap: 12px 24px; flex-wrap: wrap; align-items: flex-end; }
.ws-controls > label, .erp-form { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.ws-controls select { min-width: 240px; }
.erp-form input { width: 180px; }
.erp-note { margin: 0; font-size: 13px; }
.erp-note.warn { color: var(--warn); }
.erp-note.ok { color: var(--ok); }
.ws-body { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); gap: 28px; align-items: start; }
.ws-form { display: grid; gap: 14px; }
.fgroup { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 6px 14px 4px; margin: 0; min-width: 0; }
.fgroup legend { font-weight: 600; padding: 0 4px; margin-left: -4px; }
.fld { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.fld:last-child { border-bottom: 0; }
.fld label { font-size: 12.5px; color: var(--muted); }
.fld .src { grid-row: 1; grid-column: 2; font-size: 11.5px; color: var(--muted); align-self: end; }
.fld input, .fld select { grid-column: 1 / -1; width: 100%; }
.fld.is-missing .src { color: var(--warn); font-weight: 600; }
.fld.is-missing input, .fld.is-missing select { border-color: var(--warn); }
.fld.is-bad .src, .fld-error { color: var(--bad); }
.fld.is-bad input { border-color: var(--bad); }
.fld-error { grid-column: 1 / -1; font-size: 12px; }
.fld-error:empty { display: none; }
.ws-doc { position: sticky; top: 72px; max-height: calc(100vh - 150px); overflow: auto; background: var(--sunk); border-radius: var(--r); padding: 28px 20px; }
.ws-foot { position: sticky; bottom: 0; z-index: 4; display: flex; justify-content: space-between; align-items: center; gap: 10px 16px; flex-wrap: wrap;
  margin: 20px calc(-1 * max(16px, env(safe-area-inset-left))) 0; padding: 12px max(16px, env(safe-area-inset-left)) calc(12px + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid var(--line); }
.progress { display: flex; gap: 6px 12px; align-items: center; flex-wrap: wrap; }
.progress .left { color: var(--warn); font-weight: 600; }
.progress .ready { color: var(--ok); font-weight: 600; }

.pdf-pages { display: grid; gap: 18px; justify-items: center; }
.pdf-pages.offscreen { position: fixed; left: -10000px; top: 0; visibility: hidden; }
.pdf-page { position: relative; background: #FFFFFF; box-shadow: 0 1px 2px rgba(30, 30, 30, .12), 0 18px 36px -26px rgba(30, 30, 30, .5); color-scheme: light; }
.pdf-page canvas { display: block; width: 100%; height: 100%; }
.pdf-layer { position: absolute; inset: 0; }
.bx { position: absolute; padding: 0; margin: 0; border: 0; background: transparent; border-radius: 2px; cursor: pointer; }
.bx.val:hover, .bx.hl { outline: 2px solid var(--amora); outline-offset: 1px; background: rgba(94, 53, 116, .08); }
.bx.gap { outline: 1px dashed #C99A45; }
.bx.gap:hover, .bx.gap.hl { outline: 2px solid #8A5600; }
.bx.fixed { pointer-events: none; }
.bx:focus-visible { outline: 2px solid var(--amora); outline-offset: 2px; }
@media (max-width: 960px) {
  .ws-body { grid-template-columns: minmax(0, 1fr); }
  .ws-doc { position: static; max-height: none; padding: 16px 0; background: none; }
}

.pdf-view { position: fixed; inset: 3vh 3vw; z-index: 30; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); display: flex; flex-direction: column; overflow: hidden; }
.pdf-bar { padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface); }
.spacer { flex: 1; }
.pdf-view iframe { flex: 1; width: 100%; border: 0; background: #FFFFFF; }
.pad { padding: 20px; }
@media (max-width: 640px) { .pdf-view { inset: 0; border-radius: 0; border: 0; } }

.tpls { list-style: none; margin: 0 0 16px; padding: 0; }
.tpl { display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid var(--line); }
.tpl:first-child { padding-top: 4px; }
.tpl-main { display: grid; gap: 2px; min-width: 0; }
.tpl-actions { gap: 4px; }
.file-btn { cursor: pointer; }
.file-btn:focus-within { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.btn.danger { color: var(--bad); }

body.locked { overflow: hidden; }
.pe { position: fixed; inset: 0; z-index: 35; background: var(--bg); display: flex; flex-direction: column; }
.pe-bar { display: flex; gap: 10px 12px; align-items: center; padding: 12px max(16px, 3vw); background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.pe-title { display: grid; min-width: 0; }
.pe-body { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 320px; min-height: 0; }
.pe-pages { overflow: auto; scrollbar-gutter: stable; padding: 24px 20px 64px; background: var(--sunk); display: grid; gap: 18px; justify-items: center; align-content: start; }
.pe-side { overflow: auto; padding: 16px 18px 32px; border-left: 1px solid var(--line); background: var(--surface); display: grid; gap: 14px; align-content: start; }
.pe-tools { display: grid; gap: 4px; }
.pe-tool { text-align: left; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); color: var(--ink); font: inherit; cursor: pointer; }
.pe-tool.on { border-color: var(--amora); background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.pe-sec h3 { font-size: 14px; margin: 0 0 6px; }
.pe-list { list-style: none; margin: 0; padding: 0; display: grid; }
.pe-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent-text); text-align: left; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.pe-note { border-top: 1px solid var(--line); padding-top: 10px; }
.pe-text span { position: absolute; color: transparent; line-height: 1; white-space: pre; cursor: text; font-family: sans-serif; }
.pe-text span::selection { background: rgba(94, 53, 116, .35); color: transparent; }
.pe-marks { position: absolute; inset: 0; pointer-events: none; }
.pe-marks > * { pointer-events: auto; }
.pe-mk, .pe-fd { position: absolute; padding: 0; border: 0; background: rgba(94, 53, 116, .16); box-shadow: inset 0 -2px 0 var(--amora); border-radius: 2px; cursor: pointer; }
.pe-fd { background: rgba(94, 53, 116, .1); outline: 1px dashed var(--amora); }
.pe-mk:hover, .pe-fd:hover, .pe-mk:focus-visible, .pe-fd:focus-visible { background: rgba(94, 53, 116, .28); outline: 2px solid var(--amora); }
.pe-tag { position: absolute; left: -1px; bottom: 100%; margin-bottom: 1px; padding: 1px 5px; font: 600 10px/1.4 var(--f-body); color: var(--creme); background: var(--amora);
  border-radius: 3px 3px 3px 0; white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; pointer-events: none; opacity: 0; }
.pe-mk:hover .pe-tag, .pe-mk:focus-visible .pe-tag, .pe-fd .pe-tag, .pe-fd:hover .pe-tag { opacity: 1; }
.pe-ar { position: absolute; border: 1.5px dashed color-mix(in srgb, var(--muted) 45%, transparent); border-radius: 3px; pointer-events: none; }
.pe-ar.original { border-style: solid; border-color: var(--bad); background: repeating-linear-gradient(-45deg, rgba(168, 40, 30, .16) 0 6px, rgba(168, 40, 30, .04) 6px 12px); }
/* Inside the area's corner: above it, the button would hide the contract's text. */
.pe-ar-restore { position: absolute; top: 3px; right: 3px; pointer-events: auto; padding: 1px 7px; border-radius: var(--r); cursor: pointer; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--line); color: var(--accent-text); font: 500 12px/18px var(--f-body); }
.pe-ar-restore:hover { border-color: var(--accent); }
.pe-off { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; text-align: center; padding: 24px;
  background: repeating-linear-gradient(-45deg, rgba(168, 40, 30, .1) 0 10px, rgba(246, 245, 238, .88) 10px 20px); }
.pe-off p { margin: 0; background: var(--surface); padding: 8px 12px; border-radius: var(--r); color: var(--ink); }
.pe-band { position: absolute; border: 1.5px dashed var(--amora); background: rgba(94, 53, 116, .1); pointer-events: none; }
/* Signature places in their own colour, so who signs where reads at a glance. */
.pe-fd.sig, .pe-mk.sig { background: color-mix(in srgb, var(--ok) 14%, transparent); outline: 1px dashed var(--ok); box-shadow: inset 0 -2px 0 var(--ok); }
.pe-fd.sig .pe-tag, .pe-mk.sig .pe-tag { background: var(--ok); color: var(--surface); opacity: 1; }
.pe-band.signature { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.pe-sec.active { border-left: 3px solid var(--ok); padding-left: 8px; }
.pe-signer.on { background: var(--accent-soft); }
.pe-signer.on > button:first-child { font-weight: 600; text-decoration: none; }
.pe-band.erase { border-color: var(--bad); background: rgba(168, 40, 30, .12); }
.pe-pages.tool-signature .pdf-page, .pe-pages.tool-field .pdf-page, .pe-pages.tool-region .pdf-page, .pe-pages.tool-erase .pdf-page { cursor: crosshair; touch-action: none; }
.pe-pages.tool-signature .pe-text, .pe-pages.tool-field .pe-text, .pe-pages.tool-region .pe-text, .pe-pages.tool-erase .pe-text { pointer-events: none; user-select: none; }
.pe-pick { position: fixed; z-index: 40; width: 320px; display: grid; gap: 8px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: 0 16px 40px -18px rgba(30, 30, 30, .45); }
.pe-pick label { display: grid; gap: 3px; font-size: 12.5px; color: var(--muted); }
.pe-pick select { width: 100%; }
.pe-pick .quote { margin: 0; font-size: 13px; }
@media (max-width: 860px) {
  .pe-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .pe-side { border-left: 0; border-top: 1px solid var(--line); max-height: 40vh; }
}

.totals { display: flex; flex-wrap: wrap; gap: 28px; margin: 0 0 22px; }
.totals div { display: flex; flex-direction: column-reverse; }
.totals dt { font-size: 12.5px; }
.totals dd { font-weight: 700; font-size: 32px; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; }
.funnel { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 7px; }
.funnel li { display: grid; grid-template-columns: 170px minmax(0, 1fr) 40px; gap: 10px; align-items: center; font-size: 13px; }
.funnel .bar { height: 14px; background: var(--sunk); border-radius: 3px; overflow: hidden; }
.funnel .bar i { display: block; height: 100%; background: var(--accent); }
.funnel .num { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 520px) { .funnel li { grid-template-columns: 1fr 40px; } .funnel .bar { grid-column: 1 / -1; grid-row: 2; } }

table { border-collapse: collapse; width: 100%; font-size: 13px; }
th { font-weight: 500; color: var(--muted); text-align: left; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
td { padding: 7px 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; vertical-align: top; }
td.r, th.r { text-align: right; }
.tbl { overflow-x: auto; }
.pe-mk.fixed { background: transparent; box-shadow: none; border: 1px dashed var(--muted); }
.pe-mk.fixed .pe-tag { background: var(--sunk); color: var(--ink); border: 1px dashed var(--muted); opacity: 1; }

/* A list holds the variables of its first person: an outline under them, so they stay clickable. */
.pe-mk.list { background: transparent; box-shadow: none; outline: 1.5px solid var(--uva); outline-offset: 1px; }
.pe-mk.list .pe-tag { background: var(--uva); }
.pe-mk.structure { background: rgba(31, 107, 69, .14); box-shadow: inset 0 -2px 0 var(--ok); }
.pe-mk.structure .pe-tag { background: var(--ok); }
/* Areas span the page width; their label sits on the left edge, always visible. */
.pe-rg { position: absolute; pointer-events: none; border-top: 1.5px dashed var(--uva); border-bottom: 1.5px dashed var(--uva); background: rgba(94, 53, 116, .05); }
.pe-rg.optional { border-color: var(--warn); background: rgba(138, 86, 0, .05); }
.pe-rg .pe-tag { position: absolute; top: 2px; left: 2px; bottom: auto; opacity: 1; pointer-events: auto; cursor: pointer; border: 0; background: var(--uva); }
.pe-rg.optional .pe-tag { background: var(--warn); }
.pe-band.region { border-color: var(--uva); border-left-width: 0; border-right-width: 0; }
.pe-pick fieldset.choice { border: 0; padding: 0; margin: 0; display: grid; gap: 4px; font-size: 13px; }
.pe-pick fieldset.choice label { display: flex; gap: 6px; align-items: center; color: var(--ink); }
.pe-pick textarea { width: 100%; font: inherit; }
.people { display: grid; gap: 6px; padding: 10px 0; }
.people .row { justify-content: space-between; }
.pick-insurer { display: grid; gap: 3px; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.detail .form.wide { max-width: none; }
.form.wide td input { width: 100%; }

/* Electronic signature */
.pill.sig { background: var(--accent-soft); color: var(--accent-text); }
.sig-status { margin: 0 0 10px; }
.signers { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 2px; }
.signer { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.signer:last-child { border-bottom: 0; }
.signer .dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--muted); }
.signer.is-signed .dot { background: var(--ok); border-color: var(--ok); }
.signer.is-declined .dot { background: var(--bad); border-color: var(--bad); }
.signer .state { font-size: 12.5px; color: var(--muted); text-align: right; }
.signer.is-signed .state { color: var(--ok); }
.signer.is-declined .state { color: var(--bad); }
@media (max-width: 460px) { .signer { grid-template-columns: 12px minmax(0, 1fr); } .signer .state, .signer > :last-child { grid-column: 2; text-align: left; justify-self: start; } }
.sig-dialog { position: fixed; z-index: 30; top: 5vh; left: max(16px, calc(50vw - 340px)); right: max(16px, calc(50vw - 340px)); max-height: 90vh; overflow: auto; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); padding: 22px; }
.sig-dialog h2 { margin: 0; font-size: 20px; }
.sig-dialog p { margin: 0; }
.sig-person { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px 14px; margin: 0; display: grid; gap: 10px; background: var(--surface); }
.sig-person.is-bad { border-color: var(--bad); }
.sig-person legend { font-weight: 600; padding: 0 4px; }
.sig-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1.2fr); gap: 10px; align-items: start; }
@media (max-width: 640px) { .sig-dialog { inset: 0; max-height: none; border-radius: 0; border: 0; } .sig-grid { grid-template-columns: minmax(0, 1fr); } }
.sig-person .fld-error { color: var(--bad); }
.sig-person [aria-invalid="true"] { border-color: var(--bad); }
.sig-actions { justify-content: flex-end; position: sticky; bottom: -22px; background: var(--bg); padding: 12px 0; }
.engine { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.engine legend { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.form label.engine-card { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--ink); cursor: pointer; }
.form label.engine-card:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.engine-card input { margin-top: 3px; }
.form h4 { margin: 10px 0 0; font-size: 14px; }
.form label.narrow { max-width: 220px; }
.form h4 + p { margin: -6px 0 0; }
