*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --verde:    #1f3d25;
  --dourado:  #9d7c38;
  --fundo:    #f6f6f3;
  --positivo: #1D9E75;
  --negativo: #D85A30;
  --acao:     #185FA5;
  --texto:    #1a1a1a;
  --suave:    #666;
  --borda:    #e0e0da;
  --branco:   #ffffff;
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--fundo);
  color: var(--texto);
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: 72px;
  min-height: 100vh;
}

/* ── HEADER ── */
.header {
  background: var(--verde);
  color: #fff;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-logo {
  font-size: 0.7rem;
  color: var(--dourado);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
}
.header h1 { font-size: 1.05rem; font-weight: 600; text-align: center; }
.header > :last-child { justify-self: end; }
.header-back {
  color: var(--dourado);
  font-size: 1.4rem;
  text-decoration: none;
  line-height: 1;
  padding: 4px;
}

/* ── METRICS ── */
.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 12px;
}
.metric-card {
  background: var(--branco);
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
}
.metric-card .label {
  font-size: 0.62rem;
  color: var(--suave);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 5px;
}
.metric-card .valor {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
  word-break: break-all;
}

/* ── SECTION ── */
.section { padding: 0 12px 12px; }
.section-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--suave);
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: 12px 2px 8px;
}

/* ── CARDS ── */
.card {
  background: var(--branco);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.card:active { opacity: .88; }
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 4px;
}
.card-cliente { font-weight: 600; font-size: .95rem; }
.card-valor   { font-size: .9rem; font-weight: 700; color: var(--verde); white-space: nowrap; }
.card-tag {
  display: inline-block;
  font-size: .68rem;
  background: var(--fundo);
  color: var(--suave);
  padding: 2px 7px;
  border-radius: 4px;
  margin-bottom: 6px;
}
.card-fase { font-size: .82rem; color: var(--suave); margin-bottom: 8px; }

/* ── PROGRESS ── */
.progress-bar {
  height: 5px;
  background: var(--fundo);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--positivo);
  border-radius: 3px;
  transition: width .3s;
}

/* ── COMPROMISSO ── */
.comp-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: var(--branco);
  border-radius: 10px;
  padding: 11px 14px;
  margin-bottom: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.comp-info .desc  { font-size: .88rem; font-weight: 500; }
.comp-info .meta  { font-size: .73rem; color: var(--suave); margin-top: 2px; }
.comp-valor       { font-size: .88rem; font-weight: 700; color: var(--negativo); white-space: nowrap; }
.comp-item.pago   { opacity: .55; }
.comp-item.pago .comp-valor { color: var(--positivo); text-decoration: line-through; }

/* ── FAB ── */
.fab {
  position: fixed;
  bottom: 82px;
  right: 16px;
  background: var(--dourado);
  color: #fff;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  line-height: 1;
  text-decoration: none;
  box-shadow: 0 3px 12px rgba(157,124,56,.45);
  z-index: 40;
}

/* ── BOTTOM NAV ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--verde);
  display: flex;
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(0,0,0,.18);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 0 8px;
  text-decoration: none;
  color: rgba(255,255,255,.55);
  font-size: .62rem;
  gap: 3px;
  -webkit-tap-highlight-color: transparent;
}
.nav-item.active, .nav-item:active { color: var(--dourado); }
.nav-icon { font-size: 1.25rem; }

/* ── FORM ── */
.form-wrap { padding: 12px; }
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--suave);
  margin-bottom: 5px;
}
.form-control {
  width: 100%;
  padding: 12px;
  border: 1.5px solid var(--borda);
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  background: var(--branco);
  color: var(--texto);
  outline: none;
  appearance: none;
  transition: border-color .2s;
}
.form-control:focus { border-color: var(--verde); }
select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23666' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ── TEMPLATE PICKER ── */
.template-options { display: flex; flex-direction: column; gap: 8px; }
.template-opt {
  border: 2px solid var(--borda);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  -webkit-tap-highlight-color: transparent;
}
.template-opt.sel { border-color: var(--verde); background: #eff5f0; }
.template-opt input[type="radio"] { display: none; }
.template-name { font-weight: 600; font-size: .9rem; margin-bottom: 2px; }
.template-desc { font-size: .75rem; color: var(--suave); }
.template-fases {
  display: none;
  flex-direction: column;
  gap: 5px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--borda);
}
.template-opt.sel .template-fases { display: flex; }
.fase-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: .78rem;
  color: var(--suave);
}
.fase-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.fase-dot.receber { background: var(--positivo); }
.fase-dot.pagar   { background: var(--negativo); }
.fase-dot.acao    { background: #ccc; }
.fase-val { margin-left: auto; font-weight: 600; color: var(--texto); }

/* ── BUTTONS ── */
.btn {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  transition: opacity .15s;
}
.btn:active { opacity: .82; }
.btn-primary { background: var(--verde); color: #fff; }
.btn-success { background: var(--positivo); color: #fff; }
.btn-danger  { background: var(--negativo); color: #fff; }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--borda);
  color: var(--texto);
}
.btn-sm {
  display: inline-block;
  width: auto;
  padding: 7px 14px;
  font-size: .82rem;
  border-radius: 8px;
}

/* ── FILTERS ── */
.filtros {
  display: flex;
  gap: 6px;
  padding: 4px 12px 12px;
  overflow-x: auto;
}
.filtro {
  flex-shrink: 0;
  padding: 7px 16px;
  border: 1.5px solid var(--borda);
  border-radius: 20px;
  background: var(--branco);
  font-size: .8rem;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: all .15s;
}
.filtro.ativo { background: var(--verde); color: #fff; border-color: var(--verde); }

/* ── DESPESA ITEM ── */
.desp-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: var(--branco);
  border-radius: 10px;
  padding: 11px 14px;
  margin-bottom: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.desp-info .desc { font-size: .88rem; font-weight: 500; }
.desp-info .cat  { font-size: .72rem; color: var(--suave); margin-top: 2px; }
.desp-val        { font-size: .88rem; font-weight: 700; color: var(--negativo); white-space: nowrap; }

/* ── CAT TOTAIS ── */
.cat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.cat-card {
  background: var(--branco);
  border-radius: 10px;
  padding: 10px 12px;
}
.cat-card .cat-nome  { font-size: .68rem; color: var(--suave); margin-bottom: 3px; }
.cat-card .cat-valor { font-size: .95rem; font-weight: 700; color: var(--negativo); }

/* ── RESUMO ── */
.totais-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 12px;
  margin-bottom: 4px;
}
.total-card {
  background: var(--branco);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
}
.total-card.full { grid-column: 1 / -1; }
.total-card .t-label { font-size: .68rem; color: var(--suave); margin-bottom: 4px; }
.total-card .t-valor { font-size: 1.25rem; font-weight: 700; }

/* ── FASE ITEM ── */
.fase-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  background: var(--branco);
  border-radius: 12px;
  margin-bottom: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.fase-item.concluido { opacity: .5; }
.fase-check {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--borda);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
}
.fase-check.ok    { background: var(--positivo); border-color: var(--positivo); color: #fff; }
.fase-check.rec   { border-color: var(--positivo); }
.fase-check.pag   { border-color: var(--negativo); }
.fase-body        { flex: 1; min-width: 0; }
.fase-nome        { font-size: .9rem; font-weight: 500; }
.fase-tipo {
  font-size: .68rem;
  margin-top: 2px;
}
.fase-tipo.receber { color: var(--positivo); }
.fase-tipo.pagar   { color: var(--negativo); }
.fase-tipo.acao    { color: var(--suave); }
.fase-valor-display { font-size: .82rem; font-weight: 600; color: var(--verde); }

/* ── CONCLUIR FORM ── */
.concluir-form {
  background: var(--fundo);
  border-radius: 10px;
  padding: 10px;
  margin-top: 8px;
  display: none;
}
.concluir-form.open { display: block; }
.concluir-form input {
  width: 100%;
  padding: 9px 11px;
  border: 1.5px solid var(--borda);
  border-radius: 8px;
  font-size: .95rem;
  font-family: inherit;
  margin-bottom: 8px;
}

/* ── MES SELECTOR ── */
.mes-wrap {
  padding: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.mes-wrap input[type="month"] { flex: 1; }

/* ── ESTADO ── */
.positivo { color: var(--positivo); }
.negativo { color: var(--negativo); }
.neutro   { color: var(--acao); }

/* ── EMPTY / LOADING ── */
.empty, .loading {
  text-align: center;
  padding: 32px 16px;
  color: var(--suave);
  font-size: .9rem;
}

/* ── REABRIR BUTTON ── */
.btn-reabrir {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 1px solid var(--borda);
  color: var(--suave);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: .72rem;
  font-family: inherit;
  cursor: pointer;
  margin-top: 6px;
  -webkit-tap-highlight-color: transparent;
  transition: opacity .15s;
}
.btn-reabrir:active { opacity: .6; }

/* ── POWERED BY ── */
.powered-by {
  text-align: center;
  padding: 10px 16px 6px;
  font-size: .58rem;
  color: rgba(0,0,0,.18);
  letter-spacing: .14em;
  font-weight: 600;
  user-select: none;
  pointer-events: none;
}

/* ── RANGE SLIDER ── */
.range-wrap { margin: 6px 0 4px; }
.range-input {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--borda);
  outline: none;
}
.range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--verde);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.range-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.range-label .pct    { font-size: 1.1rem; font-weight: 700; color: var(--verde); }
.range-label .calc   { font-size: .82rem; color: var(--suave); }

/* ── SECÇÃO TABS ── */
.sec-tabs {
  display: flex;
  gap: 0;
  margin: 0 12px 16px;
  border-radius: 10px;
  background: var(--fundo);
  border: 1.5px solid var(--borda);
  overflow: hidden;
}
.sec-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  font-size: .85rem;
  font-family: inherit;
  font-weight: 600;
  color: var(--suave);
  cursor: pointer;
  transition: background .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
.sec-tab.ativo { background: var(--verde); color: #fff; }
.sec-tab:not(:last-child) { border-right: 1.5px solid var(--borda); }

/* ── BADGE ── */
.badge {
  display: inline-block;
  background: var(--dourado);
  color: #fff;
  border-radius: 10px;
  font-size: .65rem;
  font-weight: 700;
  padding: 1px 6px;
  margin-left: 4px;
}

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 82px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--verde);
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: .88rem;
  z-index: 200;
  opacity: 0;
  transition: opacity .3s, transform .3s;
  white-space: nowrap;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── ANULADO ── */
.comp-item.anulado { opacity: .5; background: var(--fundo); }
.comp-item.anulado .comp-info .desc { text-decoration: line-through; }
.comp-item.anulado .comp-valor { text-decoration: line-through; color: var(--suave); }

/* ── DELETE ROW BUTTON ── */
.btn-del-reg {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--negativo);
  opacity: .45;
  font-size: .82rem;
  padding: 4px 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity .15s;
}
.btn-del-reg:active { opacity: 1; }

/* ── COMPROMISSO SECTION ── */
.comp-section-label {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  margin: 10px 2px 6px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.comp-item .comp-btn {
  flex-shrink: 0;
  background: none;
  border: 1.5px solid var(--borda);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: .72rem;
  font-family: inherit;
  cursor: pointer;
  color: var(--suave);
  -webkit-tap-highlight-color: transparent;
  transition: all .15s;
}
.comp-item .comp-btn:active { opacity: .7; }
.overdue-badge {
  display: inline-block;
  background: var(--negativo);
  color: #fff;
  border-radius: 8px;
  font-size: .6rem;
  font-weight: 700;
  padding: 1px 6px;
  margin-top: 3px;
}
.comp-add-form {
  background: var(--branco);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
}
.comp-tipo-btns { display: flex; gap: 6px; margin-bottom: 10px; }
.comp-tipo-btn {
  flex: 1;
  padding: 9px;
  border: 1.5px solid var(--borda);
  border-radius: 8px;
  font-size: .82rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: var(--suave);
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.comp-tipo-btn.sel-rec { background: #e8f5f0; border-color: var(--positivo); color: var(--positivo); }
.comp-tipo-btn.sel-pag { background: #fdf0eb; border-color: var(--negativo); color: var(--negativo); }

/* ── CHART CARDS ── */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 12px;
  margin-bottom: 8px;
}
.chart-card {
  background: var(--branco);
  border-radius: 12px;
  padding: 12px 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
  min-width: 0;
}
.chart-title {
  font-size: .65rem;
  font-weight: 700;
  color: var(--suave);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 8px;
}
.chart-canvas-wrap {
  position: relative;
  height: 140px;
}
.chart-vazio {
  text-align: center;
  font-size: .78rem;
  color: var(--suave);
  padding: 44px 0;
}
.chart-legend { margin-top: 6px; }
.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .66rem;
  color: var(--suave);
  margin-bottom: 2px;
  overflow: hidden;
}
.legend-item span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── RESUMO COMPROMISSOS ── */
.comp-resumo-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: var(--branco);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 6px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  border-left: 3px solid transparent;
}
.comp-resumo-item.vencido {
  background: #fdf0eb;
  border-left-color: var(--negativo);
}
.vencido-badge {
  display: inline-block;
  background: var(--negativo);
  color: #fff;
  border-radius: 4px;
  font-size: .58rem;
  font-weight: 700;
  padding: 1px 5px;
  margin-left: 6px;
  vertical-align: middle;
  letter-spacing: .03em;
}

/* ── ANNUAL TABLE ── */
.ano-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .8rem;
}
.ano-table th {
  font-size: .65rem;
  color: var(--suave);
  font-weight: 700;
  text-align: right;
  padding: 5px 4px 8px;
  border-bottom: 2px solid var(--borda);
}
.ano-table th:first-child { text-align: left; }
.ano-table td {
  padding: 8px 4px;
  border-top: 1px solid var(--borda);
  text-align: right;
}
.ano-table td:first-child { text-align: left; font-weight: 500; }
.ano-table tfoot td { font-weight: 700; border-top: 2px solid var(--borda); }
.ano-table tr.sem-dados td { opacity: .35; }

/* ── WORK INFO CARD ── */
.info-card {
  background: var(--verde);
  color: #fff;
  padding: 16px;
  margin: 12px;
  border-radius: 14px;
}
.info-card .info-cliente { font-size: 1.1rem; font-weight: 700; margin-bottom: 4px; }
.info-card .info-desc    { font-size: .82rem; opacity: .8; margin-bottom: 10px; }
.info-card .info-row     { display: flex; justify-content: space-between; }
.info-card .info-val     { font-size: 1rem; font-weight: 700; color: var(--dourado); }
.info-card .info-tag     { font-size: .72rem; opacity: .7; }

/* ── v1.5 AGENDADO ── */
.fase-check.ag {
  border: 2px dashed #c8a000;
  color: #c8a000;
}
.fase-agendado-badge {
  display: inline-block;
  background: #fff8e6;
  color: #9a6f00;
  border: 1px solid #f0c040;
  border-radius: 6px;
  font-size: .75rem;
  font-weight: 600;
  padding: 3px 8px;
  margin-top: 6px;
}
.btn-reagendar {
  background: none;
  border: none;
  color: var(--suave);
  font-size: .72rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 2px 0;
  margin-top: 4px;
  font-family: inherit;
  display: block;
  -webkit-tap-highlight-color: transparent;
}
.fase-tipo.entrada { color: var(--positivo); }
.fase-tipo.saida   { color: var(--negativo); }
