:root {
    --bg-primary: #f8f9fa;
    --bg-secondary: #e9ecef;
    --bg-card: #ffffff;
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
    --text-muted: #a0aec0;
    --accent-purple: #6b46c1;
    --accent-green: #48bb78;
    --accent-cyan: #00bcd4;
    --accent-red: #c53030;
    /* Cor para destaque negativo ou botão calcular */
    --border-color: #e2e8f0;
    --shadow-color: rgba(0, 0, 0, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
}

/* ===== Header ===== */
.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    box-shadow: 0 2px 4px var(--shadow-color);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 32px;
    height: 32px;
    color: var(--accent-purple);
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ===== Main Content ===== */
.main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

/* ===== Tabs Navigation ===== */
.tab-nav {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0;
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    margin-bottom: -2px;
    /* Para sobrepor a linha de borda */
}

.tab-btn:hover {
    color: var(--accent-purple);
}

.tab-btn.active {
    color: var(--accent-purple);
    border-bottom-color: var(--accent-purple);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Main Inputs Section ===== */
.main-inputs-section {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px var(--shadow-color);
}

.main-inputs-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.main-input-card {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.main-input-card label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.currency-input {
    display: flex;
    align-items: center;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    transition: border-color 0.2s;
}

.currency-input:focus-within {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 2px rgba(107, 70, 193, 0.1);
}

.currency-prefix {
    font-weight: 600;
    color: var(--text-secondary);
    margin-right: 0.5rem;
}

.currency-input input {
    border: none;
    background: transparent;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    width: 100%;
    outline: none;
    font-family: inherit;
}

.period-input-group {
    display: flex;
    align-items: center;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.25rem;
}

.period-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: white;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 2px var(--shadow-color);
}

.period-btn:hover {
    background: var(--bg-secondary);
    color: var(--accent-purple);
}

.period-input-group input {
    width: 60px;
    text-align: center;
    border: none;
    background: transparent;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    outline: none;
    font-family: inherit;
}

.period-select {
    border: none;
    background: transparent;
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 500;
    outline: none;
    padding: 0 0.5rem;
    cursor: pointer;
    font-family: inherit;
}

/* ===== Rates Section ===== */
.rates-section {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px var(--shadow-color);
}

.rates-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.rates-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.rates-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.api-status {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.api-status .success {
    color: var(--accent-green);
    font-weight: bold;
}

.api-status .error {
    color: #e53e3e;
    font-weight: bold;
}

.rates-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.rate-card {
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 1rem;
    border-left: 3px solid var(--accent-purple);
}

.rate-card label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.info-tooltip {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-muted);
    color: white;
    font-size: 0.7rem;
    cursor: help;
    margin-left: 0.25rem;
}

.rate-value {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
}

.rate-value input {
    border: none;
    background: transparent;
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: inherit;
    outline: none;
    min-width: 0;
    /* Permite que o JS controle a largura exata */
    padding: 0;
    margin: 0;
}

.rate-suffix {
    font-size: 1rem;
    color: var(--text-secondary);
}

/* ===== Parameters Section ===== */
.params-section {
    margin-bottom: 1.5rem;
}

.params-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.param-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem 1.25rem;
}

.param-card label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.param-value {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
}

.param-value input {
    border: none;
    background: transparent;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: inherit;
    outline: none;
    min-width: 0;
    /* Permite que o JS controle a largura exata */
    padding: 0;
    margin: 0;
}

.param-value.readonly input {
    color: var(--text-muted);
}

.param-suffix {
    font-size: 1rem;
    color: var(--text-secondary);
}

.param-value.with-buttons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.param-value.with-suffix-label {
    flex-wrap: wrap;
}

.suffix-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    border-left: 1px solid var(--border-color);
    padding-left: 0.5rem;
    margin-left: 0.5rem;
}

.adj-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--accent-purple);
    background: transparent;
    color: var(--accent-purple);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.adj-btn:hover {
    background: var(--accent-purple);
    color: white;
}

/* ===== Section Styles ===== */
.section-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.section-icon {
    width: 22px;
    height: 22px;
    color: var(--accent-purple);
}

/* ===== Table Section ===== */
.table-section {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px var(--shadow-color);
}

.table-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-primary);
    border-radius: 8px;
    margin-bottom: 1.5rem;
    border-left: 4px solid var(--accent-purple);
}

.table-summary-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.table-summary-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.table-summary-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.table-summary-value.highlight {
    color: var(--accent-purple);
}

.table-wrapper {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    min-width: 700px;
}

.comparison-table thead {
    background: linear-gradient(135deg, #2a3f5f 0%, #1e3a5f 100%);
}

.comparison-table th {
    padding: 0.85rem 0.75rem;
    text-align: center;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

.comparison-table th.row-label {
    text-align: left;
    width: 180px;
}

.comparison-table th.col-lci {
    background: rgba(72, 187, 120, 0.9);
}

.comparison-table th.col-cdb {
    background: rgba(107, 70, 193, 0.9);
}

.comparison-table th.col-tesouro {
    background: rgba(237, 137, 54, 0.9);
}

.comparison-table th.col-prefixado {
    background: rgba(255, 193, 7, 0.9);
}

.comparison-table th.col-ipca {
    background: rgba(236, 64, 122, 0.9);
}

.comparison-table th.col-fundo {
    background: rgba(66, 153, 225, 0.9);
}

.comparison-table th.col-poupanca {
    background: rgba(113, 128, 150, 0.9);
}

.comparison-table tbody tr {
    background: var(--bg-card);
}

.comparison-table tbody tr:nth-child(even) {
    background: var(--bg-primary);
}

.comparison-table tbody tr:hover {
    background: rgba(107, 70, 193, 0.05);
}

.comparison-table td {
    padding: 0.75rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.comparison-table td.row-label {
    text-align: left;
    font-weight: 500;
    color: var(--text-primary);
}

.comparison-table .highlight-row {
    background: rgba(0, 188, 212, 0.1) !important;
}

.comparison-table .highlight-row td {
    font-weight: 600;
    color: var(--accent-cyan);
    border-bottom: none;
}

.comparison-table .highlight-row td.row-label {
    color: var(--text-primary);
}

/* ===== Chart Section ===== */
.chart-section {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px var(--shadow-color);
}

.chart-container {
    position: relative;
    height: 350px;
    width: 100%;
}

/* ===== Methodology Section ===== */
.methodology-section {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px var(--shadow-color);
}

.methodology-content {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.methodology-card {
    padding: 1rem;
    background: var(--bg-primary);
    border-radius: 8px;
    border-left: 3px solid var(--text-muted);
}

.methodology-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.methodology-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.methodology-card.full-width {
    grid-column: 1 / -1;
    border-left-color: var(--accent-purple);
}

.ir-table-wrapper {
    margin-top: 1rem;
    overflow-x: auto;
}

.ir-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.ir-table th {
    text-align: left;
    padding: 0.5rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
}

.ir-table td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

/* ===== Footer ===== */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 1rem;
    text-align: center;
}

.footer p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ===== Responsive Design ===== */
@media (max-width: 1024px) {
    .main-inputs-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .rates-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .table-summary {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .main-inputs-grid {
        grid-template-columns: 1fr !important;
        /* Force single column on mobile */
    }

    .rates-row {
        grid-template-columns: 1fr 1fr;
    }

    .params-grid {
        grid-template-columns: 1fr;
    }

    .table-summary {
        grid-template-columns: 1fr;
    }

    .chart-container {
        height: 280px;
    }

    .rates-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .methodology-content {
        grid-template-columns: 1fr;
    }

    .results-cards-section {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }

    .rates-row {
        grid-template-columns: 1fr;
    }

    .main {
        padding: 1rem;
    }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ===== Actions ===== */
.actions-container {
    display: flex;
    justify-content: flex-end;
    margin-top: 1rem;
}

.reset-btn {
    background: transparent;
    border: 1px solid var(--text-muted);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.reset-btn:hover {
    background: var(--bg-card);
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.primary-btn {
    background: var(--accent-red);
    /* Usando vermelho para destaque como na imagem */
    border: none;
    color: white;
    padding: 0.75rem 2rem;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(197, 48, 48, 0.2);
}

.primary-btn:hover {
    background: #9b2c2c;
    transform: translateY(-1px);
}

/* ===== Juros Compostos Results ===== */
.results-cards-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 2px 4px var(--shadow-color);
}

.result-card.highlight {
    background: var(--accent-red);
    /* Destaque vermelho */
    color: white;
    border-color: var(--accent-red);
}

.result-card label {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.result-card.highlight label {
    color: rgba(255, 255, 255, 0.9);
}

.result-card .result-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.result-card.highlight .result-value {
    color: white;
}

/* ===== AdSense Slots ===== */
.ad-slot {
    display: none;
    /* Ocultado temporariamente a pedido do usuário */
    width: 100%;
    min-height: 100px;
    /* Altura mínima para evitar CLS */
    background: var(--bg-primary);
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    margin: 2rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    overflow: hidden;
}

.ad-slot::before {
    content: 'Espaço para Publicidade';
}

/* ===== SEO Content ===== */
.seo-section {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px var(--shadow-color);
}

.seo-content h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.seo-content h3 {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.seo-content p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.6;
}

.seo-content ul {
    list-style-type: disc;
    padding-left: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.seo-content li {
    margin-bottom: 0.5rem;
}

/* ===== Footer Links ===== */
.footer-links {
    margin-bottom: 1rem;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    margin: 0 0.5rem;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--accent-purple);
    text-decoration: underline;
}