/* ── Reset & Variáveis ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #f4f3ef;
  --surface:      #ffffff;
  --surface-alt:  #f0eeea;
  --border:       #e0ddd6;
  --text:         #1a1916;
  --text-muted:   #6b6860;
  --accent:       #1a3a2a;
  --accent-light: #2d5c42;
  --accent-dim:   #e8f0eb;
  --accent-mid:   #4a8c65;
  --danger:       #8b2020;
  --danger-dim:   #fdf0f0;
  --warning:      #7a5c10;
  --warning-dim:  #fdf8e8;
  --success:      #1a4a28;
  --success-dim:  #eaf4ee;
  --orange:       #c44a10;
  --orange-dim:   #fff0e8;
  --sidebar-w:    240px;
  --topbar-h:     56px;
  --radius:       8px;
  --radius-lg:    14px;
  --shadow:       0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.04);
  --shadow-lg:    0 8px 32px rgba(0,0,0,.12);
  --transition:   .16s ease;
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body:    'DM Sans', system-ui, sans-serif;
}

html { font-size: 16px; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
}

/* ══════════════════════════════════════════════════════════════
   LAYOUT — SIDEBAR + MAIN
══════════════════════════════════════════════════════════════ */

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--accent);
  display: flex; flex-direction: column;
  z-index: 200;
  box-shadow: 2px 0 12px rgba(0,0,0,.15);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}

.sidebar-logo {
  max-height: 44px; max-width: 160px;
  object-fit: contain; border-radius: 6px;
  display: block; margin: 0 auto;
}

.sidebar-brand-text {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: #e8f0eb;
  text-align: center;
  line-height: 1.3;
  display: block;
}

.sidebar-empresa {
  padding: .6rem 1.25rem;
  background: rgba(0,0,0,.15);
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.sidebar-empresa-label { font-size: .65rem; text-transform: uppercase; letter-spacing: .08em; color: #7fbf9a; }
.sidebar-empresa-nome  { font-size: .8rem; color: #c8d8cc; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-nav { flex: 1; padding: .75rem 0; }

.nav-section-title {
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #5d9070;
  padding: .75rem 1.25rem .3rem;
}

.nav-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .6rem 1.25rem;
  color: #c8d8cc;
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  position: relative;
  white-space: nowrap;
  overflow: hidden;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active {
  background: rgba(255,255,255,.14);
  color: #fff;
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px;
  background: #7fbf9a;
  border-radius: 0 2px 2px 0;
}
.nav-icon { font-size: 1rem; flex-shrink: 0; width: 20px; text-align: center; }

.nav-badge {
  margin-left: auto;
  background: var(--orange);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  min-width: 18px; height: 18px;
  border-radius: 99px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

.sidebar-footer {
  padding: .75rem 1.25rem 1rem;
  border-top: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}
.sidebar-user { font-size: .8rem; color: #9dbfa8; margin-bottom: .5rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user strong { display: block; color: #e8f0eb; font-size: .875rem; }
.sidebar-logout {
  display: flex; align-items: center; gap: .5rem;
  color: #c8d8cc; font-size: .8rem;
  text-decoration: none;
  padding: .4rem .6rem; border-radius: var(--radius);
  transition: background var(--transition);
}
.sidebar-logout:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ── Main area ─────────────────────────────────────────────── */

.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 2rem;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.topbar-title { font-family: var(--font-display); font-size: 1.15rem; color: var(--accent); font-weight: 400; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.topbar-chip {
  background: var(--accent-dim);
  color: var(--accent);
  font-size: .75rem;
  font-weight: 600;
  padding: .2rem .75rem;
  border-radius: 99px;
}

.page-content { padding: 2rem; flex: 1; }

/* ── Login page (sem sidebar) ──────────────────────────────── */
.auth-page {
  min-height: 100vh; width: 100%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(45,92,66,.6) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(26,58,42,.8) 0%, transparent 50%);
  padding: 1rem;
}
.auth-box { width: 100%; max-width: 420px; background: var(--surface);
  border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; }
.auth-header { background: var(--accent); padding: 2rem 2rem 1.5rem; text-align: center; }
.auth-logo { max-height: 60px; max-width: 200px; object-fit: contain; display: block; margin: 0 auto .75rem; }
.auth-title { font-family: var(--font-display); font-size: 1.4rem; color: #e8f0eb; font-weight: 400; }
.auth-sub { color: #9dbfa8; font-size: .8rem; margin-top: .25rem; }
.auth-body { padding: 2rem; }

/* ══════════════════════════════════════════════════════════════
   COMPONENTES
══════════════════════════════════════════════════════════════ */

/* ── Formulários ───────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }
.form-label {
  display: block; font-size: .75rem; font-weight: 600;
  color: var(--text-muted); letter-spacing: .06em;
  text-transform: uppercase; margin-bottom: .35rem;
}
.form-input, .form-select {
  width: 100%; padding: .65rem 1rem;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  font-family: var(--font-body); font-size: .95rem;
  color: var(--text); background: var(--bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-input:focus, .form-select:focus {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 3px rgba(45,92,66,.12);
  background: #fff;
}
textarea.form-input { resize: vertical; min-height: 90px; }

/* ── Botões ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .6rem 1.25rem; border-radius: var(--radius);
  font-family: var(--font-body); font-size: .875rem;
  font-weight: 600; cursor: pointer; border: none;
  text-decoration: none; transition: all var(--transition); white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-light); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(26,58,42,.25); }
.btn-outline { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.btn-outline:hover { background: var(--accent-dim); }
.btn-danger  { background: var(--danger-dim); color: var(--danger); border: 1.5px solid #e8b4b4; }
.btn-danger:hover { background: #f9dede; }
.btn-pdf    { background: var(--accent); color: #fff; }
.btn-pdf:hover { background: var(--accent-light); }
.btn-warning { background: var(--warning-dim); color: var(--warning); border: 1.5px solid #e6c87a; }
.btn-sm { padding: .3rem .75rem; font-size: .78rem; }
.btn-xs { padding: .2rem .5rem; font-size: .72rem; }
.btn-full { width: 100%; justify-content: center; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}
.card-sm { padding: 1rem 1.25rem; }

/* ── Página de seção ───────────────────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem; flex-wrap: wrap; gap: .75rem;
}
.flex-wrap { flex-wrap: wrap; }
.section-title { font-family: var(--font-display); font-size: 1.35rem; color: var(--accent); font-weight: 400; }
.section-subtitle { color: var(--text-muted); font-size: .85rem; }

/* ── Flash messages ────────────────────────────────────────── */
.flash-container { margin-bottom: 1.25rem; display: flex; flex-direction: column; gap: .4rem; }
.flash { padding: .7rem 1.1rem; border-radius: var(--radius); font-size: .85rem; font-weight: 500; border-left: 4px solid; }
.flash-success { background: var(--success-dim); color: var(--success); border-color: #2d8c50; }
.flash-error   { background: var(--danger-dim);  color: var(--danger);  border-color: #c0392b; }
.flash-warning { background: var(--warning-dim); color: var(--warning); border-color: #e6a800; }

/* ── Stat cards ────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem 1.5rem; box-shadow: var(--shadow); }
.stat-value { font-family: var(--font-display); font-size: 2rem; color: var(--accent); font-weight: 400; line-height: 1; }
.stat-label { color: var(--text-muted); font-size: .8rem; margin-top: .3rem; }

/* ── Tabelas ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th { text-align: left; padding: .65rem 1rem; font-size: .7rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text-muted); border-bottom: 2px solid var(--border); white-space: nowrap; }
tbody td { padding: .8rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-alt); }
.td-right  { text-align: right; }
.td-center { text-align: center; }
.td-nowrap { white-space: nowrap; }

/* ── Badges ────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: .15rem .65rem; border-radius: 99px; font-size: .72rem; font-weight: 700; }
.badge-green  { background: var(--success-dim); color: var(--success); }
.badge-gray   { background: var(--surface-alt); color: var(--text-muted); border: 1px solid var(--border); }
.badge-blue   { background: #e8f0fb; color: #1a3a6a; }
.badge-orange { background: var(--orange-dim); color: var(--orange); }
.badge-red    { background: var(--danger-dim); color: var(--danger); }

/* ── Status de visualização ────────────────────────────────── */
.vis-dot { font-size: 1rem; line-height: 1; }
.vis-sim { color: #2d8c50; }
.vis-nao { color: #c0392b; }

/* ── Contracheque cards ────────────────────────────────────── */
.cc-list { display: flex; flex-direction: column; gap: .6rem; }
.cc-item {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem 1.25rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); transition: box-shadow var(--transition), transform var(--transition);
  text-decoration: none; color: var(--text);
}
.cc-item:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.cc-item.nao-visto { border-left: 4px solid var(--orange); }
.cc-icon { width: 40px; height: 40px; background: var(--accent-dim); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }
.cc-info { flex: 1; min-width: 0; }
.cc-ref  { font-weight: 600; font-size: .95rem; }
.cc-meta { font-size: .78rem; color: var(--text-muted); margin-top: .1rem; }
.cc-liquido { font-size: 1.05rem; font-weight: 700; color: var(--accent); text-align: right; white-space: nowrap; }
.cc-actions { display: flex; gap: .4rem; flex-shrink: 0; }

/* ── Totais do contracheque ────────────────────────────────── */
.cc-totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin-bottom: 1.25rem; }
.cc-total  { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem 1.25rem; text-align: center; box-shadow: var(--shadow); }
.cc-total-label { font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.cc-total-value { font-size: 1.3rem; font-weight: 700; margin-top: .3rem; }
.cc-total.proventos .cc-total-value { color: var(--success); }
.cc-total.descontos .cc-total-value { color: var(--danger); }
.cc-total.liquido   .cc-total-value { color: var(--accent); }
.cc-total.liquido   { border: 2px solid var(--accent); }

/* ── Valores na tabela de verbas ───────────────────────────── */
.val-provento { color: var(--success); font-weight: 600; }
.val-desconto { color: var(--danger);  font-weight: 600; }

/* ── Documentos ────────────────────────────────────────────── */
.doc-list { display: flex; flex-direction: column; gap: .6rem; }
.doc-item { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.doc-item.nao-lido { border-left: 4px solid var(--orange); }
.doc-icon { width: 42px; height: 42px; background: var(--orange-dim); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; }
.doc-info { flex: 1; min-width: 0; }
.doc-title { font-weight: 600; font-size: .9rem; }
.doc-meta  { font-size: .75rem; color: var(--text-muted); margin-top: .1rem; }
.badge-novo { background: var(--orange-dim); color: var(--orange); border: 1px solid #f5c4a8; padding: .1rem .5rem; border-radius: 99px; font-size: .68rem; font-weight: 700; }
.cat-tag    { background: var(--accent-dim); color: var(--accent); padding: .15rem .55rem; border-radius: 99px; font-size: .7rem; font-weight: 600; display: inline-block; }

/* ── Welcome banner ────────────────────────────────────────── */
.welcome-banner {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
  color: #e8f0eb; border-radius: var(--radius-lg); padding: 1.5rem 2rem;
  margin-bottom: 1.5rem; position: relative; overflow: hidden;
}
.welcome-banner::after { content: '⬡'; position: absolute; right: 1.5rem; top: 50%; transform: translateY(-50%); font-size: 5rem; opacity: .07; }
.welcome-banner h2 { font-family: var(--font-display); font-size: 1.4rem; font-weight: 400; }
.welcome-info { display: flex; gap: 2rem; margin-top: .75rem; flex-wrap: wrap; }
.wi-label { font-size: .65rem; letter-spacing: .08em; text-transform: uppercase; color: #7fbf9a; }
.wi-value { font-size: .875rem; font-weight: 500; }

/* ── Upload zone ───────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius-lg);
  padding: 2.5rem; text-align: center; cursor: pointer;
  transition: all var(--transition); background: var(--bg);
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--accent-light); background: var(--accent-dim); }
.upload-icon { font-size: 2.5rem; margin-bottom: .5rem; }
.upload-text { font-size: .875rem; color: var(--text-muted); }
.upload-text strong { color: var(--accent); }

/* ── Filtros ───────────────────────────────────────────────── */
.filter-bar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem 1.25rem; margin-bottom: 1.25rem; display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
.filter-group { display: flex; flex-direction: column; gap: .25rem; min-width: 140px; }
.filter-label { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.filter-input, .filter-select { padding: .45rem .8rem; border: 1.5px solid var(--border); border-radius: var(--radius); font-size: .85rem; background: var(--bg); color: var(--text); outline: none; }
.filter-input:focus, .filter-select:focus { border-color: var(--accent-light); }

/* ── Empresa cards ─────────────────────────────────────────── */
.empresa-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.empresa-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem; box-shadow: var(--shadow); transition: box-shadow var(--transition); }
.empresa-card:hover { box-shadow: var(--shadow-lg); }
.empresa-card.inativa { opacity: .6; }
.empresa-nome { font-weight: 700; font-size: 1rem; margin-bottom: .25rem; }
.empresa-cnpj { font-size: .78rem; color: var(--text-muted); font-family: monospace; }
.empresa-stats { display: flex; gap: 1rem; margin-top: .75rem; font-size: .78rem; color: var(--text-muted); }
.empresa-stat strong { display: block; font-size: 1.1rem; color: var(--accent); font-weight: 700; }

/* ── Seleção de empresa ────────────────────────────────────── */
.empresa-select-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.empresa-select-card {
  background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.5rem; text-align: center; text-decoration: none; color: var(--text);
  transition: all var(--transition); box-shadow: var(--shadow);
}
.empresa-select-card:hover { border-color: var(--accent); background: var(--accent-dim); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.empresa-select-icon { font-size: 2rem; margin-bottom: .5rem; }
.empresa-select-nome { font-weight: 700; font-size: 1rem; }
.empresa-select-cnpj { font-size: .75rem; color: var(--text-muted); margin-top: .2rem; }
.empresa-select-cargo { font-size: .78rem; color: var(--accent-mid); margin-top: .3rem; font-weight: 500; }

/* ── Empty state ───────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3rem 2rem; color: var(--text-muted); }
.empty-icon  { font-size: 2.5rem; margin-bottom: .75rem; opacity: .5; }

/* ── Comunicados ───────────────────────────────────────────── */
.comunicado-fixado { background: var(--accent); color: #e8f0eb; border-radius: var(--radius-lg); padding: .875rem 1.25rem; display: flex; gap: .75rem; align-items: flex-start; margin-bottom: .5rem; }
.comunicado-fixado-titulo { font-weight: 700; font-size: .9rem; }
.comunicado-fixado-corpo  { font-size: .83rem; opacity: .85; margin-top: .15rem; }
.comunicado-normal { border-left: 4px solid var(--accent-mid); padding: .75rem 1rem; background: var(--bg); border-radius: 0 var(--radius) var(--radius) 0; margin-bottom: .4rem; }
.comunicado-titulo { font-weight: 600; font-size: .88rem; }
.comunicado-corpo  { font-size: .82rem; color: var(--text-muted); margin-top: .15rem; }

/* ── Utilitários ───────────────────────────────────────────── */
.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: .8rem; }
.text-xs     { font-size: .72rem; }
.text-right  { text-align: right; }
.font-bold   { font-weight: 700; }
.font-mono   { font-family: monospace; }
.mt-1 { margin-top: .5rem; }  .mt-2 { margin-top: 1rem; }   .mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; }  .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-1 { gap: .5rem; } .gap-2 { gap: .75rem; }
.w-full { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 1rem; }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVO
══════════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
  :root { --sidebar-w: 200px; }
}

@media (max-width: 700px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .page-content { padding: 1rem; }
  .cc-totals { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .cc-item { flex-wrap: wrap; }
  .cc-actions { width: 100%; }
  .topbar { padding: 0 1rem; }
  .menu-toggle { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; background: var(--accent-dim); border: none; border-radius: var(--radius); cursor: pointer; font-size: 1.2rem; color: var(--accent); }
}

@media (min-width: 701px) {
  .menu-toggle { display: none; }
}
