/* Tema escuro do sistema (mesma identidade do modelo aprovado). */
:root {
  --bg: #0a0e17;
  --panel: #111827;
  --panel2: #0f1523;
  --border: #1f2937;
  --text: #e2e8f0;
  --muted: #64748b;
  --soft: #94a3b8;
  --accent: #22d3ee;
  --purple: #a78bfa;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --pink: #ec4899;
  --sidebar: 240px;
  --sidebar-recolhida: 68px;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; }
html { background: var(--bg); }
body { background: var(--bg); color: var(--text); min-height: 100vh; overflow-x: hidden; }
.escondido { display: none !important; }
a { color: var(--accent); }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; transition: grid-template-columns .2s; }
.app.recolhida { grid-template-columns: var(--sidebar-recolhida) 1fr; }

.sidebar {
  background: var(--panel2); border-right: 1px solid var(--border);
  padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; gap: 6px;
}
.sidebar-topo { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 14px; }
.brand {
  font-size: 1.02rem; font-weight: 700; padding: 8px 6px; white-space: nowrap; overflow: hidden;
  background: linear-gradient(90deg, #22d3ee, #a78bfa); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand small { display: block; font-size: .7rem; font-weight: 500; -webkit-text-fill-color: var(--muted); }
.btn-recolher {
  flex-shrink: 0; width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel); color: var(--soft); cursor: pointer; font-size: .9rem;
}
.btn-recolher:hover { color: var(--text); border-color: #374151; }

.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav button {
  text-align: left; background: transparent; border: none; color: var(--soft);
  padding: 11px 12px; border-radius: 8px; font-size: .87rem; font-weight: 500; cursor: pointer;
  transition: all .15s; display: flex; align-items: center; gap: 10px; white-space: nowrap;
  border-left: 3px solid transparent;
}
.sidebar nav button .ico { width: 20px; text-align: center; flex-shrink: 0; }
.sidebar nav button:hover { background: #1a2233; color: var(--text); }
.sidebar nav button.active {
  background: linear-gradient(90deg, rgba(34, 211, 238, .15), transparent);
  color: var(--accent); border-left-color: var(--accent);
}
.sidebar-footer {
  margin-top: auto; padding: 12px 8px 4px; border-top: 1px solid var(--border);
  font-size: .72rem; color: var(--muted); line-height: 1.5; display: flex; flex-direction: column; gap: 8px;
}
.sidebar-footer strong { color: #cbd5e1; }
.usuario-linha { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.cargo { font-size: .66rem; padding: 2px 8px; border-radius: 99px; background: rgba(100, 116, 139, .25); color: #cbd5e1; }
.cargo-dev { background: rgba(236, 72, 153, .2); color: #f9a8d4; }
.cargo-admin { background: rgba(167, 139, 250, .2); color: #c4b5fd; }
.btn-sair { width: 100%; }

/* Menu recolhido: só os ícones. */
.app.recolhida .sidebar { padding: 16px 10px; }
.app.recolhida .brand,
.app.recolhida .sidebar nav button .rotulo,
.app.recolhida .sidebar-footer .detalhe { display: none; }
.app.recolhida .sidebar-topo { justify-content: center; }
.app.recolhida .sidebar nav button { justify-content: center; padding: 11px 0; }
.app.recolhida .btn-sair .rotulo { display: none; }

main { padding: 24px; min-width: 0; }
header.topo { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
header.topo .titulos { display: flex; align-items: center; gap: 12px; }
header.topo h1 { font-size: 1.35rem; color: var(--text); }
header.topo .sub { font-size: .78rem; color: var(--muted); margin-top: 3px; }
.acoes-topo { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.btn-menu { display: none; }
.sidebar-fundo { display: none; }

/* ---------- Botões e campos ---------- */
.btn {
  border: none; padding: 9px 16px; border-radius: 9px; font-weight: 600; font-size: .83rem; cursor: pointer;
  transition: transform .15s, box-shadow .15s, opacity .15s; display: inline-flex; align-items: center;
  justify-content: center; gap: 6px; text-decoration: none; color: #fff;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: wait; transform: none; }
.btn-primary { background: linear-gradient(90deg, #22d3ee, #6366f1); color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-ghost { background: var(--panel); color: #cbd5e1; border: 1px solid var(--border); }
.btn-sm { padding: 6px 11px; font-size: .76rem; }
.btn-icone { padding: 5px 8px; font-size: .78rem; border-radius: 7px; }

label { display: block; font-size: .72rem; color: var(--soft); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; font-weight: 600; }
input, select, textarea {
  width: 100%; background: var(--panel2); border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 11px; color: var(--text); font-size: .87rem; font-family: inherit; transition: border-color .2s, box-shadow .2s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34, 211, 238, .12); }
input[type="date"] { color-scheme: dark; }
select { cursor: pointer; }
select option { background: var(--panel2); }
input[type="file"] { padding: 7px; font-size: .8rem; }
.dica { font-size: .74rem; color: var(--muted); margin-top: 6px; line-height: 1.45; }

/* ---------- Páginas ---------- */
.page { display: none; animation: fadeIn .25s; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.filter-bar {
  display: flex; gap: 12px; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 16px; margin-bottom: 18px; align-items: end;
}
.filter-bar > div { flex: 1; min-width: 140px; }
.filter-bar label { margin-bottom: 4px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 18px;
  transition: transform .2s, border-color .2s; position: relative; overflow: hidden; min-width: 0;
}
.kpi:hover { transform: translateY(-3px); border-color: #374151; }
.kpi .lbl { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.kpi .val { font-size: 1.7rem; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .val small { font-size: .9rem; color: var(--muted); font-weight: 500; }
.kpi .sub { font-size: .76rem; color: var(--muted); margin-top: 4px; }
.kpi .trend { font-size: .78rem; font-weight: 700; margin-top: 4px; }
.kpi.green { border-left: 3px solid var(--green); }
.kpi.yellow { border-left: 3px solid var(--yellow); }
.kpi.red { border-left: 3px solid var(--red); }
.kpi.blue { border-left: 3px solid var(--accent); }
.kpi.purple { border-left: 3px solid var(--purple); }
.up { color: var(--red); }
.down { color: var(--green); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; }
.mb { margin-bottom: 16px; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 18px; min-width: 0; }
.panel h3 { font-size: .92rem; color: #cbd5e1; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.panel h3 small { color: var(--muted); font-weight: 400; font-size: .72rem; }
.chart-wrap { position: relative; height: 260px; }
.chart-wrap.alto { height: 300px; }
.chart-wrap.baixo { height: 220px; }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; border-radius: 10px; }
.table-wrap.limitada { max-height: 560px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th {
  text-align: left; padding: 11px 10px; color: var(--muted); font-weight: 600; text-transform: uppercase;
  font-size: .66rem; letter-spacing: .5px; border-bottom: 1px solid var(--border); white-space: nowrap;
  position: sticky; top: 0; background: var(--panel);
}
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
td { padding: 10px; border-bottom: 1px solid var(--border); color: #cbd5e1; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #1a2233; }
td.acoes { white-space: nowrap; text-align: right; }
td.acoes .btn + .btn { margin-left: 4px; }
td.obs { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--soft); }
tr.inativo td { opacity: .5; }
#reg-tbody td:nth-child(2), #colab-tbody td:first-child { min-width: 190px; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: .7rem; font-weight: 700; white-space: nowrap; }
.badge.red { background: rgba(239, 68, 68, .15); color: #fca5a5; }
.badge.yellow { background: rgba(234, 179, 8, .15); color: #fcd34d; }
.badge.green { background: rgba(34, 197, 94, .15); color: #86efac; }
.badge.blue { background: rgba(34, 211, 238, .15); color: #67e8f9; }
.badge.gray { background: rgba(100, 116, 139, .2); color: #cbd5e1; }

/* ---------- Formulários ---------- */
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 14px; }
.form-acoes { display: flex; gap: 8px; flex-wrap: wrap; }
.form-compacto { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Mapa de calor ---------- */
.heatmap { display: grid; gap: 4px; font-size: .7rem; }
.heatmap .cell {
  min-height: 34px; border-radius: 4px; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; transition: transform .15s;
}
.heatmap .cell:hover { transform: scale(1.08); }
.heatmap .label { display: flex; align-items: center; color: var(--muted); font-weight: 600; }
.heatmap .header { color: var(--muted); text-align: center; font-weight: 700; padding: 2px 0; }

/* ---------- Previsão ---------- */
.method-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.method-card.best { border-color: var(--green); background: linear-gradient(180deg, rgba(34, 197, 94, .06), var(--panel)); }
.method-card h4 { font-size: .85rem; color: #cbd5e1; margin-bottom: 4px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.method-card .formula { font-family: 'Courier New', monospace; font-size: .72rem; color: var(--muted); margin-bottom: 12px; }
.method-card .forecast { font-size: 1.5rem; font-weight: 700; }
.method-card .meta { font-size: .72rem; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.tag-best { background: var(--green); color: #fff; padding: 2px 8px; border-radius: 10px; font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; font-size: .76rem; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.section-subtitle { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin: 24px 0 10px; }
.explicacao { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; font-size: .83rem; line-height: 1.7; color: var(--soft); }
.explicacao code { color: #cbd5e1; }

/* ---------- Avisos, padrões, relatório ---------- */
.aviso { padding: 11px 14px; border-radius: 10px; font-size: .84rem; line-height: 1.5; margin-bottom: 16px;
  background: rgba(234, 179, 8, .08); border: 1px solid rgba(234, 179, 8, .3); color: #fde68a; }
.aviso ul { margin: 6px 0 0 18px; }
.lista-padroes { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.lista-padroes li { display: flex; gap: 10px; align-items: flex-start; font-size: .84rem; line-height: 1.45; color: #cbd5e1;
  padding: 10px 12px; border-radius: 8px; background: var(--panel2); border-left: 3px solid var(--accent); }
.lista-padroes li.atencao { border-left-color: var(--yellow); }
.lista-padroes li.alerta { border-left-color: var(--red); }
.relatorio-exec { color: #cbd5e1; line-height: 1.8; font-size: .9rem; }
.relatorio-exec hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.relatorio-exec .rodape { color: var(--soft); font-size: .8rem; font-style: italic; margin-top: 12px; }
.botoes-relatorio { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.empty { text-align: center; padding: 40px 20px; color: #475569; }
.empty .icon { font-size: 2.4rem; opacity: .5; margin-bottom: 8px; }
.lista-simples { list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: .82rem; margin-top: 12px; }
.lista-simples li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px;
  border-radius: 8px; background: var(--panel2); }
.lista-simples li small { display: block; color: var(--muted); }
.lista-simples a { word-break: break-all; }
.mais { text-align: center; margin-top: 12px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 20% 0%, rgba(34, 211, 238, .08), transparent 50%), var(--bg); }
.login-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 14px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 16px; padding: 32px 28px; box-shadow: 0 20px 60px rgba(0, 0, 0, .45); }
.login-card h2 { font-size: 1.25rem; }
.login-card .sub { font-size: .85rem; color: var(--muted); margin-top: -8px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; text-transform: none; letter-spacing: 0; font-size: .82rem; }
.marca { font-size: 1.2rem; font-weight: 800; display: flex; flex-direction: column;
  background: linear-gradient(90deg, #22d3ee, #a78bfa); -webkit-background-clip: text; background-clip: text; color: transparent; }
.marca span { font-size: .78rem; font-weight: 600; -webkit-text-fill-color: var(--muted); }
.marca-login { margin-bottom: 6px; }
.campo-senha { position: relative; display: block; }
.campo-senha input { padding-right: 40px; }
.mostrar-senha { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; cursor: pointer; font-size: 1rem; opacity: .7; }
.btn-primario { background: linear-gradient(90deg, #22d3ee, #6366f1); color: #fff; }
.btn-largo { width: 100%; }
.alerta { padding: 10px 12px; border-radius: 10px; font-size: .88rem; line-height: 1.45; }
.alerta-erro { background: rgba(239, 68, 68, .12); border: 1px solid rgba(239, 68, 68, .4); }
.alerta-ok { background: rgba(34, 197, 94, .12); border: 1px solid rgba(34, 197, 94, .4); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; right: 24px; max-width: 380px; background: #14532d; color: #86efac;
  padding: 13px 20px; border-radius: 10px; font-weight: 600; box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  transform: translateY(100px); opacity: 0; transition: all .3s; z-index: 2000; border-left: 4px solid var(--green);
  font-size: .87rem; pointer-events: none;
}
.toast.visivel { transform: none; opacity: 1; }
.toast.erro { background: #450a0a; color: #fca5a5; border-color: var(--red); }

/* ---------- Responsivo ---------- */
@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .grid-2, .grid-2-1 { grid-template-columns: 1fr; }
  .app, .app.recolhida { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 260px; max-width: 85vw; z-index: 40;
    transform: translateX(-100%); transition: transform .2s; }
  .sidebar.aberta { transform: none; }
  .btn-recolher { display: none; }
  .app.recolhida .brand, .app.recolhida .sidebar nav button .rotulo,
  .app.recolhida .sidebar-footer .detalhe, .app.recolhida .btn-sair .rotulo { display: revert; }
  .app.recolhida .sidebar nav button { justify-content: flex-start; padding: 11px 12px; }
  .sidebar-fundo.aberta { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 30; }
  .btn.btn-menu { display: inline-flex; }
  main { padding: 16px; }
  header.topo h1 { font-size: 1.1rem; }
  .kpi .val { font-size: 1.4rem; }
}

/* ---------- Dicas ao passar o mouse ---------- */
.dica-flutuante {
  position: fixed; z-index: 1000; max-width: 300px; padding: 8px 11px; border-radius: 8px;
  background: #1e293b; color: var(--text); border: 1px solid #334155; box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
  font-size: .76rem; line-height: 1.45; pointer-events: none; opacity: 0; transition: opacity .12s;
  text-transform: none; letter-spacing: normal; font-weight: 400; top: -999px; left: -999px;
}
.dica-flutuante.visivel { opacity: 1; }

/* ---------- Registro coletivo ---------- */
label.check {
  display: flex; align-items: center; gap: 6px; margin: 7px 0 0; text-transform: none; letter-spacing: normal;
  font-size: .74rem; font-weight: 500; color: var(--soft); cursor: pointer;
}
label.check input { width: auto; margin: 0; accent-color: var(--accent); }
select:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Fechamento mensal ---------- */
.formula-linha {
  font-family: Consolas, 'Courier New', monospace; font-size: .84rem; color: var(--soft);
  background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; margin-bottom: 14px;
}
tfoot tr.total td {
  font-weight: 700; color: var(--text); border-top: 2px solid #374151; border-bottom: none;
  position: sticky; bottom: 0; background: var(--panel);
}
.form-observacao { display: flex; gap: 12px; align-items: flex-end; }
.form-observacao textarea { resize: vertical; min-height: 64px; }
.form-observacao .btn { white-space: nowrap; }
.observacao-mes { color: #cbd5e1; font-size: .88rem; line-height: 1.5; }

/* ---------- Faltas e atestados ---------- */
.grade-datas table { font-size: .8rem; }
.grade-datas th, .grade-datas td { white-space: nowrap; }
.grade-datas td { vertical-align: top; }
.grade-datas td.datas { line-height: 1.5; }
.grade-datas .mes-1 { background: rgba(148, 163, 184, .05); }
.grade-datas th.mes-1 { background: #151d2c; }
.grade-datas .fixa { position: sticky; left: 0; background: var(--panel); z-index: 1; min-width: 190px; }
.grade-datas th.fixa { z-index: 2; }
.vazio-x { color: #374151; }

/* ---------- Sobre o absenteísmo ---------- */
.texto-longo p, .texto-longo li { font-size: .88rem; line-height: 1.6; color: #cbd5e1; }
.texto-longo p + p, .texto-longo ul + p, .texto-longo p + ul { margin-top: 10px; }
.texto-longo ul { margin-left: 20px; }
.texto-longo li + li { margin-top: 6px; }
.texto-longo .no-sistema {
  border-left: 3px solid var(--accent); background: rgba(34, 211, 238, .06); padding: 10px 12px; border-radius: 0 8px 8px 0;
}
.texto-longo td { white-space: normal; vertical-align: top; }

@media (max-width: 760px) {
  .form-observacao { flex-direction: column; align-items: stretch; }
}
