:root {
  --fundo: #f5f7fa;
  --superficie: #ffffff;
  --borda: #dde3ea;
  --borda-forte: #c5cfda;
  --texto: #1e293b;
  --texto-2: #5b6b7f;
  --primaria: #1f4e79;
  --primaria-escura: #163a5a;
  --primaria-clara: #e6eef6;
  --lateral: #15324d;

  --pend-fundo: #fef3c7; --pend-texto: #92400e; --pend-borda: #f59e0b;
  --env-fundo: #dcfce7;  --env-texto: #166534;  --env-borda: #22c55e;
  --atr-fundo: #fee2e2;  --atr-texto: #991b1b;  --atr-borda: #ef4444;
  --ag-fundo: #f1f5f9;   --ag-texto: #475569;   --ag-borda: #94a3b8;

  --raio: 8px;
  --sombra: 0 1px 2px rgba(15, 23, 42, .06), 0 2px 8px rgba(15, 23, 42, .05);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 14px;
  color: var(--texto);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
[hidden] { display: none !important; }
body { background: var(--fundo); }
.tela-app { display: flex; height: 100vh; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
code { font-family: Consolas, monospace; font-size: 12.5px; background: var(--primaria-clara); padding: 1px 5px; border-radius: 4px; }
h1, h2, h3 { margin: 0; font-weight: 600; }

/* ---------- Lateral ---------- */
.lateral { width: 230px; flex: none; background: var(--lateral); color: #dbe6f1; display: flex; flex-direction: column; }
.marca { display: flex; gap: 10px; align-items: center; padding: 18px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.marca-icone { flex: none; border-radius: 7px; }
.marca b { display: block; color: #fff; font-size: 15px; }
.marca small { color: #9fb4c9; font-size: 12px; }
nav { display: flex; flex-direction: column; padding: 10px 8px; gap: 2px; }
.nav-item { all: unset; cursor: pointer; padding: 10px 12px; border-radius: 6px; display: flex; align-items: center; justify-content: space-between; color: #dbe6f1; }
.nav-item:hover { background: rgba(255,255,255,.07); }
.nav-item:focus-visible { outline: 2px solid #7fb2e5; }
.nav-item.ativo { background: #fff; color: var(--primaria); font-weight: 600; }
.badge { background: var(--pend-borda); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; font-weight: 700; line-height: 19px; }
.badge.tem-atraso { background: var(--atr-borda); }
.lateral-rodape { margin-top: auto; padding: 14px; }
.botao-lateral { width: 100%; background: rgba(255,255,255,.1) !important; color: #fff !important; border-color: rgba(255,255,255,.2) !important; }
.botao-lateral:hover { background: rgba(255,255,255,.18) !important; }

/* ---------- Principal ---------- */
.principal { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topo { display: flex; align-items: baseline; gap: 16px; padding: 16px 24px 10px; }
.topo h1 { font-size: 22px; }
.hoje { color: var(--texto-2); }
.conteudo { flex: 1; overflow: auto; padding: 4px 24px 32px; }

.barra { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.barra .nota { margin: 0; max-width: 760px; }
.espaco { flex: 1; }
.periodo { font-size: 18px; min-width: 200px; }

input[type=search], input:not([type]), input[type=text], input[type=email], input[type=number], input[type=password], select, textarea {
  border: 1px solid var(--borda-forte); border-radius: 6px; padding: 7px 10px; background: #fff; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc3ea; border-color: var(--primaria); }
input[type=search] { width: 240px; }
select { max-width: 320px; }

/* ---------- Botões ---------- */
.botao { border: 1px solid var(--borda-forte); background: #fff; border-radius: 6px; padding: 7px 14px; cursor: pointer; white-space: nowrap; }
.botao:hover:not(:disabled) { background: #f1f5f9; }
.botao:disabled { opacity: .45; cursor: not-allowed; }
.botao:focus-visible, .botao-icone:focus-visible { outline: 2px solid #4a90d9; outline-offset: 1px; }
.botao-primario { background: var(--primaria); border-color: var(--primaria); color: #fff; }
.botao-primario:hover:not(:disabled) { background: var(--primaria-escura); }
.botao-perigo { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.botao-perigo:hover:not(:disabled) { background: #991b1b; }
.botao-perigo-leve { color: #b91c1c; }
.botao-ok { background: #15803d; border-color: #15803d; color: #fff; }
.botao-ok:hover:not(:disabled) { background: #166534 !important; }
.botao-whats { color: #0f7a3e; border-color: #7fd3a1; }
.botao-p { padding: 4px 9px; font-size: 12.5px; }
.botao-icone { border: none; background: transparent; cursor: pointer; font-size: 18px; line-height: 1; padding: 4px 8px; border-radius: 4px; color: var(--texto-2); }
.botao-icone:hover:not(:disabled) { background: #eef2f6; }
.botao-icone:disabled { opacity: .25; cursor: default; }
.grupo-botoes { display: flex; gap: 4px; }
.alternar { display: inline-flex; border: 1px solid var(--borda-forte); border-radius: 6px; overflow: hidden; }
.alternar button { border: none; background: #fff; padding: 7px 14px; cursor: pointer; }
.alternar button.ativo { background: var(--primaria); color: #fff; }
.botoes-linha { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }

/* ---------- Status ---------- */
.selo { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 10px; white-space: nowrap; border: 1px solid transparent; }
.selo-pendente { background: var(--pend-fundo); color: var(--pend-texto); border-color: #fcd34d; }
.selo-enviado { background: var(--env-fundo); color: var(--env-texto); border-color: #86efac; }
.selo-atrasado { background: var(--atr-fundo); color: var(--atr-texto); border-color: #fca5a5; }
.selo-agendado, .selo-fora { background: var(--ag-fundo); color: var(--ag-texto); border-color: #cbd5e1; }

.legenda { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; margin-bottom: 12px; font-size: 12px; color: var(--texto-2); }
.leg { padding: 1px 8px; border-radius: 4px; border-left: 4px solid; }
.leg.st-pendente { background: var(--pend-fundo); border-color: var(--pend-borda); color: var(--pend-texto); }
.leg.st-atrasado { background: var(--atr-fundo); border-color: var(--atr-borda); color: var(--atr-texto); }
.leg.st-enviado { background: var(--env-fundo); border-color: var(--env-borda); color: var(--env-texto); }
.leg.st-agendado { background: var(--ag-fundo); border-color: var(--ag-borda); color: var(--ag-texto); }
.leg-sep { width: 1px; height: 16px; background: var(--borda-forte); }
.leg-etapa::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--cor-etapa); margin-right: 5px; vertical-align: -1px; }

/* ---------- Calendário mensal ---------- */
.grade-mes { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--borda); border-radius: var(--raio); overflow: hidden; background: var(--borda); gap: 1px; box-shadow: var(--sombra); }
.grade-cab { background: #eef2f6; padding: 6px 8px; font-size: 12px; font-weight: 600; color: var(--texto-2); text-transform: uppercase; }
.dia { background: #fff; min-height: 128px; padding: 4px 5px 6px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.dia:hover { background: #f8fbff; }
.dia:focus-visible { outline: 2px solid #4a90d9; outline-offset: -2px; }
.dia.fim-semana { background: #fafbfc; }
.dia.fora { background: #f6f7f9; }
.dia.fora .dia-num { color: #a6b1bd; }
.dia.hoje { box-shadow: inset 0 0 0 2px var(--primaria); }
.dia.hoje .dia-num { background: var(--primaria); color: #fff; border-radius: 10px; padding: 0 7px; }
.dia-topo { display: flex; justify-content: space-between; align-items: center; min-height: 20px; }
.dia-num { font-weight: 600; font-size: 13px; }
.dia-prazos { font-size: 11px; color: var(--atr-texto); background: #fff1f1; border-radius: 8px; padding: 0 6px; }
.chip { display: flex; gap: 4px; align-items: baseline; font-size: 11.5px; padding: 2px 5px; border-radius: 4px; border-left: 4px solid var(--cor-etapa); overflow: hidden; white-space: nowrap; line-height: 1.35; }
.chip-nome { font-weight: 600; flex: none; max-width: 62%; overflow: hidden; text-overflow: ellipsis; }
.chip-etapa { color: inherit; opacity: .8; overflow: hidden; text-overflow: ellipsis; }
.chip.st-pendente { background: var(--pend-fundo); color: var(--pend-texto); }
.chip.st-enviado { background: var(--env-fundo); color: var(--env-texto); }
.chip.st-atrasado { background: var(--atr-fundo); color: var(--atr-texto); }
.chip.st-agendado { background: var(--ag-fundo); color: var(--ag-texto); }
.chip-mais { font-size: 11.5px; color: var(--primaria); font-weight: 600; padding-left: 4px; }

/* ---------- Calendário semanal ---------- */
.grade-semana { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; align-items: start; }
.coluna-dia { background: #fff; border: 1px solid var(--borda); border-radius: var(--raio); min-width: 0; box-shadow: var(--sombra); }
.coluna-dia.hoje { border-color: var(--primaria); box-shadow: 0 0 0 1px var(--primaria); }
.coluna-cab { all: unset; cursor: pointer; display: block; width: 100%; box-sizing: border-box; padding: 8px 10px; border-bottom: 1px solid var(--borda); background: #f3f6f9; border-radius: var(--raio) var(--raio) 0 0; text-transform: capitalize; }
.coluna-cab:hover { background: #e9eff5; }
.coluna-cab small { display: block; color: var(--texto-2); text-transform: none; }
.coluna-dia.hoje .coluna-cab { background: var(--primaria); color: #fff; }
.coluna-dia.hoje .coluna-cab small { color: #d6e4f2; }
.coluna-itens { padding: 6px; display: flex; flex-direction: column; gap: 6px; }
.prazos-semana { all: unset; cursor: pointer; font-size: 12px; color: var(--atr-texto); padding: 4px 6px; border-radius: 4px; background: #fff1f1; }

/* ---------- Cartão de envio ---------- */
.lista-cartoes { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 10px; margin-bottom: 8px; }
.cartao { background: #fff; border: 1px solid var(--borda); border-left: 5px solid var(--cor-etapa); border-radius: var(--raio); padding: 10px 12px; display: flex; flex-direction: column; gap: 5px; min-width: 0; box-shadow: var(--sombra); }
.cartao.st-pendente { background: #fffdf3; }
.cartao.st-atrasado { background: #fff8f8; }
.cartao.st-enviado { background: #f7fdf9; }
.cartao-topo { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.etapa-tag { font-size: 12px; font-weight: 600; color: var(--cor-etapa); filter: brightness(.8); }
.cartao-nome { all: unset; cursor: pointer; font-weight: 600; font-size: 14.5px; }
.cartao-nome:hover { text-decoration: underline; color: var(--primaria); }
.cartao-nome:focus-visible { outline: 2px solid #4a90d9; }
.cartao-info { font-size: 12.5px; color: var(--texto-2); }
.cartao-prazo { font-size: 12.5px; font-weight: 600; }
.st-pendente .cartao-prazo { color: var(--pend-texto); }
.st-atrasado .cartao-prazo { color: var(--atr-texto); }
.st-enviado .cartao-prazo { color: var(--env-texto); }
.st-agendado .cartao-prazo { color: var(--ag-texto); }
.cartao-link { font-size: 12px; color: var(--primaria); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: Consolas, monospace; }
.cartao-link.sem-link { color: var(--atr-texto); font-family: inherit; }
.cartao-acoes { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 3px; }
.cartao.compacto { padding: 6px 7px; gap: 3px; border-left-width: 4px; }
.cartao.compacto .cartao-nome { font-size: 12.5px; line-height: 1.25; }
.cartao.compacto .etapa-tag { font-size: 11px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cartao.compacto .cartao-prazo { font-size: 11.5px; font-weight: 400; color: var(--texto-2); display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.cartao.compacto .cartao-acoes { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.cartao.compacto .botao-p { padding: 2px 4px; font-size: 11px; }

/* ---------- Painel ---------- */
.grupo-painel { margin-bottom: 18px; }
.grupo-cab { all: unset; cursor: pointer; display: flex; align-items: baseline; gap: 10px; margin: 6px 0 10px; }
.grupo-cab h3 { font-size: 17px; }
.grupo-cab small { color: var(--texto-2); }
.grupo-cab:focus-visible { outline: 2px solid #4a90d9; }
.seta { width: 12px; color: var(--texto-2); }
.contagem { background: #e2e8f0; border-radius: 10px; padding: 0 8px; font-size: 12.5px; font-weight: 700; }
.g-hoje .contagem { background: var(--pend-fundo); color: var(--pend-texto); }
.g-atrasados .contagem { background: var(--atr-fundo); color: var(--atr-texto); }
.g-proximos .contagem { background: var(--ag-fundo); color: var(--ag-texto); }

/* ---------- Tabelas ---------- */
.tabela { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--borda); border-radius: var(--raio); overflow: hidden; box-shadow: var(--sombra); }
.tabela th { text-align: left; background: #eef2f6; font-size: 12.5px; color: var(--texto-2); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--borda); position: sticky; top: 0; }
.tabela td { padding: 7px 10px; border-bottom: 1px solid #edf1f5; vertical-align: middle; }
.tabela tbody tr:hover { background: #f8fbff; }
.tabela .num { text-align: right; font-variant-numeric: tabular-nums; }
.tabela .acoes-col { text-align: right; white-space: nowrap; }
.tabela .acoes-col .botao { margin-left: 3px; }
.nowrap { white-space: nowrap; }
.cpf { font-family: Consolas, monospace; font-size: 12.5px; }
.mudo { color: #a6b1bd; }
.link-nome { all: unset; cursor: pointer; font-weight: 600; }
.link-nome:hover { color: var(--primaria); text-decoration: underline; }
.link-nome:focus-visible { outline: 2px solid #4a90d9; }
.tabela-etapas tr.inativa td { opacity: .5; }
.tabela-etapas .link-col { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.ordem-col { white-space: nowrap; width: 70px; }
.ordem-col .botao-icone { font-size: 12px; padding: 3px 5px; }
.barra-col { width: 26%; min-width: 160px; }
.mini-barra { position: relative; height: 10px; background: #eef2f6; border-radius: 5px; }
.mini-barra span { position: absolute; top: 0; bottom: 0; border-radius: 5px; }
.bolinha { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; }
.interruptor { position: relative; display: inline-block; width: 34px; height: 19px; }
.interruptor input { opacity: 0; width: 0; height: 0; }
.interruptor span { position: absolute; inset: 0; background: #cbd5e1; border-radius: 10px; cursor: pointer; transition: .15s; }
.interruptor span::before { content: ""; position: absolute; width: 15px; height: 15px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .15s; }
.interruptor input:checked + span { background: #15803d; }
.interruptor input:checked + span::before { transform: translateX(15px); }
.interruptor input:focus-visible + span { outline: 2px solid #4a90d9; }

/* ---------- Modais ---------- */
.modal-fundo { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 20px; z-index: 50; overflow: auto; }
.modal:focus { outline: none; }
.modal { background: #fff; border-radius: 10px; width: 100%; box-shadow: 0 20px 50px rgba(0,0,0,.25); display: flex; flex-direction: column; max-height: calc(100vh - 80px); }
.modal-topo { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--borda); }
.modal-topo h2 { font-size: 17px; }
.modal-corpo { padding: 16px 18px; overflow: auto; }
.modal-acoes { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.confirmar-texto { line-height: 1.5; margin-top: 0; }
.secao-titulo { font-size: 14.5px; margin: 14px 0 10px; display: flex; gap: 8px; align-items: center; }
.secao-titulo:first-child { margin-top: 0; }
.modal-dia .lista-cartoes { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

/* ---------- Formulários ---------- */
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form .largo { grid-column: 1 / -1; }
.campo { display: flex; flex-direction: column; gap: 4px; }
.campo > span { font-size: 12.5px; font-weight: 600; color: var(--texto-2); }
.campo-check { flex-direction: row; align-items: center; gap: 8px; padding-top: 20px; }
.campo-check > span { font-weight: 400; color: var(--texto); font-size: 14px; }
.com-botao { display: flex; gap: 6px; }
.com-botao input { flex: 1; }
.campo-invalido { border-color: #dc2626 !important; background: #fff7f7 !important; }
.erro-campo { color: #b91c1c; font-size: 12px; }
.opcoes { display: flex; flex-direction: column; gap: 4px; padding-top: 2px; }
.campos-auto { font-size: 12.5px; color: var(--texto-2); display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.campos-auto .botao { font-family: Consolas, monospace; }
.previa small { color: var(--texto-2); }
.previa pre { white-space: pre-wrap; font-family: inherit; background: #f3f8f4; border: 1px solid #cfe7d6; border-radius: 8px; padding: 10px 12px; margin: 4px 0 0; }
.nota { color: var(--texto-2); font-size: 12.5px; line-height: 1.45; }

/* ---------- Ficha do colaborador ---------- */
.ficha-dados { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 16px; background: #f6f8fb; border: 1px solid var(--borda); border-radius: var(--raio); padding: 12px 14px; }
.ficha-dados small { display: block; color: var(--texto-2); font-size: 12px; }
.ficha-dados .largo { grid-column: 1 / -1; }
.ficha-dados .obs { white-space: pre-wrap; }
.ficha-acoes { display: flex; gap: 8px; margin: 10px 0 4px; }
.linha-tempo { list-style: none; padding: 0; margin: 0; position: relative; }
.linha-tempo::before { content: ""; position: absolute; left: 47px; top: 6px; bottom: 6px; width: 2px; background: var(--borda); }
.lt-item { display: grid; grid-template-columns: 96px 1fr; gap: 10px; margin-bottom: 10px; position: relative; }
.lt-marca { text-align: center; padding-top: 10px; }
.lt-marca span { position: relative; z-index: 1; display: inline-block; font-size: 11.5px; font-weight: 600; background: #fff; border: 2px solid var(--cor-etapa); border-radius: 10px; padding: 1px 7px; }
.lt-item.st-enviado .lt-marca span { background: var(--env-fundo); }
.lt-item.st-atrasado .lt-marca span { background: var(--atr-fundo); }
.lt-item.st-pendente .lt-marca span { background: var(--pend-fundo); }

/* ---------- Configurações ---------- */
.paineis-config { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; align-items: start; }
.caixa { background: #fff; border: 1px solid var(--borda); border-radius: var(--raio); padding: 16px 18px; box-shadow: var(--sombra); }
.caixa h3 { font-size: 16px; margin-bottom: 12px; }
.caminho { display: inline-block; word-break: break-all; }

/* ---------- Vazio e avisos ---------- */
.vazio { text-align: center; padding: 60px 20px; color: var(--texto-2); background: #fff; border: 1px dashed var(--borda-forte); border-radius: var(--raio); }
.vazio-p { color: var(--texto-2); font-size: 12.5px; margin: 4px 2px; }
#avisos { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: 420px; }
.aviso { background: #1e293b; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 8px 20px rgba(0,0,0,.2); transition: opacity .35s, transform .35s; }
.aviso-ok { border-left: 4px solid #22c55e; }
.aviso-erro { border-left: 4px solid #ef4444; background: #3b1414; }
.aviso.saindo { opacity: 0; transform: translateY(6px); }

@media (max-width: 1150px) {
  .lateral { width: 190px; }
  .ficha-dados { grid-template-columns: 1fr 1fr; }
}

/* ---------- Login e topo ---------- */
.tela-login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: linear-gradient(160deg, #15324d 0%, #1f4e79 60%, #2b6aa3 100%); }
.caixa-login { width: 100%; max-width: 380px; background: #fff; border-radius: 12px; padding: 28px 28px 24px; box-shadow: 0 20px 50px rgba(0,0,0,.3); display: flex; flex-direction: column; gap: 12px; }
.caixa-login .logo-login { align-self: center; border-radius: 14px; box-shadow: 0 4px 14px rgba(0,0,0,.18); margin-bottom: 4px; }
.caixa-login h1 { text-align: center; font-size: 22px; }
.caixa-login .nota { text-align: center; margin: -8px 0 6px; }
.caixa-login input { width: 100%; }
.caixa-login .botao { padding: 10px; font-size: 15px; margin-top: 6px; }
.login-aviso { background: var(--atr-fundo); color: var(--atr-texto); border-radius: 6px; padding: 8px 10px; margin: 0; font-size: 13px; }
.topo { align-items: center; }
.usuario-nome { color: var(--texto-2); font-size: 13px; }
.form-1col { grid-template-columns: 1fr; }
.erro-geral { max-width: 520px; margin: 80px auto; padding: 24px; background: #fff; border-radius: 10px; border: 1px solid var(--borda); }
.tabela-etapas td:first-child .botao-icone { font-size: 12px; }

@media (max-width: 820px) {
  .tela-app { flex-direction: column; height: auto; min-height: 100vh; overflow: visible; }
  .lateral { width: 100%; }
  .lateral nav { flex-direction: row; flex-wrap: wrap; }
  .lateral-rodape { margin-top: 0; }
  .principal { overflow: visible; }
  .conteudo { overflow: visible; padding: 4px 12px 24px; }
  .topo { flex-wrap: wrap; padding: 12px; }
  .grade-semana { grid-template-columns: 1fr; }
  .form { grid-template-columns: 1fr; }
  .tabela { display: block; overflow-x: auto; }
}
