/* Fatia A · Chegada: Pastas (árvore + drill-down), Documento ("A IA leu", Distribuir para), Receber lote, Avisos.
   Só tokens de tokens.css; nenhum hex aqui. */

.nowrap { white-space: nowrap; }
.back-link { display: inline-flex; align-items: center; gap: var(--s-1); min-height: var(--tap); color: var(--muted); text-decoration: none;
  font-weight: 500; justify-self: start; margin-bottom: calc(-1 * var(--s-4)); }
.back-link:hover { color: var(--ink); }
.back-link .icon { width: 18px; height: 18px; }

/* ── Pastas ── */
.page-folders { gap: var(--s-4); }
.folders-layout { display: grid; gap: var(--s-6); align-items: start; }
.folder-tree { display: none; }
@media (min-width: 1024px) {
  .folders-layout { grid-template-columns: 272px minmax(0, 1fr); }
  .folder-tree { display: grid; gap: var(--s-1); position: sticky; top: calc(var(--topbar-h) + var(--s-6)); max-height: calc(100vh - var(--topbar-h) - var(--s-12));
    overflow-y: auto; padding-right: var(--s-2); }
  .folder-main .back-link { display: none; }
}
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { padding-left: var(--s-4); border-left: 1px solid var(--line); margin-left: var(--s-3); }
.tree-all, .tree-link { display: flex; align-items: center; gap: var(--s-2); min-height: 36px; padding: var(--s-1) var(--s-2); border-radius: var(--r-sm);
  color: var(--ink); text-decoration: none; font-size: var(--fs-sm); }
.tree-all { font-weight: 600; color: var(--muted); }
.tree-link:hover, .tree-all:hover { background: var(--surface-2); }
.tree-link[aria-current="page"], .tree-all[aria-current="page"] { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); font-weight: 600; color: var(--ink); }
.tree-num { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.tree-name { flex: 1; min-width: 0; }
.tree-count { flex: none; min-width: 22px; padding: 0 6px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--muted);
  font-size: var(--fs-xs); text-align: center; font-variant-numeric: tabular-nums; }

.folder-main { position: relative; display: grid; gap: var(--s-5); min-width: 0; }
.folder-main.is-dragging > :not(.drop-overlay) { opacity: .35; }
.drop-overlay { position: absolute; inset: 0; z-index: 5; display: grid; place-content: center; justify-items: center; gap: var(--s-2); text-align: center;
  border: 2px dashed var(--link); border-radius: var(--r-lg); background: var(--link-soft); color: var(--ink); padding: var(--s-6); pointer-events: none; }
.drop-overlay .icon { color: var(--link); }
.drop-form { display: none; }

.search-form { position: relative; display: flex; align-items: center; }
.search-form .icon { position: absolute; left: var(--s-3); color: var(--muted); pointer-events: none; }
.search-form input { width: 100%; min-height: var(--tap); padding: 0 var(--s-3) 0 40px; font: inherit; font-size: 16px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--edge); border-radius: var(--r-md); }
.search-form input:focus-visible { outline: none; border-color: var(--link); box-shadow: var(--focus); }
@media (min-width: 768px) { .search-form input { font-size: var(--fs-md); } }
#folder_results { display: grid; gap: var(--s-5); }
.section-title .count { font-weight: 500; }
.results-count { margin: 0; }

.folder-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
@media (min-width: 720px) { .folder-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .folder-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.folder-card-link { display: flex; align-items: center; gap: var(--s-3); min-height: 64px; padding: var(--s-3) var(--s-4); border: 1px solid var(--line);
  border-radius: var(--r-md); background: var(--surface); color: var(--ink); text-decoration: none; box-shadow: var(--shadow-1); }
.folder-card-link:hover { background: var(--surface-2); }
.folder-card-link > .icon { color: var(--muted); }
.folder-card-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.folder-card-name { font-weight: 600; overflow-wrap: anywhere; }
.folder-card-meta { font-size: var(--fs-sm); color: var(--muted); }
.folder-card-chevron { color: var(--muted); }
.is-sealed .folder-card-link { background: var(--surface-2); box-shadow: none; }

.doc-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.doc-row { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-top: 1px solid var(--line); }
.doc-row:first-child { border-top: 0; }
.doc-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.doc-title { font-weight: 600; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
.doc-title:hover { text-decoration: underline; }
.doc-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; font-size: var(--fs-sm); color: var(--muted); }
.doc-meta .icon { width: 14px; height: 14px; }
.doc-obsolete { text-decoration: none; }
.doc-side { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s-1); flex: none; max-width: 45%; }
@media (max-width: 640px) {
  .doc-row { flex-direction: column; gap: var(--s-2); }
  .doc-side { justify-content: flex-start; max-width: none; }
}

/* ── Documento ── */
.page-document { gap: var(--s-5); }
.doc-head .title { overflow-wrap: anywhere; }
.doc-sub { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1) var(--s-3); color: var(--muted); font-size: var(--fs-sm); }
.reading { display: grid; gap: var(--s-4); }
.ai-card { border-left: 4px solid var(--link); }
.ai-card-check { border-left-color: var(--warn); }
.ai-card .card-title .icon { color: var(--link); }
.ai-facts { grid-template-columns: 96px 1fr; }
.ai-facts dd { font-weight: 500; }
.ai-facts dd.is-doubt { color: var(--warn); }
@media (max-width: 640px) { .ai-facts { grid-template-columns: 84px 1fr; } }
.ai-deliverable { margin: 0; }
.btn-attention { border-color: var(--warn); color: var(--warn); font-weight: 600; }
.check-grid { display: grid; gap: 0 var(--s-4); }
@media (min-width: 640px) { .check-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
fieldset.field { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.field legend { padding: 0; margin-bottom: var(--s-1); }
.ai-fields { max-width: none; gap: var(--s-4); }
.person-check { align-items: center; padding: var(--s-2) 0; border-top: 1px solid var(--line); }
.person-check:first-of-type { border-top: 0; }
.person-check .who { display: grid; min-width: 0; }
.person-check .who span { font-size: var(--fs-sm); color: var(--muted); }
.person-check input:disabled ~ .who { opacity: .7; }
.distribute-form { max-width: none; gap: var(--s-4); }
/* Ação principal sempre à vista (como em Abrir contrato): prazo + Distribuir grudam no rodapé enquanto a lista rola. */
.distribute-bar { position: sticky; bottom: 0; z-index: 50; display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-2) var(--s-3);
  margin: 0 calc(-1 * var(--s-5)) calc(-1 * var(--s-5)); padding: var(--s-3) var(--s-5); background: var(--surface);
  border-top: 1px solid var(--line); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.distribute-bar .distribute-due { flex: 0 1 10rem; min-width: 8.5rem; }
.distribute-bar .btn-primary { flex: 1 1 7rem; justify-content: center; }
.distribute-bar .save-first { flex-basis: 100%; order: -1; }
@media (max-width: 1023px) { .page .distribute-bar { bottom: var(--bottomnav-h); } }
.save-first { display: none; }
.reading:has(.ai-form) .distribute { opacity: .5; }
.reading:has(.ai-form) .distribute .save-first { display: block; color: var(--warn); }
.reading:has(.ai-form) .distribute button[type="submit"] { pointer-events: none; }
.doc-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.doc-actions .hint { flex-basis: 100%; }
.doc-tab-panel { display: grid; gap: var(--s-3); }
.drawer-body .doc-sub { margin-top: calc(-1 * var(--s-2)); }

/* ── Receber lote ── */
.upload-form { max-width: none; }
.dropzone { display: grid; justify-items: center; gap: var(--s-2); text-align: center; padding: var(--s-8) var(--s-4); border: 2px dashed var(--edge);
  border-radius: var(--r-lg); background: var(--surface); cursor: pointer; font-size: var(--fs-md) !important; }
.dropzone .icon { color: var(--muted); }
.dropzone.is-over, .upload-form.is-dragging .dropzone { border-color: var(--link); background: var(--link-soft); }
.upload-form .field { position: relative; }
.dropzone-input { position: absolute; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip: rect(0 0 0 0); }
.dropzone-input:focus-visible + * { outline: none; }
.upload-form:has(.dropzone-input:focus-visible) .dropzone { box-shadow: var(--focus); }
.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-1); font-size: var(--fs-sm); }
.file-list li { padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); background: var(--surface-2); overflow-wrap: anywhere; }
.file-list li.is-bad { background: var(--bad-soft); color: var(--bad); }

.batch { display: grid; gap: var(--s-4); }
.batch-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.batch-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-3); }
@media (min-width: 900px) { .batch-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.batch-card { border-left: 4px solid var(--link); align-content: start; }
.batch-card:has(.card-link:hover) { background: var(--surface-2); }
.batch-card .card-actions .btn, .batch-card .why { position: relative; z-index: 1; }
.batch-card .card-actions span.btn { z-index: auto; pointer-events: none; }
.batch-card .hint .icon { display: inline; width: 16px; height: 16px; vertical-align: -3px; margin-right: 4px; color: var(--ok); }

/* ── Avisos ── */
.notices .list-item { align-items: center; }
.notice-when { color: var(--muted); font-weight: 400; white-space: nowrap; }
.notice.is-unread::before { left: -14px; top: 50%; }
.notices .list-item.is-unread .list-title { font-weight: 600; }
.notices { padding-left: var(--s-4); }
.see-all { justify-self: start; }
.received-item .list-main > span:last-child .pill { margin-top: var(--s-1); }
.sent-to { display: block; overflow-wrap: anywhere; }
.sent-sentence { min-width: 0; }
.sent-channels { display: flex; flex-wrap: wrap; gap: var(--s-1); }
@media (min-width: 641px) { #mensagens { table-layout: fixed; } #mensagens th:nth-child(1) { width: 24%; } #mensagens th:nth-child(2) { width: 120px; } #mensagens th:nth-child(4) { width: 110px; } .sent-channels { display: table-cell; } .sent-channels .pill { margin: 2px 0; } }
@media (max-width: 640px) { #mensagens .sent-sentence { grid-column: 1 / -1; } }

/* Ajustes da revisão por prints */
.doc-row, .folder-card, .list-item, .batch-card, .file-list li, .tree li { max-width: none; }
@media (max-width: 1023px) { .hide-mobile { display: none; } }
.why summary { cursor: pointer; color: var(--muted); font-size: var(--fs-sm); min-height: 32px; display: flex; align-items: center; }
.why p { margin-top: var(--s-1); }

/* Documento: "Distribuído para" com uma linha por pessoa e as tarefas dela por baixo */
.person-tasks { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.person-tasks > li { display: block; }

/* Caixas do Databook (6.1.N): nome do entregável em destaque, "LID-ENT-001 · Rev 0 · data" em cinza embaixo */
.folder-card-name .code-ref { display: block; font-weight: 400; }
.folder-card-name .code-ref { font-size: var(--fs-sm); margin-top: 2px; }
.title .code-ref { font-size: var(--fs-sm); font-weight: 400; white-space: nowrap; }

/* Avisos: "Ver mensagens enviadas ›" é botão secundário, na mesma linha do "Marcar todos como lidos" */
.notif-actions { gap: var(--s-2); }
.notif-actions .btn { padding-left: var(--s-3); padding-right: var(--s-3); }
@media (max-width: 640px) {
  .notif-actions { flex-wrap: nowrap; width: 100%; }
  .notif-actions > * { flex: 1 1 0; min-width: 0; }
  .notif-actions .btn { width: 100%; justify-content: center; font-size: var(--fs-sm); white-space: normal; text-align: center; line-height: 1.2; }
  .notif-actions .button-to { display: flex; }
}
