:root {
  --bg: #f4f6f5; --card: #ffffff; --ink: #1c2a26; --muted: #62736d; --line: #dfe6e3;
  --brand: #0f5c4d; --brand-2: #0b4439; --accent: #c9822b;
  --ok: #1f7a4d; --ok-bg: #e3f4ea; --warn: #8a5a00; --warn-bg: #fdf0d3;
  --bad: #a3322b; --bad-bg: #fbe5e3; --info: #1d5f8c; --info-bg: #e1eef7; --gray-bg: #e8ecea;
  --radius: 10px; --shadow: 0 1px 2px rgba(20,40,35,.06), 0 4px 14px rgba(20,40,35,.05);
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); line-height: 1.45; }
a { color: var(--brand); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }

/* layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--brand-2); color: #e8f3ef; padding: 1rem .75rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { font-weight: 700; font-size: 1.1rem; padding: .25rem .6rem 1rem; letter-spacing: .01em; }
.brand small { display: block; font-weight: 400; font-size: .75rem; opacity: .7; }
.side nav a { display: flex; align-items: center; justify-content: space-between; color: #d3e6df; text-decoration: none; padding: .5rem .65rem; border-radius: 8px; margin-bottom: 2px; }
.side nav a:hover { background: rgba(255,255,255,.08); }
.side nav a.ativo { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }
.side .sep { margin: .8rem .65rem .3rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; opacity: .55; }
.side .user { margin-top: 1.2rem; padding: .75rem .65rem 0; border-top: 1px solid rgba(255,255,255,.14); font-size: .85rem; }
.side .user form { margin-top: .5rem; }
.contador { background: var(--accent); color: #fff; border-radius: 99px; font-size: .72rem; padding: 0 .5rem; font-weight: 700; }
main { padding: 1.5rem 1.75rem 3rem; max-width: 1280px; width: 100%; }
.topo { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.acoes { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* cards e grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); }
.kpi .rot { color: var(--muted); font-size: .8rem; }
.kpi .val { font-size: 1.45rem; font-weight: 700; margin-top: .15rem; }
.kpi .sub { color: var(--muted); font-size: .8rem; }
.kpi.alerta .val { color: var(--bad); }
.kpi a { text-decoration: none; color: inherit; display: block; }

/* tabelas */
.tabela-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: .55rem .6rem; border-bottom: 2px solid var(--line); white-space: nowrap; }
td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:hover td { background: #f8faf9; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.vazio { text-align: center; color: var(--muted); padding: 2rem 1rem; }

/* formulários */
label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: .2rem; color: #33463f; }
input, select, textarea { width: 100%; padding: .55rem .65rem; border: 1px solid #c5d0cb; border-radius: 8px; font: inherit; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid #7fc2b0; border-color: var(--brand); }
textarea { min-height: 90px; resize: vertical; }
.campo { margin-bottom: .85rem; }
.campo small { color: var(--muted); font-size: .78rem; }
.linha { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.check input { width: auto; }
.filtros { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; margin-bottom: 1rem; }
.filtros .campo { margin: 0; min-width: 130px; flex: 1 1 130px; }
.filtros .campo.grande { flex: 2 1 220px; }

/* botões */
.btn { display: inline-block; padding: .5rem .95rem; border-radius: 8px; border: 1px solid var(--brand); background: var(--brand); color: #fff; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center; }
.btn:hover { background: var(--brand-2); }
.btn.sec { background: #fff; color: var(--brand); }
.btn.sec:hover { background: #eef6f3; }
.btn.perigo { background: #fff; color: var(--bad); border-color: var(--bad); }
.btn.perigo:hover { background: var(--bad-bg); }
.btn.peq { padding: .3rem .65rem; font-size: .85rem; }
.btn.bloco { display: block; width: 100%; }
.side .btn.sec { background: transparent; color: #e8f3ef; border-color: rgba(255,255,255,.35); width: 100%; }

/* avisos e selos */
.flash { padding: .7rem .95rem; border-radius: 8px; margin-bottom: .7rem; border: 1px solid; font-size: .93rem; }
.flash.ok { background: var(--ok-bg); border-color: #b4dcc4; color: #14532f; }
.flash.erro { background: var(--bad-bg); border-color: #efbab5; color: #7d221c; }
.flash.info { background: var(--info-bg); border-color: #b6d4e8; color: #144a6e; }
.aviso { background: var(--warn-bg); border: 1px solid #ecd49a; color: #5e3d00; padding: .7rem .95rem; border-radius: 8px; font-size: .9rem; margin-bottom: 1rem; }
.badge { display: inline-block; padding: .12rem .55rem; border-radius: 99px; font-size: .76rem; font-weight: 700; white-space: nowrap; background: var(--gray-bg); color: #44524d; }
.b-disponivel, .b-ativo, .b-paga, .b-quitado, .b-aprovada, .b-convertida { background: var(--ok-bg); color: var(--ok); }
.b-reservado, .b-ativa, .b-liberada { background: var(--info-bg); color: var(--info); }
.b-aberta, .b-pendente { background: var(--warn-bg); color: var(--warn); }
.b-vendido, .b-cancelada, .b-cancelado, .b-recusada { background: var(--bad-bg); color: var(--bad); }
.b-bloqueado, .b-expirada { background: var(--gray-bg); color: #44524d; }
.b-atraso { background: var(--bad); color: #fff; }

/* espelho de vendas */
.legenda { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; align-items: center; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: .3rem .8rem; font: inherit; font-size: .85rem; cursor: pointer; display: inline-flex; gap: .4rem; align-items: center; }
.chip.on { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); font-weight: 700; }
.dot { width: .75rem; height: .75rem; border-radius: 3px; display: inline-block; }
.quadra { margin-bottom: 1.1rem; }
.quadra h3 { display: flex; gap: .6rem; align-items: baseline; }
.lotes { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: .45rem; }
.lote { display: block; border-radius: 8px; padding: .45rem .5rem; text-decoration: none; color: var(--ink); border: 1px solid transparent; border-left-width: 5px; min-height: 62px; }
.lote b { display: block; font-size: 1.05rem; }
.lote small { display: block; font-size: .72rem; opacity: .85; }
.lote:hover { filter: brightness(.96); box-shadow: var(--shadow); }
.lote.s-disponivel { background: var(--ok-bg); border-color: #b4dcc4; border-left-color: var(--ok); }
.lote.s-reservado { background: var(--warn-bg); border-color: #ecd49a; border-left-color: var(--accent); }
.lote.s-vendido { background: var(--bad-bg); border-color: #efbab5; border-left-color: var(--bad); }
.lote.s-bloqueado { background: repeating-linear-gradient(45deg, #eceff0, #eceff0 6px, #e2e6e8 6px, #e2e6e8 12px); border-color: #d0d6d9; border-left-color: #72808a; }
.dot.s-disponivel { background: var(--ok); } .dot.s-reservado { background: var(--accent); } .dot.s-vendido { background: var(--bad); } .dot.s-bloqueado { background: #72808a; }
.barra { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--gray-bg); min-width: 120px; }
.barra span { display: block; height: 100%; }

dl.det { display: grid; grid-template-columns: 170px 1fr; gap: .4rem .9rem; margin: 0; }
dl.det dt { color: var(--muted); font-size: .85rem; }
dl.det dd { margin: 0; }
.login-box { max-width: 380px; margin: 9vh auto; }
.login-box .card { padding: 1.6rem; }
.simul { background: #f0f7f4; border: 1px dashed #9cc7b9; border-radius: 8px; padding: .8rem 1rem; }
.simul .linha { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.simul b { font-size: 1.1rem; display: block; }
pre.contrato { white-space: pre-wrap; font-family: Georgia, "Times New Roman", serif; font-size: 1rem; line-height: 1.6; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: .6rem; }
  .side nav { display: flex; gap: .3rem; overflow-x: auto; padding-bottom: .3rem; }
  .side nav a { white-space: nowrap; }
  .side .sep, .side .user { display: none; }
  .side .user-mini { display: flex !important; }
  main { padding: 1rem .9rem 2.5rem; }
  .g2, .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  dl.det { grid-template-columns: 1fr; }
}
@media (max-width: 520px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }
.user-mini { display: none; justify-content: space-between; align-items: center; padding: .4rem .3rem 0; font-size: .85rem; }
.user-mini form { margin: 0; }
.user-mini .btn { width: auto !important; padding: .2rem .6rem; }

@media print {
  .side, .acoes, .no-print, .flash, .aviso { display: none !important; }
  .shell { display: block; } main { padding: 0; max-width: none; }
  body { background: #fff; } .card { box-shadow: none; border: none; padding: 0; }
  .carne-parcela { break-inside: avoid; }
}
.carne-parcela { border: 1px dashed #777; border-radius: 6px; padding: .7rem 1rem; margin-bottom: .7rem; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .4rem 1rem; }
.carne-parcela div small { display: block; color: var(--muted); font-size: .72rem; text-transform: uppercase; }
