/* ==========================================================================
   PHM FINPLAN — DESIGN SYSTEM & FOLHA DE ESTILOS
   Educação Financeira Pedagógica · Paleta Esmeralda & Nobreza Visual
   Prof. Paulo Henrique Maciel · PHM Tech
   ========================================================================== */

:root, [data-theme="light"] {
  --fin-emerald: #059669;
  --fin-emerald-active: #047857;
  --fin-emerald-light: #10b981;
  --fin-emerald-bg: rgba(5, 150, 105, 0.1);
  --fin-emerald-border: rgba(5, 150, 105, 0.25);
  --emerald: #059669;
  --sim-invested-color: #2563eb;
  --sim-interest-color: #059669;
}

[data-theme="sepia"] {
  --fin-emerald: #065f46;
  --fin-emerald-active: #065f46;
  --fin-emerald-light: #047857;
  --fin-emerald-bg: rgba(6, 95, 70, 0.14);
  --fin-emerald-border: rgba(6, 95, 70, 0.35);
  --emerald: #065f46;
  --sim-invested-color: #78401a;
  --sim-interest-color: #065f46;
}

[data-theme="dark"] {
  --fin-emerald: #10b981;
  --fin-emerald-active: #059669;
  --fin-emerald-light: #34d399;
  --fin-emerald-bg: rgba(16, 185, 129, 0.15);
  --fin-emerald-border: rgba(16, 185, 129, 0.35);
  --emerald: #10b981;
  --sim-invested-color: #38bdf8;
  --sim-interest-color: #34d399;
}

/* --------------------------------------------------------------------------
   1. HERO PRINCIPAL & CONTROLES
   -------------------------------------------------------------------------- */
.finplan-main-app {
  min-height: calc(100vh - 70px);
  background-color: var(--bg);
  padding-bottom: 4rem;
}

.finplan-local-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--phm-space-3, .75rem);
  margin-top: var(--phm-space-4, 1rem);
}

@media (max-width: 480px) {
  .finplan-local-actions .phm-button {
    width: 100%;
  }
}

.finplan-section-hero {
  padding: 2.75rem 0 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.finplan-master-hero {
  text-align: center;
  max-width: 820px;
  margin: 0 auto 2.25rem;
}

.finplan-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface-soft);
  color: var(--emerald);
  border: 1px solid var(--line-strong, rgba(16, 185, 129, 0.3));
  padding: 0.35rem 0.85rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 0.85rem;
}

.finplan-hero-badge .kicker-num {
  color: var(--teal);
  font-weight: 800;
}

.finplan-hero-title {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 3.5vw, 2.75rem);
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 0.75rem;
}

.finplan-hero-highlight {
  color: var(--emerald);
}

.finplan-hero-lead {
  font-size: 1.05rem;
  color: var(--text-soft);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

/* SELETOR DE PERÍODO TEMPORAL */
.period-selector-bar {
  display: inline-flex;
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line-strong, #cbd5e1);
  border-radius: 4px;
  padding: 4px;
  gap: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.period-pill-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-soft, #334155);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.42rem 0.95rem;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.period-pill-btn:hover:not(.active) {
  color: var(--text);
  background: var(--surface);
}

.period-pill-btn.active {
  background-color: var(--fin-emerald-active, #047857) !important;
  color: #ffffff !important;
  border-color: var(--fin-emerald-active, #047857) !important;
  box-shadow: 0 2px 8px rgba(4, 120, 87, 0.4) !important;
  font-weight: 800 !important;
}

/* --------------------------------------------------------------------------
   2. 4 CARDS MÉTRICOS PESSOAIS
   -------------------------------------------------------------------------- */
.finplan-kpis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}

.finplan-kpi-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1.4rem 1.6rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.03);
  transition: transform var(--transition), box-shadow var(--transition);
}

.finplan-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

.kpi-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.kpi-card-header span {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-card-icon {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-balance .kpi-card-icon { background: rgba(5, 150, 105, 0.1); color: var(--emerald); }
.kpi-income .kpi-card-icon { background: rgba(14, 165, 233, 0.1); color: #0ea5e9; }
.kpi-expense .kpi-card-icon { background: rgba(225, 29, 72, 0.1); color: var(--rose); }
.kpi-savings .kpi-card-icon { background: rgba(124, 58, 237, 0.1); color: #7c3aed; }

.kpi-card-val {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.1;
  margin-bottom: 0.35rem;
  letter-spacing: -0.02em;
}

.kpi-card-sub {
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* --------------------------------------------------------------------------
   3. SEÇÕES EM CARTÕES (PANELS)
   -------------------------------------------------------------------------- */
.finplan-section-builder,
.finplan-section-table,
.finplan-section-simulator {
  padding-top: 2rem;
}

.finplan-card-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1.75rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  min-width: 0;
  max-width: 100%;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--line);
}

.panel-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.panel-title-wrap h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--navy);
  margin: 0;
  letter-spacing: -0.01em;
}

.panel-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.panel-tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--emerald);
  background: rgba(5, 150, 105, 0.08);
  border: 1px solid rgba(5, 150, 105, 0.2);
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.panel-tag .kicker-num {
  color: var(--teal);
  font-weight: 800;
  margin-right: 0.25rem;
}

.finplan-builder-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.75rem;
  min-width: 0;
}

/* --------------------------------------------------------------------------
   4. FORMULÁRIO DE LANÇAMENTO
   -------------------------------------------------------------------------- */
.finplan-form {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-soft);
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.finplan-form input,
.finplan-form select {
  height: 42px;
  border: 1px solid var(--line);
  padding: 0 0.85rem;
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.finplan-form input:focus,
.finplan-form select:focus {
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

/* Campos compostos do simulador e da descrição personalizada */
.input-addon-group {
  display: flex;
  align-items: stretch;
  width: 100%;
  min-height: 42px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-addon-group:focus-within {
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

.input-addon-chip {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 0.75rem;
  background: var(--surface-soft);
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.input-addon-chip.prefix {
  border-right: 1px solid var(--line);
}

.input-addon-chip.suffix {
  border-left: 1px solid var(--line);
}

.fin-input-styled {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  height: 40px;
  padding: 0 0.75rem;
  border: 0;
  outline: 0;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  box-sizing: border-box;
}

.input-with-prefix {
  position: relative;
  display: flex;
  align-items: center;
}

.input-prefix {
  position: absolute;
  left: 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
}

.input-with-prefix input {
  padding-left: 2.25rem;
  width: 100%;
}

.input-suffix {
  position: absolute;
  right: 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* TOGGLE RECEITA / DESPESA */
.tx-type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.type-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  transition: all 0.2s ease;
  background: var(--surface-soft);
  color: var(--text-soft);
  user-select: none;
}

.type-btn input {
  display: none;
}

.type-income:has(input:checked) {
  background: rgba(14, 165, 233, 0.12);
  border-color: #0ea5e9;
  color: #0284c7;
}

.type-expense:has(input:checked) {
  background: rgba(225, 29, 72, 0.12);
  border-color: var(--rose);
  color: var(--rose);
}

.btn-submit-tx {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  background: var(--emerald);
  color: #ffffff;
  border: 1px solid var(--emerald);
  height: 44px;
  border-radius: 4px;
  font-size: 0.92rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(5, 150, 105, 0.25);
  margin-top: 0.5rem;
}

.btn-submit-tx:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

/* --------------------------------------------------------------------------
   5. BARRAS DE CATEGORIA & REGRA 50-30-20
   -------------------------------------------------------------------------- */
.categories-breakdown-box {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 180px;
}

.category-bar-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.cat-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-soft);
}

.cat-bar-track {
  height: 8px;
  background: var(--surface-soft);
  border-radius: 2px;
  overflow: hidden;
}

.cat-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--emerald);
  transition: width 0.4s ease;
}

.rule-50-30-20-box {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-top: 1.5rem;
  font-size: 0.84rem;
  line-height: 1.55;
  color: var(--text-soft);
}

.rule-50-30-20-box h4 {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* --------------------------------------------------------------------------
   6. TABELA DE HISTÓRICO
   -------------------------------------------------------------------------- */
.table-header-flex {
  flex-wrap: wrap;
  gap: 1rem;
}

.table-actions-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  min-width: 0;
}

.table-actions-toolbar select {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 0.65rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--surface);
  color: var(--text);
}

.btn-table-action {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  height: 34px;
  padding: 0 0.75rem;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.btn-table-action:hover {
  background: var(--line);
}

.btn-danger-action:hover {
  background: rgba(225, 29, 72, 0.1);
  color: var(--rose);
  border-color: var(--rose);
}

.finplan-table-wrapper {
  overflow-x: auto;
  max-width: 100%;
}

.finplan-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.finplan-table th,
.finplan-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}

.finplan-table th {
  background: var(--surface-soft);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.74rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.tx-badge-type {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.badge-income { background: rgba(14, 165, 233, 0.12); color: #0284c7; }
.badge-expense { background: rgba(225, 29, 72, 0.12); color: var(--rose); }

.btn-delete-row {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 4px;
  transition: color 0.15s ease;
}

.btn-delete-row:hover {
  color: var(--rose);
}

/* --------------------------------------------------------------------------
   7. SIMULADOR DE JUROS COMPOSTOS & GRÁFICO SVG
   -------------------------------------------------------------------------- */
.simulator-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 2rem;
  min-width: 0;
}

@media (max-width: 900px) {
  .finplan-builder-grid,
  .simulator-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .header-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .header-actions > *,
  .btn-header-action,
  .nav-pref-trigger {
    min-width: 0;
    width: 100%;
  }

  .finplan-section-hero {
    padding-top: 2rem;
  }

  .finplan-card-panel {
    padding: 1rem;
  }

  .panel-header,
  .table-actions-toolbar,
  .filter-group,
  .table-actions-toolbar select {
    width: 100%;
  }

  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .table-actions-toolbar {
    align-items: stretch;
  }

  .btn-table-action {
    justify-content: center;
  }

  .form-row-2 {
    grid-template-columns: 1fr;
  }
}

.sim-controls-panel {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  background: var(--surface-soft);
  padding: 1.25rem;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.range-val-badge {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--emerald);
  background: var(--fin-emerald-bg, rgba(5, 150, 105, 0.1));
  border: 1px solid var(--fin-emerald-border, rgba(5, 150, 105, 0.25));
  padding: 0.18rem 0.6rem;
  border-radius: 4px;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

/* ==========================================================================
   PAINEL DE RESULTADOS E GRÁFICO DO SIMULADOR
   ========================================================================== */
.sim-results-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 0;
}

/* 3 CARDS DE KPI (TOTAL ACUMULADO, INVESTIDO, JUROS) */
.sim-kpis-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

@media (max-width: 640px) {
  .sim-kpis-row {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
}

.sim-kpi-item {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.sim-kpi-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.sim-kpi-item span {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sim-kpi-item strong {
  font-family: var(--font-mono);
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  font-weight: 700;
  line-height: 1.15;
  word-break: break-word;
  letter-spacing: -0.02em;
}

/* CONTAINER DO GRÁFICO */
.sim-chart-container {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.sim-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.sim-chart-header > span:first-child {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.01em;
}

.sim-legend {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 4px;
}

.dot-invested {
  background: var(--sim-invested-color, #2563eb);
}

.dot-interest {
  background: var(--sim-interest-color, #059669);
}

/* ÁREA DAS BARRAS DO GRÁFICO */
.sim-svg-chart-box {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 6px;
  height: 220px;
  padding: 12px 6px 4px;
  border-bottom: 2px solid var(--line-strong, #cbd5e1);
  overflow-x: auto;
  overflow-y: hidden;
  min-width: 0;
}

.sim-bar-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  flex: 1 1 0;
  min-width: 16px;
  max-width: 44px;
  height: 100%;
  position: relative;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.sim-bar-column:hover {
  transform: translateY(-3px);
}

.sim-bar-column:hover .sim-stacked-bar {
  filter: brightness(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.sim-stacked-bar {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border-radius: 2px 2px 0 0;
  overflow: hidden;
  background: transparent;
  transition: height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.bar-interest {
  width: 100%;
  background: var(--sim-interest-color, #059669);
  border-radius: 2px 2px 0 0;
  transition: height 0.3s ease;
}

.bar-invested {
  width: 100%;
  background: var(--sim-invested-color, #2563eb);
  transition: height 0.3s ease;
}

.sim-year-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 0.45rem;
  text-align: center;
  white-space: nowrap;
  user-select: none;
}

/* ==========================================================================
   BARRA (LINHA) DO SLIDER EM BRANCO (#ffffff) PARA MÁXIMA VISUALIZAÇÃO
   ========================================================================== */
.input-range-wrap {
  width: 100%;
  margin: 0.5rem 0;
  padding: 2px 0;
}

.input-range-wrap input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  margin: 0;
  padding: 0;
  border-radius: 4px;
  background: transparent !important;
  border: 0 !important;
  outline: none;
  cursor: pointer;
  box-shadow: none;
}

[data-theme="dark"] .input-range-wrap input[type="range"] {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

[data-theme="sepia"] .input-range-wrap input[type="range"] {
  background: transparent !important;
  border: 0 !important;
}

.input-range-wrap input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 4px;
  background: #ffffff !important;
}

.input-range-wrap input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 4px;
  background: #ffffff !important;
}

.input-range-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: var(--fin-emerald-active, #047857) !important;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4) !important;
  border: 2.5px solid #ffffff !important;
  margin-top: -8px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.input-range-wrap input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.18);
  box-shadow: 0 0 12px rgba(5, 150, 105, 0.7) !important;
}

.input-range-wrap input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: var(--fin-emerald-active, #047857) !important;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4) !important;
  border: 2.5px solid #ffffff !important;
  transition: transform 0.15s ease;
}

.input-range-wrap input[type="range"]:focus-visible {
  outline: 2px solid var(--fin-emerald-active, #047857);
  outline-offset: 2px;
}

/* GRID 2 LINHAS X 3 COLUNAS PARA PRESETS DE ANOS */
.sim-years-presets-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  margin-top: 0.5rem;
}

.sim-years-presets-grid .years-preset-btn {
  width: 100%;
  text-align: center;
  padding: 0.38rem 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text-soft);
  cursor: pointer;
  transition: all 0.15s ease;
}

.sim-years-presets-grid .years-preset-btn:hover {
  border-color: var(--emerald);
  color: var(--emerald);
  background: rgba(5, 150, 105, 0.05);
}

.sim-years-presets-grid .years-preset-btn.active {
  background: var(--emerald);
  color: #ffffff;
  border-color: var(--emerald);
}

/* ==========================================================================
   ALTO CONTRASTE E CORES ROBUSTAS PARA PRESETS (CLARO, SÉPIA E ESCURO)
   ========================================================================== */
:root {
  --fin-emerald-active: #047857;
  --fin-emerald-shadow: rgba(4, 120, 87, 0.35);
}

[data-theme="sepia"] {
  --fin-emerald-active: #065f46;
  --fin-emerald-shadow: rgba(6, 95, 70, 0.4);
}

[data-theme="dark"] {
  --fin-emerald-active: #059669;
  --fin-emerald-shadow: rgba(5, 150, 105, 0.5);
}

/* Botões inativos */
.rate-preset-btn,
.years-preset-btn,
.sim-years-presets-grid .years-preset-btn {
  background: var(--surface) !important;
  border: 1px solid var(--line-strong, #cbd5e1) !important;
  color: var(--text) !important;
  font-family: var(--font-mono) !important;
  font-size: 0.78rem !important;
  font-weight: 700 !important;
  padding: 0.35rem 0.55rem !important;
  border-radius: 4px !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
}

.rate-preset-btn:hover,
.years-preset-btn:hover,
.sim-years-presets-grid .years-preset-btn:hover {
  border-color: var(--fin-emerald-active) !important;
  color: var(--fin-emerald-active) !important;
  background: rgba(5, 150, 105, 0.08) !important;
}

/* Botões ATIVOS: Contraste Máximo (Fundo Verde Esmeralda Sólido + Texto Branco Puro) */
.rate-preset-btn.active,
.years-preset-btn.active,
.sim-years-presets-grid .years-preset-btn.active {
  background-color: var(--fin-emerald-active) !important;
  color: #ffffff !important;
  border-color: var(--fin-emerald-active) !important;
  font-weight: 800 !important;
  box-shadow: 0 2px 8px var(--fin-emerald-shadow) !important;
}

/* GRID DE 3 COLUNAS PARA PRESETS DE RENTABILIDADE */
.sim-rate-presets-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  margin-top: 0.5rem;
}

.sim-rate-presets-grid .rate-preset-btn {
  width: 100%;
  text-align: center;
  padding: 0.38rem 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 4px;
  background: var(--surface) !important;
  border: 1px solid var(--line-strong, #cbd5e1) !important;
  color: var(--text) !important;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sim-rate-presets-grid .rate-preset-btn:hover {
  border-color: var(--fin-emerald-active) !important;
  color: var(--fin-emerald-active) !important;
  background: rgba(5, 150, 105, 0.08) !important;
}

.sim-rate-presets-grid .rate-preset-btn.active {
  background-color: var(--fin-emerald-active) !important;
  color: #ffffff !important;
  border-color: var(--fin-emerald-active) !important;
  font-weight: 800 !important;
  box-shadow: 0 2px 8px var(--fin-emerald-shadow) !important;
}

/* P1-10 — contraste WCAG AA em superfícies claras */
:root:not([data-theme="dark"]) .finplan-hero-badge,
:root:not([data-theme="dark"]) .panel-tag,
:root:not([data-theme="dark"]) #tag-category-count,
:root:not([data-theme="dark"]) #sim-res-total { color: #047857 !important; }
:root:not([data-theme="dark"]) #sim-res-invested { color: #1e40af !important; }
:root:not([data-theme="dark"]) #sim-res-interest { color: #0f766e !important; }
:root:not([data-theme="dark"]) td[style*="var(--emerald)"] { color: #047857 !important; }
:root:not([data-theme="dark"]) .tx-badge-type.badge-income { color: #075985 !important; }
:root:not([data-theme="dark"]) .type-income:has(input:checked) span { color: #075985 !important; }
:root:not([data-theme="dark"]) .btn-submit-tx { background: #047857 !important; border-color: #047857 !important; }
:root:not([data-theme="dark"]) th { color: #475569 !important; }
:root:not([data-theme="dark"]) .brand-accent-gold { color: #7a5a0a !important; }
:root:not([data-theme="dark"]) .footer-brand-sep { color: #64748b !important; }
[data-theme="dark"] #sim-res-total { color: #34d399 !important; }
[data-theme="dark"] #sim-res-invested { color: #7dd3fc !important; }
[data-theme="dark"] #sim-res-interest { color: #2dd4bf !important; }
[data-theme="dark"] .period-pill-btn.active,
[data-theme="dark"] .rate-preset-btn.active,
[data-theme="dark"] .years-preset-btn.active,
[data-theme="dark"] .btn-submit-tx { background: #047857 !important; border-color: #047857 !important; }
[data-theme="dark"] .type-income:has(input:checked) span,
[data-theme="dark"] .tx-badge-type.badge-income { color: #7dd3fc !important; }

/* ==========================================================================
   CABEÇALHO CANÔNICO DO ECOSSISTEMA PHM TECH — BOTÕES GHOST & NAVEGAÇÃO
   ========================================================================== */
.phm-ecosystem-header .phm-ecosystem-header__inner,
.phm-ecosystem-header .nav-wrap {
  justify-content: flex-start !important;
}

.phm-ecosystem-header .phm-projects-menu > summary,
.phm-ecosystem-header .phm-hub-back {
  width: 34px !important;
  min-width: 34px !important;
  height: 34px !important;
  min-height: 34px !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border: 1px solid transparent !important;
  border-radius: 4px !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--text-soft, #475569) !important;
  transition: all 0.15s ease;
}

.phm-ecosystem-header .phm-projects-menu > summary::-webkit-details-marker {
  display: none !important;
}

.phm-ecosystem-header .phm-projects-menu > summary span,
.phm-ecosystem-header .phm-projects-menu > summary svg:last-child,
.phm-ecosystem-header .phm-hub-back span {
  display: none !important;
}

.phm-ecosystem-header .phm-projects-menu > summary svg:first-child,
.phm-ecosystem-header .phm-hub-back svg {
  margin: 0 !important;
}

.phm-ecosystem-header .phm-projects-menu > summary:hover,
.phm-ecosystem-header .phm-projects-menu[open] > summary,
.phm-ecosystem-header .phm-hub-back:hover {
  border-color: var(--line, #e2e8f0) !important;
  background: var(--surface-soft, #f1f5f9) !important;
  color: var(--fin-emerald, #059669) !important;
}

[data-theme="dark"] .phm-ecosystem-header .phm-projects-menu > summary,
[data-theme="dark"] .phm-ecosystem-header .phm-hub-back {
  color: #94a3b8 !important;
}

[data-theme="dark"] .phm-ecosystem-header .phm-projects-menu > summary:hover,
[data-theme="dark"] .phm-ecosystem-header .phm-projects-menu[open] > summary,
[data-theme="dark"] .phm-ecosystem-header .phm-hub-back:hover {
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
  color: #34d399 !important;
}

[data-theme="sepia"] .phm-ecosystem-header .phm-projects-menu > summary,
[data-theme="sepia"] .phm-ecosystem-header .phm-hub-back {
  color: #715842 !important;
}

[data-theme="sepia"] .phm-ecosystem-header .phm-projects-menu > summary:hover,
[data-theme="sepia"] .phm-ecosystem-header .phm-projects-menu[open] > summary,
[data-theme="sepia"] .phm-ecosystem-header .phm-hub-back:hover {
  background: rgba(67, 52, 34, 0.08) !important;
  border-color: rgba(67, 52, 34, 0.15) !important;
  color: #065f46 !important;
}

.phm-ecosystem-header .menu-toggle {
  display: none !important;
}

@media (max-width: 900px) {
  .phm-ecosystem-header .menu-toggle {
    display: inline-flex !important;
    width: 34px !important;
    min-width: 34px !important;
    height: 34px !important;
    min-height: 34px !important;
    padding: 0 !important;
    align-items: center !important;
    justify-content: center !important;
    border: 1px solid transparent !important;
    border-radius: 4px !important;
    background: transparent !important;
    box-shadow: none !important;
    color: var(--text-soft, #475569) !important;
    cursor: pointer;
    transition: all 0.15s ease;
  }
  .phm-ecosystem-header .menu-toggle:hover {
    border-color: var(--line, #e2e8f0) !important;
    background: var(--surface-soft, #f1f5f9) !important;
    color: var(--fin-emerald, #059669) !important;
  }
  [data-theme="dark"] .phm-ecosystem-header .menu-toggle {
    color: #94a3b8 !important;
  }
  [data-theme="dark"] .phm-ecosystem-header .menu-toggle:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    color: #34d399 !important;
  }
  [data-theme="sepia"] .phm-ecosystem-header .menu-toggle {
    color: #715842 !important;
  }
  [data-theme="sepia"] .phm-ecosystem-header .menu-toggle:hover {
    background: rgba(67, 52, 34, 0.08) !important;
    border-color: rgba(67, 52, 34, 0.15) !important;
    color: #065f46 !important;
  }
  .phm-ecosystem-header .header-editorial-nav {
    display: none !important;
  }
  .phm-ecosystem-header .header-editorial-nav.open {
    display: flex !important;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    background: var(--surface, #0f172a);
    border-bottom: 1px solid var(--line, rgba(255, 255, 255, 0.1));
    padding: 1rem 1.25rem;
    gap: 0.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
    z-index: 999;
  }
  .phm-ecosystem-header .header-editorial-nav.open a {
    padding: 0.65rem 0.85rem !important;
    font-size: 0.85rem !important;
    border-radius: 4px !important;
  }
  [data-theme="light"] .phm-ecosystem-header .header-editorial-nav.open {
    background: #ffffff;
    border-bottom-color: var(--line, #e2e8f0);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
  }
  [data-theme="sepia"] .phm-ecosystem-header .header-editorial-nav.open {
    background: #f4ecdc;
    border-bottom-color: var(--line, #e2e8f0);
    box-shadow: 0 10px 25px rgba(67, 52, 34, 0.12);
  }
}

body.finplan-app-body {
  overflow-x: hidden;
}

.phm-ecosystem-header {
  width: 100% !important;
  max-width: 100vw !important;
  box-sizing: border-box !important;
}

@media (max-width: 640px) {
  .phm-ecosystem-header .phm-ecosystem-header__inner {
    padding-inline: 0.35rem !important;
    gap: 0.2rem !important;
  }
  .phm-ecosystem-header .nav-left-cluster {
    flex-shrink: 1 !important;
    min-width: 0 !important;
  }
  .phm-ecosystem-header .app-logo-wordmark {
    height: 20px !important;
    max-width: 85px !important;
    width: auto !important;
  }
  .phm-ecosystem-header .nav-cluster-divider {
    display: none !important;
  }
  .phm-ecosystem-header .phm-ecosystem-header__actions {
    gap: 0.15rem !important;
    flex-shrink: 0 !important;
  }
  .phm-ecosystem-header .nav-pref-trigger,
  .phm-ecosystem-header .phm-projects-menu > summary,
  .phm-ecosystem-header .phm-hub-back,
  .phm-ecosystem-header .menu-toggle {
    width: 30px !important;
    min-width: 30px !important;
    height: 30px !important;
    min-height: 30px !important;
    padding: 0 !important;
    border-radius: 4px !important;
    justify-content: center !important;
  }
}

/* Salvaguarda de Acessibilidade: Skip Link fora do fluxo visual quando não focado */
.phm-skip-link {
  position: absolute !important;
  top: -9999px !important;
  left: 1rem !important;
  z-index: 999999 !important;
  padding: 0.5rem 1rem !important;
  background: #0b1329 !important;
  color: #34d399 !important;
  border: 1px solid #059669 !important;
  border-radius: 4px !important;
  font-family: var(--font-body, system-ui, sans-serif) !important;
  font-size: 0.85rem !important;
  font-weight: 600 !important;
  text-decoration: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.phm-skip-link:focus,
.phm-skip-link:focus-visible {
  top: 1rem !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  outline: 2px solid #34d399 !important;
}

