/* ═══════════════════════════════════════════════════════════════
   FolhaLab — Base: variáveis, tipografia, reset global
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* ── Cores principais ──────────────────────────────────────── */
  --vermelho:   #DA291C;
  --vermelho-h: rgba(218, 41, 28, .07);  /* hover/bg sutil */
  --grafite:    #1a1a1a;
  --texto:      #333;
  --texto-sec:  #666;
  --cinza:      #f4f4f6;
  --cinza-md:   #e8e8ec;
  --borda:      #e3e3e8;
  --branco:     #fff;

  /* ── Sombras ────────────────────────────────────────────────── */
  --sombra-xs: 0 1px 2px rgba(0,0,0,.05);
  --sombra-sm: 0 2px 8px rgba(0,0,0,.07);
  --sombra-md: 0 4px 16px rgba(0,0,0,.08);

  /* ── Arredondamentos ─────────────────────────────────────────── */
  --radius-sm: .5rem;
  --radius-md: .75rem;
  --radius-lg: 1rem;
}

/* ═══════════════════════════════════════════════════════════════
   Reset e base
   ═══════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--texto);
  background: #fafafa;
  font: 15px/1.55 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Arial, sans-serif;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  margin: .4rem 0;
  font-weight: 700;
  line-height: 1.25;
  color: var(--grafite);
}
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }

.lead {
  color: var(--texto-sec);
  margin: .25rem 0 .75rem;
  font-size: .96rem;
}

a { color: var(--grafite); text-decoration: none; }
a:hover { color: var(--vermelho); }

[hidden] { display: none !important; }

input, select, textarea, button { font: inherit; }

input, select, textarea {
  font-size: .95rem;
  line-height: 1.4;
  color: var(--grafite);
  background: #fff;
  border: 1px solid var(--borda);
  border-radius: var(--radius-sm);
  padding: .5rem .7rem;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #aaa;
  box-shadow: 0 0 0 3px rgba(0,0,0,.06);
}

label {
  display: grid;
  gap: .3rem;
  font-size: .88rem;
  font-weight: 600;
  color: #444;
}

/* ═══════════════════════════════════════════════════════════════
   Tabela geral
   ═══════════════════════════════════════════════════════════════ */
.table-wrap {
  display: block;
  overflow-x: auto;
  overflow-y: hidden;
  width: 100%;
  max-width: calc(100vw - 2.5rem);
  border-radius: var(--radius-sm);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.table th,
.table td {
  border: 1px solid var(--borda);
  padding: .5rem .65rem;
  text-align: left;
}
.table th {
  background: var(--cinza);
  font-weight: 600;
  color: #444;
  font-size: .83rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
  vertical-align: bottom;
}
.table td { vertical-align: top; }
.table tr:hover td { background: #fafafa; }
.table tr.is-alert td { background: #fff3f0; }

/* ── Folha específica ───────────────────────────────────────── */
.table--folha {
  display: table;
  table-layout: auto;
  width: max-content;
  min-width: 1200px;
}
.table--folha th { text-transform: none; letter-spacing: 0; font-size: .875rem; }

/* Colunas da folha */
.table--folha th.col-matricula, .table--folha td.col-matricula { min-width:90px;  white-space:nowrap; }
.table--folha th.col-nome,      .table--folha td.col-nome      { min-width:240px; }
.table--folha th.col-evento,    .table--folha td.col-evento    { min-width:240px; }
.table--folha th.col-codigo,    .table--folha td.col-codigo    { min-width:90px;  white-space:nowrap; }
.table--folha th.col-ref,       .table--folha td.col-ref       { min-width:70px;  white-space:nowrap; }
.table--folha th.col-valor,     .table--folha td.col-valor     { min-width:120px; white-space:nowrap; }
.table--folha th.col-cpf,       .table--folha td.col-cpf       { min-width:130px; white-space:nowrap; }
.table--folha th.col-cargo,     .table--folha td.col-cargo     { min-width:160px; }
.table--folha th.col-regime,    .table--folha td.col-regime    { min-width:90px;  white-space:nowrap; }
.table--folha th.col-fgts,      .table--folha td.col-fgts      { min-width:70px;  white-space:nowrap; }
.table--folha th.col-processamento, .table--folha td.col-processamento { min-width:130px; white-space:nowrap; }
.table--folha th.col-acoes,     .table--folha td.col-acoes     { min-width:200px; white-space:nowrap; }
.table--folha td.col-acoes .btn { padding:5px 10px; font-size:.82rem; }
.table--folha td.col-acoes .btn + .btn { margin-left:5px; }

.text-ellipsis {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.table--folha td.col-nome .text-ellipsis,
.table--folha td.col-evento .text-ellipsis { max-width: 240px; }

.table td.actions {
  width: 140px;
  min-width: 140px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
}
.table th.actions  { width: 140px; min-width: 140px; }
.table td.actions .btn { white-space: nowrap; }

.table.eventos td.incidencia,
.table.eventos th.incidencia { width: 80px; text-align: center; }

.table-sm th, .table-sm td { font-size: .875rem; }

/* ═══════════════════════════════════════════════════════════════
   Badges e labels
   ═══════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  background: var(--cinza);
  border-radius: 999px;
  padding: .2rem .6rem;
  font-size: .8rem;
  font-weight: 600;
  line-height: 1.3;
}
.badge-warn {
  background: #ffe9e6;
  color: #b42318;
}

/* ═══════════════════════════════════════════════════════════════
   Destaques / alertas inline
   ═══════════════════════════════════════════════════════════════ */
.irrf-highlight {
  background: #fff7e6;
  border-left: 3px solid var(--vermelho);
  padding: .6rem .9rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: .5rem 0 .8rem;
  font-weight: 600;
  font-size: .93rem;
}

/* ═══════════════════════════════════════════════════════════════
   Helpers / utilitários
   ═══════════════════════════════════════════════════════════════ */
.colunas-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  margin: 10px 0;
}
.competencia-field { max-width: 240px; }
