:root {
  --azul: #00406c;
  --azul-2: #0a5591;
  --laranja: #ff7b1a;
  --laranja-2: #e9690b;
  --laranja-claro: #fff1e6;
  --fundo: #f4f6fb;
  --card: #ffffff;
  --borda: #e3e8f2;
  --texto: #1d2433;
  --suave: #6b7489;
  --verde: #2e7d32;
  --verde-claro: #e7f4e8;
  --vermelho: #c62828;
  --vermelho-claro: #fdeaea;
  --amarelo: #b26a00;
  --amarelo-claro: #fff4e0;
  --raio: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  display: flex;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  color: var(--texto);
  background: var(--fundo);
}

/* ---------- menu lateral ---------- */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--azul);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
}
.marca { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; }
.marca strong, .marca span { display: block; line-height: 1.2; }
.marca span { font-size: 18px; font-weight: 700; }
.marca strong { font-weight: 400; font-size: 12px; opacity: .8; }
.logo { width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 0 2px rgba(255,255,255,.85); }
nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  background: none; border: 0; color: #d3e0ec;
  padding: 11px 12px; border-radius: 8px;
  font: inherit; font-size: 14.5px; text-align: left; cursor: pointer;
}
.nav-item .ico { width: 18px; text-align: center; opacity: .85; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.ativo { background: var(--laranja); color: #fff; font-weight: 600; }
.badge-nav {
  margin-left: auto; font-style: normal; font-size: 11.5px; font-weight: 700;
  background: var(--vermelho); color: #fff; box-shadow: 0 0 0 2px var(--azul); border-radius: 20px; padding: 1px 8px;
}
.badge-nav:empty { display: none; }
.rodape-side { margin-top: auto; font-size: 12px; opacity: .7; padding: 8px; }

/* ---------- conteúdo ---------- */
main { flex: 1; overflow-y: auto; padding: 24px 28px 40px; }
.topo { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; }
.topo h1 { margin: 0; font-size: 22px; }
.topo p { margin: 2px 0 0; color: var(--suave); font-size: 13px; }

.card {
  background: var(--card);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  padding: 16px 18px;
}
.card h2 { margin: 0 0 12px; font-size: 15px; }
.card h2 small { font-weight: 400; color: var(--suave); }

/* filtros */
.filtros {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  background: var(--card); border: 1px solid var(--borda); border-radius: var(--raio);
  padding: 12px 14px; margin-bottom: 16px;
}
.filtros label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--suave); font-weight: 600; }
.filtros .busca { flex: 1; min-width: 220px; }

input, select, textarea {
  font: inherit; color: var(--texto);
  border: 1px solid #cfd6e4; border-radius: 7px;
  padding: 7px 10px; background: #fff; min-height: 35px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #ffc597; border-color: var(--laranja); }
textarea { resize: vertical; min-height: 90px; }

.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; border-radius: 7px;
  padding: 8px 14px; min-height: 35px;
  background: var(--laranja); color: #fff;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { background: var(--laranja-2); }
.btn.sec { background: #fff; color: var(--azul); border-color: #cfd6e4; }
.btn.sec:hover { background: #eaf1f7; border-color: var(--azul); }
.btn.verde { background: var(--verde); }
.btn.verde:hover { background: #276b2b; }
.btn.perigo { background: #fff; color: var(--vermelho); border-color: #f0c4c4; }
.btn.perigo:hover { background: var(--vermelho-claro); }
.btn.zap { background: #25d366; color: #0b3d1f; }
.btn.zap:hover { background: #1fbe5a; }
.btn.mini { padding: 4px 9px; min-height: 28px; font-size: 12.5px; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi { position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--cor, var(--azul)); }
.kpi .rot { color: var(--suave); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.kpi .val { font-size: 25px; font-weight: 700; margin-top: 4px; color: var(--cor, var(--texto)); }
.kpi .sub { color: var(--suave); font-size: 12.5px; margin-top: 2px; }

.graficos { display: grid; grid-template-columns: 1fr 1.6fr; gap: 14px; }
.graficos > *, .resumo > *, .kpis > * { min-width: 0; }
.caixa-grafico { position: relative; height: 330px; }

/* tabela */
.tabela-wrap { overflow: auto; max-height: calc(100vh - 300px); border-radius: var(--raio); border: 1px solid var(--borda); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  position: sticky; top: 0; z-index: 1;
  background: #e8eff5; color: var(--azul); text-align: left;
  font-size: 12px; text-transform: uppercase; letter-spacing: .3px;
  padding: 10px; border-bottom: 1px solid var(--borda); white-space: nowrap;
}
th[data-ordem] { cursor: pointer; }
th[data-ordem]:hover { text-decoration: underline; }
td { padding: 8px 10px; border-bottom: 1px solid #eef1f6; white-space: nowrap; }
td.nome { white-space: normal; min-width: 220px; font-weight: 500; }
tr:hover td { background: #fff8f2; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.acoes { text-align: right; }
td.acoes .btn { margin-left: 4px; }
.vazio { padding: 40px; text-align: center; color: var(--suave); }

.tag { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 700; }
.tag.PAGO { background: var(--verde-claro); color: var(--verde); }
.tag.VENCIDO { background: var(--vermelho-claro); color: var(--vermelho); }
.tag.NO_PRAZO { background: var(--amarelo-claro); color: var(--amarelo); }
.ok { color: var(--verde); font-weight: 700; }
.nao { color: #b0b7c6; }

.resumo { display: flex; gap: 14px; margin-bottom: 14px; align-items: stretch; }
.resumo .kpis { flex: 1; margin: 0; }
.resumo .mini-pizza { width: 230px; padding: 8px; }
.resumo .mini-pizza .caixa-grafico { height: 120px; }
.contagem { color: var(--suave); font-size: 13px; margin: 0 0 8px; }

/* modal */
.modal-fundo { position: fixed; inset: 0; background: rgba(15, 25, 50, .45); display: grid; place-items: center; z-index: 50; }
.oculto { display: none !important; }
.modal { background: #fff; border-radius: 12px; width: 560px; max-width: 94vw; max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--borda); }
.modal h3 { margin: 0; font-size: 17px; }
.fechar { border: 0; background: none; font-size: 24px; cursor: pointer; color: var(--suave); }
.modal form { padding: 18px 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.modal form label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--suave); }
.modal form .full { grid-column: 1 / -1; }
.modal form .check { flex-direction: row; align-items: center; gap: 8px; color: var(--texto); font-weight: 500; }
.modal form .check input { min-height: 0; width: 17px; height: 17px; }
.modal .rodape { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.modal .info { grid-column: 1 / -1; background: var(--laranja-claro); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.modal .secao { grid-column: 1 / -1; margin: 6px 0 -4px; font-size: 13px; font-weight: 700; color: var(--azul); border-top: 1px solid var(--borda); padding-top: 12px; }

.toast {
  position: fixed; bottom: 22px; right: 22px; z-index: 60;
  background: var(--texto); color: #fff; padding: 11px 18px; border-radius: 8px;
  opacity: 0; transform: translateY(10px); transition: .25s; pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }
.toast.erro { background: var(--vermelho); }

.boas-vindas { max-width: 620px; margin: 60px auto; text-align: center; padding: 36px; }
.boas-vindas h2 { font-size: 22px; }
.boas-vindas p { color: var(--suave); line-height: 1.6; }

.config-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.config-grid .card { display: flex; flex-direction: column; gap: 10px; }
.config-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--suave); }
.config-grid .botoes { display: flex; flex-wrap: wrap; gap: 8px; }
.ajuda { color: var(--suave); font-size: 12.5px; margin: 0; line-height: 1.5; }

/* status da sincronização */
.rodape-side { opacity: 1; display: flex; flex-direction: column; gap: 8px; }
.rodape-side #data-hoje { opacity: .7; }
.status-sync { background: rgba(255,255,255,.08); border-radius: 8px; padding: 9px 10px; font-size: 12px; line-height: 1.45; }
.status-sync:empty { display: none; }
.status-sync .usuario { font-weight: 600; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-sync .linha { display: flex; align-items: center; gap: 6px; opacity: .9; }
.status-sync .ponto { width: 8px; height: 8px; border-radius: 50%; background: #9aa6bf; flex-shrink: 0; }
.status-sync .online .ponto { background: #4caf50; }
.status-sync .sincronizando .ponto { background: #ffc107; }
.status-sync .offline .ponto, .status-sync .sessao .ponto { background: #ef5350; }
.status-sync .acoes-sync { display: flex; gap: 6px; margin-top: 6px; }
.status-sync .acoes-sync button { flex: 1; font: inherit; font-size: 11.5px; color: #fff; background: rgba(255,255,255,.12); border: 0; border-radius: 6px; padding: 4px 6px; cursor: pointer; }
.status-sync .acoes-sync button:hover { background: rgba(255,255,255,.22); }

/* login */
.login-fundo { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: radial-gradient(circle at 50% 0%, #0a5591 0%, var(--azul) 55%, #002a47 100%); }
.login-fundo::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 6px; background: var(--laranja); }
.login-caixa { width: 380px; max-width: 92vw; background: #fff; border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-caixa { border-top: 5px solid var(--laranja); }
.login-caixa .marca { padding: 0 0 4px; color: var(--azul); flex-direction: column; text-align: center; gap: 8px; }
.login-caixa .logo { width: 104px; height: 104px; box-shadow: 0 6px 18px rgba(0,64,108,.25); }
.login-caixa .marca strong { color: var(--laranja-2); font-weight: 700; letter-spacing: .5px; text-transform: uppercase; font-size: 12px; opacity: 1; }
.login-caixa h2 { text-align: center; }
.login-caixa h2 { margin: 4px 0 0; font-size: 19px; }
.login-caixa label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--suave); }
.login-caixa .btn { justify-content: center; }
.login-caixa .btn:disabled { opacity: .6; cursor: wait; }
.login-erro { color: var(--vermelho); font-size: 13px; margin: 0; min-height: 1em; }
.login-erro:empty { display: none; }

a.btn { text-decoration: none; }
tr.inativo td { color: var(--suave); }

/* ---------- celular / tablet ---------- */
@media (max-width: 860px) {
  html, body { height: auto; }
  body { display: block; min-height: 100%; }
  .so-pc { display: none !important; }

  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    width: auto; padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    flex-direction: row; box-shadow: 0 -2px 12px rgba(0,0,0,.18);
  }
  .sidebar .marca, .sidebar .rodape-side { display: none; }
  nav { flex-direction: row; width: 100%; gap: 2px; }
  .nav-item {
    flex: 1; min-width: 0; position: relative;
    flex-direction: column; gap: 2px; padding: 7px 2px;
    font-size: 10.5px; text-align: center;
  }
  .nav-item .ico { font-size: 17px; width: auto; }
  .nav-item .txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .nav-item .txt[data-curto] { font-size: 0; }
  .nav-item .txt[data-curto]::after { content: attr(data-curto); font-size: 10.5px; }
  .badge-nav { position: absolute; top: 2px; left: 50%; margin-left: 6px; font-size: 10px; padding: 0 5px; }

  main { overflow: visible; padding: 14px 12px calc(84px + env(safe-area-inset-bottom)); }
  .topo { flex-wrap: wrap; }
  .topo h1 { font-size: 20px; }
  .topo > div { flex-wrap: wrap; }

  .filtros { padding: 10px; }
  .filtros label { flex: 1 1 140px; }
  .filtros .busca { flex-basis: 100%; min-width: 0; }
  .filtros select, .filtros input { width: 100%; }
  .filtros .btn { flex: 1 1 100%; justify-content: center; }

  .kpis { grid-template-columns: 1fr 1fr !important; gap: 10px; }
  .card { padding: 12px 14px; }
  .kpi .val { font-size: 19px; }
  .kpi .rot { font-size: 11px; }
  .kpi .sub { font-size: 11.5px; }
  .graficos, .config-grid { grid-template-columns: 1fr; }
  .caixa-grafico { height: 260px; }
  .resumo { flex-direction: column; }
  .resumo .mini-pizza { display: none; }

  /* tabelas viram cartões */
  .tabela-wrap { max-height: none; overflow: visible; border: 0; background: none; }
  .tabela-wrap table, .tabela-wrap tbody, .tabela-wrap tr, .tabela-wrap td { display: block; width: 100%; }
  .tabela-wrap thead { display: none; }
  .tabela-wrap tr { background: #fff; border: 1px solid var(--borda); border-radius: var(--raio); margin-bottom: 10px; padding: 8px 12px; }
  .tabela-wrap tr:hover td { background: none; }
  .tabela-wrap td { border: 0; padding: 3px 0; white-space: normal; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .tabela-wrap td::before { content: attr(data-rotulo); color: var(--suave); font-size: 12px; font-weight: 600; text-align: left; flex-shrink: 0; }
  .tabela-wrap td[data-vazio] { display: none; }
  .tabela-wrap td.nome { font-size: 15px; font-weight: 600; text-align: left; min-width: 0; padding-bottom: 4px; }
  .tabela-wrap td.nome::before { display: none; }
  .tabela-wrap td.acoes { justify-content: flex-end; flex-wrap: wrap; gap: 6px; padding-top: 8px; margin-top: 4px; border-top: 1px solid #eef1f6; }
  .tabela-wrap td.acoes::before { display: none; }
  .tabela-wrap td.acoes .btn { margin: 0; }
  .btn.mini { min-height: 34px; padding: 6px 12px; font-size: 13px; }

  .modal-fundo { place-items: end center; }
  .modal { width: 100%; max-width: 100%; max-height: 94vh; border-radius: 14px 14px 0 0; }
  .modal form { grid-template-columns: 1fr; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  input, select, textarea { font-size: 16px; } /* evita zoom automático no iPhone */
  .toast { left: 12px; right: 12px; bottom: calc(80px + env(safe-area-inset-bottom)); text-align: center; }
  .boas-vindas { margin: 20px auto; padding: 22px; }
}

/* identidade Conexão: detalhes em laranja */
.sidebar { border-right: 4px solid var(--laranja); }
.marca strong { color: var(--laranja); opacity: 1 !important; font-weight: 700 !important; text-transform: uppercase; letter-spacing: .6px; }
.topo h1 { color: var(--azul); }
.card h2 { color: var(--azul); }
.kpi::before { background: var(--cor, var(--laranja)); }
.btn.sec { color: var(--azul); }
.modal header { border-bottom: 3px solid var(--laranja); }
.modal .secao { color: var(--laranja-2); }
th[data-ordem]:hover { color: var(--laranja-2); }
.cab-mobile { display: none; }
@media (max-width: 860px) {
  .sidebar { border-right: 0; border-top: 3px solid var(--laranja); }
  .cab-mobile {
    display: flex; align-items: center; gap: 10px;
    position: sticky; top: 0; z-index: 30;
    background: var(--azul); color: #fff; border-bottom: 3px solid var(--laranja);
    padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
  }
  .cab-mobile img { width: 38px; height: 38px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(255,255,255,.85); }
  .cab-mobile strong { display: block; color: var(--laranja); font-size: 11px; letter-spacing: .6px; text-transform: uppercase; line-height: 1.2; }
  .cab-mobile span { display: block; font-weight: 700; font-size: 16px; line-height: 1.2; }
}
