:root {
    --azul: #1B4F8A;
    --ambar: #E8A020;
    --cinza-bg: #f4f6f9;
    --texto: #1f2733;
    --borda: #d9dee6;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--texto);
    background: var(--cinza-bg);
    line-height: 1.5;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.card {
    background: #fff;
    border: 1px solid var(--borda);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
}

h1 { color: var(--azul); margin-top: 0; }
a { color: var(--azul); }

.muted { color: #6b7480; }

/* Barra superior (autenticado) */
.topbar {
    background: var(--azul);
    color: #fff;
}
.topbar__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: .75rem;
    padding-bottom: .75rem;
}
.topbar__marca { color: #fff; font-weight: 600; text-decoration: none; }
.topbar__usuario { display: flex; align-items: center; gap: .75rem; font-size: .95rem; }
.inline { display: inline; margin: 0; }
.link-btn {
    background: none;
    border: 0;
    color: #cfe0f2;
    cursor: pointer;
    font: inherit;
    text-decoration: underline;
    padding: 0;
}
.link-btn:hover { color: #fff; }

/* Formulários */
.card--auth { max-width: 400px; margin: 3rem auto 0; }
label { display: block; margin: 1rem 0 .25rem; font-weight: 600; font-size: .9rem; }
input[type="email"],
input[type="password"],
input[type="text"] {
    width: 100%;
    padding: .6rem .7rem;
    border: 1px solid var(--borda);
    border-radius: 6px;
    font: inherit;
}
input:focus { outline: 2px solid var(--azul); outline-offset: 1px; }

.btn {
    display: inline-block;
    margin-top: 1.25rem;
    padding: .6rem 1.2rem;
    border: 0;
    border-radius: 6px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.btn--primario { background: var(--azul); color: #fff; }
.btn--primario:hover { background: #163f6f; }

.btn--secundario { background: #fff; color: var(--azul); border: 1px solid var(--azul); }
.btn--secundario:hover { background: #eef4fb; }

/* Alertas */
.alerta {
    margin-top: 1rem;
    margin-bottom: 1rem;
    padding: .7rem .9rem;
    border-radius: 6px;
    font-size: .95rem;
}
.alerta--erro    { background: #fdecea; border: 1px solid #f5c2c0; color: #9b1c17; }
.alerta--sucesso { background: #e7f6ec; border: 1px solid #b7e0c4; color: #1c6b3a; }

/* Navegação na barra superior */
.topbar__nav { display: flex; gap: 1rem; margin-right: auto; margin-left: 1.5rem; }
.topbar__nav a { color: #cfe0f2; text-decoration: none; }
.topbar__nav a:hover { color: #fff; }

/* Cabeçalho de card com ação à direita */
.card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}
.card__head h1 { margin: 0; }

/* Tabelas */
.tabela-wrap { overflow-x: auto; }
.tabela { width: 100%; border-collapse: collapse; }
.tabela th, .tabela td {
    text-align: left;
    padding: .6rem .5rem;
    border-bottom: 1px solid var(--borda);
    vertical-align: middle;
}
.tabela th { font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; color: #6b7480; }
.tabela code { background: #f0f3f7; padding: .1rem .35rem; border-radius: 4px; font-size: .9em; }
.col-acoes { width: 1%; white-space: nowrap; }
.linha-vigente { background: #eef6ee; }
.col-check { width: 1%; text-align: center; white-space: nowrap; }
.col-check input { width: 1.05rem; height: 1.05rem; cursor: pointer; }
.acoes { display: flex; gap: .75rem; align-items: center; white-space: nowrap; }
.link { color: var(--azul); text-decoration: none; }
.link:hover { text-decoration: underline; }

/* Selos de status */
.badge {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 600;
}
.badge--ok       { background: #e7f6ec; color: #1c6b3a; }
.badge--off      { background: #eceff3; color: #6b7480; }
.badge--rascunho { background: #e8f0fa; color: var(--azul); }

/* Formulários maiores + ações */
.card--form { max-width: 560px; }
.uf-input { text-transform: uppercase; max-width: 6rem; }
.erro-campo { color: #9b1c17; font-size: .85rem; margin: .25rem 0 0; }
.form-acoes { display: flex; gap: .75rem; align-items: center; margin-top: 1.5rem; }
.form-acoes .btn { margin-top: 0; }

/* Atalhos do painel */
.atalhos { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1.25rem 0; }
.atalhos .btn { margin-top: 0; }

/* Formulário de competência */
.linha-dupla { display: flex; gap: 1rem; flex-wrap: wrap; }
.linha-dupla > div { flex: 1 1 12rem; }
select {
    width: 100%;
    padding: .6rem .7rem;
    border: 1px solid var(--borda);
    border-radius: 6px;
    font: inherit;
    background: #fff;
}
input[type="number"] {
    width: 100%;
    padding: .6rem .7rem;
    border: 1px solid var(--borda);
    border-radius: 6px;
    font: inherit;
}
input[type="file"] {
    width: 100%;
    padding: .5rem;
    border: 1px dashed var(--borda);
    border-radius: 6px;
    background: #fafbfc;
}

/* Selo âmbar de alerta de formato (RN-017) */
.badge--alerta {
    background: #fdf1dc;
    color: #8a5a09;
    border: 1px solid var(--ambar);
}

/* Resultado do upload */
.resultado-upload { margin: 1rem 0 1.5rem; }
.resultado-upload h2 { font-size: 1rem; margin: 0 0 .5rem; }
.lista-resultado { list-style: none; padding: 0; margin: 0; }
.lista-resultado li {
    padding: .5rem .7rem;
    border-radius: 6px;
    margin-bottom: .4rem;
    font-size: .95rem;
    display: flex;
    gap: .5rem;
    align-items: baseline;
}
.res-ok   { background: #e7f6ec; color: #1c6b3a; }
.res-erro { background: #fdecea; color: #9b1c17; }
.res-badge { font-weight: 700; }

/* Breadcrumb */
.breadcrumb { margin: 0 0 1rem; font-size: .9rem; color: #6b7480; }
.breadcrumb a { color: var(--azul); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb span { margin: 0 .35rem; color: #b0b8c2; }

/* Botão de link com variação de perigo (excluir rascunho) */
.link-btn--perigo { color: #9b1c17; }
.link-btn--perigo:hover { color: #6f130f; }

/* Selo âmbar inline dentro da célula de arquivo */
.tabela .badge--alerta { margin-left: .4rem; font-weight: 600; }

/* Botão compacto (ações inline em tabelas) */
.btn--sm { padding: .3rem .7rem; font-size: .85rem; }

/* Abas (Auditoria / Downloads) */
.tabs { display: flex; gap: .5rem; }
.tab {
    padding: .35rem .8rem;
    border: 1px solid var(--borda);
    border-radius: 6px;
    text-decoration: none;
    color: var(--azul);
    font-size: .9rem;
}
.tab--ativa { background: var(--azul); color: #fff; border-color: var(--azul); }

/* Paginação */
.pager { display: flex; gap: .75rem; margin-top: 1rem; }

/* JSON de detalhes na auditoria */
pre.json {
    margin: .5rem 0 0;
    padding: .5rem .6rem;
    background: #f0f3f7;
    border-radius: 6px;
    max-width: 40rem;
    max-height: 16rem;
    overflow: auto;
    font-size: .8rem;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Lista de resumo (dt/dd) em telas de ação */
.resumo { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0 0 1.25rem; }
.resumo dt { color: #6b7480; font-size: .9rem; }
.resumo dd { margin: 0; }

/* Filtro da área do destinatário */
.filtro {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f7f9fc;
    border: 1px solid var(--borda);
    border-radius: 8px;
}
.filtro__linha { display: flex; flex-wrap: wrap; gap: 1rem; }
.filtro__linha label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; }
.filtro__linha select { min-width: 12rem; }
.filtro__tipos {
    margin: 1rem 0 0;
    padding: .75rem 1rem;
    border: 1px solid var(--borda);
    border-radius: 6px;
}
.filtro__tipos legend { font-size: .85rem; color: #6b7480; padding: 0 .35rem; }
.filtro__tipo {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    margin-right: 1.25rem;
    font-size: .95rem;
}
.filtro .form-acoes { margin-top: 1rem; }

/* Grade de permissões: cliente (linha) × tipo (coluna) */
.tabela--grade th, .tabela--grade td { text-align: center; }
.tabela--grade .grade__cliente,
.tabela--grade .grade__canto {
    text-align: left;
    white-space: nowrap;
    text-transform: none;
    letter-spacing: 0;
    font-size: .95rem;
    color: inherit;
}
.tabela--grade .grade__cliente .muted { font-weight: 400; }
.tabela--grade .grade__cel input { width: 1.1rem; height: 1.1rem; cursor: pointer; }
.tabela--grade tbody tr:hover { background: #f7f9fc; }
