@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #0d0d0f;
  --bg-2: #141417;
  --card: #1a1a1e;
  --card-2: #222227;
  --line: #2c2c33;
  --text: #f2f2f4;
  --muted: #9a9aa5;
  --red: #e0202a;
  --red-2: #ff3b44;
  --red-soft: rgba(224, 32, 42, .14);
  --green: #2ecc71;
  --green-soft: rgba(46, 204, 113, .14);
  --yellow: #f5c542;
  --orange: #ff8a3d;
  --orange-soft: rgba(255, 138, 61, .16);
  --yellow-soft: rgba(245, 197, 66, .14);
  --blue: #4da3ff;
  --blue-soft: rgba(77, 163, 255, .14);
  --marca: var(--red);
  --marca-soft: var(--red-soft);
  --radius: 14px;
  --serif: 'Cinzel', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }

/* ---------- marca ---------- */
.brand { display: inline-flex; flex-direction: column; align-items: center; text-decoration: none; line-height: 1; }
.brand b { font-family: var(--serif); color: var(--marca); font-size: 26px; letter-spacing: 1px; }
.brand small { display: flex; align-items: center; gap: 6px; font-size: 9px; letter-spacing: 4px; color: #ddd; margin-top: 3px; }
.brand small::before, .brand small::after { content: ""; width: 16px; height: 1px; background: var(--marca); }
.brand-lg b { font-size: 46px; }
.brand-lg small { font-size: 13px; letter-spacing: 7px; }
.brand-lg small::before, .brand-lg small::after { width: 40px; }

/* ---------- comuns ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--card-2); border-radius: 10px;
  padding: 9px 14px; cursor: pointer; text-decoration: none; font-weight: 600; font-size: 14px;
  transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(1.15); }
.btn-red { background: var(--marca); border-color: var(--marca); color: #fff; }
.btn-green { background: #1fa855; border-color: #1fa855; color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn-xs { padding: 3px 8px; font-size: 12px; border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: default; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card h3 { font-family: var(--serif); font-size: 17px; margin: 0 0 12px; letter-spacing: .5px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card h3 small { font-family: var(--sans); font-size: 12px; color: var(--muted); font-weight: 400; letter-spacing: 0; }
.muted { color: var(--muted); }
.pos { color: var(--green); }
.neg { color: var(--red-2); }
.warn { color: var(--yellow); }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.tag-green { background: var(--green-soft); color: var(--green); }
.tag-red { background: var(--red-soft); color: var(--red-2); }
.tag-yellow { background: var(--yellow-soft); color: var(--yellow); }
.tag-blue { background: var(--blue-soft); color: var(--blue); }
.tag-gray { background: #2a2a30; color: var(--muted); }

.grid { display: grid; gap: 14px; }
.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)); }
@media (max-width: 900px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .g2, .g3 { grid-template-columns: 1fr; } }

label.f { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.in, select.in, textarea.in {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; color: var(--text); width: 100%;
}
.in:focus { outline: 2px solid var(--marca); outline-offset: -1px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

/* ---------- KPI ---------- */
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.kpi .lbl { font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.kpi .val { font-size: 24px; font-weight: 700; margin: 4px 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi.hl { border-color: rgba(224, 32, 42, .55); }
.kpi.hl-green { border-color: rgba(46, 204, 113, .45); }

/* ---------- tabela ---------- */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 860px; }
.tbl th, .tbl td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th { background: var(--card-2); color: var(--muted); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; font-weight: 600; position: sticky; top: 0; z-index: 1; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tbody tr:hover { background: rgba(255, 255, 255, .03); }
.tbl td.desc { white-space: normal; min-width: 150px; max-width: 240px; }
.tbl td.cat { white-space: normal; max-width: 150px; line-height: 1.3; }
.tbl tr.r-atrasado { background: rgba(224, 32, 42, .13); }
.tbl tr.r-atrasado td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.tbl tr.r-futuro { color: #b9b9c3; }
.tbl tr.r-futuro td:first-child { box-shadow: inset 3px 0 0 #50505a; }
.tbl tr.r-pago td:first-child { box-shadow: inset 3px 0 0 var(--blue); }
.tbl tr.r-hoje { background: rgba(245, 197, 66, .08); }
.tbl tr.r-hoje td:first-child { box-shadow: inset 3px 0 0 var(--yellow); }
.tbl tr.divider td { background: var(--bg-2); color: var(--yellow); font-size: 12px; font-weight: 600; padding: 6px 10px; letter-spacing: .5px; }
.cat-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* ---------- barras ---------- */
.bar { height: 8px; background: #2a2a30; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; }
.lines > div { padding: 9px 0; border-bottom: 1px solid var(--line); }
.lines > div:last-child { border-bottom: 0; }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .65); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 16px; width: 100%; max-width: 560px; padding: 20px; }
.modal-x { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line); background: var(--card-2); color: var(--text); font-size: 15px; cursor: pointer; z-index: 2; }
.modal-x:hover { border-color: var(--red); color: var(--red); }
.modal h2 { padding-right: 40px; }
.modal h2 { font-family: var(--serif); font-size: 20px; margin: 0 0 16px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; flex-wrap: wrap; max-width: 100%; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--muted); }
.seg button.on { background: var(--card-2); color: var(--text); }
.seg button.on.in-e { background: var(--green-soft); color: var(--green); }
.seg button.on.in-s { background: var(--red-soft); color: var(--red-2); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1fa855; color: #fff; padding: 10px 18px; border-radius: 10px; font-weight: 600; z-index: 60; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); }

.alert { border-radius: 12px; padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.alert-red { background: var(--red-soft); border: 1px solid rgba(224, 32, 42, .4); }
.alert-yellow { background: var(--yellow-soft); border: 1px solid rgba(245, 197, 66, .35); }
.alert-blue { background: var(--blue-soft); border: 1px solid rgba(77, 163, 255, .35); }
.alert-green { background: var(--green-soft); border: 1px solid rgba(46, 204, 113, .35); }

/* ---------- app (painel/financeiro) ---------- */
.app { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--bg-2); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.side .brand { margin: 4px 0 6px; }
.side .area { text-align: center; font-size: 10px; letter-spacing: 2.5px; color: var(--marca); font-weight: 700; margin-bottom: 16px; }
.side a.nav { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 9px; text-decoration: none; color: var(--muted); font-weight: 500; }
.side a.nav:hover { background: var(--card); color: var(--text); }
.side a.nav.on { background: var(--marca-soft); color: var(--text); }
.side a.nav .ic { width: 20px; text-align: center; }
.side .bottom { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.main { padding: 22px 26px 60px; min-width: 0; }
.main h1 { font-family: var(--serif); font-size: 26px; margin: 0; letter-spacing: .5px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .muted { font-size: 13px; }
.mtabs { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; }
.mtabs button { border: 1px solid var(--line); background: var(--card); color: var(--muted); border-radius: 8px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.mtabs button.on { background: var(--marca); border-color: var(--marca); color: #fff; }
.topbar-m { display: none; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 250px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .topbar-m { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--bg-2); position: sticky; top: 0; z-index: 30; }
  .main { padding: 18px 16px 60px; }
}

/* ---------- login ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: radial-gradient(ellipse at top, #3a0c10 0%, var(--bg) 60%); }
.login .box { width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 28px 22px; text-align: center; }
.login .box h2 { font-family: var(--serif); font-size: 18px; margin: 18px 0 4px; }

/* ---------- gráfico ---------- */
.chart svg { width: 100%; height: auto; display: block; }
.chart .ax { fill: var(--muted); font-size: 11px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

@media (max-width: 620px) {
  .kpi { padding: 12px; }
  .kpi .val { font-size: 17px !important; }
  .kpi .lbl { font-size: 10px; letter-spacing: .8px; }
  .seg { max-width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .seg button { white-space: nowrap; padding: 6px 10px; }
  .card { padding: 14px; }
  .main h1 { font-size: 22px; }
  .conta-row { flex-wrap: wrap !important; }
  .conta-row > div:nth-child(2) { flex-basis: calc(100% - 64px) !important; }
}

/* linha de custo do orçamento do vendedor */
.linha-custo { display: grid; grid-template-columns: 160px minmax(0, 1fr) 100px 100px 34px; gap: 6px; margin-bottom: 6px; align-items: center; }
#custos .linha-custo:has([data-cvv]) { grid-template-columns: minmax(0, 1fr) 76px 92px 92px 34px; }
.linha-custo:not(:has([data-cvv])) { grid-template-columns: 160px minmax(0, 1fr) 100px 34px; }
.linha-custo.muted { grid-template-columns: minmax(0, 1fr) 76px 92px 92px 34px; }
@media (max-width: 640px) {
  .linha-custo, .linha-custo:not(:has([data-cvv])) { grid-template-columns: minmax(0, 1fr) 90px 34px; } .linha-custo [data-cd] { grid-column: 1 / -1; order: -1; }
  #custos .linha-custo:has([data-cvv]) { grid-template-columns: 56px minmax(0, 1fr) minmax(0, 1fr) 34px; } #custos .linha-custo [data-ct] { grid-column: 1 / -1; }
  .linha-custo.muted { display: none; }
}

/* custos fixos (aluguel, água, luz, internet, funcionários) em laranja */
.seg button.on.in-f { background: var(--orange-soft); color: var(--orange); }
.btn-orange { background: var(--orange); border-color: var(--orange); color: #1a1205; }
.btn-orange:hover { filter: brightness(1.08); }
.tbl tr.r-fixo td:first-child { box-shadow: inset 3px 0 0 var(--orange); }
.tbl td.fx { color: var(--orange); }
.tag-orange { background: var(--orange-soft); color: var(--orange); }
.g4.linha-pedra { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) 78px minmax(0, .8fr) minmax(0, 1.1fr); gap: 8px; }
@media (max-width: 900px) { .g4.linha-pedra { grid-template-columns: repeat(2, minmax(0, 1fr)); } .linha-pedra + .linha-pedra { border-top: 1px solid var(--line); padding-top: 8px; } }
/* campo de pedra: é texto livre (as sugestões aparecem ao digitar), sem a setinha que parece lista fechada */
input[data-pn]::-webkit-calendar-picker-indicator, input[data-pl]::-webkit-calendar-picker-indicator, input[data-ct]::-webkit-calendar-picker-indicator { display: none !important; }

/* Obras: a tabela cabe na tela do notebook sem rolar para o lado (data e vendedor embaixo do cliente, % embaixo do lucro) */
table.tbl.tbl-obras { min-width: 0; font-size: 13px; }
.tbl-obras th, .tbl-obras td { padding: 9px 8px; }
.tbl-obras td.cli { white-space: normal; min-width: 130px; max-width: 200px; }
.tbl-obras td.desc { min-width: 140px; max-width: 220px; }
@media (max-width: 900px) { table.tbl.tbl-obras { min-width: 760px; } }
/* Lançamentos: cabe na tela sem rolar para o lado (descrição e categoria embaixo do nome, botões embaixo da situação) */
table.tbl.tbl-lanc { min-width: 0; font-size: 13px; }
.tbl-lanc th, .tbl-lanc td { padding: 4px 8px; }
/* linhas baixas (pedido do Saulo 28/10): cliente, descrição e categoria na mesma linha */
.tbl-lanc td.quem { white-space: normal; min-width: 180px; line-height: 1.25; }
.tbl-lanc td.acoes .btn-xs { padding-top: 2px; padding-bottom: 2px; }
.tbl-lanc td.acoes { white-space: nowrap; }
@media (max-width: 900px) { table.tbl.tbl-lanc { min-width: 720px; } }
/* Resumo do mês no celular: gráfico e "Para onde vai o dinheiro" cabem na tela */
@media (max-width: 620px) { .res-g2 { grid-template-columns: minmax(0, 1fr); } }
