:root {
  --fundo: #f3f5f7; --sup: #ffffff; --borda: #dde2e8; --texto: #16202b; --texto2: #5a6675;
  --marca: #1f4e79; --marca-esc: #173a5b; --ok: #1a7f4b; --ruim: #c0392b; --aviso: #9a6400;
  --rec: #2a78d6; --desp: #eb6834;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; background: var(--fundo); color: var(--texto); font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; line-height: 1.45; }
a { color: var(--marca); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0; } h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
small { font-size: .82rem; } .apagado { color: var(--texto2); }
[hidden] { display: none !important; }

/* estrutura */
#app { display: flex; min-height: 100vh; }
aside { width: 220px; flex: none; background: var(--marca-esc); color: #fff; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.marca { padding: 1.2rem 1.1rem; font-weight: 700; font-size: 1.15rem; } .marca span, .login h1 span { font-weight: 400; opacity: .75; }
nav { display: flex; flex-direction: column; flex: 1; overflow: auto; }
nav a { color: #d6e2ee; padding: .65rem 1.1rem; border-left: 3px solid transparent; }
nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
nav a.ativo { background: rgba(255,255,255,.14); color: #fff; border-left-color: #fff; font-weight: 600; }
.conta { padding: 1rem 1.1rem; border-top: 1px solid rgba(255,255,255,.15); display: flex; flex-direction: column; gap: .2rem; align-items: flex-start; }
.conta small { opacity: .7; margin-bottom: .4rem; } .conta a, .conta .link { color: #d6e2ee; font-size: .88rem; }
main { flex: 1; min-width: 0; padding: 1.5rem 2rem 4rem; max-width: 1300px; }
main > header { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.voltar { font-size: .88rem; }
section { background: var(--sup); border: 1px solid var(--borda); border-radius: 10px; padding: 1.1rem 1.2rem; margin-top: 1.2rem; }
.duas { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; } .duas.larga { grid-template-columns: 2fr 1fr; }
.duas section { margin-top: 1.2rem; min-width: 0; }

/* botões e campos */
button { font: inherit; cursor: pointer; border-radius: 7px; border: 1px solid var(--marca); background: var(--marca); color: #fff; padding: .5rem .95rem; font-weight: 600; }
button:hover { background: var(--marca-esc); } button:disabled { opacity: .6; cursor: default; }
button.sec { background: var(--sup); color: var(--marca); border-color: var(--borda); } button.sec:hover { background: #eef3f8; }
button.peq { padding: .25rem .6rem; font-size: .85rem; }
button.perigo { background: var(--sup); color: var(--ruim); border-color: var(--ruim); }
button.link { background: none; border: 0; padding: 0; color: var(--marca); font-weight: 600; text-align: left; } button.link:hover { text-decoration: underline; background: none; }
button.link.perigo { color: var(--ruim); font-weight: 400; }
input, select, textarea { font: inherit; color: inherit; background: #fff; border: 1px solid #c3ccd6; border-radius: 7px; padding: .48rem .6rem; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus, button:focus-visible, .barra:focus-visible { outline: 2px solid var(--rec); outline-offset: 1px; }
.filtros { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: .9rem; }
.filtros input, .filtros select { width: auto; } .filtros input[type=search] { flex: 1; min-width: 180px; max-width: 360px; }
.filtros label { display: flex; align-items: center; gap: .4rem; color: var(--texto2); }
.esp { flex: 1; } .resumo { color: var(--texto2); font-size: .9rem; } .resumo b { color: var(--texto); }
.mes { min-width: 11rem; text-align: center; font-size: 1.05rem; }

/* tabelas */
.rolagem { overflow-x: auto; background: var(--sup); border: 1px solid var(--borda); border-radius: 10px; }
section .rolagem { border: 0; border-radius: 0; margin: 0 -1.2rem -1.1rem; }
section details .rolagem { margin: .6rem 0 0; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--borda); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--texto2); font-weight: 600; white-space: nowrap; background: #f8fafb; }
tbody tr:last-child td { border-bottom: 0; } tbody tr:hover { background: #f8fafc; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; } .acoes { text-align: right; white-space: nowrap; }
.nq { white-space: nowrap; font-variant-numeric: tabular-nums; }
.vazio { color: var(--texto2); text-align: center; padding: 1.4rem; }
.sinal { font-weight: 700; color: var(--texto2); }

/* selos */
.selo { display: inline-block; padding: .12rem .55rem; border-radius: 99px; font-size: .8rem; font-weight: 600; white-space: nowrap; background: #e8edf2; color: #3b4755; }
.selo.ok, .selo.s-concluida { background: #dff3e7; color: #135c36; } .selo.ruim, .selo.s-cancelada { background: #fbe3e0; color: #96281b; }
.selo.aviso, .selo.s-medicao, .selo.s-orcamento { background: #fdf0d2; color: #7a4f00; }
.selo.s-producao, .selo.s-instalacao { background: #dceafb; color: #174f95; } .selo.s-contrato { background: #d9f1f4; color: #0f5560; } .selo.s-liberada { background: #e6e1fa; color: #41339a; }

.selo.tp-aluminio { background: #e3e7ec; color: #2f3a47; } .selo.tp-componentes { background: #fdf0d2; color: #7a4f00; } .selo.tp-vidros { background: #d9f1f4; color: #0f5560; }

/* cartões e fichas */
.cartoes { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .9rem; }
.cartao { background: var(--sup); border: 1px solid var(--borda); border-radius: 10px; padding: .9rem 1rem; display: flex; flex-direction: column; gap: .15rem; }
section .cartao { background: #f8fafb; }
.cartao span { color: var(--texto2); font-size: .85rem; } .cartao b { font-size: 1.35rem; font-variant-numeric: tabular-nums; } .cartao small { color: var(--texto2); }
.cartao.ruim { border-color: #e9b4ad; } .cartao.ruim b { color: var(--ruim); } .cartao.aviso { border-color: #ecd08f; } .cartao.aviso b { color: var(--aviso); }
.abas { display: flex; gap: .3rem; margin: 1.3rem 0 0; border-bottom: 2px solid var(--borda); overflow-x: auto; }
.abas button { background: none; border: 0; border-bottom: 3px solid transparent; border-radius: 0; margin-bottom: -2px; color: var(--texto2); padding: .6rem 1rem; white-space: nowrap; }
.abas button:hover { background: #e9eef3; color: var(--texto); } .abas button.ativa { color: var(--marca); border-bottom-color: var(--marca); }
.abas + .cartoes, .abas + .filtros { margin-top: 1.2rem; }
button.sec.perigo { color: var(--ruim); border-color: #e9b4ad; } button.sec.perigo:hover { background: #fdf1ef; }
td.det { font-size: .86rem; color: var(--texto2); min-width: 220px; word-break: break-word; } .filtros.centro { justify-content: center; margin-top: 1rem; }
a.botao { display: inline-block; background: var(--marca); color: #fff; border-radius: 7px; padding: .5rem .95rem; font-weight: 600; } a.botao:hover { background: var(--marca-esc); text-decoration: none; }
h2.sub { margin-top: 1.4rem; } button.perigo:not(.sec):not(.link) { background: var(--ruim); color: #fff; border-color: var(--ruim); }
.nota { color: var(--texto2); font-size: .9rem; margin: .9rem 0; }
.cartoes + .rolagem { margin-top: 1.2rem; }
.ficha { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; background: var(--sup); border: 1px solid var(--borda); border-radius: 10px; padding: 1.1rem 1.2rem; }
.ficha div { display: flex; flex-direction: column; gap: .15rem; align-items: flex-start; } .ficha span:first-child { color: var(--texto2); font-size: .82rem; }
.ficha .t { grid-column: 1 / -1; } .ficha p { margin: 0; white-space: pre-wrap; }
.ficha.rt { background: #f8fafb; margin: .9rem 0; grid-template-columns: 1fr 2fr 1fr 1fr; } .ficha.rt p { margin: 0; white-space: pre-wrap; word-break: break-word; }
@media (max-width: 820px) { .ficha.rt { grid-template-columns: 1fr; } }
.lista { list-style: none; margin: 0; padding: 0; } .lista li { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem 0; border-bottom: 1px solid var(--borda); }
.lista li:last-child { border: 0; } .lista.cat span { flex: 1; display: flex; flex-direction: column; gap: .25rem; } .lista.cat i { display: block; height: 6px; border-radius: 3px; background: var(--desp); min-width: 3px; }
.lista b { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* agenda */
.agenda { list-style: none; margin: 0; padding: 0; } .agenda li { display: flex; gap: .7rem; align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--borda); }
.agenda li:last-child { border: 0; } .agenda .dia { width: 3.2rem; font-weight: 700; display: flex; flex-direction: column; flex: none; } .agenda .dia small { font-weight: 400; color: var(--texto2); }
.agenda .txt { flex: 1; display: flex; flex-direction: column; min-width: 0; } .agenda .feito .txt { text-decoration: line-through; opacity: .6; }
.ponto { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; background: #7b8794; }
.t-medicao { background: #eda100; } .t-instalacao { background: #2a78d6; } .t-entrega, .t-material { background: #1baf7a; } .t-vistoria { background: #6250d6; }
.t-visita { background: #e87ba4; } .t-prazo { background: #16202b; } .t-receita { background: #008300; } .t-despesa { background: #e34948; } .t-outro { background: #7b8794; }
.legenda { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .85rem; color: var(--texto2); margin-bottom: .8rem; }
.legenda span { display: flex; align-items: center; gap: .35rem; } .legenda i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.legenda i.ponto { border-radius: 50%; } .legenda i.rec { background: var(--rec); } .legenda i.desp { background: var(--desp); }
.legenda i.prev { background: repeating-linear-gradient(45deg, #7b8794 0 2px, transparent 2px 4px); border: 1px solid #7b8794; }

/* calendário */
.cal { background: var(--sup); border: 1px solid var(--borda); border-radius: 10px; overflow: hidden; }
.sem, .grade { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.sem span { padding: .45rem; font-size: .8rem; font-weight: 600; color: var(--texto2); text-align: center; background: #f8fafb; border-bottom: 1px solid var(--borda); }
.grade .dia { min-height: 96px; padding: .3rem; border-right: 1px solid var(--borda); border-bottom: 1px solid var(--borda); display: flex; flex-direction: column; gap: 2px; cursor: pointer; overflow: hidden; }
.grade .dia:nth-child(7n) { border-right: 0; } .grade .dia.fora { background: #f8fafb; cursor: default; } .grade .dia:hover:not(.fora) { background: #f3f7fb; }
.grade .dia b { font-size: .85rem; } .grade .dia.hoje b { background: var(--marca); color: #fff; border-radius: 99px; width: 1.6rem; height: 1.6rem; display: grid; place-items: center; }
.grade small { color: var(--texto2); }
.chip { font-size: .74rem; color: #fff; border-radius: 4px; padding: 1px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip.t-medicao { color: #16202b; } .chip.t-visita { color: #16202b; } .chip.feito { opacity: .5; text-decoration: line-through; }

/* gráfico */
.grafico { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; height: 210px; border-bottom: 1px solid var(--borda); }
.grafico .col { display: flex; flex-direction: column; min-width: 0; } .grafico .col > span { text-align: center; font-size: .78rem; color: var(--texto2); padding-top: 4px; height: 22px; margin-bottom: -22px; }
.par { flex: 1; display: flex; gap: 2px; align-items: flex-end; justify-content: center; }
.barra { width: 42%; max-width: 22px; display: flex; flex-direction: column; gap: 2px; min-height: 0; cursor: default; }
.barra i { display: block; min-height: 2px; } .barra i:first-child { border-radius: 4px 4px 0 0; }
.barra.rec i { background: var(--rec); } .barra.desp i { background: var(--desp); }
.barra.rec i.prev { background: repeating-linear-gradient(45deg, var(--rec) 0 2px, transparent 2px 4px); border: 1px solid var(--rec); }
.barra.desp i.prev { background: repeating-linear-gradient(45deg, var(--desp) 0 2px, transparent 2px 4px); border: 1px solid var(--desp); }
.barra:hover, .barra:focus { filter: brightness(.88); }
.dica-grafico { margin: 1.9rem 0 .4rem; font-size: .88rem; color: var(--texto2); min-height: 1.3em; }
details summary { cursor: pointer; color: var(--marca); font-size: .9rem; }

/* janela de formulário */
dialog.modal { border: 0; border-radius: 12px; padding: 0; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 24px); box-shadow: 0 20px 60px rgba(0,0,0,.3); color: var(--texto); }
dialog::backdrop { background: rgba(15,25,35,.5); }
dialog form { padding: 1.3rem 1.4rem; } dialog h2 { font-size: 1.2rem; margin-bottom: 1rem; }
.campos { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem 1rem; }
.campo { display: flex; flex-direction: column; gap: .25rem; min-width: 0; } .campo.t { grid-column: 1 / -1; }
.campo > span { font-size: .85rem; font-weight: 600; color: var(--texto2); } .campo small { color: var(--texto2); }
.tique { display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; white-space: nowrap; }
.tique input { width: 1.15rem; height: 1.15rem; accent-color: var(--ok); cursor: pointer; }
.arq-atual { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; background: #f3f7fb; border: 1px solid var(--borda); border-radius: 7px; padding: .4rem .6rem; }
.arq-atual a { font-weight: 600; word-break: break-all; }
.itens { display: flex; flex-direction: column; gap: .4rem; margin-bottom: .5rem; }
.item { display: grid; grid-template-columns: 1fr 4.2rem 3.6rem 6.5rem 1.5rem; gap: .35rem; align-items: center; }
.botoes { display: flex; gap: .6rem; margin-top: 1.2rem; align-items: center; }
.erro { color: var(--ruim); font-weight: 600; margin: .8rem 0 0; }

/* login */
.login { margin: auto; padding: 1rem; width: 100%; max-width: 400px; }
.login form { background: var(--sup); border: 1px solid var(--borda); border-radius: 12px; padding: 1.8rem; display: flex; flex-direction: column; gap: .9rem; }
.login h1 { color: var(--marca); } .login p { margin: 0; color: var(--texto2); } .login .erro { color: var(--ruim); }

#aviso { position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 150%); background: #16202b; color: #fff; padding: .65rem 1.1rem; border-radius: 8px; transition: transform .2s; z-index: 99; max-width: calc(100vw - 2rem); }
#aviso.visivel { transform: translate(-50%, 0); } #aviso.erro { background: var(--ruim); }

/* celular */
@media (max-width: 820px) {
  #app { flex-direction: column; }
  aside { width: 100%; height: auto; position: static; }
  .marca { padding: .7rem 1rem; }
  nav { flex-direction: row; overflow-x: auto; } nav a { white-space: nowrap; border-left: 0; border-bottom: 3px solid transparent; padding: .55rem .9rem; } nav a.ativo { border-bottom-color: #fff; }
  .conta { flex-direction: row; flex-wrap: wrap; gap: .3rem 1rem; padding: .5rem 1rem; align-items: center; } .conta small { margin: 0; }
  main { padding: 1rem 16px 4rem; }
  .duas, .duas.larga { grid-template-columns: 1fr; gap: 0; }
  .campos { grid-template-columns: 1fr; }
  .item { grid-template-columns: 1fr 3.4rem 3rem 5rem 1.4rem; }
  .grade .dia { min-height: 62px; } .chip { font-size: .62rem; padding: 0 3px; }
  section .rolagem { margin: 0 -1.2rem -1.1rem; }
}
