/*
 * Portal Moinho Engenharia Legal.
 *
 * Mesma base visual dos sistemas Moinho Tarefas (painel), JVL-django e R.Moulin: menu lateral, mesmos nomes de
 * classe (.shell, .sidebar, .brand, .nav-group, .content, .workspace-header, .panel, .section-heading,
 * .table-wrap, .data-table, .field, .control, .button, .message, .form-errors, .auth-page, .auth-card), mesmas
 * medidas e o mesmo comportamento no celular. Os cartões dos sistemas seguem o .stat-tile do painel do JVL-django.
 *
 * Diferenças pedidas para o portal (decisão do usuário em 13/10/2026):
 * - fonte Poppins em todo o texto, servida pelo próprio portal (licença OFL em fontes/OFL.txt);
 * - só as cores do manual da marca, sem cinzas, transparências, sombras ou degradês: azul #2E2C49 (texto,
 *   botões, campos), dourado #D2AE6D (só acento: linhas, bordas, selos; nunca texto corrido sobre branco, por
 *   falta de contraste) e branco #FFFFFF (fundo). Os papéis de cor do padrão (--ink, --muted, --line...) mantêm
 *   os nomes e apontam para essas três cores; erros aparecem em azul com borda, sem vermelho.
 * Sem JavaScript: o menu do celular usa <details>, como nos outros sistemas.
 */
@font-face {
    font-family: "Poppins";
    src: url("fontes/Poppins-Regular.ttf") format("truetype");
    font-style: normal;
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: "Poppins";
    src: url("fontes/Poppins-SemiBold.ttf") format("truetype");
    font-style: normal;
    font-weight: 600;
    font-display: swap;
}

:root {
    /* Manual da marca: as únicas cores do portal */
    --moinho-azul: #2E2C49;
    --moinho-dourado: #D2AE6D;
    --branco: #FFFFFF;
    /* Papéis do padrão dos outros sistemas, só com as cores da marca */
    --accent: var(--moinho-azul);
    --accent-ink: var(--moinho-azul);
    --on-accent: var(--branco);
    --paper: var(--branco);
    --sidebar: var(--branco);
    --canvas: var(--branco);
    --ink: var(--moinho-azul);
    --ink-soft: var(--moinho-azul);
    --muted: var(--moinho-azul);
    --line: var(--moinho-dourado);
    --control-border: var(--moinho-azul);
    --radius: 10px;
    --field-height: 44px;
    color-scheme: light;
    font-family: "Poppins", sans-serif;
    font-size: 14px;
    font-synthesis: none;
    color: var(--ink);
    background: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; line-height: 1.5; color: var(--ink); background: var(--canvas); }
button, input, select, textarea { font: inherit; }
a { color: var(--accent-ink); text-underline-offset: 3px; }
h1, h2, h3 { color: var(--ink); }
::selection { background: var(--moinho-dourado); color: var(--moinho-azul); }
svg { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.skip-link { position: absolute; z-index: 20; left: -9999px; background: var(--ink); color: var(--paper); padding: 10px; }
.skip-link:focus { left: 12px; top: 12px; }

/* ---------------------------------------------------------------- logotipo */
/*
 * Área livre mínima de 2/3 da altura do logotipo, sem alterar a imagem. O PNG (600 x 373 px) tem o desenho em
 * 514 x 161 px, com 106 px livres em cima e embaixo e 43 px nas laterais; 2/3 de 161 = 107,3 px. O espaçamento
 * completa a diferença em proporção à largura exibida (--logo): 0,25% em cima e embaixo e 10,8% nas laterais.
 * Nenhum outro elemento entra nessa área. Largura exibida sempre acima do mínimo de 3 cm do manual.
 */
.logo-area { --logo: 160px; display: block; width: fit-content; padding: calc(var(--logo) * .0025) calc(var(--logo) * .108); }
.logo-area img { display: block; width: var(--logo); height: auto; }

/* ---------------------------------------------------------------- estrutura */
.shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 24px 16px 16px; background: var(--sidebar); border-right: 1px solid var(--line); }
.brand { display: block; width: fit-content; margin: 0 auto 16px; text-decoration: none; }
.desktop-nav { display: grid; gap: 28px; }
.mobile-nav { display: none; }
.nav-group { display: grid; gap: 4px; }
.nav-label { margin: 0; padding: 0 12px 8px; font-size: 12px; font-weight: 600; letter-spacing: .015em; color: var(--muted); }
.nav-group a { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 40px; padding: 10px 12px; border-radius: 8px; color: var(--ink-soft); font-size: 13px; text-decoration: none; }
.nav-group a:hover { text-decoration: underline; }
.nav-group a[aria-current="page"] { padding-left: 9px; border-left: 3px solid var(--moinho-dourado); border-radius: 0 8px 8px 0; font-weight: 600; color: var(--accent-ink); }
.logout { display: flex; align-items: center; gap: 9px; margin-top: auto; padding: 17px 0 0; border-top: 1px solid var(--line); }
.avatar { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 50%; background: var(--paper); border: 1px solid var(--line); color: var(--accent-ink); font-size: 13px; font-weight: 600; }
.account { display: grid; flex: 1; min-width: 0; line-height: 1.25; }
.account strong { font-size: 12px; font-weight: 600; overflow-wrap: anywhere; }
.account small { font-size: 12px; color: var(--muted); }
.link-button { padding: 4px; border: 0; background: var(--paper); color: var(--accent-ink); font-size: 12px; font-weight: 600; cursor: pointer; }
.link-button:hover { text-decoration: underline; }

.content { width: min(1440px, 100%); min-width: 0; margin: 0 auto; padding: 38px clamp(20px, 4vw, 56px) 56px; }
.workspace-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 30px; }
.workspace-header h1 { font-weight: 600; font-size: clamp(26px, 2.4vw, 32px); line-height: 1.2; letter-spacing: -.03em; margin: 0 0 8px; overflow-wrap: anywhere; }
.workspace-header .muted { margin: 0; font-size: 14px; }
.eyebrow { margin: 0 0 8px; color: var(--accent-ink); font-size: 12px; font-weight: 600; letter-spacing: .01em; }

/* ---------------------------------------------------------------- blocos */
.panel { margin-bottom: 16px; padding: 20px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.panel ul { margin: 0; padding-left: 20px; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.section-heading h2 { margin: 0 0 4px; font-weight: 600; font-size: 16px; letter-spacing: -.02em; }
.section-description { max-width: 90ch; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.form-panel { max-width: 560px; }
.empty { max-width: 600px; padding: 30px; background: var(--paper); border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.note { margin: 4px 0; color: var(--muted); font-size: 13px; }
.status { display: inline-flex; align-items: center; white-space: nowrap; border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: 12px; line-height: 1.6; font-weight: 600; background: var(--paper); color: var(--accent-ink); }
.status-neutro { border-style: dashed; }

/* ---------------------------------------------------------------- cartões dos sistemas (como o .stat-tile do JVL-django) */
.system-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 16px; margin: 0; padding: 0; list-style: none; }
.system-grid > li { display: flex; min-width: 0; }
.system-tile { display: flex; flex-direction: column; gap: 8px; width: 100%; min-width: 0; padding: 18px 20px; background: var(--paper); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius); color: var(--ink); text-decoration: none; }
.system-name { margin: 0; font-size: 18px; font-weight: 600; line-height: 1.3; letter-spacing: -.02em; overflow-wrap: anywhere; }
.system-description { flex: 1; margin: 0; font-size: 14px; line-height: 1.6; }
.system-action { display: inline-flex; align-self: flex-start; align-items: center; gap: 8px; margin-top: 8px; padding: 8px 14px; border: 1px solid var(--accent); border-radius: 7px; background: var(--accent); color: var(--on-accent); font-size: 13px; font-weight: 600; }
a.system-tile:hover { border-color: var(--accent); }
a.system-tile:hover .system-name { text-decoration: underline; }
a.system-tile:hover .system-action { background: var(--paper); color: var(--accent); }
.system-tile.is-soon { border-style: dashed; border-left: 3px dashed var(--moinho-dourado); cursor: not-allowed; }
.system-tile.is-soon .status { align-self: flex-start; margin-top: 8px; }

/* ---------------------------------------------------------------- tabelas */
.table-wrap { max-width: 100%; overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 13px 15px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.row-actions form { margin: 0; }

/* ---------------------------------------------------------------- usuários cadastrados */
/* Um bloco por pessoa: identidade e etiquetas; dados de acesso; e, abaixo de um fio, duas zonas lado a lado
   (sistemas liberados com o próprio botão, ações da conta). No celular, as zonas ficam uma embaixo da outra. */
.panel ul.lista-usuarios { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.usuario { min-width: 0; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.usuario-identidade { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 8px 16px; }
.usuario-identidade h3 { margin: 0; font-weight: 600; font-size: 15px; letter-spacing: -.01em; }
.usuario-email { margin: 2px 0 0; font-size: 13px; overflow-wrap: anywhere; }
.usuario-etiquetas { display: flex; flex-wrap: wrap; gap: 6px; }
.usuario-dados { display: flex; flex-wrap: wrap; gap: 4px 28px; margin: 12px 0 0; font-size: 13px; }
.usuario-dados div { display: flex; flex-wrap: wrap; gap: 0 6px; }
.usuario-dados dt { font-weight: 600; }
.usuario-dados dd { margin: 0; }
.usuario-zonas { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 28px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.zona { display: grid; align-content: start; justify-items: start; gap: 8px; min-width: 0; margin: 0; }
.zona fieldset { display: grid; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.zona-titulo { margin: 0 0 2px; padding: 0; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.zona .note { margin: 0; }

/* ---------------------------------------------------------------- botões e formulários */
.button { display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 9px 14px; white-space: nowrap; border: 1px solid var(--accent); border-radius: 7px; background: var(--accent); color: var(--on-accent); font-size: 13px; font-weight: 600; text-decoration: none; cursor: pointer; }
.button:hover { background: var(--paper); color: var(--accent); }
.button.secondary { background: var(--paper); border-color: var(--accent); color: var(--ink); }
.button.secondary:hover { background: var(--accent); color: var(--on-accent); }
.button.wide { width: 100%; min-height: var(--field-height); }
.button.small { min-height: 34px; padding: 6px 10px; font-size: 12px; }
.field { display: grid; min-width: 0; gap: 7px; margin-bottom: 22px; }
.field > label { font-size: 13px; font-weight: 600; }
.field small { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.control { width: 100%; min-height: var(--field-height); padding: 10px 12px; border: 1px solid var(--control-border); border-radius: 7px; background: var(--paper); color: var(--ink); font-size: 14px; }
/* Preenchimento automático do navegador: mantém fundo branco e texto azul. */
.control:-webkit-autofill { -webkit-text-fill-color: var(--ink); box-shadow: 0 0 0 1000px var(--paper) inset; }
.check-field { display: flex; align-items: center; gap: 10px; }
.check-field > label { font-size: 13px; font-weight: 400; }
.check-field input[type="checkbox"] { appearance: none; display: grid; place-content: center; flex: 0 0 auto; width: 20px; height: 20px; margin: 0; border: 2px solid var(--control-border); border-radius: 4px; background: var(--paper); cursor: pointer; }
.check-field input[type="checkbox"]::before { content: ""; width: 10px; height: 6px; border-left: 2px solid var(--paper); border-bottom: 2px solid var(--paper); transform: translateY(-1px) rotate(-45deg); }
.check-field input[type="checkbox"]:checked { background: var(--accent); }

/* ---------------------------------------------------------------- mensagens */
.message { margin: 0 0 18px; padding: 11px 14px; border: 1px solid var(--line); border-left: 4px solid var(--moinho-dourado); border-radius: 0 7px 7px 0; background: var(--paper); font-size: 14px; }
.form-errors { margin: 0 0 18px; padding: 13px 15px; border: 1px solid var(--moinho-azul); border-left: 4px solid var(--moinho-azul); border-radius: 0 7px 7px 0; background: var(--paper); color: var(--moinho-azul); font-size: 13px; font-weight: 600; }
.resultado { border: 2px solid var(--accent); border-top: 3px solid var(--moinho-dourado); }
.dados { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; align-items: baseline; margin: 0; }
.dados dt { font-size: 13px; font-weight: 600; }
.dados dd { margin: 0; overflow-wrap: anywhere; }
.senha-provisoria { display: inline-block; padding: 4px 10px; border: 1px dashed var(--accent); border-radius: 6px; font-family: inherit; font-size: 18px; font-weight: 600; letter-spacing: .04em; user-select: all; }

/* ---------------------------------------------------------------- login */
.auth-page { display: grid; min-height: 100vh; place-items: center; padding: 18px; background: var(--canvas); }
/* Faixa dourada no topo do cartão: detalhe da paleta oficial, sem sombra nem degradê (manual da marca). */
.auth-card { width: min(100%, 430px); padding: 28px; background: var(--paper); border: 1px solid var(--line); border-top: 3px solid var(--moinho-dourado); border-radius: var(--radius); }
.auth-card .auth-logo { --logo: 240px; margin: -6px auto 14px; }
.auth-card h1 { margin: 0 0 6px; font-weight: 600; font-size: 22px; letter-spacing: -.03em; }
.auth-card .muted { margin: 0 0 20px; font-size: 13px; }

/* ---------------------------------------------------------------- segundo fator (aplicativo autenticador) */
.auth-card.wide { width: min(100%, 520px); }
.passos { margin: 0 0 20px; padding-left: 20px; font-size: 13px; }
.passos li { margin-bottom: 14px; }
.passos .note { display: block; margin-top: 6px; }
/* QR code (SVG dentro da página, sem cores próprias): módulos escuros no azul da marca, sobre o branco. Sem o
   contorno da regra geral de "svg" (feita para os ícones de traço), que engrossaria cada módulo e apagaria o código. */
/* Centralizado no cartão: "auto" centraliza no item da lista, e o deslocamento de -10px desfaz metade do recuo de
   20px da lista numerada (.passos). */
.qr-svg { display: block; position: relative; left: -10px; width: 200px; height: 200px; margin: 12px auto 8px; background: var(--paper); stroke: none; }
.qr-svg .dark { fill: var(--moinho-azul); stroke: none; }
.chave-totp { display: block; margin-top: 6px; padding: 8px 10px; border: 1px dashed var(--accent); border-radius: 6px; font-family: inherit; font-size: 15px; font-weight: 600; letter-spacing: .06em; overflow-wrap: anywhere; user-select: all; }
/* Código por e-mail (Etapa C) e cadastro opcional do aplicativo, que se abre ao clicar. */
.form-email { margin: 12px 0 18px; }
.auth-card .form-codigo { margin-bottom: 18px; }
.cadastro-opcional { padding-top: 14px; border-top: 1px solid var(--line); }
.cadastro-opcional summary { font-size: 13px; font-weight: 600; cursor: pointer; }
.cadastro-opcional .passos { margin-top: 14px; }
.codigos-recuperacao { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 28px; margin: 0 0 22px; padding-left: 24px; font-size: 15px; font-weight: 600; letter-spacing: .04em; }

/* ---------------------------------------------------------------- acessibilidade */
.control:focus, button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------------------------------------------------------------- telas menores */
@media (max-width: 1200px) {
    .content { padding-inline: 28px; }
}
@media (max-width: 760px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; padding: 16px; border-right: 0; border-bottom: 1px solid var(--line); }
    .brand { margin: 0 0 8px; }
    .brand .logo-area { --logo: 150px; }
    .desktop-nav { display: none; }
    .mobile-nav { display: block; margin-bottom: 6px; }
    .mobile-nav summary { padding: 8px 0; color: var(--accent-ink); font-size: 14px; font-weight: 600; cursor: pointer; }
    .mobile-nav .nav-group { margin-top: 9px; }
    .logout { margin-top: 8px; padding-top: 12px; }
    .content { padding: 26px 18px 38px; }
    .workspace-header { flex-direction: column; align-items: flex-start; gap: 18px; margin-bottom: 24px; }
    .workspace-header h1 { font-size: 27px; }
    .table-wrap { overflow: visible; border: 0; }
    .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; }
    .data-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
    .data-table tr { margin-bottom: 10px; padding: 4px 0; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; }
    .data-table td { display: grid; grid-template-columns: minmax(106px, .7fr) minmax(0, 1.3fr); gap: 8px; padding: 9px 12px; border: 0; font-size: 14px; text-align: left; overflow-wrap: anywhere; }
    .data-table td::before { content: attr(data-label); color: var(--muted); font-size: 13px; font-weight: 600; }
    .usuario-zonas { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
    .auth-card { padding: 22px 18px; }
    .auth-card .auth-logo { --logo: 180px; }
}
