/* Design tokens (diretrizes-ux-ui-multiplataforma §1.3): semantic colors, spacing scale
   4/8/12/16/24/32/48px, one radius, one shadow. The definitive component base for the product
   is a D1 decision; these tokens are the contract every screen builds on meanwhile. */
:root {
    color-scheme: light;
    --brand: #1f3a5f;
    --brand-contrast: #ffffff;
    /* --brand doubles as the topbar background, so it must go *darker* in dark mode while text
       accents must go *lighter*. --brand-text is the accent-on-surface role: links, focus rings
       and emphasis that have to clear WCAG AA contrast (diretrizes §1.6) in both themes. */
    --brand-text: #1f3a5f;
    --brand-accent: #b08d4f;
    --surface: #f5f6f8;
    --card: #ffffff;
    --text: #22272e;
    --muted: #5d6672;
    --border: #cbd2dc;
    --danger: #b3261e;
    --warning-bg: #fdf3d7;
    --warning-border: #e0c36b;
    --overdue-bg: #fbe1df;
    --overdue-border: #c94b3f;
    --topbar-link: #d8e0ec;
    --diff-added: #2e7d32;
    --diff-removed: #c62828;
    /* conformidade-visual-prototipo-redesign, Requisito 56: fundo de baixa opacidade (mesma técnica
       alpha de --sidebar-active-bg) para o círculo de ícone de confirmação em Verify/Index. */
    --diff-added-bg: rgb(46 125 50 / 12%);
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --radius: 8px;
    --shadow: 0 1px 3px rgb(0 0 0 / 12%);
    --sidebar-active-bg: rgb(31 58 95 / 8%);
}

/* Escuro é opt-in via alternância manual (theme-toggle.js seta data-theme no <html>), nunca
   automático pelo SO — claro é o padrão do produto independente de prefers-color-scheme. */
:root[data-theme="dark"] {
    color-scheme: dark;
    --brand: #16283f;
    --brand-text: #9dc0ea;
    --surface: #14171c;
    --card: #1e232b;
    --text: #e6e9ee;
    --muted: #9aa4b1;
    --border: #3a424e;
    --danger: #ff8a80;
    --warning-bg: #3a3320;
    --warning-border: #8a7433;
    --overdue-bg: #3d1f1c;
    --overdue-border: #e08277;
    --topbar-link: #c3cede;
    --diff-added: #6dbb70;
    --diff-removed: #ff8a80;
    --diff-added-bg: rgb(109 187 112 / 18%);
    --shadow: 0 1px 3px rgb(0 0 0 / 40%);
    --sidebar-active-bg: rgb(157 192 234 / 14%);
}

* {
    box-sizing: border-box;
}

/* conformidade-visual-prototipo-redesign, Requisito 57: único <hr> do produto (Verify/Index) usava o
   estilo "inset" padrão do navegador, sem tratamento de dark mode. */
hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: var(--space-4) 0;
}

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, sans-serif;
    background: var(--surface);
    color: var(--text);
}

/* TODO item 261: without wrapping, the links of a signed-in topbar made a 390 px page 1,089 px wide. */
.topbar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-items: center;
    justify-content: space-between;
    background: var(--brand);
    color: var(--brand-contrast);
    padding: var(--space-2) var(--space-5);
}

.brand {
    font-weight: 600;
    letter-spacing: 0.02em;
}

.topbar-user {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: var(--space-3);
    font-size: 0.9rem;
}

.inline-form {
    display: inline;
}

/* navegacao-lateral-persistente, achado 3: toggle de tema com ícone de linha (sem emoji) —
   pill bordeada sobre o fundo escuro da topbar, mesmo desenho do protótipo. */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    flex-shrink: 0;
    background: none;
    border: 1px solid rgb(255 255 255 / 35%);
    color: var(--topbar-link);
    border-radius: 999px;
    padding: 6px var(--space-3);
    font: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    min-height: 32px;
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--brand-text);
    outline-offset: 2px;
}

/* --topbar-link (~1.3:1 on a light surface) is a light-on-dark accent designed for the dark topbar/
   .undo-toast backgrounds only — every other surface needs the contextual override below. */
.link-button {
    background: none;
    border: none;
    color: var(--topbar-link);
    cursor: pointer;
    text-decoration: underline;
    font: inherit;
    /* Minimum effective click area on desktop/web: ~32px (diretrizes §1.2, Lei de Fitts). */
    padding: var(--space-2) var(--space-3);
    min-height: 32px;
}

/* conformidade-visual-prototipo-redesign, Requisito 3: .link-button on a light surface (.card or any
   .banner, including the "Tentar novamente" retry button inside .banner.warning) needs a dark-on-light
   accent instead of --topbar-link. var(--brand-text) already clears WCAG AA (≥4.5:1) against .card and
   .banner.warning in both themes — verified: light ~11.5:1/~10.4:1, dark ~8.4:1/~6.7:1. Does not affect
   .undo-toast .link-button (disjoint context, preserved below) nor .move-buttons button (higher
   specificity already overrides via `color: inherit`). */
.card .link-button,
.banner .link-button {
    color: var(--brand-text);
}

/* margin horizontal 0 (não auto): .content é item de um flex container coluna (.app-shell-main) —
   margem auto nas laterais anula align-items:stretch (a especificação de flexbox dá prioridade à
   margem automática sobre o stretch), fazendo o elemento encolher para o tamanho do conteúdo em
   vez de ocupar a largura disponível, mesmo sem max-width. */
.content {
    margin: var(--space-6) 0;
    padding: 0 var(--space-4);
}

/* .content deixou de ter max-width fixo (60rem) para grades/tabelas/dashboards aproveitarem toda
   a largura da tela. Texto corrido e formulários verticais (rótulo empilhado sobre campo — ver
   "form label"/"form input" abaixo) continuam com uma largura confortável de leitura: um <form>
   que envolve uma <table> (ex.: barra de filtro por coluna, filtros-e-ordenacao-em-tabelas.md) ou
   já é compacto (.inline-form/.inline-form-group) fica de fora do limite. */
.content p,
.content form:not(.inline-form):not(.inline-form-group):not(:has(table)) {
    max-width: 40rem;
}

.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: var(--space-5) var(--space-6);
}

.login-card {
    max-width: 24rem;
    margin: var(--space-6) auto;
}

.card h1 {
    margin-top: 0;
    color: var(--brand);
}

:root[data-theme="dark"] .card h1 {
    color: var(--text);
}

/* conformidade-visual-prototipo-redesign, Requisito 5: telas sem sidebar/sessão (Account/Login,
   Verify/Index, DistributionAccess/Index e /Expired, Account/Denied) — o protótipo centraliza um card
   estreito no viewport inteiro, em vez do fluxo padrão de .content (topo, max-width:60rem). Envolver a
   raiz da tela em .standalone-viewport e trocar .card/.login-card por .standalone-card; a subtração
   aproximada de 4rem cobre a altura real da .topbar nas duas densidades usadas no produto. */
.standalone-viewport {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 4rem);
}

.standalone-card {
    width: 100%;
    max-width: 26rem;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: var(--space-5) var(--space-6);
}

.standalone-card h1 {
    margin-top: 0;
    color: var(--brand);
}

:root[data-theme="dark"] .standalone-card h1 {
    color: var(--text);
}

.muted {
    color: var(--muted);
}

.facts {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: var(--space-1) var(--space-4);
}

.facts dt {
    color: var(--muted);
}

.facts dd {
    margin: 0;
}

/* conformidade-visual-prototipo-redesign, Requisito 58: variante em caixa de destaque para dados de
   identificação (hoje só Verify/Index) — classe irmã em vez de alterar .facts base, que Requisito 15
   também vai reaproveitar dentro de .detail-layout-aside sem necessariamente querer a caixa. Combinar
   como <dl class="facts facts-box">. */
.facts-box {
    background: var(--surface);
    padding: var(--space-4);
    border-radius: var(--radius);
}

form label {
    display: block;
    margin: var(--space-4) 0 var(--space-1);
    font-size: 0.9rem;
}

/* conformidade-visual-prototipo-redesign, Requisito 11: select/textarea nunca tinham estilo (chrome
   nativo do navegador) e checkbox/radio herdavam indevidamente a caixa de texto full-width abaixo. */
form input,
form select,
form textarea {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    background: var(--card);
    color: var(--text);
}

form textarea {
    resize: vertical;
    min-height: 6rem;
}

form input[type="checkbox"],
form input[type="radio"] {
    width: auto;
    padding: 0;
    border: none;
    accent-color: var(--brand);
}

button.primary {
    margin-top: var(--space-5);
    width: 100%;
    padding: var(--space-3);
    background: var(--brand);
    color: var(--brand-contrast);
    border: none;
    border-radius: 6px;
    font: inherit;
    cursor: pointer;
    min-height: 40px;
}

button.primary:hover {
    filter: brightness(1.1);
}

button.primary:disabled {
    opacity: 0.7;
    cursor: progress;
}

.validation-summary {
    color: var(--danger);
    font-size: 0.9rem;
}

.validation-summary ul {
    margin: var(--space-2) 0;
    padding-left: 1.2rem;
}

/* asp-validation-summary="All" renders its empty list even with no error. */
.validation-summary-valid {
    display: none;
}

/* Field-bound validation error (diretrizes §3.3): shown under its own input, not only in a
   generic summary at the top. */
.field-error {
    display: block;
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: var(--space-1);
    min-height: 1em;
}

.banner {
    border-radius: var(--radius);
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-4);
}

.banner.warning {
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
}

/* conformidade-visual-prototipo-redesign, Requisito 22: ifc-upload-conversion.js já aplica
   className="banner error" para bloqueio/erro; reaproveita os tokens de dano já existentes na
   paleta (--overdue-bg/--overdue-border, o par vermelho do produto) em vez de criar tokens novos. */
.banner.error {
    background: var(--overdue-bg);
    border: 1px solid var(--overdue-border);
}

/* D1 core-document screens (spec d1-nucleo-documental): listings, matrix and status badges. */
/* flex-wrap (TODO item 261): at 390 px the title and the actions beside it pushed the page wider. */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

.page-header h1 {
    margin: 0;
    color: var(--brand);
}

:root[data-theme="dark"] .page-header h1 {
    color: var(--text);
}

/* conformidade-visual-prototipo-redesign, Requisito 7: inline-flex + gap (mesmo padrão de
   .theme-toggle/.sidebar-nav-item) para alinhar um SVG opcional antes do texto — comportamento
   idêntico a inline-block para o caso já existente de texto puro (nenhum HTML atual muda). */
.primary-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--brand);
    color: var(--brand-contrast);
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    min-height: 32px;
    line-height: 1.5rem;
}

.primary-link:hover {
    filter: brightness(1.1);
}

/* Lower-emphasis navigation/shortcut action next to a .primary-link (UX/UI retrofit, Requirement
   16) — Von Restorff applied only to distinguish the primary action from secondary ones, never to
   mutually-exclusive workflow decisions (see Documents/Details, left neutral by design). */
.secondary-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    min-height: 32px;
    line-height: 1.5rem;
}

.secondary-link:hover {
    background: var(--surface);
}

.danger-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: transparent;
    color: var(--danger, #b3261e);
    border: 1px solid var(--danger, #b3261e);
    border-radius: 6px;
    font-weight: 600;
    min-height: 32px;
    line-height: 1.5rem;
    cursor: pointer;
}

.danger-link:hover {
    background: var(--danger, #b3261e);
    color: var(--brand-contrast);
}

/* conformidade-visual-prototipo-redesign, Requisito 39: ação de configuração pouco frequente
   ("Criar categoria" em IssueCategories/Index) com ênfase propositalmente baixa — borda tracejada,
   cor muted, em vez de .primary-link. */
.subtle-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: transparent;
    color: var(--muted);
    border: 1px dashed var(--border);
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    min-height: 32px;
    line-height: 1.5rem;
}

.subtle-link:hover,
.subtle-link:focus-visible {
    color: var(--brand-text);
    border-color: var(--brand-text);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--border);
}

.data-table th {
    color: var(--muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.data-table tbody tr:nth-child(even) {
    background: var(--surface);
}

.badge {
    display: inline-block;
    padding: 2px var(--space-2);
    border-radius: 999px;
    font-size: 0.8rem;
    background: var(--warning-bg);
    color: var(--text);
    border: 1px solid var(--warning-border);
}

.badge.muted {
    background: transparent;
    border-color: var(--border);
    color: var(--muted);
}

/* Success/"current" state (D6, Requirement 10) — the only badge variant not already covered by the
   warning-toned base .badge (used for "obsolete") or the neutral .badge.muted. */
.badge.current {
    background: transparent;
    border-color: var(--diff-added);
    color: var(--diff-added);
}

/* conformidade-visual-prototipo-redesign, Requisito 12 (avaliação de "Perguntas em aberto") e
   Requisito 14 (status "recusado"/"falhou" de distribuição): variante vermelha, mesmo padrão
   transparente de .badge.current — reaproveita --danger, já existente, sem precisar de um par
   --danger-bg/--danger-border novo. */
.badge.danger {
    background: transparent;
    border-color: var(--danger);
    color: var(--danger);
}

/* busca-profunda-em-desenhos-dwg, Requisito 5: indicador visual próprio para um resultado de busca
   casado pelo conteúdo extraído do arquivo (desenho DWG ou modelo IFC) — mesmo padrão transparente de
   .badge.current/.badge.danger, com --brand-text para não ser confundido com sucesso (verde) nem
   alerta (vermelho). Renomeado de .badge.drawing por busca-profunda-em-modelos-ifc, Requisito 1. */
.badge.extracted-content {
    background: transparent;
    border-color: var(--brand-text);
    color: var(--brand-text);
}

/* Grid-editable Discipline × Group/Company permission matrix (RF-02-04). */
.permission-matrix {
    width: 100%;
    border-collapse: collapse;
}

.permission-matrix th,
.permission-matrix td {
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border);
    text-align: center;
}

.permission-matrix th:first-child,
.permission-matrix td:first-child {
    text-align: left;
}

/* conformidade-visual-prototipo-redesign, Requisito 48: reaproveita a aparência de .data-table
   (th mudo/uppercase, zebra-striping) sem exigir mudança de HTML — a matriz mantém a borda sólida
   por célula (estilo planilha é intencional aqui, diferente de .data-table). */
.permission-matrix th {
    color: var(--muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.permission-matrix tbody tr:nth-child(even) {
    background: var(--surface);
}

.section-title {
    margin-top: var(--space-6);
    margin-bottom: var(--space-3);
    color: var(--brand);
}

:root[data-theme="dark"] .section-title {
    color: var(--text);
}

.inline-form-group {
    display: flex;
    gap: var(--space-3);
    align-items: end;
    flex-wrap: wrap;
    margin-bottom: var(--space-5);
}

.inline-form-group label {
    margin: 0 0 var(--space-1);
}

.inline-form-group button.primary {
    margin-top: 0;
    width: auto;
    padding: var(--space-2) var(--space-4);
}

/* D3 — apontamentos: filtros, edição em massa, badge de atraso e o viewer PDF com pinos. */
.filter-form,
.mass-edit {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-items: center;
    margin-bottom: var(--space-4);
}

/* Separa visualmente os campos "quem/onde" dos campos "quando/ordenar" dentro do mesmo
   <form> de filtro (identidade visual, Requisito 4) — sem quebrar o submit único. */
.filter-form-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-items: center;
    padding-right: var(--space-4);
    border-right: 1px solid var(--border);
}

.filter-form-group:last-of-type {
    padding-right: 0;
    border-right: none;
}

/* A filter input needs its own visible caption: two adjacent "dd/mm/aaaa" boxes are
   indistinguishable without one, and the global `form input { width: 100% }` would otherwise
   stretch each filter across the whole row. */
.filter-field {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    max-width: 100%;
}

.filter-field > label {
    margin: 0;
    font-size: 0.8rem;
    color: var(--muted);
}

.filter-field > input,
.filter-field > select {
    width: auto;
    min-width: 10rem;
    /* A select grows to its longest option ("Name (e-mail)" in the person picker) and pushed a
       390 px page sideways. */
    max-width: 100%;
}

.mass-edit {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-3);
    margin-top: var(--space-4);
}

.badge.overdue {
    background: var(--overdue-bg);
    border: 1px solid var(--overdue-border);
    color: var(--text);
}

.stacked-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    max-width: 560px;
}

/* conformidade-visual-prototipo-redesign, Requisito 34: subgrupo de 2 colunas dentro de
   .stacked-form (ex.: Categoria/Prioridade/Local/Visibilidade em Issues/Create e Edit), mantendo
   Título/Descrição fora dela em largura total. */
.stacked-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
}

@media (max-width: 640px) {
    .stacked-form-grid {
        grid-template-columns: 1fr;
    }
}

/* conformidade-visual-prototipo-redesign, Requisito 44: fieldset nu (chrome padrão do navegador) em
   Distributions/Create e Issues/Create. */
.field-group {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-4);
}

.field-group > legend {
    padding: 0 var(--space-2);
    font-weight: 600;
    color: var(--text);
}

.comment-list {
    list-style: none;
    padding-left: 0;
}

.comment-list > li {
    border-top: 1px solid var(--border);
    padding: var(--space-2) 0;
}

.pdf-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    align-items: center;
    overflow-x: auto;
}

.pdf-container.pin-mode .pdf-page {
    cursor: crosshair;
}

.pdf-page {
    position: relative;
    box-shadow: var(--shadow);
}

.issue-pin {
    position: absolute;
    transform: translate(-50%, -100%);
    font-size: 20px;
    text-decoration: none;
}

.dwg-container {
    position: relative;
    overflow-x: auto;
}

.dwg-container.pin-mode {
    cursor: crosshair;
}

/* TODO item 269 (a): DwgViewer only — the SVG and its pins move together inside .dwg-stage. */
.dwg-zoomable {
    /* The drawing is paper in both themes: on the dark card the monochrome strokes vanished. */
    background: #ffffff;
    height: 70vh;
    overflow: hidden;
    touch-action: none;
    cursor: grab;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.dwg-zoomable.dragging {
    cursor: grabbing;
}

.dwg-stage {
    position: relative;
    transform-origin: 0 0;
}

.dwg-stage svg {
    display: block;
}

/* TODO item 269 (b): monochrome by default, as the drawing plots — the AutoCAD screen colors
   (yellow, white) are drawn for a dark background. A filter on the <svg> itself, because it acts
   on the rendered result, block content included; pins sit outside it. */
.dwg-mono .dwg-stage svg {
    filter: brightness(0);
}

.dwg-zoomable:focus-visible {
    outline: 2px solid var(--brand-text);
    outline-offset: 2px;
}

/* verificacao-carimbo-vs-metadados, Requisito 11: retângulo de seleção da calibração da área do
   carimbo — mesma técnica de posicionamento percentual absoluto do .issue-pin, sobre o mesmo
   .dwg-container reaproveitado (arraste em vez de clique único). */
.titleblock-area-selection {
    position: absolute;
    display: none;
    border: 2px dashed var(--brand-text);
    background: rgb(31 58 95 / 15%);
    pointer-events: none;
}

.dwg-container svg {
    max-width: 100%;
    height: auto;
}

.dwg-compare-container {
    position: relative;
    overflow-x: auto;
}

.dwg-compare-layer {
    display: block;
    max-width: 100%;
    height: auto;
    mix-blend-mode: multiply;
}

.dwg-compare-layer-a {
    filter: invert(13%) sepia(89%) saturate(4429%) hue-rotate(357deg) brightness(88%) contrast(96%);
}

.dwg-compare-layer-b {
    position: absolute;
    top: 0;
    left: 0;
    filter: invert(39%) sepia(66%) saturate(722%) hue-rotate(88deg) brightness(93%) contrast(88%);
}

/* Non-blocking undo toast (UX/UI retrofit, Requirement 4) — minimal hand-written component, no
   external toast library, consistent with the Restrição against new JS dependencies. */
.undo-toast {
    position: fixed;
    bottom: var(--space-5);
    right: var(--space-5);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    background: var(--text);
    color: var(--card);
    border-radius: var(--radius);
    padding: var(--space-3) var(--space-4);
    box-shadow: var(--shadow);
    z-index: 1000;
}

.undo-toast .link-button {
    color: var(--topbar-link);
}

/* Loading placeholder for the 3D/2D viewers (UX/UI retrofit, Requirements 6-7) — an approximate
   silhouette of the viewport, shown while the model/SVG is fetched and parsed, replaced by the real
   content (or the error banner) once the load settles. */
@keyframes viewer-skeleton-pulse {
    0%, 100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

.viewer-skeleton {
    position: absolute;
    inset: 0;
    min-height: 400px;
    background: var(--border);
    border-radius: var(--radius);
    animation: viewer-skeleton-pulse 1.4s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
    .viewer-skeleton {
        animation: none;
    }
}

/* Traditional numbered pagination (UX/UI retrofit, Requirements 14-15), shared by every paginated
   listing via the _Pager partial. */
.pager {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-4);
}

.pager a,
.pager-current {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 32px;
    padding: var(--space-1) var(--space-2);
    border-radius: 6px;
    text-decoration: none;
}

.pager a {
    color: var(--brand);
    border: 1px solid var(--border);
}

.pager a:hover {
    background: var(--surface);
}

.pager-current {
    background: var(--brand);
    color: var(--brand-contrast);
    font-weight: 600;
}

:root[data-theme="dark"] .pager a {
    color: var(--text);
}

/* Filtros e ordenação em tabelas — cabeçalho clicável (_SortableHeader) e linha de filtro por
   coluna (_ColumnFilterText/_ColumnFilterSelect) dentro do <thead>, compartilhados pelas 4 tabelas
   principais (Requisitos 1-2, 12-13). */
.sortable-header {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    color: inherit;
    text-transform: inherit;
    letter-spacing: inherit;
    cursor: pointer;
}

.sortable-header:hover,
.sortable-header:focus-visible {
    color: var(--brand-text);
}

.sortable-header:focus-visible {
    outline: 2px solid var(--brand-text);
    outline-offset: 2px;
}

.sort-arrow {
    font-size: 0.7rem;
}

.data-table .column-filter-row th,
.data-table .column-filter-row td.column-filter {
    padding-top: 0;
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--border);
}

.column-filter input[type="text"],
.column-filter input[type="number"],
.column-filter select {
    width: 100%;
    font-size: 0.85rem;
    padding: var(--space-1) var(--space-2);
}

/* Narrow columns (Fase, Nível, Local) squeezed their select down to "F▾"/"Ní▾", hiding which
   column the filter belongs to. A floor width keeps the caption readable — paired with
   .table-scroll below so the overflow scrolls inside the table, never the whole page. */
.column-filter select {
    min-width: 7.5rem;
}

.table-scroll {
    overflow-x: auto;
}

/* Tree-view-documentos — botões ↑/↓ de reordenação (_MoveButtons, Requisitos 12-13) e as
   sublistas de catálogo (DocumentFolders/Subdisciplines por Discipline, Levels por Location) que
   ganharam um item por linha para caber o botão. */
.move-buttons {
    display: inline-flex;
    gap: var(--space-1);
    margin: 0;
}

.move-buttons button {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0 var(--space-1);
    cursor: pointer;
    color: inherit;
    font: inherit;
}

.move-buttons button:disabled {
    opacity: 0.35;
    cursor: default;
}

.move-buttons button:not(:disabled):hover,
.move-buttons button:not(:disabled):focus-visible {
    color: var(--brand-text);
    border-color: var(--brand-text);
}

.catalog-sublist {
    list-style: none;
    margin: 0 0 var(--space-2);
    padding: 0;
}

.catalog-sublist li {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) 0;
}

/* Tree-view-documentos — árvore de navegação/filtro lateral de Documents/Index (Requisitos 1-2, 17). */
.document-index-layout {
    display: grid;
    /* minmax(0, 1fr), not 1fr: a 1fr track never shrinks below its content, so the wide table
       stretched the page to 2,158 px instead of scrolling inside its .table-scroll (item 261). */
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
    gap: var(--space-4);
    align-items: start;
}

@media (max-width: 900px) {
    .document-index-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

.document-tree-panel {
    position: sticky;
    top: var(--space-4);
    max-height: calc(100vh - var(--space-6));
    overflow-y: auto;
}

.document-tree-nav ul[role="tree"],
.document-tree-nav ul[role="group"] {
    list-style: none;
    margin: 0;
    padding-left: var(--space-4);
}

.document-tree-nav ul[role="tree"] {
    padding-left: 0;
}

.tree-node-row {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) 0;
}

.tree-node[role="treeitem"]:focus {
    outline: none;
}

.tree-node[role="treeitem"]:focus > .tree-node-row {
    outline: 2px solid var(--brand-text);
    outline-offset: 2px;
    border-radius: 4px;
}

.tree-toggle {
    background: none;
    border: none;
    padding: 0;
    width: 1.2em;
    cursor: pointer;
    color: var(--muted);
    font-size: 0.7rem;
}

.tree-toggle-spacer {
    display: inline-block;
    width: 1.2em;
}

.tree-node-label {
    text-decoration: none;
    color: var(--text);
}

.tree-node-label:hover,
.tree-node-label:focus-visible {
    color: var(--brand-text);
    text-decoration: underline;
}

.tree-node-root > .tree-node-row .tree-node-label {
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    cursor: default;
}

/* conformidade-visual-prototipo-redesign, Requisito 25: contagem de documentos por disciplina
   (ex. "Arquitetura 62"), alinhada à direita dentro de .tree-node-row (flex) via margin-left:auto. */
.tree-node-count {
    margin-left: auto;
    color: var(--muted);
    font-size: 0.8rem;
}

/* indicadores-portfolio-projects-index: scope selector, summary KPIs, storage indicator and donut charts on Projects/Index. */
.scope-selector-form {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-5);
}

.scope-selector-form select {
    padding: var(--space-1) var(--space-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--card);
    color: var(--text);
}

.portfolio-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}

.portfolio-kpi {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding: var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.portfolio-kpi-value {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--brand);
}

/* --brand is the topbar *background* in dark mode, so it fails contrast as text on --card
   (same reason .card h1 falls back to --text above). The KPI number is the whole point of
   the tile — it has to clear WCAG AA (diretrizes §1.6). */
:root[data-theme="dark"] .portfolio-kpi-value {
    color: var(--text);
}

.portfolio-kpi-value.muted {
    font-size: 1rem;
    font-weight: 400;
    color: var(--muted);
}

.portfolio-kpi-label {
    color: var(--muted);
    font-size: 0.875rem;
}

.portfolio-storage-kpi.portfolio-storage-warning {
    background: var(--warning-bg);
    border-color: var(--warning-border);
}

.portfolio-storage-bar {
    height: 8px;
    border-radius: 4px;
    background: var(--surface);
    overflow: hidden;
    margin-top: var(--space-1);
}

.portfolio-storage-bar-fill {
    height: 100%;
    background: var(--brand);
}

.portfolio-storage-warning .portfolio-storage-bar-fill {
    background: var(--warning-border);
}

/* navegacao-lateral-persistente, achado 5b: mesma barra/preenchimento do card de armazenamento
   acima, em miniatura, dentro da célula "Armazenamento" da tabela de projetos — o preenchimento
   é sempre a % da cota TOTAL da empresa, nunca uma escala independente por projeto. */
.project-storage-cell {
    min-width: 120px;
}

.project-storage-cell .portfolio-storage-bar {
    margin-top: 0;
    margin-bottom: 3px;
}

.project-storage-cell-label {
    font-size: 0.75rem;
    color: var(--muted);
}

.portfolio-chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: var(--space-5);
}

.donut-chart-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.donut-chart {
    width: 140px;
    height: 140px;
    border-radius: 50%;
}

.donut-legend {
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100%;
    font-size: 0.875rem;
}

.donut-legend li {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) 0;
}

.donut-legend a {
    color: var(--text);
    text-decoration: none;
}

.donut-legend a:hover,
.donut-legend a:focus-visible {
    color: var(--brand-text);
    text-decoration: underline;
}

.donut-legend-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* painel-do-projeto: Project Dashboard (Projects/Details) — collapsible sections, clickable KPI
   cards with a semantic accent stripe (diretrizes §1.5: color is never the only signal — every
   card also carries its status label as text), funnel, Discipline x Status grid, activity feed. */
.dashboard-section {
    margin-bottom: var(--space-6);
}

.dashboard-section-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    padding: var(--space-2) 0;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-4);
    cursor: pointer;
    font: inherit;
    text-align: left;
    color: var(--text);
    min-height: 32px;
}

.dashboard-section-header:hover {
    color: var(--brand-text);
}

.dashboard-section-header:focus-visible {
    outline: 2px solid var(--brand-text);
    outline-offset: 2px;
}

.dashboard-section-header h2 {
    margin: 0;
    font-size: 1.1rem;
    color: inherit;
}

.dashboard-section-chevron {
    display: inline-block;
    transition: transform 0.15s ease;
}

.dashboard-section-header[aria-expanded="false"] .dashboard-section-chevron {
    transform: rotate(-90deg);
}

.dashboard-section-header[aria-expanded="false"] + .dashboard-section-body {
    display: none;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.kpi-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border);
    border-left: 4px solid var(--kpi-accent, var(--border));
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    min-height: 32px;
}

.kpi-card:hover,
.kpi-card:focus-visible {
    background: var(--surface);
    outline: 2px solid var(--brand-text);
    outline-offset: 2px;
}

.kpi-card-value {
    font-size: 1.5rem;
    font-weight: 600;
}

.kpi-card-label {
    color: var(--muted);
    font-size: 0.85rem;
}

.funnel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--space-2);
    align-items: stretch;
    margin-bottom: var(--space-4);
}

.funnel-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    padding: var(--space-4) var(--space-2);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    text-align: center;
    min-height: 32px;
    position: relative;
}

.funnel-step:hover,
.funnel-step:focus-visible {
    border-color: var(--brand-text);
    outline: 2px solid var(--brand-text);
    outline-offset: 2px;
}

.funnel-step:not(:last-child)::after {
    content: "\2192";
    position: absolute;
    right: calc(-1 * var(--space-2) - 4px);
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
}

.funnel-step-value {
    font-size: 1.4rem;
    font-weight: 600;
}

.funnel-step-label {
    color: var(--muted);
    font-size: 0.8rem;
}

/* navegacao-lateral-persistente, achado 6: barra empilhada por disciplina no lugar da antiga grade
   numérica — mesmas 3 cores/legenda literais do protótipo do handoff (Aberta/Em andamento/Concluída). */
.discipline-issue-chart {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.discipline-issue-chart-legend {
    display: flex;
    gap: var(--space-4);
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: var(--space-1);
}

.discipline-issue-chart-legend li {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.discipline-issue-chart-legend-swatch {
    display: inline-block;
    width: 11px;
    height: 11px;
    border-radius: 3px;
}

.discipline-issue-bar-row {
    display: grid;
    grid-template-columns: 140px 1fr 90px;
    align-items: center;
    gap: var(--space-3);
}

.discipline-issue-bar-name {
    font-size: 0.88rem;
}

.discipline-issue-bar-track {
    display: flex;
    height: 24px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--surface);
}

.discipline-issue-bar-segment-open {
    background: var(--warning-border);
}

.discipline-issue-bar-segment-inprogress {
    background: var(--brand-text);
}

.discipline-issue-bar-segment-done {
    background: var(--diff-added);
}

/* TODO item 264: each segment links to Issues/Index filtered by its discipline and bucket. */
.discipline-issue-bar-track a {
    display: block;
}

.discipline-issue-bar-track a:focus-visible {
    outline: 2px solid var(--brand-text);
    outline-offset: -2px;
}

.discipline-issue-bar-counts {
    font-size: 0.78rem;
    color: var(--muted);
    text-align: right;
    white-space: nowrap;
}

.activity-feed {
    list-style: none;
    margin: 0;
    padding: 0;
}

.activity-feed li {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border);
}

.activity-feed li:last-child {
    border-bottom: none;
}

.activity-feed-text {
    flex: 1;
}

.activity-feed-time {
    color: var(--muted);
    font-size: 0.8rem;
    white-space: nowrap;
}

/* navegacao-breadcrumb-e-historico: hierarchical breadcrumb (diretrizes §3.2 — mandatory at depth >=3)
   and the "<- Voltar" button (native history.back(), diretrizes §1.1 "controle e liberdade"). Colors
   match the prototype's own breadcrumb (brand/muted/border) via the product's real tokens, not the
   prototype's literal hex — the prototype itself is cited as a NEW proposal, not a fidelity source
   (diretrizes §3.7: real <nav>/<button>, never the prototype's <div onClick>). */
.breadcrumb {
    margin-bottom: var(--space-3);
    font-size: 0.85rem;
    color: var(--muted);
}

.breadcrumb-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1);
    list-style: none;
    margin: 0;
    padding: 0;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.breadcrumb-item:not(:last-child)::after {
    content: "/";
    color: var(--border);
    margin-left: var(--space-1);
}

.breadcrumb-item a {
    color: var(--brand-text);
    text-decoration: underline;
}

.breadcrumb-item a:hover,
.breadcrumb-item a:focus-visible {
    color: var(--muted);
}

.breadcrumb-item span[aria-current="page"] {
    color: var(--text);
    font-weight: 600;
}

.breadcrumb-item-ellipsis {
    display: none;
}

.breadcrumb-expand {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    padding: 0 var(--space-1);
    min-height: 32px;
    min-width: 32px;
}

.breadcrumb-expand:hover,
.breadcrumb-expand:focus-visible {
    color: var(--brand-text);
}

/* Requirement 11: below this width, middle levels collapse behind the "…" toggle. */
@media (max-width: 640px) {
    .breadcrumb-item-middle {
        display: none;
    }

    .breadcrumb-item-middle.breadcrumb-item-expanded {
        display: flex;
    }

    .breadcrumb-item-ellipsis {
        display: flex;
    }
}

.back-button {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-4);
    background: var(--card);
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 999px;
    font: inherit;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    min-height: 32px;
}

.back-button:hover,
.back-button:focus-visible {
    color: var(--brand-text);
    border-color: var(--brand-text);
}

.page-header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.settings-list {
    list-style: none;
    margin: var(--space-5) 0 0;
    padding: 0;
    display: grid;
    gap: var(--space-4);
}

.settings-list > li {
    padding: var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.settings-list > li > p {
    margin: var(--space-1) 0 0;
    font-size: 0.9rem;
}

/* navegacao-lateral-persistente: sidebar fixa (dentro do contexto de um projeto) + menu hamburguer
   abaixo de 900px (mesmo breakpoint de .document-index-layout). .app-shell só existe nas telas com
   sidebar (Requisito 10) — as demais mantêm o layout centralizado atual sem alteração. */
.app-shell {
    display: flex;
    min-height: 100vh;
    align-items: flex-start;
}

.app-shell-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.sidebar {
    width: 232px;
    flex-shrink: 0;
    background: var(--card);
    border-right: 1px solid var(--border);
    padding: var(--space-5) var(--space-3);
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-height: 100vh;
    position: sticky;
    top: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-2) var(--space-5);
}

.sidebar-brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--brand);
    color: var(--brand-contrast);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.sidebar-brand-name {
    font-weight: 600;
}

.sidebar-nav {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 9px var(--space-2);
    border-radius: 6px;
    text-decoration: none;
    color: var(--muted);
    font-weight: 500;
    font-size: 0.9rem;
    min-height: 36px;
}

.sidebar-nav-item:hover {
    background: var(--surface);
}

.sidebar-nav-item:focus-visible {
    outline: 2px solid var(--brand-text);
    outline-offset: -2px;
}

/* TODO item 104: o badge de contagem (Fila de Aprovação por Projeto) fica alinhado à direita do item,
   mesmo padrão de contador em navegação lateral de outros produtos — sem isso ele ficaria colado ao
   texto, no meio do item. */
.sidebar-nav-item .badge {
    margin-left: auto;
}

.sidebar-nav-item.active {
    background: var(--sidebar-active-bg);
    color: var(--brand-text);
    font-weight: 600;
}

.sidebar-current-project {
    margin-top: var(--space-4);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border);
}

.sidebar-current-project-label {
    font-size: 0.72rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0 var(--space-2) 4px;
}

.sidebar-current-project-name {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0 var(--space-2) var(--space-2);
    line-height: 1.3;
}

.sidebar-switch-project {
    background: none;
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: 6px;
    padding: 7px var(--space-2);
    font: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    width: 100%;
    min-height: 32px;
    text-decoration: none;
    display: block;
    text-align: center;
}

.sidebar-switch-project:hover {
    background: var(--surface);
}

.sidebar-toggle {
    display: none;
    background: none;
    border: 1px solid rgb(255 255 255 / 35%);
    color: var(--topbar-link);
    border-radius: 6px;
    padding: var(--space-1) var(--space-2);
    font: inherit;
    cursor: pointer;
    min-height: 32px;
    min-width: 32px;
}

.sidebar-overlay {
    display: none;
}

@media (max-width: 900px) {
    .sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1001;
        transform: translateX(-100%);
        transition: transform 0.15s ease;
        box-shadow: var(--shadow);
    }

    .app-shell.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .app-shell.sidebar-open .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgb(0 0 0 / 40%);
        z-index: 1000;
    }
}

/* conformidade-visual-prototipo-redesign — componentes novos identificados na auditoria completa do
   produto contra o protótipo do handoff. Cada bloco cita o(s) Requisito(s) que atende. */

/* Requisito 13: toggle switch reutilizável para configurações booleanas (Projects/Configure,
   NotificationPreferences/Index), substituindo o par badge+link de texto. Mantém o mecanismo
   js-config-toggle-form já existente — .toggle-switch-saving reflete o postback em voo (Caso
   extremo 7) sem pular direto para o novo estado antes da confirmação do servidor. */
.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
    padding: 0;
    background: var(--border);
    border: none;
    border-radius: 999px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.toggle-switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--card);
    box-shadow: var(--shadow);
    transition: transform 0.15s ease;
}

.toggle-switch[aria-checked="true"],
.toggle-switch[aria-pressed="true"] {
    background: var(--brand);
}

.toggle-switch[aria-checked="true"]::after,
.toggle-switch[aria-pressed="true"]::after {
    transform: translateX(18px);
}

.toggle-switch:focus-visible {
    outline: 2px solid var(--brand-text);
    outline-offset: 2px;
}

.toggle-switch:disabled,
.toggle-switch.toggle-switch-saving {
    opacity: 0.6;
    cursor: progress;
}

@media (prefers-reduced-motion: reduce) {
    .toggle-switch,
    .toggle-switch::after {
        transition: none;
    }
}

/* Requisito 15: layout de 2 colunas para telas de detalhe (Documents/Details, Issues/Details) —
   conteúdo principal + coluna lateral de metadados (<dl class="facts">, opcionalmente com
   .facts-box). Mesmo breakpoint de .document-index-layout/.viewer-layout. */
.detail-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--space-5);
    align-items: start;
}

.detail-layout-main,
.detail-layout-aside {
    min-width: 0;
}

@media (max-width: 900px) {
    .detail-layout {
        grid-template-columns: 1fr;
    }
}

/* Requisito 9: dropzone estilizada envolvendo o <input type="file"> nativo (Documents/Upload,
   UploadIfc, UploadDwg, Issues/ImportBcf). O input continua funcional por trás da dropzone (Caso
   extremo 8: clicar nela abre o seletor de arquivo do SO normalmente) — visualmente oculto com a
   técnica clip padrão de acessibilidade, nunca display:none (manteria o Tab funcional). */
.dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-6) var(--space-4);
    text-align: center;
    color: var(--muted);
    background: var(--surface);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    cursor: pointer;
}

.dropzone:hover,
.dropzone.dropzone-active {
    border-color: var(--brand-text);
    color: var(--brand-text);
}

.dropzone:focus-within {
    outline: 2px solid var(--brand-text);
    outline-offset: 2px;
}

.dropzone input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.dropzone-text {
    font-size: 0.9rem;
}

.dropzone-hint {
    font-size: 0.8rem;
    color: var(--muted);
}

.dropzone-filename {
    font-weight: 600;
    color: var(--text);
}

/* Requisito 21: seletor de abas em pílula no topo de Documents/Upload, UploadIfc e UploadDwg,
   navegando entre as 3 rotas (cada <a> é um link real, preservando projectId/
   AsNewRevisionOfDocumentId na query string — nunca um <div onClick>, diretrizes §3.7). */
.pill-tabs {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    margin-bottom: var(--space-4);
    background: var(--surface);
    border-radius: 999px;
}

.pill-tab {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1) var(--space-4);
    border-radius: 999px;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    min-height: 32px;
}

.pill-tab:hover {
    color: var(--text);
}

.pill-tab.active,
.pill-tab[aria-current="page"] {
    background: var(--card);
    color: var(--brand-text);
    box-shadow: var(--shadow);
}

/* Requisito 23: card "Progresso da revisão" em Documents/Details — stepper horizontal de 5 etapas
   numeradas, mapeando os 8 RevisionStatusLabels aos 5 rótulos do protótipo. .completed cobre as
   etapas já ultrapassadas pela revisão vigente, .current destaca a etapa atual. */
.revision-stepper {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
}

.revision-stepper-step {
    position: relative;
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
    text-align: center;
}

.revision-stepper-step:not(:last-child)::after {
    content: "";
    position: absolute;
    top: 13px;
    left: 50%;
    z-index: 0;
    width: 100%;
    height: 2px;
    background: var(--border);
}

.revision-stepper-circle {
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--surface);
    color: var(--muted);
    font-weight: 600;
    font-size: 0.85rem;
    border: 2px solid var(--border);
    border-radius: 50%;
}

.revision-stepper-label {
    color: var(--muted);
    font-size: 0.78rem;
}

.revision-stepper-step.completed .revision-stepper-circle {
    background: var(--diff-added);
    color: var(--brand-contrast);
    border-color: var(--diff-added);
}

.revision-stepper-step.current .revision-stepper-circle {
    background: var(--brand);
    color: var(--brand-contrast);
    border-color: var(--brand);
}

.revision-stepper-step.current .revision-stepper-label {
    color: var(--text);
    font-weight: 600;
}

/* Requisito 36: stepper compartilhado de 2 pills ("1. Enviar arquivo" / "2. Revisar e confirmar")
   no topo de Issues/ImportBcf e ReviewBcfImport. */
.import-stepper {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.import-stepper-step {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1) var(--space-4);
    background: var(--surface);
    color: var(--muted);
    font-weight: 600;
    font-size: 0.85rem;
    border-radius: 999px;
}

.import-stepper-step.current {
    background: var(--brand);
    color: var(--brand-contrast);
}

/* Requisito 35: disciplinas envolvidas como tags/pills clicáveis em Issues/Create, preservando
   <input type="checkbox"> para acessibilidade (o rótulo inteiro é a área de clique). Estado marcado
   via :has() (navegadores evergreen) com .selected como fallback explícito para o JS aplicar
   diretamente, caso a view precise de suporte mais amplo. */
.discipline-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    color: var(--text);
    font-size: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    user-select: none;
}

.discipline-pill:has(input:checked),
.discipline-pill.selected {
    background: var(--sidebar-active-bg);
    color: var(--brand-text);
    font-weight: 600;
    border-color: var(--brand-text);
}

/* Requisitos 26-27: área do visualizador IFC (Documents/IfcViewer) inteira sem tokens do design
   system — toolbar de ações, grid principal+sidebar de propriedades, linha de disciplina federável
   e o próprio container do canvas 3D (troca o style="width:100%;height:600px;position:relative"
   inline por uma classe dedicada, mesmo padrão de .pdf-container/.dwg-container/
   .dwg-compare-container). */
.viewer-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3);
    margin-bottom: var(--space-3);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.viewer-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: var(--space-4);
    align-items: start;
}

@media (max-width: 900px) {
    .viewer-layout {
        grid-template-columns: 1fr;
    }
}

.viewer-sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.federate-discipline-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    padding: var(--space-1) 0;
}

.ifc-viewer-container {
    position: relative;
    width: 100%;
    height: 600px;
}

/* Requisito 31: legenda de diff compartilhada por CompareRevisionsResult e
   CompareDwgRevisionsResult, extraída do <span style="color:..."> inline — mesmo padrão de
   .discipline-issue-chart-legend/-swatch, com swatch quadrado (12x12px, radius:3px) em vez de
   redondo, conforme o protótipo. */
.diff-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    margin-bottom: var(--space-3);
    padding: 0;
    color: var(--muted);
    font-size: 0.875rem;
    list-style: none;
}

.diff-legend li {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.diff-legend-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    border-radius: 3px;
}

.diff-legend-swatch-added {
    background: var(--diff-added);
}

/* D7, Requirement 24: an element present in both Revisions whose quantities changed. */
.diff-legend-swatch-changed {
    background: var(--warning-border);
}

.diff-legend-swatch-removed {
    background: var(--diff-removed);
}

/* Requisito 56: ícone de confirmação em círculo colorido no topo de Verify/Index — verde/check para
   Vigente sobre --diff-added-bg (token novo, Restrição da spec), âmbar/alerta para Obsoleta
   reaproveitando --warning-bg/--warning-border já existentes. O SVG interno usa
   stroke="currentColor"/fill="currentColor" e herda a cor do ícone via `color`. */
.confirmation-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    border-radius: 50%;
}

.confirmation-icon-success {
    background: var(--diff-added-bg);
    color: var(--diff-added);
}

.confirmation-icon-warning {
    background: var(--warning-bg);
    color: var(--warning-border);
}

.app-footer {
    padding: var(--space-3) var(--space-5);
    text-align: center;
}

.app-footer-link {
    color: var(--muted);
    font-size: 0.8rem;
    text-decoration: none;
}

.app-footer-link:hover,
.app-footer-link:focus-visible {
    color: var(--brand-text);
    text-decoration: underline;
}

/* d8a-busca-full-text, Requisito 9: destaque do termo buscado. O <mark> nativo traz um amarelo
   fixo do navegador, que ignora os tokens e o tema escuro; os tokens de aviso ja tem par
   claro/escuro e o texto sobre eles clareia AA nos dois (diretrizes secao 1.6). */
mark {
    background: var(--warning-bg);
    color: var(--text);
    padding: 0 var(--space-1);
    border-radius: var(--radius);
}

/* gantt-simplificado-do-plano (RF-15-03): Gantt em HTML/CSS puro, sem biblioteca de gráfico — a
   Restrição da spec. Barras são posicionadas por left/width em porcentagem, calculada no servidor
   por PlanTimelineBuilder.PercentOf. Sendo DOM e não canvas, a tela é navegável por leitor de tela
   e imprime pelo navegador sem trabalho extra. */
.gantt {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    overflow: hidden;
}

.gantt-row,
.gantt-ruler {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--border);
}

.gantt-label {
    flex: 0 0 22%;
    min-width: 12ch;
    color: var(--text);
    font-size: 0.9rem;
}

.gantt-track {
    position: relative;
    flex: 1 1 auto;
    height: 20px;
}

.gantt-ruler .gantt-track {
    height: 1.4rem;
}

.gantt-tick {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    font-size: 0.72rem;
    color: var(--muted);
    white-space: nowrap;
}

/* Requisito 12: a linha de hoje. Fica atrás das barras (z-index 0) para não cortá-las ao meio. */
.gantt-today {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--overdue-border);
    z-index: 0;
}

.gantt-bar {
    position: absolute;
    border-radius: var(--radius);
    z-index: 1;
    min-width: 2px;
}

/* Requisito 3: previsto e realizado se distinguem por POSIÇÃO (metades diferentes da faixa),
   TEXTURA (listrado × sólido) e cor — não só por cor, que sozinha reprova em WCAG 2.1 AA. */
.gantt-bar-planned {
    top: 0;
    height: 8px;
    background: repeating-linear-gradient(
        45deg,
        var(--border) 0 4px,
        transparent 4px 8px
    );
    border: 1px solid var(--border);
}

.gantt-bar-actual {
    bottom: 0;
    height: 8px;
    background: var(--brand);
}

/* Requisito 4: a ponta aberta de um par em andamento. A seta à direita é o que distingue
   "ainda correndo" de "terminou exatamente hoje", que sem ela seriam idênticos. */
.gantt-bar-open::after {
    content: "›";
    position: absolute;
    right: -0.6rem;
    top: -0.45rem;
    color: var(--brand);
    font-weight: 700;
}

.gantt-bar-envelope {
    top: 4px;
    height: 10px;
    background: var(--sidebar-active-bg);
    border: 1px solid var(--brand);
}

.gantt-swatch {
    position: static;
    display: inline-block;
    width: 28px;
    height: 8px;
    vertical-align: middle;
}

.gantt-row-child .gantt-label {
    padding-left: var(--space-4);
    color: var(--muted);
}

/* Casos extremos 3 e 4: a linha sinalizada continua desenhada — o aviso é uma faixa à esquerda,
   não a remoção do dado. */
.gantt-row-flagged {
    background: var(--warning-bg);
    border-left: 3px solid var(--warning-border);
}

.gantt-flag,
.gantt-incomplete {
    margin-left: var(--space-2);
    font-size: 0.75rem;
    color: var(--muted);
    white-space: nowrap;
}

.gantt-unplanned {
    margin-left: var(--space-2);
    font-size: 0.75rem;
    font-style: italic;
    color: var(--muted);
}

/* Requisito 7: três estados por FORMA (glifo ◆ ◈ ◇) e por cor. */
.gantt-milestone {
    position: absolute;
    top: -2px;
    transform: translateX(-50%);
    z-index: 2;
    font-size: 1rem;
    line-height: 1;
}

.gantt-milestone-reached {
    color: var(--diff-added);
}

.gantt-milestone-atrisk {
    color: var(--overdue-border);
}

.gantt-milestone-pending {
    color: var(--muted);
}

.gantt-phase > summary {
    cursor: pointer;
    font-weight: 600;
}

.gantt-toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.gantt-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    list-style: none;
    padding: var(--space-3) 0;
    margin: 0;
    font-size: 0.8rem;
    color: var(--muted);
}

.gantt-legend li {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.gantt-orphan-milestones {
    margin-top: var(--space-5);
}

/* Texto só para leitor de tela: o nome e o estado de cada Marco, que no visual são um glifo. */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media print {
    .gantt-toolbar {
        display: none;
    }
}

/* Requisito 14 / checklist 6.2, "layout testado em pelo menos 2 tamanhos de tela": conferido a
   1920px (a largura de referência da spec) e a 820px. Abaixo de 900px a coluna de rótulo fixa em 22%
   espremia a faixa das barras até torná-la ilegível — as barras continuavam corretas em porcentagem,
   só que sobre uma faixa de poucas dezenas de pixels. Aqui rótulo e faixa passam a empilhar, e a
   faixa recupera a largura inteira. */
@media (max-width: 900px) {
    .gantt-row,
    .gantt-ruler {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-1);
    }

    .gantt-label {
        flex: 1 1 auto;
        min-width: 0;
    }

    .gantt-row-child .gantt-label {
        padding-left: var(--space-2);
    }

    /* A faixa precisa de altura própria quando empilhada: sem isto ela herdaria os 20px pensados
       para a linha lado a lado e os rótulos da régua se sobreporiam às barras. */
    .gantt-track {
        height: 24px;
    }

    .gantt-legend {
        gap: var(--space-2);
    }
}

/* pre-visualizacao-assincrona, Requisitos 8-10: the Revision thumbnail — 48 px high in the tables, up to 320 px wide on
   the Document page — and its placeholders. The table column gives way below 640 px of viewport. */
.thumbnail {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #ffffff;
}

.thumbnail-small {
    height: 48px;
    max-width: 72px;
    object-fit: contain;
}

.thumbnail-large {
    width: 100%;
    max-width: 320px;
    height: auto;
}

.thumbnail-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    color: var(--muted);
    font-size: 0.7rem;
    line-height: 1.1;
    text-align: center;
}

.thumbnail-small.thumbnail-placeholder {
    width: 64px;
}

.thumbnail-large.thumbnail-placeholder {
    aspect-ratio: 4 / 3;
}

.thumbnail-neutral {
    background: repeating-linear-gradient(45deg, var(--surface), var(--surface) 6px, transparent 6px, transparent 12px);
}

.thumbnail[hidden] {
    display: none;
}

@media (max-width: 640px) {
    .thumbnail-column {
        display: none;
    }
}
