/* Gestão Documental F&M — identidade de produto Navy Editorial (brand-spec-fm.md §2). */

@font-face {
  font-family: "IBM Plex Sans";
  src: url("fontes/ibm-plex-sans-var-latin.woff2") format("woff2");
  font-weight: 100 700;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Serif";
  src: url("fontes/ibm-plex-serif-latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

:root {
  /* rampa navy (hue 253) */
  --navy-950: oklch(0.22 0.05 253);
  --navy-900: oklch(0.28 0.058 253);
  --navy: oklch(0.34 0.062 253);
  --navy-700: oklch(0.42 0.07 253);
  --navy-100: oklch(0.93 0.018 253);
  --navy-50: oklch(0.965 0.01 253);
  --gold: #C9A227;
  --gold-escuro: oklch(0.58 0.11 92);

  --bg: oklch(0.975 0.004 253);
  --superficie: #fff;
  --linha: oklch(0.9 0.012 253);
  --linha-forte: oklch(0.82 0.018 253);
  --ink: oklch(0.26 0.022 253);
  --mut: oklch(0.47 0.02 253);
  --sobre-navy: oklch(0.86 0.025 253);

  --erro: oklch(0.5 0.13 15);
  --erro-fundo: oklch(0.96 0.02 15);
  --alerta: oklch(0.5 0.12 60);
  --alerta-fundo: oklch(0.96 0.035 75);
  --ok: oklch(0.47 0.1 155);
  --ok-fundo: oklch(0.96 0.03 155);

  --fonte: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --fonte-titulo: "IBM Plex Serif", Georgia, serif;
  --fonte-mono: ui-monospace, "Cascadia Mono", Consolas, monospace;

  --raio: 6px;
  --raio-g: 10px;
  --sombra: 0 1px 2px oklch(0.26 0.022 253 / 0.08), 0 4px 8px oklch(0.26 0.022 253 / 0.06);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --z-sticky: 10;
  --z-menu: 20;
  --z-dialogo: 40;
  --z-aviso: 50;

  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 15px/1.5 var(--fonte);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.25; text-wrap: balance; }
h1 { font: 600 1.5rem/1.2 var(--fonte-titulo); letter-spacing: -0.01em; }
h2 { font-size: 1.0625rem; font-weight: 600; }
h3 { font-size: 0.9375rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--navy-700); text-underline-offset: 2px; }
a:hover { color: var(--navy); }
[hidden] { display: none !important; }
.mut { color: var(--mut); }
.mono { font-family: var(--fonte-mono); font-size: 0.875em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- moldura ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100dvh; }
#menu {
  background: var(--navy-900);
  color: var(--sobre-navy);
  padding: 20px 12px;
  position: sticky; top: 0; height: 100dvh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
}
.marca { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; color: #fff; text-decoration: none; }
.marca-sinal {
  width: 30px; height: 30px; border-radius: var(--raio);
  display: grid; place-items: center;
  background: var(--navy); border: 1px solid var(--gold);
  font: 600 13px/1 var(--fonte-titulo); color: var(--gold);
}
.marca-nome { font: 600 15px/1.2 var(--fonte-titulo); }
.marca-nome small { display: block; font: 400 12px/1.3 var(--fonte); color: var(--sobre-navy); }
.menu-grupo { margin: 16px 10px 4px; font-size: 12px; font-weight: 500; color: oklch(0.72 0.03 253); }
.menu-item {
  display: flex; align-items: center; gap: 10px;
  min-height: 40px; padding: 8px 10px; border-radius: var(--raio);
  color: var(--sobre-navy); text-decoration: none; font-weight: 450;
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}
.menu-item:hover { background: oklch(1 0 0 / 0.07); color: #fff; }
.menu-item[aria-current="page"] { background: oklch(1 0 0 / 0.1); color: #fff; box-shadow: inset 0 0 0 1px oklch(0.8 0.12 92 / 0.45); }
.menu-item svg { width: 18px; height: 18px; flex: none; opacity: 0.85; }
.menu-rodape { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid oklch(1 0 0 / 0.1); font-size: 13px; }
.menu-rodape strong { display: block; color: #fff; font-weight: 500; overflow-wrap: anywhere; }
.menu-rodape button { margin-top: 8px; }

.topo-movel { display: none; }
#conteudo { min-width: 0; padding: 28px 36px 64px; max-width: 1280px; width: 100%; }

.cabecalho { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 20px; }
.cabecalho .acoes, .barra-acoes { display: flex; flex-wrap: wrap; gap: 8px; }
.trilha { display: flex; flex-wrap: wrap; gap: 4px; font-size: 13px; color: var(--mut); margin-bottom: 6px; }
.trilha a { color: var(--mut); text-decoration: none; }
.trilha a:hover { color: var(--navy); text-decoration: underline; }
.trilha span[aria-hidden] { opacity: 0.6; }

/* ---------- controles ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 8px 14px;
  font: 500 14px/1.2 var(--fonte);
  color: var(--ink); background: var(--superficie);
  border: 1px solid var(--linha-forte); border-radius: var(--raio);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease);
}
.btn:hover { background: var(--navy-50); border-color: var(--navy-700); color: var(--ink); }
.btn:active { background: var(--navy-100); }
.btn:disabled, .btn[aria-busy="true"] { opacity: 0.55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn-primario { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primario:hover { background: var(--navy-900); border-color: var(--navy-900); color: #fff; }
.btn-perigo { color: var(--erro); border-color: oklch(0.8 0.06 15); }
.btn-perigo:hover { background: var(--erro-fundo); border-color: var(--erro); color: var(--erro); }
.btn-fantasma { border-color: transparent; background: transparent; }
.btn-icone { min-width: 38px; padding: 8px; }
#menu .btn { color: var(--sobre-navy); background: transparent; border-color: oklch(1 0 0 / 0.2); }
#menu .btn:hover { background: oklch(1 0 0 / 0.08); color: #fff; }

.campo { display: grid; gap: 6px; }
.campo label, .rotulo { font-size: 13px; font-weight: 500; }
.campo .ajuda { font-size: 13px; color: var(--mut); }
input[type="text"], input[type="email"], input[type="password"], input[type="search"],
input[type="datetime-local"], input:not([type]), select, textarea {
  width: 100%; min-height: 40px; padding: 8px 10px;
  font: 400 15px/1.4 var(--fonte); color: var(--ink);
  background: var(--superficie);
  border: 1px solid var(--linha-forte); border-radius: var(--raio);
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}
textarea { min-height: 88px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--mut); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy-700); box-shadow: 0 0 0 3px oklch(0.8 0.12 92 / 0.35); }
input[aria-invalid="true"] { border-color: var(--erro); }
.codigo-totp { font: 500 22px/1 var(--fonte-mono); letter-spacing: 0.3em; text-align: center; }
.checks { display: grid; gap: 6px 16px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.checks label { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; min-height: 28px; cursor: pointer; }
.checks input { margin-top: 3px; accent-color: var(--navy); }
.form { display: grid; gap: 14px; }
.form .linha { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.msg-erro { color: var(--erro); background: var(--erro-fundo); border-radius: var(--raio); padding: 10px 12px; font-size: 14px; }
.msg-ok { color: var(--ok); background: var(--ok-fundo); border-radius: var(--raio); padding: 10px 12px; font-size: 14px; }

/* ---------- selos ---------- */
.selo {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500; line-height: 1.5; white-space: nowrap;
  background: var(--navy-50); color: var(--navy-700);
}
.selo-alerta { background: var(--alerta-fundo); color: var(--alerta); }
.selo-erro { background: var(--erro-fundo); color: var(--erro); }
.selo-ok { background: var(--ok-fundo); color: var(--ok); }
.selo-sigiloso { background: var(--navy); color: #fff; }

/* ---------- lista de itens (tabela → cartões) ---------- */
.painel { background: var(--superficie); border: 1px solid var(--linha); border-radius: var(--raio-g); }
.tabela { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabela th {
  text-align: left; font-size: 12px; font-weight: 500; color: var(--mut);
  padding: 10px 14px; border-bottom: 1px solid var(--linha);
  position: sticky; top: 0; background: var(--superficie); z-index: var(--z-sticky);
}
.tabela td { padding: 8px 14px; border-bottom: 1px solid var(--linha); vertical-align: middle; }
.tabela tr:last-child td { border-bottom: 0; }
.tabela tbody tr { transition: background-color 120ms var(--ease); }
.tabela tbody tr:hover { background: var(--navy-50); }
.tabela tbody tr.selecionado { background: var(--navy-100); }
.tabela .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tabela .acoes-col { width: 1%; white-space: nowrap; text-align: right; }
.tabela .col-sec { display: none; }
.item-nome { display: flex; align-items: center; gap: 10px; min-width: 0; }
.item-nome a, .item-nome button.link {
  color: var(--ink); font-weight: 500; text-decoration: none; overflow-wrap: anywhere;
  background: none; border: 0; padding: 4px 0; font: inherit; font-weight: 500; text-align: left; cursor: pointer;
}
.item-nome a:hover, .item-nome button.link:hover { color: var(--navy); text-decoration: underline; }
.item-icone { width: 20px; height: 20px; flex: none; color: var(--navy-700); }
.item-icone.pasta { color: var(--gold-escuro); }
.item-sub { font-size: 13px; color: var(--mut); }
.mais { display: flex; justify-content: center; padding: 14px; }

.vazio { padding: 48px 24px; text-align: center; color: var(--mut); display: grid; gap: 8px; justify-items: center; }
.vazio strong { color: var(--ink); font-weight: 500; }
.esqueleto td > span {
  display: block; height: 12px; border-radius: 4px;
  background: linear-gradient(90deg, var(--navy-50), var(--navy-100), var(--navy-50));
  background-size: 200% 100%; animation: brilho 1.2s linear infinite;
}
@keyframes brilho { to { background-position: -200% 0; } }

/* menu "⋯" por item */
.menu-acoes { position: relative; }
.menu-flutuante {
  position: fixed; z-index: var(--z-menu); min-width: 200px;
  background: var(--superficie); border: 1px solid var(--linha); border-radius: var(--raio);
  box-shadow: var(--sombra); padding: 4px;
}
.menu-flutuante [role="menuitem"] {
  display: flex; width: 100%; align-items: center; gap: 8px; min-height: 40px; padding: 8px 12px;
  background: none; border: 0; border-radius: 4px; font: 400 14px/1.2 var(--fonte); color: var(--ink);
  text-align: left; cursor: pointer; text-decoration: none;
}
.menu-flutuante [role="menuitem"]:hover, .menu-flutuante [role="menuitem"]:focus-visible { background: var(--navy-50); outline: none; }
.menu-flutuante [role="menuitem"].perigo { color: var(--erro); }

/* ---------- painel lateral de documento ---------- */
.lateral {
  position: fixed; inset: 0 0 0 auto; width: min(720px, 100vw); z-index: var(--z-dialogo);
  background: var(--superficie); border-left: 1px solid var(--linha); box-shadow: var(--sombra);
  display: grid; grid-template-rows: auto 1fr; transform: translateX(0);
  transition: transform 220ms var(--ease);
}
.lateral[hidden] { display: grid !important; transform: translateX(102%); visibility: hidden; }
.lateral-topo { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--linha); }
.lateral-topo h2 { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.lateral-corpo { overflow-y: auto; padding: 18px; display: grid; gap: 20px; align-content: start; }
.previa { width: 100%; height: min(70vh, 720px); border: 1px solid var(--linha); border-radius: var(--raio); background: var(--navy-50); }
.previa-vazia { display: grid; place-items: center; height: 180px; border: 1px dashed var(--linha-forte); border-radius: var(--raio); color: var(--mut); text-align: center; padding: 16px; }
.dados { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 14px; }
.dados dt { color: var(--mut); }
.dados dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- diálogos ---------- */
dialog {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  padding: 0; border: 1px solid var(--linha); border-radius: var(--raio-g);
  color: var(--ink); background: var(--superficie); box-shadow: var(--sombra);
}
dialog.largo { width: min(820px, calc(100vw - 32px)); }
dialog::backdrop { background: oklch(0.22 0.05 253 / 0.45); }
dialog[open] { animation: surgir 180ms var(--ease); }
@keyframes surgir { from { opacity: 0; transform: translateY(6px); } }
.dialogo-corpo { padding: 20px; display: grid; gap: 14px; }
.dialogo-rodape { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--linha); background: var(--navy-50); border-radius: 0 0 var(--raio-g) var(--raio-g); }
.seletor-lista { max-height: 320px; overflow-y: auto; border: 1px solid var(--linha); border-radius: var(--raio); }
.seletor-lista button {
  display: flex; width: 100%; align-items: center; gap: 8px; min-height: 42px; padding: 8px 12px;
  background: none; border: 0; border-bottom: 1px solid var(--linha); font: inherit; text-align: left; cursor: pointer; color: var(--ink);
}
.seletor-lista button:last-child { border-bottom: 0; }
.seletor-lista button:hover { background: var(--navy-50); }
.seletor-lista button:disabled { color: var(--mut); cursor: not-allowed; background: none; }

/* ---------- envio de arquivos ---------- */
.soltar { outline: 2px dashed var(--navy-700); outline-offset: -6px; background: var(--navy-50); }
.envios { position: fixed; right: 16px; bottom: 16px; z-index: var(--z-aviso); width: min(360px, calc(100vw - 32px)); display: grid; gap: 8px; }
.envio { background: var(--superficie); border: 1px solid var(--linha); border-radius: var(--raio); box-shadow: var(--sombra); padding: 10px 12px; font-size: 13px; display: grid; gap: 6px; }
.envio-nome { font-weight: 500; overflow-wrap: anywhere; }
.envio progress { width: 100%; height: 6px; accent-color: var(--navy); }

/* ---------- avisos ---------- */
#avisos { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: var(--z-aviso); display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); pointer-events: none; }
.aviso {
  pointer-events: auto; padding: 12px 16px; border-radius: var(--raio);
  background: var(--navy-950); color: #fff; font-size: 14px; box-shadow: var(--sombra);
  animation: surgir 200ms var(--ease);
}
.aviso.erro { background: var(--erro); }

/* ---------- abas ---------- */
.abas { display: flex; gap: 4px; border-bottom: 1px solid var(--linha); margin-bottom: 18px; overflow-x: auto; }
.abas button {
  min-height: 42px; padding: 8px 14px; background: none; border: 0; border-bottom: 2px solid transparent;
  font: 500 14px/1 var(--fonte); color: var(--mut); cursor: pointer; white-space: nowrap;
}
.abas button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--gold); }

/* ---------- matriz de acesso efetivo ---------- */
.matriz-wrap { overflow-x: auto; }
.matriz td, .matriz th { white-space: nowrap; }
.matriz .sim { color: var(--ok); font-weight: 600; }
.matriz .nao { color: var(--mut); font-size: 12px; }
.matriz .negado { color: var(--erro); font-size: 12px; }

/* ---------- barra (cota) ---------- */
.barra { height: 8px; border-radius: 999px; background: var(--navy-100); overflow: hidden; }
.barra > span { display: block; height: 100%; background: var(--navy); }
.barra.alerta > span { background: var(--alerta); }

/* ---------- telas de acesso (login / convite) ---------- */
.acesso { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 520px); }
.acesso-lado {
  background: var(--navy-900); color: var(--sobre-navy);
  padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
}
.acesso-lado h1 { color: #fff; font-size: 2rem; max-width: 16ch; }
.acesso-lado p { max-width: 42ch; margin-top: 12px; }
.acesso-lado .marca { padding: 0; }
.acesso-lado small { font-size: 13px; }
.acesso-form { padding: 48px; display: flex; flex-direction: column; justify-content: center; gap: 24px; background: var(--superficie); }
.acesso-form h2 { font: 600 1.375rem/1.25 var(--fonte-titulo); }
.passos { display: grid; gap: 22px; }
.passo { display: grid; gap: 12px; }
.passo-num { font-size: 13px; font-weight: 600; color: var(--gold-escuro); }
.qr { width: 200px; max-width: 100%; padding: 10px; background: #fff; border: 1px solid var(--linha); border-radius: var(--raio); }
.qr svg { display: block; width: 100%; height: auto; }
.segredo { font: 500 14px/1.4 var(--fonte-mono); letter-spacing: 0.08em; word-break: break-all; background: var(--navy-50); padding: 8px 10px; border-radius: var(--raio); }

/* ---------- responsivo ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .topo-movel {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: var(--z-menu);
    background: var(--navy-900); color: #fff; padding: 8px 12px;
  }
  .topo-movel .marca { padding: 0; }
  .topo-movel .btn { color: #fff; background: transparent; border-color: oklch(1 0 0 / 0.25); min-width: 44px; min-height: 44px; }
  #menu { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); height: 100dvh; z-index: var(--z-dialogo); transform: translateX(-102%); transition: transform 220ms var(--ease); }
  body.menu-aberto #menu { transform: none; box-shadow: var(--sombra); }
  body.menu-aberto::after { content: ""; position: fixed; inset: 0; background: oklch(0.22 0.05 253 / 0.45); z-index: calc(var(--z-dialogo) - 1); }
  #menu .marca { display: none; }
  #conteudo { padding: 18px 16px 88px; }
  .acesso { grid-template-columns: 1fr; }
  .acesso-lado { padding: 24px 20px; }
  .acesso-lado h1 { font-size: 1.5rem; }
  .acesso-lado .acesso-extra { display: none; }
  .acesso-form { padding: 24px 20px 40px; justify-content: flex-start; }
}
@media (max-width: 640px) {
  .btn, .menu-item { min-height: 44px; }
  .tabela.cartoes thead { display: none; }
  .tabela.cartoes, .tabela.cartoes tbody, .tabela.cartoes tr, .tabela.cartoes td { display: block; width: 100%; }
  .tabela.cartoes tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 12px 14px; border-bottom: 1px solid var(--linha); }
  .tabela.cartoes td { padding: 0; border: 0; grid-column: 1; }
  .tabela.cartoes td.col-nome { grid-column: 1; }
  .tabela.cartoes td.acoes-col { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
  .tabela.cartoes td.col-sec { grid-column: 1; font-size: 13px; color: var(--mut); text-align: left; }
  .tabela.cartoes td.col-sec:empty, .tabela.cartoes td.col-oculta { display: none; }
  .tabela.cartoes td[data-rotulo]::before { content: attr(data-rotulo) ": "; color: var(--mut); }
  .cabecalho { align-items: stretch; }
  .cabecalho .acoes { width: 100%; }
  .cabecalho .acoes .btn { flex: 1; }
  .lateral { width: 100vw; border-left: 0; }
  .previa { height: 60vh; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
.bloco { margin-bottom: 18px; }
