/* =====================================================================
   Analisador de PBA – sistema visual
   Tokens → base → layout (trilho lateral, topo, abas) → componentes → telas
   ===================================================================== */

:root {
  /* cores: neutros (slate) + primária institucional + semânticas */
  --n-0: #ffffff; --n-25: #fbfcfd; --n-50: #f6f8fa; --n-100: #eef1f5; --n-150: #e6eaf0; --n-200: #dde3ea;
  --n-300: #c7cfd9; --n-400: #98a2b3; --n-500: #667085; --n-600: #475467; --n-700: #344054; --n-800: #1d2939; --n-900: #101828;
  --primary: #1f5fbf; --primary-600: #1a51a3; --primary-700: #154387; --primary-50: #eef4fd; --primary-100: #dce8fb;
  --danger: #c4320a; --danger-50: #fef3f2; --danger-100: #fee4e2;
  --ok: #067647; --ok-50: #ecfdf3; --ok-100: #d1fadf;
  --warn: #b54708; --warn-50: #fffaeb; --warn-100: #fef0c7;

  --bg: var(--n-50); --panel: var(--n-0); --line: var(--n-200); --line-soft: var(--n-100);
  --text: var(--n-900); --text-2: var(--n-700); --muted: var(--n-500);
  --primary-2: var(--primary-50); /* compatibilidade */

  /* barra lateral */
  --sb-bg: #0f1e33; --sb-bg-2: #16294a; --sb-line: #22375a; --sb-text: #d7e0ec; --sb-muted: #8ea0ba;
  --sb-w: 272px; --sb-w-min: 68px;

  /* forma e espaço */
  --r-sm: 6px; --r: 8px; --r-lg: 12px; --r-xl: 16px;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px;
  --sh-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --sh-sm: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --sh-md: 0 6px 16px -4px rgba(16, 24, 40, .12), 0 2px 6px -2px rgba(16, 24, 40, .06);
  --sh-lg: 0 20px 40px -8px rgba(16, 24, 40, .22);
  --ring: 0 0 0 3px rgba(31, 95, 191, .28);

  /* tipografia */
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Inter", Roboto, Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "Courier New", monospace;
  --fs-xs: 11.5px; --fs-sm: 12.5px; --fs: 14px; --fs-md: 15px; --fs-lg: 17px; --fs-xl: 20px;
  --ease: cubic-bezier(.2, .7, .3, 1);
  --radius: var(--r); /* compatibilidade */
}

/* ---------------- base ---------------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font: var(--fs)/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { color: var(--text); letter-spacing: -.01em; }
a { color: var(--primary); }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }
::selection { background: var(--primary-100); }
.ic { display: inline-flex; flex: none; line-height: 0; }
.ic svg { display: block; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.row { display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------------- layout geral ---------------- */
#app { display: grid; grid-template-columns: var(--sb-w) 1fr; height: 100vh; transition: grid-template-columns .22s var(--ease); }
#app.collapsed { grid-template-columns: var(--sb-w-min) 1fr; }
#main { overflow: auto; min-width: 0; scroll-behavior: smooth; }

/* ---------------- barra lateral (trilho) ---------------- */
#sidebar {
  background: var(--sb-bg); color: var(--sb-text); display: flex; flex-direction: column; gap: var(--s-1);
  padding: var(--s-3) var(--s-3) var(--s-3); min-height: 0; overflow: hidden; border-right: 1px solid #0a1627;
}
.sb-head { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-1) var(--s-1) var(--s-3); }
.sb-logo { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, #2f7be6, #1a4f9c); color: #fff; box-shadow: 0 4px 10px rgba(0, 0, 0, .25); }
.sb-brand { min-width: 0; flex: 1; }
.sb-title { font-weight: 700; font-size: var(--fs-md); color: #fff; white-space: nowrap; }
.sb-sub { font-size: var(--fs-xs); color: var(--sb-muted); white-space: nowrap; }
.sb-toggle { color: var(--sb-muted) !important; }
.sb-toggle:hover { background: var(--sb-bg-2) !important; color: #fff !important; }

.sb-item {
  display: flex; align-items: center; gap: var(--s-3); width: 100%; min-height: 38px; padding: 8px 10px;
  border: 0; border-radius: var(--r); background: transparent; color: var(--sb-text); font: inherit; font-size: var(--fs);
  cursor: pointer; text-align: left; white-space: nowrap; transition: background .15s, color .15s;
}
.sb-item:hover { background: var(--sb-bg-2); color: #fff; }
.sb-item .ic { color: var(--sb-muted); }
.sb-item:hover .ic { color: #fff; }
.sb-primary { background: var(--primary); color: #fff; font-weight: 600; margin-bottom: var(--s-2); box-shadow: 0 2px 6px rgba(0, 0, 0, .25); }
.sb-primary .ic { color: #fff; }
.sb-primary:hover { background: #2a6fd6; }

.sb-search { position: relative; margin-bottom: var(--s-2); }
.sb-search .input { background: var(--sb-bg-2); border-color: var(--sb-line); color: #fff; padding-left: 34px; height: 36px; }
.sb-search .input::placeholder { color: var(--sb-muted); }
.sb-search .input:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59, 130, 246, .3); }
.sb-search-ic { position: absolute; left: 11px; top: 10px; color: var(--sb-muted); pointer-events: none; }
.sb-search-btn { display: none; }

.sb-label { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--sb-muted); padding: var(--s-2) 10px var(--s-1); }
.sb-list { list-style: none; margin: 0 -4px; padding: 0 4px; overflow-y: auto; overflow-x: hidden; flex: 1; scrollbar-width: thin; scrollbar-color: var(--sb-line) transparent; }
.sb-an {
  display: flex; align-items: center; gap: var(--s-3); width: 100%; padding: 7px 8px; margin-bottom: 2px;
  border: 0; border-radius: var(--r); background: transparent; color: var(--sb-text); font: inherit; text-align: left; cursor: pointer;
}
.sb-an:hover { background: var(--sb-bg-2); }
.sb-an.active { background: rgba(47, 123, 230, .22); box-shadow: inset 3px 0 0 #5b9bf0; }
.sb-an.active .li-t { color: #fff; }
.sb-an-txt { display: flex; flex-direction: column; min-width: 0; }
.sb-an .li-t { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-an .li-s { font-size: var(--fs-xs); color: var(--sb-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-empty { padding: 10px; font-size: var(--fs-sm); color: var(--sb-muted); }

.sb-foot { display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--sb-line); padding-top: var(--s-2); margin-top: var(--s-2); }
.sb-backup { display: flex; align-items: center; gap: var(--s-3); padding: 6px 10px 8px; font-size: var(--fs-xs); color: var(--sb-muted); }
.sb-backup .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; margin: 0 7px; background: #32d583; box-shadow: 0 0 0 3px rgba(50, 213, 131, .18); }
.sb-backup.warn { color: #fec84b; }
.sb-backup.warn .dot { background: #fdb022; box-shadow: 0 0 0 3px rgba(253, 176, 34, .2); }

/* avatar (iniciais com cor estável) */
.avatar {
  --av-h: 210; width: 32px; height: 32px; border-radius: 9px; flex: none; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; letter-spacing: .02em; color: hsl(var(--av-h) 70% 92%);
  background: linear-gradient(135deg, hsl(var(--av-h) 55% 42%), hsl(calc(var(--av-h) + 30) 55% 32%));
}
.avatar.lg { width: 44px; height: 44px; border-radius: 12px; font-size: 15px; }

/* recolhido: só ícones, com dica ao lado */
#app.collapsed #sidebar { padding: var(--s-3) 10px; }
#app.collapsed .lbl, #app.collapsed .sb-search .input, #app.collapsed .sb-search-ic { display: none; }
#app.collapsed .sb-head { flex-direction: column; gap: var(--s-2); padding-bottom: var(--s-2); }
#app.collapsed .sb-item, #app.collapsed .sb-an { justify-content: center; padding: 8px 0; gap: 0; }
#app.collapsed .sb-search-btn { display: flex; }
#app.collapsed .sb-an.active { box-shadow: inset 0 0 0 2px #5b9bf0; }
#app.collapsed .sb-backup { justify-content: center; padding: 8px 0; }
#app.collapsed .sb-backup .dot { margin: 0; }
#app.collapsed .sb-list { margin: 0; padding: 0; }

/* dica flutuante */
#tip {
  position: fixed; z-index: 100; max-width: 320px; padding: 6px 10px; border-radius: var(--r-sm);
  background: var(--n-900); color: #fff; font-size: var(--fs-sm); line-height: 1.35; box-shadow: var(--sh-md); pointer-events: none;
  animation: tipIn .12s var(--ease);
}
@keyframes tipIn { from { opacity: 0; transform: translateY(2px); } }

/* ---------------- topo, cabeçalho, abas ---------------- */
#topbar {
  display: flex; align-items: center; gap: var(--s-3); padding: 0 var(--s-6); height: 52px;
  background: rgba(255, 255, 255, .92); backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 6;
}
#crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; min-width: 0; overflow: hidden; white-space: nowrap; }
#crumbs a { color: var(--muted); text-decoration: none; overflow: hidden; text-overflow: ellipsis; border-radius: 4px; padding: 2px 4px; }
#crumbs a:hover { color: var(--text); background: var(--n-100); }
#crumbs .sep { color: var(--n-300); display: inline-flex; }
#crumbs > :last-child { color: var(--text); font-weight: 600; }
.save-status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--muted); }
.save-status.ok { color: var(--ok); }
.save-status.busy { color: var(--muted); }
.save-status.err { color: var(--danger); font-weight: 600; }

#workspace { display: flex; flex-direction: column; min-height: calc(100% - 52px); }
#ws-header { display: flex; justify-content: space-between; align-items: center; gap: var(--s-4); padding: var(--s-5) var(--s-6) var(--s-3); background: var(--panel); }
.ws-id { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.ws-title { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -.015em; line-height: 1.25; }
.ws-sub { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; font-size: var(--fs-sm); color: var(--muted); }
.ws-razao { color: var(--muted); }
.ws-actions { display: flex; gap: var(--s-2); align-items: center; }
.chip { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px; background: var(--n-100); color: var(--text-2); font-size: var(--fs-xs); font-weight: 600; border: 1px solid var(--line); }
.chip-warn { background: var(--warn-50); color: var(--warn); border-color: var(--warn-100); }

#tabs {
  display: flex; gap: var(--s-1); padding: 0 var(--s-6); background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 52px; z-index: 5; overflow-x: auto;
}
.tab {
  position: relative; display: inline-flex; align-items: center; gap: var(--s-2); border: 0; background: none;
  padding: 12px 12px 13px; font: inherit; font-weight: 500; color: var(--muted); cursor: pointer; white-space: nowrap; border-radius: var(--r) var(--r) 0 0;
  transition: color .15s;
}
.tab:hover { color: var(--text); }
.tab::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: transparent; transition: background .15s; }
.tab.active { color: var(--primary); font-weight: 600; }
.tab.active::after { background: var(--primary); }
.tab .count { min-width: 20px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: 999px; background: var(--n-100); color: var(--text-2); font-size: var(--fs-xs); font-weight: 700; }
.tab.active .count { background: var(--primary-50); color: var(--primary); }
#tab-body { padding: var(--s-5) var(--s-6) 80px; max-width: 1680px; width: 100%; }
.banner { margin: var(--s-3) var(--s-6) 0; padding: 10px 14px; border-radius: var(--r); background: var(--warn-50); color: #7a2e0e; border: 1px solid var(--warn-100); }

/* estado vazio */
.empty { max-width: 460px; margin: 14vh auto; text-align: center; padding: 0 var(--s-4); }
.empty-ic { width: 76px; height: 76px; margin: 0 auto var(--s-4); border-radius: 22px; display: grid; place-items: center; color: var(--primary); background: var(--primary-50); box-shadow: inset 0 0 0 1px var(--primary-100); }
.empty h1 { font-size: 22px; margin: 0 0 6px; }
.empty p { color: var(--muted); margin: 0 0 var(--s-4); }
.empty .btn { margin-bottom: var(--s-5); }

/* ---------------- componentes ---------------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-5); margin-bottom: var(--s-4); box-shadow: var(--sh-xs); }
.card h2 { font-size: var(--fs-md); font-weight: 650; margin: 0 0 var(--s-3); }
.card h3 { font-size: var(--fs-xs); margin: var(--s-4) 0 var(--s-2); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.sec-title { margin: var(--s-8) 0 var(--s-1); font-size: var(--fs-lg); font-weight: 700; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--s-3) var(--s-4); }
.grid .wide { grid-column: span 2; }
.field label { display: block; font-size: var(--fs-sm); font-weight: 500; color: var(--text-2); margin-bottom: 5px; }

.input, select, textarea {
  width: 100%; min-height: 36px; padding: 7px 10px; border: 1px solid var(--n-300); border-radius: var(--r); font: inherit;
  background: var(--n-0); color: inherit; box-shadow: var(--sh-xs); transition: border-color .15s, box-shadow .15s;
}
.input:hover, select:hover, textarea:hover { border-color: var(--n-400); }
.input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
textarea { resize: vertical; min-height: 64px; line-height: 1.45; }
input[type=checkbox] { accent-color: var(--primary); }
select { cursor: pointer; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 7px 14px;
  border: 1px solid var(--n-300); border-radius: var(--r); background: var(--n-0); color: var(--text-2); font: inherit; font-weight: 600; font-size: 13.5px;
  cursor: pointer; white-space: nowrap; box-shadow: var(--sh-xs); transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { background: var(--n-50); border-color: var(--n-400); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-600); border-color: var(--primary-600); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-50); border-color: var(--danger-100); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--n-100); }
.btn.small { min-height: 28px; padding: 3px 9px; font-size: var(--fs-sm); border-radius: var(--r-sm); gap: 5px; }
.btn.lg { min-height: 44px; padding: 10px 20px; font-size: var(--fs-md); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.icon { font-size: 18px; padding: 4px 10px; line-height: 1; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none; border: 0; border-radius: var(--r);
  background: transparent; color: var(--muted); cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--n-100); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-50); color: var(--danger); }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; background: var(--n-100); color: var(--n-600); }
.pill.blue { background: var(--primary-50); color: var(--primary); }
.pill.red { background: var(--danger-100); color: var(--danger); }
.pill.green { background: var(--ok-100); color: var(--ok); }
.pill.orange { background: var(--warn-100); color: var(--warn); }

table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th, table.tbl td { border-bottom: 1px solid var(--line-soft); padding: 8px 10px; text-align: left; vertical-align: top; }
table.tbl th { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
table.tbl tr:last-child td { border-bottom: 0; }
tr.sel td { background: var(--primary-50); }

/* controle segmentado */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--r); background: var(--n-100); border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; padding: 5px 12px; font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; color: var(--muted); border-radius: 6px; transition: background .15s, color .15s; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--n-0); color: var(--text); font-weight: 600; box-shadow: var(--sh-sm); }
.seg button.on[data-v="NAT"], .seg button.on[data-v="NAO"] { color: var(--danger); }
.seg button.on[data-v="SIM"], .seg button.on[data-v="AT"] { color: var(--ok); }
.seg button.on[data-v="PRC"] { color: var(--warn); }

/* diálogo e toast */
dialog { border: 0; border-radius: var(--r-xl); padding: 0; width: min(720px, 94vw); box-shadow: var(--sh-lg); color: var(--text); }
dialog[open] { animation: dlgIn .18s var(--ease); }
@keyframes dlgIn { from { opacity: 0; transform: translateY(8px) scale(.98); } }
dialog::backdrop { background: rgba(16, 24, 40, .5); backdrop-filter: blur(2px); }
.dlg-h { padding: var(--s-5) var(--s-6) var(--s-2); font-weight: 700; font-size: var(--fs-lg); }
.dlg-b { padding: var(--s-2) var(--s-6) var(--s-5); max-height: 70vh; overflow: auto; }
.dlg-b > p { white-space: pre-line; }
.dlg-f { padding: var(--s-4) var(--s-6); border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: var(--s-2); background: var(--n-25); border-radius: 0 0 var(--r-xl) var(--r-xl); }
#toast {
  position: fixed; bottom: var(--s-6); right: var(--s-6); max-width: 420px; background: var(--n-900); color: #fff;
  padding: 12px 16px; border-radius: var(--r-lg); z-index: 90; box-shadow: var(--sh-lg); font-size: var(--fs-sm); animation: toastIn .2s var(--ease);
}
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* ---------------- 1. Dados SLIM + anexos ---------------- */
.chk-list label { display: flex; gap: var(--s-2); padding: 6px 4px; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.chk-list label:hover { background: var(--n-25); }
.anx-bar { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.anx-chip {
  display: inline-flex; gap: 6px; align-items: center; min-height: 34px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--n-0); cursor: pointer; font: inherit; font-size: 13px; color: var(--text-2); max-width: 320px; transition: border-color .15s, background .15s;
}
.anx-chip:hover { border-color: var(--n-400); }
.anx-chip .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.anx-chip.active { border-color: var(--primary); background: var(--primary-50); color: var(--primary); font-weight: 600; }
.anx-layout2 { display: grid; grid-template-columns: 1fr 380px; gap: var(--s-4); align-items: start; }
.viewer { background: #3d4146; border-radius: var(--r-lg); min-height: 70vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--sh-sm); }
.viewer-bar { display: flex; gap: 6px; align-items: center; padding: 8px 10px; background: #2b2e32; color: #e4e7ec; position: sticky; top: 100px; z-index: 3; }
.viewer-bar .input { width: 64px; min-height: 30px; padding: 3px 6px; color: var(--text); background: #fff; }
.viewer-bar .btn { min-height: 30px; padding: 3px 10px; background: #3d4146; border-color: #50555b; color: #e4e7ec; box-shadow: none; }
.viewer-bar .btn:hover { background: #4a4f55; color: #fff; }
.viewer-canvas { overflow: auto; padding: var(--s-4); text-align: center; max-height: 78vh; }
.viewer-canvas canvas { box-shadow: 0 4px 18px rgba(0, 0, 0, .45); background: #fff; max-width: none; border-radius: 2px; }
.viewer-msg { color: #d0d5dd; padding: 48px; text-align: center; }
.notes-panel { position: sticky; top: 104px; }
.note { border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; margin-bottom: var(--s-2); background: var(--n-0); transition: border-color .15s; }
.note:hover { border-color: var(--n-300); }
.note .ref { font-size: var(--fs-sm); color: var(--primary); cursor: pointer; font-weight: 600; }
.note .txt { white-space: pre-wrap; margin: 4px 0 8px; }
.note.included { border-left: 3px solid var(--ok); }

/* ---------------- 2. Normas ---------------- */
.norma-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s-3); }
.norma-card {
  display: flex; flex-direction: column; gap: var(--s-2); padding: 14px; border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--n-0); cursor: pointer; transition: border-color .15s, box-shadow .15s, background .15s; min-height: 124px;
}
.norma-card:hover { border-color: var(--n-300); box-shadow: var(--sh-md); }
.norma-card.on { border-color: var(--primary); background: linear-gradient(180deg, var(--primary-50), var(--n-0)); box-shadow: 0 0 0 1px var(--primary) inset; }
.norma-card .nc-top { display: flex; gap: var(--s-2); align-items: flex-start; }
.norma-card .nc-top input { margin-top: 2px; width: 17px; height: 17px; flex: none; }
.norma-card .nc-title { font-weight: 650; font-size: 13.5px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.norma-card .nc-ementa { font-size: var(--fs-sm); color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.norma-card .nc-cats { display: flex; flex-wrap: wrap; gap: 4px; margin-top: auto; }
.nm-layout { display: grid; grid-template-columns: 300px 1fr; gap: var(--s-4); align-items: start; }
.nm-list { list-style: none; margin: 0; padding: 0; max-height: 70vh; overflow: auto; }
.nm-list li { padding: 8px 10px; border-radius: var(--r); cursor: pointer; font-size: 13px; display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.nm-list li:hover { background: var(--n-50); }
.nm-list li.active { background: var(--primary-50); color: var(--primary); font-weight: 600; }
.nm-item { border-bottom: 1px solid var(--line-soft); padding: 10px 0; }

/* ---------------- 3. Análise ---------------- */
.cat-bar { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--s-2); margin-bottom: var(--s-4); }
.cat-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 10px 12px; min-height: 60px;
  border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--n-0); cursor: pointer; font: inherit; position: relative;
  box-shadow: var(--sh-xs); transition: border-color .15s, box-shadow .15s, background .15s;
}
.cat-btn:hover { border-color: var(--n-300); box-shadow: var(--sh-sm); }
.cat-btn.active { border-color: var(--primary); background: var(--primary-50); box-shadow: 0 0 0 1px var(--primary) inset; }
.cat-btn .cat-n { font-size: var(--fs-xs); color: var(--muted); font-weight: 700; }
.cat-btn.active .cat-n { color: var(--primary); }
.cat-btn .cat-t { font-weight: 600; font-size: 13px; line-height: 1.25; }
.cat-btn .count { position: absolute; top: 8px; right: 8px; min-width: 20px; height: 20px; display: grid; place-items: center; background: var(--danger); color: #fff; border-radius: 999px; padding: 0 6px; font-size: var(--fs-xs); font-weight: 700; }
.cat-btn .hits { font-size: var(--fs-xs); color: var(--primary); font-weight: 600; }
.norma-bar { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)) !important; }
.norma-bar .cat-t { font-size: 12.5px; }
.ana-layout { display: grid; grid-template-columns: minmax(380px, 44%) 1fr; gap: var(--s-4); align-items: start; }
.ana-layout > div:first-child { position: sticky; top: 112px; max-height: calc(100vh - 124px); overflow: auto; padding-right: 2px; }
.resp-auto { display: inline-block; font-weight: 700; padding: 2px 10px; border-radius: 999px; font-size: var(--fs-xs); letter-spacing: .02em; }
.resp-auto.NAO { background: var(--danger-100); color: var(--danger); }
.resp-auto.SIM { background: var(--ok-100); color: var(--ok); }

details.grp { border: 1px solid var(--line); border-radius: var(--r-lg); margin-bottom: var(--s-2); background: var(--n-0); overflow: hidden; }
details.grp > summary {
  cursor: pointer; padding: 10px 14px; font-weight: 600; font-size: 13.5px; display: flex; justify-content: space-between; align-items: center; gap: var(--s-2);
  background: var(--n-25); list-style: none; transition: background .15s;
}
details.grp > summary::-webkit-details-marker { display: none; }
details.grp > summary:hover { background: var(--n-50); }
details.grp > summary::before { content: ''; width: 7px; height: 7px; border-right: 2px solid var(--n-400); border-bottom: 2px solid var(--n-400); transform: rotate(-45deg); margin-right: 6px; transition: transform .15s; flex: none; }
details.grp[open] > summary::before { transform: rotate(45deg); }
details.grp[open] > summary { border-bottom: 1px solid var(--line-soft); }
details.grp > summary span:first-of-type { flex: 1; }
.grp-body { padding: 4px 14px 10px; }

.item { padding: 10px 0; border-bottom: 1px solid var(--line-soft); transition: background .15s; }
.item:last-child { border-bottom: 0; }
.item.no-parecer { background: linear-gradient(90deg, var(--danger-50), transparent 60%); box-shadow: inset 3px 0 0 var(--danger); padding-left: 10px; margin-left: -14px; padding-right: 14px; margin-right: -14px; }
.item-head { display: flex; gap: var(--s-2); align-items: flex-start; }
.item-head input[type=checkbox] { margin-top: 2px; width: 18px; height: 18px; flex: none; accent-color: var(--danger); cursor: pointer; }
.item-head .item-t { flex: 1; }
.item-t { font-size: 13.5px; cursor: pointer; white-space: pre-line; color: var(--text-2); }
.item-t b { color: var(--text); }
.item-t.collapsed { max-height: 3.3em; overflow: hidden; -webkit-mask-image: linear-gradient(180deg, #000 60%, transparent); mask-image: linear-gradient(180deg, #000 60%, transparent); }
.item-sel { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; padding-top: 6px; }
.mods { margin: 8px 0 0 26px; border-left: 2px solid var(--line); padding-left: 8px; }
.lib-m { display: flex; gap: var(--s-2); padding: 6px 8px; border-radius: var(--r); align-items: flex-start; transition: background .15s; }
.lib-m:hover { background: var(--n-50); }
.lib-m .t { flex: 1; font-size: 13px; color: var(--text-2); }
.lib-m.sel { cursor: pointer; }
.lib-m.sel input[type=checkbox] { margin-top: 2px; width: 16px; height: 16px; flex: none; accent-color: var(--ok); }
.lib-m.sel.on { background: var(--ok-50); }
.lib-m.sel.on .t { color: var(--text); }
.cat-select { width: auto; max-width: 210px; min-height: 30px; padding: 3px 8px; font-size: var(--fs-sm); }
select.mini { width: 56px; min-height: 26px; padding: 2px 4px; font-size: var(--fs-xs); }
select.input.small { width: 120px; min-height: 30px; padding: 3px 6px; font-size: var(--fs-sm); }

/* exigências (lista editável na Análise) */
.ex { display: grid; grid-template-columns: 28px 1fr auto; gap: var(--s-2); padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.ex:last-of-type { border-bottom: 0; }
.ex .n { font-weight: 700; color: var(--muted); padding-top: 8px; text-align: right; font-variant-numeric: tabular-nums; }
.ex textarea { min-height: 56px; }
.ex .tools { display: flex; flex-direction: column; gap: 4px; }
.ex.atendida textarea { text-decoration: line-through; color: var(--muted); background: var(--n-50); }
.ex .ref { font-size: var(--fs-sm); color: var(--primary); cursor: pointer; font-weight: 600; }

/* ---------------- 4. Parecer e saídas ---------------- */
.out-layout { display: grid; grid-template-columns: 1.3fr 1fr; gap: var(--s-4); align-items: start; }
.out-actions { position: static; }
.preview-frame { width: 100%; height: 75vh; border: 0; border-radius: var(--r); background: #3d4146; display: block; }
#txt-out { font-family: var(--mono); font-size: 12px; min-height: 60vh; white-space: pre-wrap; background: var(--n-25); }

/* ---------------- responsivo ---------------- */
@media (max-width: 1250px) {
  .cat-bar { grid-template-columns: repeat(4, 1fr); }
  .ana-layout, .out-layout, .anx-layout2, .nm-layout { grid-template-columns: 1fr; }
  .ana-layout > div:first-child, .notes-panel { position: static; max-height: none; }
}
@media (max-width: 900px) {
  :root { --sb-w: 240px; }
  #tab-body, #ws-header, #topbar, #tabs { padding-left: var(--s-4); padding-right: var(--s-4); }
  .cat-bar { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* subtítulo de capítulo dentro das listas de itens */
.sub-sec { margin: 12px 0 2px; padding: 4px 0; font-size: var(--fs-xs); font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px dashed var(--primary-100); }
.grp-body > .sub-sec:first-child { margin-top: 4px; }

/* comentários sugeridos no cartão do item marcado */
.mods-t { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); margin: 2px 0 4px; }
.mods-hint { margin: 4px 0 0 26px; font-size: var(--fs-xs); color: var(--muted); }
.item.no-parecer .mods { background: var(--n-0); border-radius: var(--r); padding: 6px 8px; border-left: 2px solid var(--ok-100); }
.ex .tools .icon-btn { width: 32px; height: 32px; align-self: flex-end; }
