/* ============================================================
   Alicerce — identidade visual
   Cores tiradas da própria logo: azul-marinho profundo e dourado.
   ============================================================ */

:root {
  --paper: #F4F1E8;
  --surface: #FBF9F3;
  --surface-raised: #FFFFFF;
  --ink: #16233A;
  --ink-soft: #4E5A6E;
  --muted: #8C93A1;
  --line: #E2DDD0;
  --line-strong: #CFC8B6;

  --navy: #16233A;
  --navy-soft: #24344F;
  --gold: #C9A24D;
  --gold-soft: #F0E4C8;
  --gold-deep: #A8863A;

  --good: #14804A;
  --good-soft: #E3F2E9;
  --critical: #C0392B;
  --critical-soft: #FBE9E7;
  --obra: #D2691E;
  --obra-soft: #FBEADC;

  --series-1: #16233A; --series-2: #C9A24D; --series-3: #2E7D6B; --series-4: #B5533C;
  --series-5: #5B6B99; --series-6: #8A7433; --series-7: #7A5C8E; --series-8: #4A7A96;

  --chart-grid: #E7E2D5;
  --shadow: 0 1px 2px rgba(22,35,58,0.05), 0 8px 24px -12px rgba(22,35,58,0.18);
  --shadow-lg: 0 2px 4px rgba(22,35,58,0.06), 0 18px 40px -20px rgba(22,35,58,0.28);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #10192A;
    --surface: #16233A;
    --surface-raised: #1B2A41;
    --ink: #ECE6D9;
    --ink-soft: #AFB7C4;
    --muted: #7E8899;
    --line: #2A3B54;
    --line-strong: #3A4D69;

    --navy: #0E1626;
    --navy-soft: #1B2A41;
    --gold: #D9BC7A;
    --gold-soft: #332E20;
    --gold-deep: #E5CE9A;

    --good: #4FBE85;
    --good-soft: #16301F;
    --critical: #E8776B;
    --critical-soft: #33201D;
    --obra: #E89355;
    --obra-soft: #35251A;

    --series-1: #8FA8CE; --series-2: #D9BC7A; --series-3: #5FBFA8; --series-4: #E08A72;
    --series-5: #93A3CE; --series-6: #C4AC6A; --series-7: #B295C4; --series-8: #7FB3CC;

    --chart-grid: #24344F;
    --shadow: 0 1px 2px rgba(0,0,0,0.35), 0 8px 24px -12px rgba(0,0,0,0.6);
    --shadow-lg: 0 2px 4px rgba(0,0,0,0.4), 0 18px 40px -20px rgba(0,0,0,0.75);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { font-weight: 600; margin: 0; }
.num { font-variant-numeric: tabular-nums; }
a { color: var(--ink); }

.wrap { max-width: 1120px; margin: 0 auto; padding: 22px 18px 72px; }

/* ---------- Cabeçalho ---------- */

header.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 18px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 13px; text-decoration: none; color: inherit; }
.brand .logo {
  width: 52px; height: 52px; border-radius: 50%; object-fit: cover;
  transform: scale(1.08);
  border: 2px solid var(--gold); background: var(--surface-raised);
  box-shadow: var(--shadow); flex: none;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-size: 25px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); }
.tag { font-size: 11.5px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }

.who {
  display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--ink-soft);
  background: var(--surface-raised); border: 1px solid var(--line);
  padding: 7px 14px; border-radius: 100px; box-shadow: var(--shadow);
}
.who-name { font-weight: 600; color: var(--ink); }
.who a { color: var(--ink-soft); text-decoration: none; }
.who a:hover { color: var(--gold-deep); }
.who a.out { color: var(--critical); }

/* ---------- Navegação de meses ---------- */

.monthbar {
  display: flex; align-items: center; gap: 10px; margin-bottom: 16px;
  flex-wrap: wrap;
}
.mnav {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 9px; text-decoration: none;
  background: var(--surface-raised); border: 1px solid var(--line);
  color: var(--ink-soft); font-size: 20px; line-height: 1; box-shadow: var(--shadow);
}
.mnav:hover { border-color: var(--gold); color: var(--gold-deep); }
.mlabel {
  font-size: 16px; font-weight: 600;
  min-width: 168px; text-align: center;
}
/* Só a primeira letra do mês em maiúscula — "capitalize" deixaria "Setembro De 2026". */
.mlabel::first-letter { text-transform: uppercase; }
.mtoday { font-size: 12.5px; color: var(--gold-deep); text-decoration: none; border-bottom: 1px dotted var(--gold); }

/* ---------- Cartões de números ---------- */

.stats {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 12px; margin-bottom: 22px;
}
@media (max-width: 1000px) { .stats { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px)  { .stats { grid-template-columns: repeat(2, 1fr); } }

.stat {
  background: var(--surface-raised); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
}
.stat .label {
  font-size: 10.5px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.07em; margin-bottom: 6px; font-weight: 600;
}
.stat .value { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.stat .sub { font-size: 11px; color: var(--muted); margin-top: 4px; }
.stat .value.good { color: var(--good); }
.stat .value.critical { color: var(--critical); }
.stat .value.obra { color: var(--obra); }

.stat.highlight {
  background: var(--navy); border-color: var(--navy);
  box-shadow: var(--shadow-lg);
}
.stat.highlight .label { color: var(--gold); }
.stat.highlight .value, .stat.highlight .value.obra { color: #FFFFFF; }
.stat.highlight .sub { color: rgba(255,255,255,0.55); }
@media (max-width: 640px) { .stat.highlight { grid-column: 1 / -1; } }

/* ---------- Abas ---------- */

nav.tabs {
  display: flex; gap: 4px; margin-bottom: 20px;
  border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none;
}
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs a {
  font-weight: 600; font-size: 14.5px; text-decoration: none; white-space: nowrap;
  padding: 11px 14px; margin-bottom: -1px; color: var(--ink-soft);
  border-bottom: 2.5px solid transparent;
}
nav.tabs a:hover { color: var(--ink); }
nav.tabs a.active { color: var(--ink); border-bottom-color: var(--gold); }

/* ---------- Estrutura de conteúdo ---------- */

.grid-2 { display: grid; grid-template-columns: 340px 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--surface-raised); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card h3 {
  font-size: 15px; font-weight: 600; margin-bottom: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.card h3 .side { font-size: 12.5px; font-weight: 500; color: var(--muted); }

/* Faixa de destaque do total da obra */
.hero {
  background: var(--navy); color: #FFFFFF; border-radius: var(--radius);
  padding: 24px 26px; box-shadow: var(--shadow-lg); margin-bottom: 16px;
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
}
.hero .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--gold); font-weight: 600; }
.hero .big { font-size: 40px; font-weight: 700; line-height: 1.1; margin-top: 6px; letter-spacing: -0.02em; }
@media (max-width: 560px) { .hero .big { font-size: 30px; } }
.hero .aside { text-align: right; font-size: 13px; color: rgba(255,255,255,0.72); }
.hero .aside b { display: block; font-size: 19px; color: #FFFFFF; font-weight: 700; }

/* ---------- Formulários ---------- */

form .field { margin-bottom: 12px; }
form label { display: block; font-size: 12px; color: var(--ink-soft); margin-bottom: 5px; font-weight: 500; }
form .hint { font-size: 11.5px; color: var(--muted); margin-top: 6px; line-height: 1.45; }
form input, form select, form textarea {
  width: 100%; font: inherit; font-size: 15px; padding: 9px 11px;
  border: 1px solid var(--line-strong); border-radius: 9px;
  background: var(--surface); color: var(--ink);
}
form input:focus, form select:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--gold); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

button.primary, .btn {
  font: inherit; font-weight: 600; font-size: 14.5px;
  background: var(--navy); color: #FFFFFF; border: none;
  padding: 11px 18px; border-radius: 9px; cursor: pointer;
  width: 100%; margin-top: 6px; text-align: center;
  text-decoration: none; display: inline-block;
}
button.primary:hover, .btn:hover { background: var(--navy-soft); }
.btn.ghost {
  background: var(--surface); color: var(--ink-soft);
  border: 1px solid var(--line-strong);
}
.btn.ghost:hover { background: var(--surface); border-color: var(--gold); color: var(--gold-deep); }
.btn-row { display: flex; gap: 10px; }
.btn-row > * { flex: 1; }

/* ---------- Tabelas ---------- */

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); font-weight: 600; padding: 0 8px 9px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td.num, th.num { text-align: right; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface); }
.empty { color: var(--muted); font-size: 13.5px; padding: 22px 4px; text-align: center; }
.tbl-wrap { overflow-x: auto; }
.desc { font-weight: 500; }
.actions { white-space: nowrap; text-align: right; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px;
  padding: 3px 9px; border-radius: 100px; background: var(--surface);
  border: 1px solid var(--line); white-space: nowrap; color: var(--ink-soft);
}
.chip.parc { background: var(--gold-soft); border-color: var(--gold); color: var(--gold-deep); font-weight: 600; }
.chip.obra { background: var(--obra-soft); border-color: var(--obra); color: var(--obra); }

.del, .edit {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 14px; line-height: 1; padding: 4px 6px; border-radius: 6px;
  text-decoration: none; display: inline-block;
}
.del:hover { color: var(--critical); background: var(--critical-soft); }
.edit:hover { color: var(--gold-deep); background: var(--gold-soft); }

/* ---------- Cartões de crédito ---------- */

.cardlist { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 6px; }
.cardpill {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 11px; padding: 10px 13px; font-size: 13px;
  text-decoration: none; color: inherit; min-width: 128px;
}
.cardpill:hover { border-color: var(--gold); }
.cardpill.on { border-color: var(--gold); background: var(--gold-soft); }
.cardpill .nm { font-weight: 600; }
.cardpill .amt { color: var(--ink-soft); font-size: 15px; font-weight: 700; }
.cardpill .mini { color: var(--muted); font-size: 11px; }

/* ---------- Gráfico de barras ---------- */

.bars .bar-row {
  display: grid; grid-template-columns: 132px 1fr 118px;
  align-items: center; gap: 10px; padding: 6px 0;
}
@media (max-width: 480px) { .bars .bar-row { grid-template-columns: 92px 1fr 104px; } }
.bars .bar-name { font-size: 12.5px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bars .bar-track { position: relative; height: 15px; background: var(--chart-grid); border-radius: 5px; overflow: hidden; }
.bars .bar-fill { position: absolute; left: 0; top: 0; height: 100%; border-radius: 5px; min-width: 3px; }
.bars .bar-val { font-size: 12.5px; text-align: right; white-space: nowrap; }
.bars .bar-share { color: var(--muted); font-size: 11px; margin-left: 6px; }
.bar-s1 { background: var(--series-1); } .bar-s2 { background: var(--series-2); }
.bar-s3 { background: var(--series-3); } .bar-s4 { background: var(--series-4); }
.bar-s5 { background: var(--series-5); } .bar-s6 { background: var(--series-6); }
.bar-s7 { background: var(--series-7); } .bar-s8 { background: var(--series-8); }

/* ---------- Evolução mês a mês ---------- */

.trend { display: flex; align-items: flex-end; gap: 10px; height: 168px; padding-top: 8px; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.trend-pair { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 3px; width: 100%; }
.trend-bar { width: 44%; max-width: 22px; border-radius: 4px 4px 0 0; min-height: 0; }
.trend-bar.in { background: var(--good); }
.trend-bar.out { background: var(--critical); }
.trend-label { font-size: 11px; color: var(--muted); margin-top: 7px; white-space: nowrap; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-soft); margin-top: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.dot.in { background: var(--good); } .dot.out { background: var(--critical); }

/* ---------- Orçamento da obra ---------- */

.progress {
  position: relative; height: 8px; background: var(--chart-grid);
  border-radius: 5px; overflow: hidden; margin-top: 8px;
}
.progress-fill { height: 100%; border-radius: 5px; background: var(--good); }
.progress.warn .progress-fill { background: var(--gold); }
.progress.over .progress-fill { background: var(--critical); }

.stagehead {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin: 22px 0 8px; flex-wrap: wrap;
}
.stagehead:first-child { margin-top: 0; }
.stagehead h3 { font-size: 14.5px; }
.stagehead .totals { display: flex; align-items: baseline; gap: 8px; font-size: 13px; }
.stagehead .totals b { font-size: 15px; }
.stage-block { border-top: 1px solid var(--line); padding-top: 4px; }
.stage-block:first-of-type { border-top: none; }

.budget-row {
  display: grid; grid-template-columns: 1fr 118px 118px 70px;
  gap: 10px; align-items: center; padding: 11px 0;
  border-bottom: 1px solid var(--line); font-size: 13.5px;
}
.budget-row:last-child { border-bottom: none; }
.budget-row .bname { font-weight: 500; }
.budget-row .over { color: var(--critical); font-weight: 600; }
.budget-row .left { color: var(--good); }
@media (max-width: 620px) {
  .budget-row { grid-template-columns: 1fr 100px; row-gap: 4px; }
  .budget-row .bname { grid-column: 1 / -1; }
}

/* ---------- Avisos ---------- */

.flash {
  background: var(--good-soft); border: 1px solid var(--good); color: var(--ink);
  font-size: 13.5px; padding: 11px 15px; border-radius: 10px; margin-bottom: 18px;
}
.flash.error { background: var(--critical-soft); border-color: var(--critical); }

/* ---------- Login e configuração ---------- */

.login-wrap { max-width: 400px; margin: 60px auto; }
.login-wrap .card { padding: 26px 26px 28px; box-shadow: var(--shadow-lg); }
.login-logo {
  display: block; width: 100%; max-width: 300px; margin: 0 auto 20px;
  border-radius: 12px; box-shadow: var(--shadow);
}
.login-wrap h1 { text-align: center; margin-bottom: 3px; font-size: 24px; }
.login-wrap .tag {
  display: block; text-align: center; color: var(--muted);
  font-size: 11.5px; text-transform: uppercase; margin-bottom: 22px; letter-spacing: 0.08em;
}
