/* =====================================================================
   FinControl — style.css
   Todos os estilos da aplicação
   ===================================================================== */

/* ── DESIGN TOKENS ─────────────────────────────────────────────────── */
:root {
  --bg: #F5F4EF;
  --surface: #FFFFFF;
  --surface2: #F0EFE9;
  --border: rgba(0,0,0,0.10);
  --border2: rgba(0,0,0,0.18);
  --text: #1A1917;
  --text2: #6B6A66;
  --text3: #9A9994;
  --green: #2D7A4F;
  --green-bg: #E6F4EC;
  --red: #C0392B;
  --red-bg: #FDECEA;
  --blue: #1A5FA8;
  --blue-bg: #E8F0FA;
  --amber: #B06A00;
  --amber-bg: #FEF3E2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

/* ── RESET ──────────────────────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ── LAYOUT ─────────────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ── SIDEBAR ────────────────────────────────────────────────────────── */
.sidebar {
  width: 230px;
  min-width: 230px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo h1 { font-size: 15px; font-weight: 600; color: var(--text); letter-spacing: -0.3px; }
.sidebar-logo p  { font-size: 12px; color: var(--text3); margin-top: 1px; }
.sidebar-section {
  padding: 12px 12px 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}
.sidebar-nav { padding: 0 8px; }

/* ── NAV ITEMS ──────────────────────────────────────────────────────── */
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 400;
  color: var(--text2);
  transition: all 0.15s;
  margin-bottom: 1px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover  { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--text); color: white; font-weight: 500; }
.nav-item .ti    { font-size: 17px; }

/* ── EMPRESA SELECTOR ───────────────────────────────────────────────── */
.empresa-selector {
  padding: 12px;
  margin-top: auto;
  border-top: 1px solid var(--border);
}
.empresa-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background: var(--bg);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: all 0.15s;
}
.empresa-btn:hover { border-color: var(--text); }
.empresa-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.empresa-btn .ti-chevron-down { margin-left: auto; font-size: 14px; color: var(--text3); }
.empresa-dropdown {
  position: absolute;
  bottom: 78px;
  left: 8px;
  right: 8px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 100;
  display: none;
}
.empresa-dropdown.open { display: block; }
.empresa-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.1s;
}
.empresa-option:hover  { background: var(--surface2); }
.empresa-option.active { font-weight: 500; }
.empresa-option:first-child { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.empresa-option:last-child  { border-radius: 0 0 var(--radius-sm) var(--radius-sm); }

/* ── MAIN / PAGES ───────────────────────────────────────────────────── */
.main { flex: 1; overflow-y: auto; }
.page        { display: none; padding: 28px 32px; max-width: 1100px; }
.page.active { display: block; }
.page-header { margin-bottom: 24px; }
.page-header h2 { font-size: 22px; font-weight: 600; letter-spacing: -0.4px; }
.page-header p  { font-size: 13.5px; color: var(--text2); margin-top: 3px; }

/* ── CARDS SUMMARY ──────────────────────────────────────────────────── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.card-metric {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.card-metric .label {
  font-size: 12px;
  color: var(--text3);
  font-weight: 500;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.card-metric .label .ti { font-size: 14px; }
.card-metric .value {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.5px;
  font-family: 'DM Mono', monospace;
}
.card-metric .sub   { font-size: 12px; color: var(--text3); margin-top: 4px; }
.card-metric.green .value { color: var(--green); }
.card-metric.red   .value { color: var(--red); }
.card-metric.blue  .value { color: var(--blue); }

/* ── TABLE ──────────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.table-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.table-header h3  { font-size: 14px; font-weight: 600; }
.table-filters    { display: flex; gap: 8px; align-items: center; }

select,
input[type=text],
input[type=date],
input[type=number] {
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  background: var(--bg);
  outline: none;
  transition: border 0.15s;
}
select:focus, input:focus { border-color: var(--text); }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
td { padding: 11px 16px; border-bottom: 1px solid var(--border); color: var(--text); }
tr:last-child td  { border-bottom: none; }
tr:hover td       { background: var(--surface2); }

/* ── BADGES ─────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
}
.badge.receita   { background: var(--green-bg); color: var(--green); }
.badge.despesa   { background: var(--red-bg);   color: var(--red); }
.badge-empresa   { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 500; }
.value-pos       { color: var(--green); font-family: 'DM Mono', monospace; font-weight: 500; }
.value-neg       { color: var(--red);   font-family: 'DM Mono', monospace; font-weight: 500; }

.badge-status { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 500; }
.badge-status.previsto { background: var(--amber-bg); color: var(--amber); }
.badge-status.pago     { background: var(--green-bg); color: var(--green); }
.badge-status.recebido { background: var(--blue-bg);  color: var(--blue);  }

.badge-natureza {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  background: var(--surface2);
  color: var(--text2);
  border: 1px solid var(--border);
}
.badge-recorrencia {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  background: var(--surface2);
  color: var(--text2);
  border: 1px solid var(--border);
}

/* ── BUTTONS ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
}
.btn-primary           { background: var(--text);    color: white;        border-color: var(--text); }
.btn-primary:hover     { background: #333; }
.btn-secondary         { background: var(--surface); color: var(--text);  border-color: var(--border2); }
.btn-secondary:hover   { background: var(--surface2); }
.btn-danger            { background: var(--red-bg);  color: var(--red);   border-color: transparent; }
.btn-danger:hover      { background: #f5c0bb; }
.btn .ti               { font-size: 16px; }

/* ── MODAL ──────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 560px;
  max-width: 96vw;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  max-height: 92vh;
  overflow-y: auto;
}
.modal h3           { font-size: 17px; font-weight: 600; margin-bottom: 18px; }
.form-grid          { display: grid; gap: 14px; }
.form-group label   { display: block; font-size: 12px; font-weight: 500; color: var(--text2); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.3px; }
.form-group input,
.form-group select  { width: 100%; }
.form-row           { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3         { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.modal-footer       { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ── CHARTS ─────────────────────────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.chart-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.chart-card h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.chart-wrap { position: relative; height: 200px; }

/* ── DRE TABLE ──────────────────────────────────────────────────────── */
.dre-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.dre-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.dre-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.dre-table tr.section td {
  font-weight: 600;
  background: var(--surface2);
  color: var(--text);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.dre-table tr.total td { font-weight: 600; font-size: 14px; background: var(--text); color: white; }
.dre-table tr.total td.pos { color: #7dffc0; }
.dre-table tr.total td.neg { color: #ffaaaa; }
.dre-table .mono { font-family: 'DM Mono', monospace; }

/* ── FLUXO ──────────────────────────────────────────────────────────── */
.fluxo-row      { display: flex; align-items: center; gap: 0; margin-bottom: 6px; }
.fluxo-label    { width: 160px; font-size: 13px; color: var(--text2); flex-shrink: 0; }
.fluxo-bar-wrap { flex: 1; background: var(--surface2); border-radius: 4px; height: 22px; overflow: hidden; position: relative; }
.fluxo-bar      { height: 100%; border-radius: 4px; transition: width 0.4s; }
.fluxo-value    { width: 110px; text-align: right; font-size: 13px; font-family: 'DM Mono', monospace; font-weight: 500; flex-shrink: 0; padding-left: 12px; }

/* ── COMPARATIVO ────────────────────────────────────────────────────── */
.comp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.comp-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 18px;
}
.comp-card .empresa-name {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.comp-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.comp-stat:last-child { border-bottom: none; }
.comp-stat .k { color: var(--text2); }

/* ── MONTH NAV ──────────────────────────────────────────────────────── */
.month-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.month-nav button {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  transition: all 0.15s;
}
.month-nav button:hover     { background: var(--surface2); }
.month-nav .current-month  { font-size: 14px; font-weight: 600; min-width: 120px; text-align: center; }

/* ── EMPTY STATE ────────────────────────────────────────────────────── */
.empty { text-align: center; padding: 40px; color: var(--text3); font-size: 14px; }
.empty .ti { font-size: 32px; display: block; margin-bottom: 8px; }

/* ── PREVISÃO DE FLUXO ──────────────────────────────────────────────── */
.prev-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.card-metric.previsto-border             { border-left: 3px solid var(--amber); }
.card-metric.previsto-border .value      { color: var(--amber); }
.card-metric.saldo-border                { border-left: 3px solid var(--blue); }
.card-metric.saldo-border .value         { color: var(--blue); }
.prev-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text3);
  padding: 0 0 8px 2px;
  margin-top: 24px;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.prev-section-label .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.realizado-row td  { opacity: 1; }
.previsto-row td   { opacity: 0.82; background: #fffdf5; }
.previsto-row:hover td { background: #fff8e6 !important; }
.rec-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  background: #F0EFE9;
  color: #6B6A66;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 20px;
  padding: 1px 7px;
}
.btn-prev-group { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.legend-item    { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text2); }
.legend-dot     { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.horizon-tab    { display: inline-flex; align-items: center; gap: 0; border: 1px solid var(--border2); border-radius: var(--radius-sm); overflow: hidden; }
.horizon-tab button {
  border: none;
  background: var(--surface);
  padding: 6px 14px;
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  color: var(--text2);
  border-right: 1px solid var(--border2);
  transition: all 0.15s;
}
.horizon-tab button:last-child { border-right: none; }
.horizon-tab button.active     { background: var(--text); color: white; font-weight: 500; }
.recorrente-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.recorrente-card .rc-left  { display: flex; flex-direction: column; gap: 3px; }
.recorrente-card .rc-title { font-size: 13.5px; font-weight: 500; }
.recorrente-card .rc-meta  { font-size: 12px; color: var(--text3); }
.recorrente-card .rc-valor { font-family: 'DM Mono', monospace; font-weight: 600; font-size: 15px; }
.recorrentes-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.prev-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}
.prev-tab {
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text2);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: inherit;
}
.prev-tab.active { color: var(--text); border-bottom-color: var(--text); }
