/* app.css — estilos da aplicação (complementam theme.css + shell.css).
   Mantém a paleta ConVert: navy da marca + dourado de acento. */

/* ── Semáforo de vencimentos ───────────────────────────────────────────── */
:root {
  --sem-vencido-bg: #ffebee;  --sem-vencido-fg: #c62828;
  --sem-critico-bg: #ffe6d5;  --sem-critico-fg: #b34700;
  --sem-atencao-bg: #fff8e1;  --sem-atencao-fg: #b26a00;
  --sem-proximo-bg: #e3f2fd;  --sem-proximo-fg: #1565c0;
  --sem-ok-bg: #e8f5e9;       --sem-ok-fg: #2e7d32;
}

/* ── Shell (sidebar + conteúdo) ────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: linear-gradient(180deg, var(--navy), var(--navy-2));
  color: #fff; display: flex; flex-direction: column; padding: 18px 14px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; flex-direction: column; gap: 7px; padding: 4px 6px 16px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand span { font-size: .64rem; color: var(--gold-soft); text-transform: uppercase; letter-spacing: 1.1px; }
/* A logo é PNG com fundo transparente — o navy do menu aparece por trás */
.logo-sidebar { width: 100%; max-width: 186px; height: auto; display: block; }
.nav { display: flex; flex-direction: column; gap: 3px; margin-top: 14px; flex: 1; overflow: auto; }
.nav-item {
  background: none; border: none; color: #cfd6e4; text-align: left; padding: 9px 12px;
  border-radius: var(--radius-sm); font-family: var(--font); font-size: .84rem;
  font-weight: 500; cursor: pointer; transition: .15s;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: linear-gradient(135deg, var(--gold), var(--gold-soft)); color: #fff; font-weight: 600; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.1); padding-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.user-chip { font-size: .8rem; color: #fff; padding: 0 4px 4px; display: flex; flex-direction: column; }
.user-chip .perfil { font-size: .64rem; color: var(--gold-soft); text-transform: uppercase; letter-spacing: .6px; }
.main { flex: 1; background: var(--bg); overflow: auto; display: flex; flex-direction: column; }
.main-inner { max-width: 1180px; margin: 0 auto; padding: 22px; width: 100%; flex: 1; }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .brand { flex-direction: row; align-items: center; justify-content: space-between; }
  .logo-sidebar { max-width: 150px; }
  .nav-item { font-size: .78rem; padding: 7px 10px; }
  .main-inner { padding: 14px; }
}

/* ── Login ─────────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: linear-gradient(135deg, var(--navy), var(--navy-2));
}
.login-card {
  background: var(--surface); border-radius: var(--radius); box-shadow: 0 20px 60px rgba(0,0,0,.3);
  width: 100%; max-width: 400px; padding: 30px 28px;
}
.logo-login { width: 100%; max-width: 268px; height: auto; display: block; margin: 0 auto 12px; }
.login-card .sub { color: var(--text-soft); font-size: .8rem; margin-bottom: 18px; text-align: center; }

/* ── Cabeçalho de página ───────────────────────────────────────────────── */
.page-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.page-head h1 { font-size: 1.35rem; color: var(--navy); margin: 0; }
.page-head p { margin: 2px 0 0; }

/* ── Cartões ───────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-soft);
  border: 1px solid var(--line); padding: 18px; margin-bottom: 14px;
}
.card h2 { font-size: .98rem; color: var(--navy); margin: 0 0 12px; display: flex; align-items: center; gap: 6px; }
.card h3 { font-size: .86rem; color: var(--navy); margin: 0; }
.sub-h { font-size: .74rem; text-transform: uppercase; letter-spacing: .5px; color: var(--text-soft); margin: 14px 0 6px; }
.resumo-card { margin-bottom: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 14px; }
@media (max-width: 860px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ── KPIs ──────────────────────────────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--navy);
  border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column;
  box-shadow: var(--shadow-soft);
}
.kpi strong { font-size: 1.7rem; color: var(--navy); line-height: 1; }
.kpi span { font-size: .72rem; color: var(--text-soft); margin-top: 5px; text-transform: uppercase; letter-spacing: .4px; }
.kpi-ok { border-left-color: var(--sem-ok-fg); }
.kpi-ok strong { color: var(--sem-ok-fg); }
.kpi-err { border-left-color: var(--sem-vencido-fg); }
.kpi-err strong { color: var(--sem-vencido-fg); }

/* ── Botões ────────────────────────────────────────────────────────────── */
.btn {
  padding: 9px 16px; border: none; border-radius: var(--radius-sm); font-size: .82rem;
  font-weight: 600; font-family: var(--font); cursor: pointer; transition: .18s;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--navy), var(--navy-soft)); color: #fff; width: 100%; justify-content: center; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); }
.btn-gold { background: linear-gradient(135deg, var(--gold), var(--gold-soft)); color: #fff; }
.btn-gold:hover:not(:disabled) { filter: brightness(1.06); }
.btn-ghost { background: #fff; color: var(--navy); border: 1.5px solid var(--line); }
.btn-ghost:hover:not(:disabled) { border-color: var(--gold); }
.btn-danger { background: #fff; color: var(--sem-vencido-fg); border: 1.5px solid var(--line); }
.btn-danger:hover:not(:disabled) { border-color: var(--sem-vencido-fg); }
.btn-sm { padding: 6px 12px; font-size: .76rem; }

/* ── Formulários ───────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 10px; }
.col-2 { grid-column: span 2; } .col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; } .col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; } .col-7 { grid-column: span 7; }
.col-8 { grid-column: span 8; } .col-12 { grid-column: span 12; }
@media (max-width: 620px) { .form-grid > .field { grid-column: span 12 !important; } }

.field { margin-bottom: 4px; }
.field label {
  display: block; font-size: .67rem; font-weight: 600; color: var(--text-soft);
  text-transform: uppercase; letter-spacing: .4px; margin-bottom: 4px;
}
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); font-size: .86rem; font-family: var(--font);
  background: #fff; color: var(--text);
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--gold); }
.field input:disabled, .field select:disabled { background: var(--surface-alt); color: var(--text-faint); }
.dica { font-size: .7rem; color: var(--text-faint); margin-top: 3px; }
.check { display: flex; align-items: center; gap: 7px; font-size: .82rem; color: var(--text);
  text-transform: none; letter-spacing: 0; font-weight: 500; }
.check input { width: auto; }

.filtros { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.filtros input, .filtros select {
  padding: 8px 11px; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  font-size: .82rem; font-family: var(--font);
}
.filtros input { flex: 1; min-width: 200px; }
.filtros input:focus, .filtros select:focus { outline: none; border-color: var(--gold); }

.erro-msg {
  background: var(--sem-vencido-bg); color: var(--sem-vencido-fg); padding: 8px 11px;
  border-radius: var(--radius-sm); font-size: .8rem; margin-bottom: 12px; display: none;
}
.erro-msg.vis { display: block; }

/* ── Tabelas ───────────────────────────────────────────────────────────── */
.tabela-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .82rem; }
thead { background: linear-gradient(135deg, var(--navy), var(--navy-soft)); color: #fff; }
th { padding: 9px 10px; text-align: left; font-size: .65rem; text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:hover { background: var(--surface-alt); }
.cel-principal { display: flex; flex-direction: column; gap: 2px; }
.link-forte { color: var(--navy); font-weight: 600; }
.link-forte:hover { color: var(--gold); }

/* ── Pills ─────────────────────────────────────────────────────────────── */
.pill { padding: 2px 9px; border-radius: 11px; font-size: .66rem; font-weight: 600; display: inline-block; white-space: nowrap; }
.pill-ok { background: var(--sem-ok-bg); color: var(--sem-ok-fg); }
.pill-adm { background: var(--sem-proximo-bg); color: var(--sem-proximo-fg); }
.pill-cli { background: #f3e8ff; color: #6b21a8; }
.pill-pend { background: var(--sem-atencao-bg); color: var(--sem-atencao-fg); }

.sem-vencido { background: var(--sem-vencido-bg); color: var(--sem-vencido-fg); }
.sem-critico { background: var(--sem-critico-bg); color: var(--sem-critico-fg); }
.sem-atencao { background: var(--sem-atencao-bg); color: var(--sem-atencao-fg); }
.sem-proximo { background: var(--sem-proximo-bg); color: var(--sem-proximo-fg); }
.sem-ok { background: var(--sem-ok-bg); color: var(--sem-ok-fg); }
.sem-sem_data { background: #ecebe6; color: #6b7280; }

.st-aberta { background: var(--sem-proximo-bg); color: var(--sem-proximo-fg); }
.st-em-andamento { background: #ede7f6; color: #4a148c; }
.st-aguardando-cliente { background: var(--sem-atencao-bg); color: var(--sem-atencao-fg); }
.st-concluída, .st-concluida { background: var(--sem-ok-bg); color: var(--sem-ok-fg); }
.st-cancelada { background: #ecebe6; color: #6b7280; }

.pr-baixa { background: #ecebe6; color: #6b7280; }
.pr-normal { background: var(--sem-proximo-bg); color: var(--sem-proximo-fg); }
.pr-alta { background: var(--sem-critico-bg); color: var(--sem-critico-fg); }
.pr-urgente { background: var(--sem-vencido-bg); color: var(--sem-vencido-fg); }

/* ── Blocos de alerta do dashboard ─────────────────────────────────────── */
.resumo-faixas { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.faixa {
  flex: 1; min-width: 62px; border-radius: var(--radius-sm); padding: 7px 4px;
  text-align: center; font-size: 1.1rem; font-weight: 700;
  display: flex; flex-direction: column; align-items: center;
}
.faixa small { font-size: .58rem; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; opacity: .85; margin-top: 2px; }

.lista-alerta { list-style: none; margin: 0; padding: 0; }
.lista-alerta li {
  display: flex; align-items: center; gap: 8px; padding: 7px 0;
  border-bottom: 1px dashed var(--line); font-size: .82rem; flex-wrap: wrap;
}
.lista-alerta li:last-child { border-bottom: none; }
.lista-alerta a { color: var(--navy); font-weight: 600; }
.lista-alerta a:hover { color: var(--gold); }
.lista-alerta .muted { flex: 1; font-size: .74rem; }

.alerta-faixa {
  background: var(--sem-atencao-bg); color: var(--sem-atencao-fg); border: 1px solid var(--sem-atencao-fg);
  border-radius: var(--radius-sm); padding: 10px 14px; font-size: .82rem; margin-bottom: 14px; font-weight: 600;
}

/* ── Pendências ────────────────────────────────────────────────────────── */
.grid-pend { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.pend {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px;
  display: flex; flex-direction: column; background: var(--surface-alt);
}
.pend.pend-alerta { border-color: var(--sem-atencao-fg); background: #fffdf5; }
.pend strong { font-size: 1.5rem; color: var(--navy); line-height: 1; }
.pend.pend-alerta strong { color: var(--sem-atencao-fg); }
.pend span { font-size: .78rem; font-weight: 600; margin-top: 4px; }
.pend small { font-size: .68rem; color: var(--text-faint); margin-top: 2px; }
.pend-lista { display: flex; flex-direction: column; gap: 2px; margin-top: 7px; }
.pend-lista a { font-size: .72rem; color: var(--navy); }
.pend-lista a:hover { color: var(--gold); }

/* ── Gráfico de barras (movimentação) ──────────────────────────────────── */
.barras {
  display: flex; gap: 6px; align-items: flex-end; height: 150px;
  padding: 8px 0 0; overflow-x: auto;
}
.barra-col { flex: 1; min-width: 34px; display: flex; flex-direction: column; align-items: center; height: 100%; }
.barra-par { flex: 1; display: flex; gap: 3px; align-items: flex-end; width: 100%; justify-content: center; }
.barra { width: 12px; border-radius: 3px 3px 0 0; min-height: 2px; transition: .3s; }
.b-ent { background: var(--sem-ok-fg); }
.b-sai { background: var(--sem-vencido-fg); }
.barra-lbl { font-size: .62rem; color: var(--text-soft); margin-top: 5px; white-space: nowrap; }
.barra-base { font-size: .68rem; font-weight: 700; color: var(--navy); }
.legenda { font-size: .7rem; color: var(--text-faint); margin-top: 8px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ponto { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ── Listas de movimentação ────────────────────────────────────────────── */
.lista-mov { list-style: none; margin: 0; padding: 0; }
.lista-mov li { padding: 7px 0; border-bottom: 1px dashed var(--line); display: flex; flex-direction: column; gap: 1px; }
.lista-mov li:last-child { border-bottom: none; }
.lista-mov a { color: var(--navy); font-weight: 600; font-size: .84rem; }
.lista-mov a:hover { color: var(--gold); }
.lista-mov .muted { font-size: .72rem; }
.motivo { font-size: .72rem; color: var(--sem-vencido-fg); font-style: italic; }
.mes-card h2 .muted { font-weight: 400; font-size: .78rem; }

/* ── Linha do tempo (comentários de tarefa) ────────────────────────────── */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  border-left: 2px solid var(--line); padding: 0 0 12px 12px; margin-left: 4px;
  font-size: .84rem; position: relative;
}
.timeline li::before {
  content: ""; position: absolute; left: -5px; top: 5px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--gold);
}
.tl-topo { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 3px; }
.tl-topo .muted { font-size: .7rem; }
.descricao {
  background: var(--surface-alt); border-radius: var(--radius-sm); padding: 11px;
  font-size: .85rem; white-space: pre-wrap; margin-bottom: 10px;
}

/* ── Abas dentro do modal ──────────────────────────────────────────────── */
.abas {
  display: flex; gap: 4px; border-bottom: 2px solid var(--line);
  margin: -4px 0 14px; overflow-x: auto; padding-bottom: 0;
}
.aba {
  background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -2px;
  padding: 8px 12px; font-family: var(--font); font-size: .8rem; font-weight: 600;
  color: var(--text-faint); cursor: pointer; white-space: nowrap;
  display: flex; align-items: center; gap: 6px; transition: .15s;
}
.aba:hover { color: var(--navy); }
.aba.ativa { color: var(--navy); border-bottom-color: var(--gold); }
.aba-op {
  font-size: .58rem; font-weight: 600; text-transform: uppercase; letter-spacing: .3px;
  background: var(--surface-alt); color: var(--text-faint); padding: 1px 5px; border-radius: 8px;
}
.aba.ativa .aba-op { background: var(--sem-atencao-bg); color: var(--sem-atencao-fg); }
.aba-painel.oculto { display: none; }
.aba-dica { margin: 0 0 12px; font-size: .78rem; color: var(--text-soft); }

/* ── Ficha: dados cadastrais ───────────────────────────────────────────── */
.dados-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px 18px; }
.dado { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.dado dt {
  font-size: .64rem; font-weight: 600; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: .4px; margin: 0;
}
.dado dd { margin: 0; font-size: .85rem; color: var(--text); word-break: break-word; }
.dado dd.vazio { color: var(--text-faint); font-style: italic; }

/* ── Modal ─────────────────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; background: rgba(30,37,51,.55); display: none;
  align-items: center; justify-content: center; padding: 16px; z-index: 200;
}
.modal.vis { display: flex; }
.modal-c { background: #fff; border-radius: var(--radius); width: 100%; max-height: 92vh; overflow: auto; }
.modal-h {
  background: linear-gradient(135deg, var(--navy), var(--navy-soft)); color: #fff;
  padding: 13px 16px; display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 2;
}
.modal-h h3 { margin: 0; font-size: .98rem; }
.modal-x { background: none; border: none; color: #fff; font-size: 1.4rem; cursor: pointer; line-height: 1; }
.modal-b { padding: 16px; }
.modal-f {
  padding: 12px 16px; border-top: 1px solid var(--line); display: flex;
  justify-content: flex-end; gap: 8px; background: var(--surface-alt);
  position: sticky; bottom: 0;
}

.cnpj-box {
  background: var(--sem-proximo-bg); border: 1px solid var(--sem-proximo-fg);
  border-radius: var(--radius-sm); padding: 10px; margin: 8px 0; font-size: .8rem;
  color: var(--sem-proximo-fg); display: none;
}
.cnpj-box.vis { display: block; }

/* ── Aviso de sessão prestes a expirar ─────────────────────────────────── */
.aviso-sessao {
  position: fixed; top: 0; left: 0; right: 0; z-index: 400;
  background: var(--sem-atencao-bg); color: var(--sem-atencao-fg);
  border-bottom: 2px solid var(--sem-atencao-fg);
  padding: 10px 16px; display: flex; align-items: center; justify-content: center;
  gap: 14px; font-size: .84rem; font-weight: 600; flex-wrap: wrap;
  box-shadow: 0 2px 12px rgba(0,0,0,.12);
}
.aviso-msg {
  background: var(--sem-atencao-bg); color: var(--sem-atencao-fg);
  border: 1px solid var(--sem-atencao-fg); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: .8rem; margin-bottom: 14px; line-height: 1.4;
}

/* ── Assinatura ────────────────────────────────────────────────────────── */
.assinatura, .rodape {
  font-size: .68rem; color: var(--text-faint); text-align: center;
  line-height: 1.45; margin: 0;
}
.assinatura-login {
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line);
}
.rodape {
  max-width: 1180px; margin: 0 auto; padding: 4px 22px 22px;
}
@media (max-width: 860px) { .rodape { padding: 4px 14px 18px; } }

/* ── Diversos ──────────────────────────────────────────────────────────── */
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.muted { color: var(--text-faint); font-size: .78rem; }

.toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 6px; z-index: 300; }
.toast { padding: 10px 15px; border-radius: var(--radius-sm); font-size: .8rem; box-shadow: var(--shadow); animation: tin .3s; max-width: 340px; }
.toast.ok { background: var(--sem-ok-bg); color: var(--sem-ok-fg); }
.toast.err { background: var(--sem-vencido-bg); color: var(--sem-vencido-fg); }
.toast.info { background: var(--sem-proximo-bg); color: var(--sem-proximo-fg); }
@keyframes tin { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
