/* Mesma identidade do painel Z3 Meta Vendas: superfícies escuras e um único azul de destaque. */
:root {
  --bg: #07090d;
  --surface: #0e1117;
  --surface-2: #131722;
  --line: #1e2430;
  --line-2: #2a3242;
  --blue: #4a8cff;
  --blue-soft: rgba(74, 140, 255, 0.14);
  --ice: #9dbfff;
  --white: #f3f5f9;
  --muted: #8a93a6;
  --dim: #5b6477;
  --ok: #3ccf91;
  --warn: #f0b44c;
  --bad: #f06a7a;
  --display: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--white); }
body { font-family: var(--body); font-size: 14px; -webkit-font-smoothing: antialiased; min-height: 100vh; }
a { color: var(--ice); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Barra superior */
.topbar { border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 10; }
.topbar .in { max-width: 1240px; margin: 0 auto; padding: 0 16px; height: 60px; display: flex; align-items: center; gap: 20px; }
.logo { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 800; font-size: 1rem; text-decoration: none; color: var(--white); flex: none; }
.logo img { height: 22px; width: auto; display: block; }
.logo span { font-family: var(--body); font-weight: 500; font-size: .82rem; color: var(--muted); padding-left: 10px; border-left: 1px solid var(--line-2); }
.logo-login { flex-direction: column; gap: 12px; }
.logo-login img { height: 34px; }
.logo-login span { border-left: 0; padding-left: 0; }
nav.menu { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; }
nav.menu a { color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: 8px; font-weight: 500; white-space: nowrap; }
nav.menu a:hover { color: var(--white); background: var(--surface-2); }
nav.menu a.ativo { color: var(--white); background: var(--blue-soft); }
.quem { display: flex; align-items: center; gap: 12px; font-size: .82rem; color: var(--muted); flex: none; }
.quem strong { color: var(--white); font-weight: 600; display: block; }
@media (max-width: 760px) {
  .topbar .in { height: auto; flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  nav.menu { order: 3; flex-basis: 100%; }
  .quem .nome { display: none; }
}

main { max-width: 1240px; margin: 0 auto; padding: 24px 16px 64px; display: grid; gap: 20px; }
.titulo { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.titulo h1 { font-family: var(--display); font-weight: 700; font-size: 1.4rem; margin: 0; letter-spacing: -0.01em; }
.titulo p { margin: 4px 0 0; color: var(--muted); font-size: .86rem; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px; min-width: 0; }
.panel h2 { font-family: var(--display); font-size: 1rem; font-weight: 700; margin: 0 0 16px; }

/* Botões */
.btn { font: inherit; font-size: .86rem; font-weight: 500; color: var(--white); background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; padding: 9px 16px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; justify-content: center; }
.btn:hover { background: var(--surface-2); border-color: #3a4458; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #5b98ff; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 6px 10px; font-size: .8rem; }
.acoes { display: flex; flex-wrap: wrap; gap: 10px; }

/* Formulários */
/* Grade fixa de 4 colunas: todo campo ocupa 1, 2, 3 ou 4 colunas, então as bordas se alinham entre as linhas. */
form.grid, .fgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px 16px; align-items: start; }
.f { display: flex; flex-direction: column; gap: 6px; min-width: 0; grid-column: span 1; }
.f.q2 { grid-column: span 2; } .f.q3 { grid-column: span 3; } .f.q4 { grid-column: 1 / -1; }
@media (max-width: 900px) {
  form.grid, .fgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .f.q2, .f.q3, .f.q4 { grid-column: 1 / -1; }
}
@media (max-width: 520px) { .f { grid-column: 1 / -1; } }
label { font-size: .76rem; font-weight: 500; color: var(--muted); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
label em { color: var(--blue); font-style: normal; }
/* Mesma altura para caixa de texto, lista, data e arquivo */
input, select, textarea { width: 100%; font: inherit; font-size: .9rem; line-height: 1.2; color: var(--white); background: var(--bg); border: 1px solid var(--line-2); padding: 0 12px; border-radius: 8px; }
input, select { height: 42px; }
textarea { padding: 10px 12px; }
select { appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%238a93a6' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
input[type=file] { padding: 0 6px 0 0; display: flex; align-items: center; color: var(--muted); font-size: .82rem; line-height: 40px; }
input[type=file]::file-selector-button { font: inherit; font-size: .8rem; height: 40px; margin-right: 10px; padding: 0 12px; border: 0; border-right: 1px solid var(--line-2); border-radius: 8px 0 0 8px; background: var(--surface-2); color: var(--white); cursor: pointer; }
input[type=file]::file-selector-button:hover { background: var(--line-2); }
select option { background: var(--surface); }
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
input[readonly] { color: var(--muted); }
input::-webkit-calendar-picker-indicator { filter: invert(.7); }
input.invalido { border-color: var(--bad); }
.dica { font-size: .72rem; color: var(--dim); line-height: 1.3; }
.dica.ok { color: var(--ok); } .dica.err { color: var(--bad); }
.secao { grid-column: 1 / -1; font-family: var(--display); font-weight: 700; font-size: .92rem; padding-top: 18px; margin-top: 6px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.secao:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.secao small { font-family: var(--body); font-weight: 400; color: var(--muted); font-size: .78rem; }
.msg { font-size: .86rem; min-height: 1.2em; }
.msg.err { color: var(--bad); } .msg.ok { color: var(--ok); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .panel { width: 100%; max-width: 380px; display: grid; gap: 18px; }
.login .logo { justify-content: center; font-size: 1.1rem; }
.login p { color: var(--muted); margin: 0; text-align: center; font-size: .86rem; }
.login form { display: grid; gap: 14px; }
#codigo { text-transform: uppercase; letter-spacing: .3em; font-weight: 600; text-align: center; font-size: 1.1rem; }

/* Tabelas */
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; font-variant-numeric: tabular-nums; }
th { font-weight: 500; font-size: .76rem; color: var(--muted); text-align: left; padding: 0 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; }
.vazio { text-align: center; color: var(--muted); padding: 32px 0; border: 1px dashed var(--line-2); border-radius: 10px; }

/* Filtros e chips */
.filtros { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filtros input { max-width: 300px; }
.filtros select { width: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chipbtn { font: inherit; font-size: .8rem; border: 1px solid var(--line-2); background: var(--surface); color: var(--muted); padding: 6px 12px; border-radius: 99px; cursor: pointer; }
.chipbtn b { color: var(--white); margin-left: 6px; font-weight: 600; }
.chipbtn.ativo { border-color: var(--blue); color: var(--white); background: var(--blue-soft); }
.st { display: inline-block; font-size: .74rem; font-weight: 500; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.st.contrato_gerado, .st.contrato_assinado { color: var(--ice); background: var(--blue-soft); }
.st.em_formalizacao { color: var(--warn); background: rgba(240,180,76,.12); }
.st.aprovada { color: var(--ice); background: rgba(157,191,255,.16); }
.st.pagamento_liberado { color: #7fe3b8; background: rgba(60,207,145,.08); border: 1px dashed rgba(60,207,145,.45); }
.st.paga { color: var(--ok); background: rgba(60,207,145,.12); }
.st.cancelada { color: var(--bad); background: rgba(240,106,122,.12); }
.tag { font-size: .72rem; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }

/* Detalhe */
.cab { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 14px; }
.cab h1 { font-family: var(--display); font-size: 1.35rem; margin: 6px 0 4px; }
.cab .meta { color: var(--muted); font-size: .84rem; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.etapas { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.etapa { display: grid; gap: 8px; font-size: .74rem; color: var(--dim); }
.etapa i { height: 4px; border-radius: 99px; background: var(--line-2); }
.etapa.feita { color: var(--muted); } .etapa.feita i { background: var(--blue); }
.etapa.atual { color: var(--white); font-weight: 600; } .etapa.atual i { background: var(--ice); }
@media (max-width: 640px) { .etapa span { display: none; } }
.abas { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.abas button { font: inherit; background: none; border: 0; color: var(--muted); padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 500; }
.abas button:hover { color: var(--white); }
.abas button.ativo { color: var(--white); border-bottom-color: var(--blue); }
dl.dados { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px 20px; margin: 0; }
dl.dados div { min-width: 0; }
dl.dados dt { font-size: .74rem; color: var(--muted); margin-bottom: 3px; }
dl.dados dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.bloco { display: grid; gap: 22px; }
.bloco h3 { font-family: var(--display); font-size: .92rem; margin: 0 0 12px; color: var(--ice); }
.linkbox { display: flex; gap: 8px; align-items: center; background: var(--bg); border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 8px 8px 12px; }
.linkbox a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aviso { border: 1px solid rgba(240,180,76,.4); background: rgba(240,180,76,.06); border-radius: 10px; padding: 12px 14px; font-size: .86rem; color: var(--warn); }
.aviso.info { border-color: rgba(74,140,255,.4); background: var(--blue-soft); color: var(--ice); }
.aviso.ok { border-color: rgba(60,207,145,.4); background: rgba(60,207,145,.06); color: var(--ok); }
ol.hist { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
ol.hist li { display: grid; grid-template-columns: 140px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: .86rem; }
ol.hist li:last-child { border-bottom: 0; }
ol.hist time { color: var(--muted); font-size: .8rem; }
ol.hist small { color: var(--muted); display: block; overflow-wrap: anywhere; }

/* Modal e toast */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal .panel { max-width: 420px; width: 100%; display: grid; gap: 14px; }
.codigo-grande { font-family: var(--display); font-size: 2rem; font-weight: 800; letter-spacing: .25em; text-align: center; padding: 16px; border-radius: 10px; background: var(--bg); border: 1px dashed var(--blue); color: var(--white); }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; width: min(420px, calc(100% - 32px)); }
#toast div { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 12px 16px; font-size: .86rem; box-shadow: 0 8px 30px rgba(0,0,0,.4); }
#toast div.err { border-color: rgba(240,106,122,.5); }
#toast div.ok { border-color: rgba(60,207,145,.5); }
