/* GVM Web — identidade visual alinhada ao SGC (sgc.mobit.com.br) */
:root {
  --primary: #021426;
  --primary-hover: #03203c;
  --primary-soft: #e8eefb;
  --navy-2: #0c3566;
  --amarelo: #fdb913;
  --amarelo-hover: #f2a20c;
  --amarelo-soft: #fff6d5;
  --azul: #2756b8;
  --azul-escuro: #1b3f93;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e5e7eb;
  --text: #021426;
  --muted: #6b7280;
  --ok: #18794e;
  --ok-soft: #e5f5ec;
  --warn: #8a5a00;
  --warn-soft: #fff4d6;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(2, 20, 38, .05), 0 4px 16px rgba(2, 20, 38, .05);
  --font: Montserrat, "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.45; }
a { color: var(--azul); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 700; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 700; }
small, .muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--primary) 0%, var(--navy-2) 100%);
  color: #cbd5e1; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 3px; }
.marca { color: #fff; font-size: 18px; font-weight: 800; padding: 4px 10px 16px; border-bottom: 1px solid rgba(255,255,255,.1); margin-bottom: 8px; }
.marca .mobit { color: var(--amarelo); }
.marca small { display: block; color: #94a3b8; font-size: 11px; font-weight: 500; margin-top: 2px; }
.menu-grupo { margin-top: 10px; }
.menu-grupo > button {
  all: unset; box-sizing: border-box; width: 100%; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #8ea3bf; font-weight: 700; padding: 6px 10px;
}
.menu-grupo > button { border-radius: 6px; }
.menu-grupo > button:hover { color: #fff; background: rgba(255,255,255,.06); }
.menu-grupo > button:focus-visible { outline: 2px solid var(--amarelo); border-radius: 6px; }
.menu-grupo > button .seta { transition: transform .15s; }
.menu-grupo.fechado > button .seta { transform: rotate(-90deg); }
.menu-grupo.fechado .menu-itens { display: none; }
.sidebar a.item {
  display: flex; align-items: center; gap: 10px; color: #cbd5e1; padding: 8px 10px; border-radius: 8px; font-size: 13.5px; text-decoration: none;
}
.sidebar a.item svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.sidebar a.item:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar a.item.ativo { background: rgba(253,185,19,.14); color: #fff; box-shadow: inset 3px 0 0 var(--amarelo); }
.sidebar a.item.ativo svg { color: var(--amarelo); opacity: 1; }
.usuario-box { margin-top: auto; border-top: 1px solid rgba(255,255,255,.1); padding: 14px 10px 0; display: flex; flex-direction: column; gap: 6px; }
.usuario-box .quem { display: flex; gap: 10px; align-items: center; color: #fff; font-weight: 600; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--amarelo); color: var(--primary); display: grid; place-items: center; font-weight: 800; font-size: 13px; object-fit: cover; flex: none; }
.usuario-box .papel { font-size: 11px; color: #94a3b8; font-weight: 500; }
.usuario-box .link { all: unset; cursor: pointer; font-size: 12px; color: #cbd5e1; padding: 3px 0; }
.usuario-box .link:hover { color: #fff; text-decoration: underline; }
.usuario-box .link.sair { color: #fca5a5; }

main { padding: 24px 28px 48px; min-width: 0; }
.topo { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.topo .sub { color: var(--muted); margin-top: 4px; font-size: 13px; }
.migalhas { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.migalhas a { color: var(--muted); }
.acoes { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn.menu-mobile { display: none; }

/* ---------- componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card, .card + .grid, .grid + .card, .grid + .grid { margin-top: 16px; }
.card-titulo { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-titulo h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid > .card { margin-top: 0; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; position: relative; overflow: hidden; display: block; color: inherit; }
a.kpi:hover { text-decoration: none; border-color: #c7d2fe; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--azul); }
.kpi.amarelo::before { background: var(--amarelo); }
.kpi.ok::before { background: var(--ok); }
.kpi.danger::before { background: var(--danger); }
.kpi.warn::before { background: #e8a317; }
.kpi .rotulo { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .valor { font-size: 26px; font-weight: 800; margin-top: 4px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .det { font-size: 12px; color: var(--muted); margin-top: 2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: inherit; font-weight: 600; font-size: 13px; padding: 8px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:focus-visible, .campo:focus-visible { outline: 2px solid var(--azul); outline-offset: 1px; }
.btn svg { width: 16px; height: 16px; }
.btn.primario { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primario:hover { background: var(--primary-hover); }
.btn.destaque { background: var(--amarelo); border-color: var(--amarelo); color: var(--primary); }
.btn.destaque:hover { background: var(--amarelo-hover); }
.btn.perigo { color: var(--danger); border-color: #f5c2bd; }
.btn.perigo:hover { background: var(--danger-soft); }
.btn.perigo.cheio { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.fantasma { border-color: transparent; background: transparent; }
.btn.fantasma:hover { background: var(--primary-soft); }
.btn.pq { padding: 5px 10px; font-size: 12px; }
.btn.icone { padding: 6px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.campo, select.campo, textarea.campo {
  font: inherit; font-size: 13.5px; color: var(--text); background: var(--surface); border: 1px solid #d1d5db; border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0;
}
textarea.campo { min-height: 90px; resize: vertical; }
.campo:focus { border-color: var(--azul); box-shadow: 0 0 0 3px rgba(39,86,184,.12); outline: none; }
.campo[readonly] { background: var(--surface-2); color: var(--muted); }
label.lbl { display: block; font-size: 12px; font-weight: 600; color: #374151; margin-bottom: 5px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px 16px; }
.form-grid .largo { grid-column: 1 / -1; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.filtros { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filtros .f { min-width: 160px; }
.busca { position: relative; flex: 1; min-width: 220px; max-width: 420px; }
.busca svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.busca .campo { padding-left: 34px; }

.badge { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--primary-soft); color: var(--azul-escuro); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.cinza { background: #eef0f3; color: #4b5563; }
.badge.amarelo { background: var(--amarelo-soft); color: #7a5300; }

/* ---------- tabelas ---------- */
.tabela-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); max-height: calc(100vh - 260px); }
.tabela-wrap.livre { max-height: none; }
table.tabela { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
.tabela th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2); text-align: left; font-weight: 700; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .03em; color: #4b5563; padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none;
}
.tabela th.ord { cursor: pointer; }
.tabela th.ord:hover { color: var(--text); }
.tabela th .seta { font-size: 10px; margin-left: 3px; color: var(--azul); }
.tabela td { padding: 8px 10px; border-bottom: 1px solid #f0f1f3; vertical-align: middle; }
.tabela tr:last-child td { border-bottom: 0; }
.tabela tbody tr:hover td { background: #fafbff; }
.tabela tr.sel td { background: #eef3ff; }
.tabela tr.clicavel { cursor: pointer; }
.tabela td.num, .tabela th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tabela td.acoes-linha { white-space: nowrap; text-align: right; width: 1%; }
.tabela td.nowrap { white-space: nowrap; }
.tabela tfoot td { position: sticky; bottom: 0; background: var(--surface-2); font-weight: 700; border-top: 1px solid var(--border); }
.tabela .ed { border: 1px solid transparent; background: transparent; font: inherit; font-size: 13px; padding: 4px 6px; border-radius: 6px; width: 100%; min-width: 90px; color: inherit; }
.tabela select.ed { min-width: 122px; padding-right: 2px; }
.tabela .ed:hover { border-color: #d1d5db; background: #fff; }
.tabela .ed:focus { border-color: var(--azul); background: #fff; outline: none; box-shadow: 0 0 0 3px rgba(39,86,184,.12); }
.tabela .ed.salvo { animation: salvo 1s; }
@keyframes salvo { 0% { background: var(--ok-soft); } 100% { background: transparent; } }
.tabela input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.vazio { text-align: center; color: var(--muted); padding: 36px 12px; }
.paginacao { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: 12.5px; color: var(--muted); gap: 10px; flex-wrap: wrap; }
.barra-selecao { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: var(--primary); color: #fff; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 12px; }
.barra-selecao .campo { width: auto; min-width: 140px; padding: 6px 8px; }
.barra-selecao .btn { padding: 6px 12px; }

/* ---------- abas ---------- */
.abas { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.abas button { all: unset; cursor: pointer; padding: 9px 14px; font-weight: 600; font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.abas button:hover { color: var(--text); }
.abas button.ativa { color: var(--text); border-bottom-color: var(--amarelo); }
.abas button:focus-visible { outline: 2px solid var(--azul); border-radius: 4px; }
.abas .cont { background: #eef0f3; border-radius: 999px; padding: 1px 7px; font-size: 11px; margin-left: 6px; }

/* ---------- modal / toast ---------- */
.modal-fundo { position: fixed; inset: 0; background: rgba(2,20,38,.45); display: grid; place-items: center; z-index: 50; padding: 20px; animation: fade .12s; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: 0 20px 60px rgba(2,20,38,.3); width: min(640px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; }
.modal.largo { width: min(980px, 100%); }
.modal header { padding: 18px 20px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal header h2 { margin: 0; }
.modal .corpo { padding: 16px 20px; overflow-y: auto; }
.modal footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); border-radius: 0 0 14px 14px; }
@keyframes fade { from { opacity: 0; } }
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast { background: var(--primary); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); font-weight: 500; max-width: 420px; animation: sobe .2s; border-left: 4px solid var(--amarelo); }
.toast.erro { background: #fff; color: var(--danger); border: 1px solid #f5c2bd; border-left: 4px solid var(--danger); }
.toast.ok { border-left-color: #4ade80; }
@keyframes sobe { from { transform: translateY(10px); opacity: 0; } }
.carregando { padding: 40px; text-align: center; color: var(--muted); }
.carregando::before { content: ""; display: inline-block; width: 18px; height: 18px; border: 2px solid #cbd5e1; border-top-color: var(--azul); border-radius: 50%; animation: gira .7s linear infinite; vertical-align: middle; margin-right: 8px; }
@keyframes gira { to { transform: rotate(360deg); } }
.aviso { padding: 12px 14px; border-radius: 10px; background: var(--amarelo-soft); color: #6b4a00; border: 1px solid #f7e0a0; font-size: 13px; }
.aviso.info { background: var(--primary-soft); color: var(--azul-escuro); border-color: #c9d6f5; }
.aviso.erro { background: var(--danger-soft); color: var(--danger); border-color: #f5c2bd; }
.lista-simples { list-style: none; margin: 0; padding: 0; }
.lista-simples li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid #f0f1f3; }
.lista-simples li:last-child { border-bottom: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--primary-soft); color: var(--azul-escuro); border-radius: 999px; padding: 4px 6px 4px 11px; font-size: 12.5px; font-weight: 600; }
.chip button { all: unset; cursor: pointer; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; line-height: 1; }
.chip button:hover { background: rgba(0,0,0,.08); }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 13px; }
.dl dt { color: var(--muted); font-weight: 600; }
.dl dd { margin: 0; }
.img-preview { max-width: 220px; max-height: 90px; border: 1px dashed #d1d5db; border-radius: 8px; padding: 4px; background: #fff; display: block; }

/* gráficos simples */
.barras { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 10px; }
.barras .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; height: 100%; justify-content: flex-end; }
.barras .pilha { width: 100%; max-width: 38px; display: flex; flex-direction: column-reverse; border-radius: 5px 5px 0 0; overflow: hidden; }
.barras .seg { width: 100%; }
.barras .rot { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.barras .v { font-size: 10.5px; font-weight: 700; color: #374151; }
.legenda { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.legenda i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.hbar { display: grid; grid-template-columns: minmax(0, 420px) minmax(80px, 1fr) 40px; gap: 10px; align-items: center; font-size: 12.5px; padding: 4px 0; }
.hbar .trilho { background: #eef0f3; border-radius: 4px; height: 8px; overflow: hidden; }
.hbar .trilho span { display: block; height: 100%; background: var(--azul); border-radius: 4px; }
.hbar .n { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.hbar .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- login ---------- */
.login-tela { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-lado { background: linear-gradient(160deg, var(--primary) 0%, var(--navy-2) 70%, #134a8a 100%); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-lado::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 380px; height: 380px; border-radius: 50%; border: 48px solid rgba(253,185,19,.12); }
.login-lado h1 { font-size: 34px; line-height: 1.15; margin-top: 18px; max-width: 460px; }
.login-lado p { color: #b8c4d6; max-width: 440px; font-size: 15px; }
.login-form { display: grid; place-items: center; padding: 32px; }
.login-form form { width: min(380px, 100%); display: flex; flex-direction: column; gap: 16px; }
.login-form h2 { font-size: 22px; margin: 0; }

/* ---------- documentos para impressão (cartas, declaração, protocolos) ---------- */
.documento { background: #fff; width: 210mm; min-height: 297mm; margin: 0 auto; padding: 18mm 16mm; box-shadow: var(--shadow); border: 1px solid var(--border); color: #000; font-size: 12px; }
.documento h1 { font-size: 16px; text-align: center; margin-bottom: 12px; }
.documento table { width: 100%; border-collapse: collapse; font-size: 10.5px; }
.documento th, .documento td { border: 1px solid #555; padding: 4px 5px; text-align: left; vertical-align: top; }
.documento th { background: #e9ecef; }
.documento .assinatura { margin-top: 36px; text-align: center; }
.documento .assinatura img { max-height: 70px; display: block; margin: 0 auto 4px; }
.documento .linha-ass { border-top: 1px solid #000; width: 280px; margin: 0 auto; padding-top: 4px; }
.documento .cab-doc { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid var(--primary); padding-bottom: 8px; margin-bottom: 14px; }
.documento .cab-doc .logo { font-weight: 800; font-size: 20px; color: var(--primary); }
.documento .cab-doc .logo span { color: var(--amarelo); }
.documento .grupo { margin-top: 14px; font-weight: 700; }
.documento .caixa { border: 1px solid #555; padding: 8px 10px; margin-bottom: 8px; }
.documento .caixa h4 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; background: #e9ecef; margin: -8px -10px 8px; padding: 5px 10px; border-bottom: 1px solid #555; }
.documento .lin { display: flex; gap: 6px; margin: 3px 0; }
.documento .lin b { white-space: nowrap; }
.documento .via { min-height: 128mm; border-bottom: 1px dashed #999; padding-bottom: 10mm; margin-bottom: 10mm; }
.documento .via:last-child { border-bottom: 0; }

@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; }
  .sidebar, .topo, .nao-imprimir, .toasts, .menu-mobile { display: none !important; }
  .layout { display: block; }
  main { padding: 0; }
  .documento { box-shadow: none; border: 0; margin: 0; width: auto; min-height: auto; }
  .quebra { page-break-before: always; }
}

/* ---------- responsivo ---------- */
@media (max-width: 1100px) { .g3 { grid-template-columns: 1fr 1fr; } .g-21 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  body.menu-aberto .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(2,20,38,.4); }
  .btn.menu-mobile { display: inline-flex; margin-bottom: 12px; }
  main { padding: 16px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .login-tela { grid-template-columns: 1fr; }
  .login-lado { display: none; }
  .tabela-wrap { max-height: none; }
  .documento { width: 100%; padding: 16px; min-height: auto; }
}
