:root {
  --fundo: #f5f4f1;
  --superficie: #ffffff;
  --texto: #1f2328;
  --suave: #5f6670;
  --linha: #dcdad5;
  --destaque: #1e4d5c;
  --destaque-escuro: #163a46;
  --destaque-claro: #e6eef0;
  --perigo: #a3321c;
  --aviso: #8a3b12;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--texto);
  background: var(--fundo);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.05rem; margin: 1.5rem 0 .5rem; color: var(--suave); font-weight: 600; }
a { color: var(--destaque); }
.suave { color: var(--suave); }
.pequeno { font-size: .85rem; }

.topo {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .25rem 1.5rem;
  padding: .6rem 1rem; background: var(--superficie); border-bottom: 1px solid var(--linha);
}
.marca { font-weight: 700; text-decoration: none; color: var(--texto); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sair { grid-column: 2; grid-row: 1; }
.menu { grid-column: 1 / -1; display: flex; gap: .25rem; overflow-x: auto; margin: 0 -.5rem; }
.menu a {
  padding: .4rem .6rem; border-radius: 6px; color: var(--suave); text-decoration: none; white-space: nowrap;
}
.menu a:hover { color: var(--texto); background: var(--fundo); }
.menu a[aria-current="page"] { color: var(--destaque); background: var(--destaque-claro); font-weight: 600; }

@media (min-width: 760px) {
  .topo { grid-template-columns: auto 1fr auto; }
  .menu { grid-column: 2; grid-row: 1; margin: 0; }
  .sair { grid-column: 3; }
}

.conteudo { max-width: 960px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.centro { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }

.cabecalho { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.cabecalho h1 { margin: 0; }

.cartao {
  width: 100%; max-width: 380px; background: var(--superficie);
  border: 1px solid var(--linha); border-radius: 8px; padding: 1.75rem;
}
.cartao.largo { max-width: 560px; }
.subtitulo { color: var(--suave); line-height: 1.5; }
.nota { font-size: .9rem; color: var(--suave); border-top: 1px solid var(--linha); padding-top: 1rem; }

label { display: block; margin-bottom: 1rem; font-size: .9rem; color: var(--suave); }
input:not([type=radio]):not([type=checkbox]) {
  display: block; width: 100%; margin-top: .3rem; padding: .6rem .7rem;
  font: inherit; color: var(--texto); background: var(--superficie);
  border: 1px solid var(--linha); border-radius: 6px;
}
input:focus { outline: 2px solid var(--destaque); outline-offset: -1px; border-color: transparent; }

button, .botao {
  display: inline-block; font: inherit; cursor: pointer; padding: .6rem 1.1rem; border: 0; border-radius: 6px;
  background: var(--destaque); color: #fff; text-decoration: none; text-align: center;
}
button:hover, .botao:hover { background: var(--destaque-escuro); }
.botao.secundario { background: var(--superficie); color: var(--texto); border: 1px solid var(--linha); }
.botao.secundario:hover { background: var(--fundo); }
.botao.perigo { background: var(--superficie); color: var(--perigo); border: 1px solid currentColor; }
.botao.perigo:hover { background: #fbecea; }
button.ligacao, .ligacao-texto {
  background: none; border: 0; padding: .25rem; color: var(--suave); cursor: pointer; font: inherit; text-decoration: underline;
}
button.ligacao { text-decoration: none; }
button.ligacao:hover, .ligacao-texto:hover { color: var(--texto); background: none; }

.cartao button[type=submit] { width: 100%; margin-top: .25rem; }

.aviso { color: var(--aviso); background: #fbeee6; padding: .6rem .8rem; border-radius: 6px; }

.pesquisa { display: flex; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.pesquisa input { margin: 0; flex: 1; min-width: 0; }

.tabela { background: var(--superficie); border: 1px solid var(--linha); border-radius: 8px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .7rem 1rem; text-align: left; vertical-align: top; }
th { font-size: .8rem; font-weight: 600; color: var(--suave); background: var(--fundo); border-bottom: 1px solid var(--linha); }
tbody tr + tr td { border-top: 1px solid var(--linha); }
tbody tr { position: relative; }
tbody tr:hover { background: #faf9f7; }
.ligacao-linha { font-weight: 600; color: var(--texto); text-decoration: none; }
.ligacao-linha::after { content: ""; position: absolute; inset: 0; }
.etiqueta {
  display: inline-block; margin-left: .4rem; padding: .05rem .4rem; font-size: .75rem;
  color: var(--suave); border: 1px solid var(--linha); border-radius: 4px; vertical-align: 1px;
}
.so-estreito { display: block; font-size: .85rem; margin-top: .15rem; }
.so-largo { display: none; }
@media (min-width: 760px) {
  .so-estreito { display: none; }
  .so-largo { display: table-cell; }
}

.vazio { padding: 3rem 1rem; text-align: center; color: var(--suave); background: var(--superficie); border: 1px dashed var(--linha); border-radius: 8px; }

.ficha { max-width: 640px; background: var(--superficie); border: 1px solid var(--linha); border-radius: 8px; padding: 1.5rem; }
.campo.com-erro input { border-color: var(--perigo); }
.erro { display: block; margin-top: .3rem; color: var(--perigo); font-size: .85rem; }
.ajuda { display: block; margin-top: .3rem; font-size: .85rem; }
.duas-colunas { display: grid; gap: 0 1rem; }
@media (min-width: 560px) { .duas-colunas { grid-template-columns: 1fr 1fr; } }

.escolha { border: 0; padding: 0; margin: 0 0 1rem; display: flex; gap: .5rem; flex-wrap: wrap; }
.escolha legend { font-size: .9rem; color: var(--suave); margin-bottom: .3rem; padding: 0; }
.escolha label {
  margin: 0; padding: .45rem .9rem; border: 1px solid var(--linha); border-radius: 6px; color: var(--texto); cursor: pointer;
}
.escolha label:has(input:checked) { border-color: var(--destaque); background: var(--destaque-claro); color: var(--destaque); font-weight: 600; }
.escolha input { accent-color: var(--destaque); margin: 0 .3rem 0 0; }

.acoes { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-top: .5rem; }
.acoes .perigo { margin-left: auto; }

dialog { border: 1px solid var(--linha); border-radius: 8px; padding: 1.5rem; max-width: 420px; width: calc(100% - 2rem); color: var(--texto); }
dialog::backdrop { background: rgb(0 0 0 / .35); }
dialog p { margin-top: 0; line-height: 1.5; }


.atalhos { display: grid; gap: .75rem; margin-bottom: 1.5rem; }
@media (min-width: 560px) { .atalhos { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); } }
.atalho {
  display: flex; flex-direction: column; gap: .2rem; padding: 1rem 1.1rem; text-decoration: none; color: var(--texto);
  background: var(--superficie); border: 1px solid var(--linha); border-radius: 8px;
}
.atalho:hover { border-color: var(--destaque); }
.atalho span { color: var(--suave); font-size: .9rem; }
.sem-quebra { white-space: nowrap; text-align: right; }

.conteudo.largo { max-width: 1200px; }
.contagem { font-size: .9rem; font-weight: 400; margin-left: .4rem; }
.forte { font-weight: 600; }
.numero { text-align: right; }
.centro-celula { text-align: center; }

select {
  display: block; width: 100%; margin-top: .3rem; padding: .6rem .7rem; font: inherit; color: var(--texto);
  background: var(--superficie); border: 1px solid var(--linha); border-radius: 6px;
}
.caixa { display: flex; align-items: center; gap: .4rem; color: var(--texto); }
.caixa input { accent-color: var(--destaque); width: 1rem; height: 1rem; margin: 0; }

.filtros { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.filtros input[type=search] { margin: 0; flex: 1 1 260px; min-width: 0; }
.filtros select { margin: 0; width: auto; flex: 0 1 12rem; }
.filtros .caixa { margin: 0; font-size: .9rem; }

.etiqueta.rever { color: #7a4d00; background: #fdf1d6; border-color: #f0d9a3; }

table.editavel td { padding: .3rem .4rem; vertical-align: middle; }
table.editavel th { padding: .55rem .5rem; }
table.editavel input:not([type=checkbox]), table.editavel select {
  margin: 0; padding: .35rem .45rem; border-color: transparent; background: transparent;
}
table.editavel input:not([type=checkbox]):hover, table.editavel select:hover { border-color: var(--linha); }
table.editavel input:not([type=checkbox]):focus, table.editavel select:focus { background: var(--superficie); }
table.editavel input[type=checkbox] { accent-color: var(--destaque); width: 1rem; height: 1rem; }
table.editavel .com-erro { border-color: var(--perigo) !important; }
table.editavel tbody tr:hover { background: transparent; }
tr.inativo td, tr.inativo td input, tr.inativo td select { color: #9a9fa6; }
.estado { font-size: .8rem; color: var(--suave); }
.estado.ok { color: #2f6b3b; }
.estado.falhou { color: var(--perigo); cursor: help; }

.so-largo-bloco { display: none; }
.so-estreito-bloco { display: block; }
@media (min-width: 900px) {
  .so-largo-bloco { display: block; }
  .so-estreito-bloco { display: none; }
}
.sem-quebra-esq { white-space: nowrap; }

textarea {
  display: block; width: 100%; margin-top: .3rem; padding: .55rem .7rem; font: inherit; color: var(--texto);
  background: var(--superficie); border: 1px solid var(--linha); border-radius: 6px; resize: vertical;
}
textarea:focus, select:focus { outline: 2px solid var(--destaque); outline-offset: -1px; border-color: transparent; }

.subnav { display: flex; gap: .25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--linha); }
.subnav a { padding: .5rem .75rem; color: var(--suave); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subnav a[aria-current="page"] { color: var(--destaque); border-bottom-color: var(--destaque); font-weight: 600; }

.escolha.vertical { flex-direction: column; }
.escolha.vertical label { width: fit-content; }

.estado-orc { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; vertical-align: middle; white-space: nowrap; }
.estado-rascunho { background: #ecebe7; color: #4d525a; }
.estado-enviado { background: #e3edf3; color: #1e4d5c; }
.estado-aceite { background: #e3f1e6; color: #2f6b3b; }
.estado-recusado { background: #f8e6e2; color: #a3321c; }
.estado-vencido { background: #fdf1d6; color: #7a4d00; }
h1 .estado-orc { font-size: .8rem; margin-left: .3rem; }

.cabecalho-orc { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin: .5rem 0 1rem; }
.cabecalho-orc h1 { margin: 0 0 .25rem; }
.cabecalho-orc p { margin: 0; }
.acoes-orc { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

.menu-mais { position: relative; }
.menu-mais summary { list-style: none; cursor: pointer; }
.menu-mais summary::-webkit-details-marker { display: none; }
.menu-mais-opcoes {
  position: absolute; right: 0; top: calc(100% + .3rem); z-index: 20; min-width: 15rem; padding: .3rem;
  background: var(--superficie); border: 1px solid var(--linha); border-radius: 8px; box-shadow: 0 6px 20px rgb(0 0 0 / .08);
}
.menu-mais-opcoes button { display: block; width: 100%; text-align: left; background: none; color: var(--texto); padding: .55rem .7rem; }
.menu-mais-opcoes button:hover { background: var(--fundo); }
.perigo-texto, .menu-mais-opcoes .perigo-texto { color: var(--perigo); }

.grupo { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.grupo-item {
  display: inline-flex; gap: .4rem; align-items: center; padding: .35rem .7rem; border: 1px solid var(--linha);
  border-radius: 6px; background: var(--superficie); color: var(--texto); text-decoration: none; font-size: .9rem;
}
.grupo-item.atual { border-color: var(--destaque); background: var(--destaque-claro); }

.editor { display: grid; gap: 1rem; align-items: start; }
@media (min-width: 1000px) { .editor { grid-template-columns: minmax(0, 1fr) 340px; } }
.painel { background: var(--superficie); border: 1px solid var(--linha); border-radius: 8px; padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.painel h2 { margin: 0 0 .8rem; color: var(--texto); font-size: 1rem; }
.painel .cabecalho h2 { margin: 0; }
.ficha-largura { max-width: 640px; margin-top: 1rem; }

.linhas { display: grid; gap: .5rem; }
.linha {
  display: grid; gap: .4rem .5rem; align-items: start; padding: .6rem;
  grid-template-columns: auto 1fr 1fr 1fr auto; border: 1px solid var(--linha); border-radius: 6px;
}
.linha .linha-descricao { margin: 0; }
.linha .linha-ordem { display: flex; flex-direction: column; gap: .15rem; }
.linha .linha-campo { font-size: .8rem; margin: 0; }
.linha-campo input { margin-top: .15rem; padding: .4rem .5rem; }
.cabecalho-linha { display: none; }

@media (max-width: 759px) {
  .linha .linha-ordem { grid-column: 1; grid-row: 1 / span 3; }
  .linha .linha-descricao { grid-column: 2 / 5; grid-row: 1; }
  .linha .linha-apagar { grid-column: 5; grid-row: 1; }
  .linha .linha-campo:nth-of-type(1) { grid-column: 2; grid-row: 2; }
  .linha .linha-campo:nth-of-type(2) { grid-column: 3; grid-row: 2; }
  .linha .linha-campo:nth-of-type(3) { grid-column: 4; grid-row: 2; }
  .linha .linha-total { grid-column: 2 / 5; grid-row: 3; }
}

@media (min-width: 760px) {
  .linha, .cabecalho-linha {
    grid-template-columns: 1.6rem minmax(0, 1fr) 4.5rem 6.5rem 4.5rem 6.5rem 1.6rem;
    align-items: center; padding: .4rem .2rem; border: 0; border-radius: 0;
  }
  .linha + .linha { border-top: 1px solid var(--linha); }
  .cabecalho-linha { display: grid; font-size: .8rem; font-weight: 600; color: var(--suave); border-bottom: 1px solid var(--linha); }
  .linha-campo span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .linha-campo input { margin: 0; }
  .linha .linha-total { font-size: .9rem; }
}

button.icone {
  background: none; color: var(--suave); padding: .1rem .35rem; border-radius: 4px; line-height: 1.2; font-size: 1rem;
}
button.icone:hover { background: var(--fundo); color: var(--texto); }
button.icone:disabled { opacity: .25; cursor: default; background: none; }
button.icone.perigo-texto { color: var(--perigo); font-size: 1.2rem; }

.linhas-acoes { margin-top: .8rem; }
.rodape-linhas { display: flex; justify-content: space-between; align-items: flex-end; gap: 1.5rem; flex-wrap: wrap; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--linha); }
.desconto-geral { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.desconto-geral label { margin: 0; }
.desconto-geral input#desconto-geral { width: 5rem; margin: 0; }
.totais { display: grid; grid-template-columns: auto auto; gap: .3rem 2rem; margin: 0 0 0 auto; }
.totais dt { color: var(--suave); }
.totais dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.totais .total { font-size: 1.15rem; font-weight: 700; color: var(--texto); padding-top: .3rem; border-top: 1px solid var(--linha); }

.abas { display: flex; gap: .25rem; margin-bottom: 1rem; flex-wrap: wrap; }
.abas button { background: var(--superficie); color: var(--suave); border: 1px solid var(--linha); padding: .45rem .9rem; }
.abas button:hover { background: var(--fundo); color: var(--texto); }
.abas button[aria-selected="true"] { background: var(--destaque-claro); color: var(--destaque); border-color: var(--destaque); font-weight: 600; }
.grelha-eq { display: grid; gap: 0 .75rem; grid-template-columns: 1fr 1fr; }
@media (min-width: 760px) { .grelha-eq { grid-template-columns: 1fr 2fr 1fr 1fr 1fr .7fr .7fr; } }
.grelha-servico { display: grid; gap: 0 .75rem; grid-template-columns: 1fr 1fr; }
@media (min-width: 760px) { .grelha-servico { grid-template-columns: 2fr 1fr 1fr; } }
.grelha-servico label:first-child { grid-column: 1 / -1; }
@media (min-width: 760px) { .grelha-servico label:first-child { grid-column: auto; } }
details summary { cursor: pointer; color: var(--suave); margin-bottom: .5rem; }

.com-sugestoes { position: relative; }
.sugestoes {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 30; max-height: 22rem; overflow-y: auto; margin-top: .2rem;
  background: var(--superficie); border: 1px solid var(--linha); border-radius: 8px; box-shadow: 0 8px 24px rgb(0 0 0 / .1);
}
.sugestao {
  display: grid; grid-template-columns: 1fr auto; gap: 0 1rem; width: 100%; text-align: left; padding: .55rem .75rem;
  background: none; color: var(--texto); border-radius: 0; font-size: .9rem;
}
.sugestao span { color: var(--suave); font-size: .8rem; }
.sugestao .sugestao-preco { grid-row: 1 / span 2; grid-column: 2; align-self: center; color: var(--texto); font-weight: 600; font-size: .9rem; }
.sugestao.ativa, .sugestao:hover { background: var(--destaque-claro); }
.sugestao.vazia { display: block; color: var(--suave); }

.tres-colunas { display: grid; gap: 0 .6rem; grid-template-columns: 1fr 1fr 1fr; }
.divisoes, .lista-simples { list-style: none; margin: 0 0 1rem; padding: 0; }
.divisoes li, .lista-simples li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .45rem 0; border-bottom: 1px solid var(--linha); }
.lista-simples li { justify-content: flex-start; flex-wrap: wrap; }
.nova-divisao { border-top: 1px solid var(--linha); padding-top: .8rem; }

.sair { display: flex; align-items: center; gap: .75rem; }
.sair form { margin: 0; }
.ligacao-topo { color: var(--suave); text-decoration: none; white-space: nowrap; }
.ligacao-topo:hover, .ligacao-topo[aria-current="page"] { color: var(--texto); }

.logotipo-atual { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.logotipo-atual img { max-height: 70px; max-width: 220px; padding: .4rem; background: var(--fundo); border: 1px solid var(--linha); border-radius: 6px; }
.enviar-logotipo { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.enviar-logotipo input[type=file] { margin: 0; flex: 1 1 220px; }
input.cor { height: 2.6rem; padding: .2rem; cursor: pointer; }

.campo-endereco { display: flex; align-items: center; gap: .4rem; }
.campo-endereco input { margin-top: .3rem; }
.campo-endereco span { margin-top: .3rem; white-space: nowrap; }
form.em-linha { display: inline; }
.novo-utilizador { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--linha); }
.painel-topo .marca .suave { font-weight: 400; }
