:root {
  --brand: #b3201f;
  --brand-dark: #8f1716;
  --brand-soft: #fbeceb;
  --ink: #1d2230;
  --ink-2: #4a5165;
  --ink-3: #7a8196;
  --line: #e2e5ec;
  --line-2: #cfd4de;
  --bg: #f4f5f8;
  --card: #ffffff;
  --ok: #1e7b4a;
  --ok-soft: #e5f4ec;
  --warn: #9a6200;
  --warn-soft: #fdf3dd;
  --err: #b3261e;
  --err-soft: #fbe9e7;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 24, 40, .06), 0 1px 1px rgba(20, 24, 40, .04);
  --shadow-lg: 0 12px 32px rgba(20, 24, 40, .16);
  font-size: 15px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
small, .muted { color: var(--ink-3); }
[x-cloak] { display: none !important; }
code { background: #eef0f4; padding: 1px 5px; border-radius: 4px; font-size: .86em; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 18px;
  padding: 8px 20px; background: #fff; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand img { width: 34px; height: 34px; object-fit: contain; }
.brand span { display: flex; flex-direction: column; line-height: 1.05; font-size: 1.02rem; }
.brand small { font-size: .68rem; font-weight: 600; letter-spacing: .04em; color: var(--ink-3); }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav::-webkit-scrollbar { display: none; }
.nav a { padding: 8px 12px; border-radius: 8px; color: var(--ink-2); font-weight: 550; white-space: nowrap; }
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.active { color: var(--brand); background: var(--brand-soft); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.usermenu { position: relative; }
.usermenu summary { list-style: none; cursor: pointer; }
.usermenu summary::-webkit-details-marker { display: none; }
.avatar {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--ink); color: #fff; font-weight: 700;
}
.usermenu-panel {
  position: absolute; right: 0; top: 44px; min-width: 230px; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; z-index: 40;
}
.usermenu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; display: flex; flex-direction: column; }
.usermenu-panel a, .usermenu-panel button {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px; border: 0; background: none;
  color: var(--ink); font: inherit; cursor: pointer;
}
.usermenu-panel a:hover, .usermenu-panel button:hover { background: var(--bg); text-decoration: none; }

/* ---------- Layout ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 24px 20px 64px; }
.container-narrow { max-width: 760px; margin: 0 auto; padding: 24px 20px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--ink-3); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 18px 20px; }
.card-head { padding: 14px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack > * + * { margin-top: var(--gap, 16px); }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-all { grid-column: 1 / -1; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grow { flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line-2);
  background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #f7f8fa; text-decoration: none; border-color: #b9bfcc; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-dark:hover { background: #000; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: #eceef2; border-color: transparent; }
.btn-danger { color: var(--err); }
.btn-danger:hover { background: var(--err-soft); border-color: #eab8b3; }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: .88rem; }
.btn-xs { min-height: 26px; padding: 2px 8px; font-size: .8rem; border-radius: 6px; }
.btn-icon { width: 32px; min-height: 32px; padding: 0; }
.inline { display: inline; }

/* ---------- Forms ---------- */
label.lbl, .lbl { display: block; font-size: .82rem; font-weight: 650; color: var(--ink-2); margin-bottom: 5px; }
.req { color: var(--brand); }
.input, select.input, textarea.input {
  width: 100%; min-height: 40px; padding: 8px 11px; border: 1px solid var(--line-2); border-radius: 8px;
  background: #fff; color: var(--ink); font: inherit; outline: none; transition: border-color .12s, box-shadow .12s;
}
textarea.input { min-height: 90px; resize: vertical; line-height: 1.45; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(179, 32, 31, .12); }
.input-sm, select.input-sm, textarea.input-sm { min-height: 32px; padding: 4px 8px; font-size: .9rem; }
.hint { font-size: .8rem; color: var(--ink-3); margin-top: 4px; }
.field { min-width: 0; }
.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); }
.choices { display: flex; flex-wrap: wrap; gap: 6px 16px; padding-top: 2px; }
.search { position: relative; }
.search .input { padding-left: 34px; }
.search svg { position: absolute; left: 10px; top: 11px; color: var(--ink-3); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 700; background: #fafbfc; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfd; }
.table .actions { text-align: right; white-space: nowrap; }
.cell-title { font-weight: 650; color: var(--ink); }
.cell-sub { font-size: .82rem; color: var(--ink-3); }

/* ---------- Badges / alerts ---------- */
.badge { display: inline-block; white-space: nowrap; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 700; letter-spacing: .02em; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-draft { background: var(--warn-soft); color: var(--warn); }
.badge-muted { background: #eceef2; color: var(--ink-2); }
.badge-err { background: var(--err-soft); color: var(--err); }
.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; font-weight: 550; border: 1px solid transparent; }
.alert-success { background: var(--ok-soft); color: var(--ok); border-color: #bfe3cf; }
.alert-error { background: var(--err-soft); color: var(--err); border-color: #f0c6c2; }
.alert-info { background: #eaf1fb; color: #1d4f91; border-color: #c7daf3; }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: #f1dcaa; }
.empty { text-align: center; padding: 48px 20px; color: var(--ink-3); }
.empty h3 { color: var(--ink); margin-bottom: 6px; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { padding: 14px 18px; }
.stat b { display: block; font-size: 1.6rem; line-height: 1.1; }
.stat span { font-size: .82rem; color: var(--ink-3); font-weight: 600; }

.filters { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 10px; padding: 14px; border-bottom: 1px solid var(--line); }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); font-size: .9rem; }

/* ---------- Cards de modelo ---------- */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.tpl-card { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 16px; border: 1.5px solid var(--line); border-radius: var(--radius); background: #fff; cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.tpl-card:hover { border-color: var(--line-2); box-shadow: var(--shadow); }
.tpl-card input { position: absolute; opacity: 0; pointer-events: none; }
.tpl-card.selected, .tpl-card:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(179, 32, 31, .1); }
.tpl-card h3 { font-size: .98rem; }
.tpl-card p { margin: 0; font-size: .84rem; color: var(--ink-3); }
.tpl-meta { margin-top: auto; font-size: .76rem; color: var(--ink-3); font-weight: 600; }

/* ---------- Toasts / modal ---------- */
.toasts { position: fixed; left: 50%; top: 64px; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { padding: 11px 16px; border-radius: 8px; background: var(--ink); color: #fff; box-shadow: var(--shadow-lg); font-weight: 550; max-width: 380px; animation: toast-in .18s ease-out; }
.toast-error { background: var(--err); }
.toast-success { background: var(--ok); }
@keyframes toast-in { from { transform: translateY(-8px); opacity: 0; } }
.modal-bg { position: fixed; inset: 0; background: rgba(15, 18, 28, .5); z-index: 80; display: grid; place-items: center; padding: 16px; }
.modal { width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto; background: #fff; border-radius: 12px; box-shadow: var(--shadow-lg); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Assinatura ---------- */
.sigpad { border: 1.5px dashed var(--line-2); border-radius: 8px; background: #fff; touch-action: none; width: 100%; height: 180px; display: block; cursor: crosshair; }
.sig-preview { display: flex; align-items: center; justify-content: center; min-height: 64px; border: 1px solid var(--line-2); border-radius: 8px; background: #fff; padding: 6px; }
.sig-preview img { max-height: 60px; max-width: 100%; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, #fff 0%, #f1f2f6 60%, #fbeceb 100%); }
.login-card { width: 100%; max-width: 380px; }
.login-card .card-body { padding: 28px; }
.login-logo { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; text-align: center; }
.login-logo img { width: 84px; height: 84px; object-fit: contain; }

/* ---------- Formulário de laudo ---------- */
.form-shell { max-width: 980px; margin: 0 auto; padding: 0 16px 120px; }
.form-bar {
  position: sticky; top: 51px; z-index: 20; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px; margin: 0 -16px 18px; background: rgba(244, 245, 248, .94); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line);
}
.form-bar .title { flex: 1; min-width: 180px; }
.form-bar .title strong { display: block; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.save-state { font-size: .8rem; color: var(--ink-3); font-weight: 600; }
.save-state.dirty { color: var(--warn); }
.save-state.error { color: var(--err); }
.sec { margin-bottom: 16px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.sec-head h2 { font-size: .95rem; text-transform: uppercase; letter-spacing: .04em; }
.sec-num { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; background: var(--ink); color: #fff; font-size: .78rem; margin-right: 8px; }
.fgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; padding: 18px; }
.w1 { grid-column: span 1; } .w2 { grid-column: span 2; } .w3 { grid-column: span 3; } .w4 { grid-column: span 4; }

.ck-list { list-style: none; margin: 0; padding: 0; }
.ck-item { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: start; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.ck-item:last-child { border-bottom: 0; }
.ck-n { font-size: .78rem; font-weight: 700; color: var(--ink-3); padding-top: 6px; }
.ck-text { padding-top: 5px; font-size: .94rem; }
.ck-note { grid-column: 2 / -1; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button {
  min-width: 44px; min-height: 36px; padding: 0 8px; border: 0; border-right: 1px solid var(--line-2); background: #fff;
  font: inherit; font-size: .82rem; font-weight: 700; color: var(--ink-2); cursor: pointer;
}
.seg button:last-child { border-right: 0; }
.seg button:hover { background: #f4f5f8; }
.seg button.on { background: var(--ink); color: #fff; }
.seg button.on.v-C { background: var(--ok); }
.seg button.on.v-NC { background: var(--err); }
.seg button.on.v-OBS { background: #b57600; }
.seg button.on.v-NA { background: #6b7285; }
.seg button.on.v-SIM { background: var(--ok); }
.seg button.on.v-NÃO { background: var(--err); }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; padding: 18px; }
.photo { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.photo img { width: 100%; height: 170px; object-fit: cover; background: #eef0f4; display: block; }
.photo .p-body { padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.photo .p-actions { display: flex; gap: 4px; justify-content: flex-end; }
.drop { border: 1.5px dashed var(--line-2); border-radius: 8px; display: grid; place-items: center; min-height: 170px; text-align: center; color: var(--ink-3); cursor: pointer; padding: 12px; background: #fafbfc; }
.drop:hover { border-color: var(--brand); color: var(--brand); }
.img-field img { max-width: 100%; max-height: 160px; border-radius: 6px; border: 1px solid var(--line); display: block; }
.uploading { font-size: .82rem; color: var(--ink-3); }

.tbl-edit { width: 100%; border-collapse: collapse; }
.tbl-edit th { text-align: left; font-size: .76rem; color: var(--ink-3); text-transform: uppercase; padding: 8px 6px; }
.tbl-edit td { padding: 4px; }

/* ---------- Visualização ---------- */
.view-shell { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; max-width: 1240px; margin: 0 auto; padding: 20px; }
.view-side { position: sticky; top: 70px; display: flex; flex-direction: column; gap: 12px; }
.view-side .btn { width: 100%; justify-content: flex-start; }
.doc-scroll { overflow-x: auto; }
.meta-list { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: .88rem; }
.meta-list dt { color: var(--ink-3); }
.meta-list dd { margin: 0; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.log { font-size: .82rem; }
.log li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.log ul { list-style: none; margin: 0; padding: 0; }

/* ---------- Construtor de modelos ---------- */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 20px; align-items: start; }
.builder-side { position: sticky; top: 118px; display: flex; flex-direction: column; gap: 12px; }
.b-sec { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); margin-bottom: 12px; }
.b-sec-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfc; border-radius: var(--radius) var(--radius) 0 0; }
.b-sec-head .type { font-size: .7rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: #fff; background: var(--ink-2); padding: 3px 8px; border-radius: 5px; white-space: nowrap; }
.b-sec-body { padding: 14px; }
.b-sec.collapsed .b-sec-body { display: none; }
.b-field { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 8px; background: #fcfcfd; }
.b-field-main { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) 100px auto; gap: 8px; align-items: end; }
.b-field-more { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.add-bar { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.add-bar .btn { justify-content: flex-start; }
.vars { font-size: .8rem; max-height: 280px; overflow: auto; }
.vars code { cursor: pointer; display: inline-block; margin: 2px 2px; }
.vars code:hover { background: var(--brand-soft); color: var(--brand); }

@media (max-width: 960px) {
  .view-shell, .builder { grid-template-columns: minmax(0, 1fr); }
  .view-side, .builder-side { position: static; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .search { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  :root { font-size: 15px; }
  .topbar { padding: 8px 12px; gap: 10px; }
  .brand span { display: none; }
  .hide-sm { display: none !important; }
  .container, .container-narrow { padding: 16px 12px 64px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .span-2, .span-3 { grid-column: auto; }
  .fgrid { grid-template-columns: 1fr; padding: 14px; }
  .w1, .w2, .w3, .w4 { grid-column: auto; }
  .ck-item { grid-template-columns: 22px 1fr; padding: 12px 14px; }
  .ck-item .ck-actions { grid-column: 2; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat b { font-size: 1.25rem; }
  .b-field-main { grid-template-columns: 1fr 1fr; }
  .b-field-more { grid-template-columns: 1fr; }
  .table th, .table td { padding: 10px; }
  .hide-mobile-col { display: none; }
  .form-bar { top: 51px; }
  .view-shell { padding: 12px; }
}

/* ---------- Editor com informações automáticas ---------- */
.st-wrap { position: relative; border: 1px solid var(--line-2); border-radius: 8px; background: #fff; transition: border-color .12s, box-shadow .12s; }
.st-wrap.st-focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(179, 32, 31, .12); }
.st-bar { display: flex; gap: 4px; flex-wrap: wrap; padding: 4px; border-bottom: 1px solid var(--line); background: #fafbfc; border-radius: 8px 8px 0 0; }
.st-btn { border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 3px 9px; font: inherit; font-size: .8rem; font-weight: 600; color: var(--ink-2); cursor: pointer; min-height: 28px; }
.st-btn:hover { background: #eceef2; }
.st-btn.st-insert { color: var(--brand); background: var(--brand-soft); border-color: #f1c9c7; }
.st-btn.st-insert:hover { background: #f8dcda; }
.st-ed { padding: 8px 11px; min-height: 120px; outline: none; line-height: 1.7; overflow-wrap: anywhere; }
.st-single .st-ed { min-height: 38px; white-space: nowrap; overflow-x: auto; }
.st-ed:empty::before { content: attr(data-placeholder); color: var(--ink-3); pointer-events: none; }
.st-ed .st-li { position: relative; padding-left: 18px; }
.st-ed .st-li::before { content: "•"; position: absolute; left: 5px; color: var(--ink-2); }
.st-chip {
  display: inline; padding: 1px 6px; margin: 0 1px; border-radius: 5px; line-height: 1.9; -webkit-box-decoration-break: clone; box-decoration-break: clone;
  background: #e8f0fe; color: #1a4fa0; border: 1px solid #c3d6f7; font-size: .88em; font-weight: 600;
  white-space: normal; cursor: default; user-select: all;
}
.st-chip.st-missing { background: var(--err-soft); color: var(--err); border-color: #f0c6c2; }
.st-menu {
  position: absolute; z-index: 60; top: 38px; left: 4px; width: min(340px, calc(100vw - 40px)); max-height: 340px;
  display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 8px;
}
.st-list { overflow: auto; margin-top: 6px; }
.st-group { font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); padding: 8px 8px 4px; }
.st-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 8px; border-radius: 6px; font: inherit; font-size: .9rem; cursor: pointer; color: var(--ink); }
.st-item:hover { background: #e8f0fe; color: #1a4fa0; }
.st-item small { display: block; color: var(--ink-3); font-size: .76rem; }
.st-empty { padding: 10px; color: var(--ink-3); font-size: .88rem; }
.st-wrap.st-target:not(.st-focus) { border-color: #7aa7ec; box-shadow: 0 0 0 3px rgba(26, 79, 160, .12); }
.vars { max-height: none; overflow: visible; font-size: .88rem; }
.vars-head { padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.vars-status { margin-top: 8px; padding: 8px 10px; border-radius: 8px; font-size: .82rem; line-height: 1.45; }
.vars-status small { display: block; color: var(--ink-3); margin-top: 2px; }
.vars-idle { background: var(--warn-soft); color: var(--warn); }
.vars-ready { background: #e8f0fe; color: #1a4fa0; }
.vars-list { max-height: 46vh; overflow-y: auto; padding: 4px 8px 10px; }
.vars-disabled { opacity: .55; }
.vars-group { font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); padding: 10px 8px 4px; }
.vars-item { display: flex; gap: 6px; align-items: baseline; width: 100%; text-align: left; border: 0; background: none; padding: 5px 8px; border-radius: 6px; font: inherit; font-size: .86rem; color: var(--ink); cursor: pointer; }
.vars-item:hover { background: #e8f0fe; color: #1a4fa0; }
.vars-plus { color: #1a4fa0; font-weight: 700; font-size: .8rem; }
.tbl-rows td { padding: 3px; }

/* ---------- Menu suspenso de linha (⋯) ---------- */
.dropdown { display: inline-block; position: relative; }
.dropdown summary { list-style: none; cursor: pointer; }
.dropdown summary::-webkit-details-marker { display: none; }
.dropdown-panel { position: fixed; top: 0; left: 0; right: auto; min-width: 200px; z-index: 90; }

/* ---------- Assistente de modelo ---------- */
.wz-steps { list-style: none; margin: 0 0 16px; padding: 0; display: flex; gap: 6px; overflow-x: auto; }
.wz-steps li { flex: 1; min-width: 0; }
.wz-steps button { width: 100%; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font: inherit; color: var(--ink-3); cursor: pointer; }
.wz-steps .wz-dot { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: #eceef2; font-size: .8rem; font-weight: 700; }
.wz-steps .wz-label { font-size: .86rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wz-steps li.active button { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 3px rgba(179, 32, 31, .1); }
.wz-steps li.active .wz-dot { background: var(--brand); color: #fff; }
.wz-steps li.done button { color: var(--ok); }
.wz-steps li.done .wz-dot { background: var(--ok-soft); color: var(--ok); }
.wz-steps li.skip button { opacity: .4; cursor: default; text-decoration: line-through; }
.wz-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.wz-choice { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1.5px solid var(--line-2); border-radius: 8px; cursor: pointer; font-size: .9rem; background: #fff; }
.wz-choice input { accent-color: var(--brand); }
.wz-choice small { color: var(--ink-3); }
.wz-choice.on { border-color: var(--brand); background: var(--brand-soft); }
.wz-blocks { display: grid; gap: 10px; }
.wz-block { border: 1.5px solid var(--line); border-radius: 10px; background: #fafbfc; transition: border-color .12s, background .12s; }
.wz-block.on { border-color: #d9a3a2; background: #fff; }
.wz-block-main { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; cursor: pointer; }
.wz-block-main input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--brand); flex: none; }
.wz-block-main p { margin: 3px 0 0; font-size: .85rem; color: var(--ink-3); }
.wz-sub { padding: 0 14px 12px 44px; }
.wz-copy { padding: 12px; border: 1px dashed var(--line-2); border-radius: 8px; background: #fafbfc; }
.wz-items { margin: 0; padding: 10px 10px 10px 34px; border: 1px solid var(--line); border-radius: 8px; background: #fafbfc; font-size: .9rem; max-height: 260px; overflow: auto; }
.wz-items li { padding: 3px 0; }
.wz-title-preview { margin-top: 8px; padding: 10px 12px; border: 1px dashed var(--line-2); border-radius: 8px; font-family: Arial, sans-serif; font-size: 1.05rem; color: #4d4d4d; letter-spacing: .02em; }
.wz-title-preview small { display: block; font-family: inherit; font-size: .72rem; color: var(--ink-3); letter-spacing: 0; margin-bottom: 2px; }
.wz-summary { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 8px; }
.wz-summary li { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: .92rem; }
.wz-summary li:last-child { border-bottom: 0; }
.wz-num { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--ink); color: #fff; font-size: .75rem; font-weight: 700; flex: none; }
.wz-nav { margin-top: 14px; }
@media (max-width: 640px) {
  .wz-steps .wz-label { display: none; }
  .wz-steps li.active .wz-label { display: inline; }
  .wz-sub { padding-left: 14px; }
}
.wz-savenorm { margin-top: 10px; padding: 12px; border-radius: 8px; background: #eef4ff; border: 1px solid #c3d6f7; font-size: .88rem; color: #1a3d73; }
.norm-row { display: grid; grid-template-columns: 220px 1fr auto; gap: 8px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.norm-row:last-of-type { border-bottom: 0; }
@media (max-width: 640px) { .norm-row { grid-template-columns: 1fr auto; } .norm-row textarea { grid-column: 1 / -1; grid-row: 2; } }

/* ---------- Pré-visualização em janela ---------- */
.pv-modal { position: fixed; inset: 0; z-index: 95; display: flex; flex-direction: column; background: rgba(15, 18, 28, .55); }
.pv-bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--line); box-shadow: var(--shadow); }
.pv-title { flex: 1; display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.pv-title span { font-size: .8rem; color: var(--ink-3); }
.pv-body { position: relative; flex: 1; }
.pv-loading { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-weight: 600; }
.pv-frame { position: relative; width: 100%; height: 100%; border: 0; background: transparent; }
.pv-embed { padding: 20px 12px 40px; }
.pv-embed-body { background: #e9ebf0; }

/* ---------- Barra superior da visualização do laudo ---------- */
.view-top { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.view-top-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.view-top-title strong { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px) { .view-top-title { order: 3; flex-basis: 100%; flex-wrap: wrap; gap: 6px; } .view-top-title strong { white-space: normal; } }
