:root {
    --primary: #0052cc;
    --primary-hover: #003d99;
    --bg-color: #f4f7fa;
    --card-bg: #ffffff;
    --text-main: #172b4d;
    --text-secondary: #5e6c84;
    --border-color: #dfe1e6;
    --success: #36b37e;
    --warning: #ffab00;
    --danger: #ff5630;
    
    /* Chart Colors */
    --color-principal: #0052cc;
    --color-interest: #ffab00;
    --color-tax: #36b37e;

    --radius: 8px;
    --shadow: 0 4px 12px rgba(0,0,0,0.05);
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    padding: 20px;
}

.calculator-container {
    max-width: 900px;
    margin: 0 auto;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 40px; /* Space for SEO content */
}

.calc-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.calc-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.logo-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.site-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

/* Tabs */
.tabs {
    display: flex;
    background: #ebecf0;
    padding: 4px;
}

.tab-btn {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--card-bg);
    color: var(--primary);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Body Layout */
.calc-body {
    display: grid;
    grid-template-columns: 1fr;
}

@media (min-width: 768px) {
    .calc-body {
        grid-template-columns: 1fr 1fr;
    }
}

/* Input Section */
.input-section {
    padding: 24px;
    border-right: 1px solid var(--border-color);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

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

.currency-symbol, .suffix {
    position: absolute;
    color: var(--text-secondary);
    font-weight: 500;
}

.currency-symbol { left: 12px; }
.suffix { right: 12px; }

input[type="text"],
input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    padding-left: 28px; /* Space for currency symbol */
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    transition: border-color 0.2s;
    font-family: inherit;
}

input[type="number"] {
    padding-left: 12px; /* Reset if no currency */
}

.input-wrapper:has(.suffix) input {
    padding-right: 30px;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 82, 204, 0.1);
}

/* Switch Toggle (Amount / %) */
.input-group-switch {
    display: flex;
    gap: 8px;
}

.input-group-switch .input-wrapper {
    flex: 1;
}

.switch-toggle {
    display: flex;
    background: #ebecf0;
    border-radius: var(--radius);
    padding: 2px;
}

.switch-btn {
    border: none;
    background: transparent;
    padding: 0 12px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
}

.switch-btn.active {
    background: var(--card-bg);
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Term Pills */
.term-pills {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.term-pill {
    flex: 1;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    padding: 8px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-main);
    transition: all 0.2s;
}

.term-pill:hover {
    border-color: var(--primary);
}

.term-pill.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

/* Advanced Options */
.advanced-options summary {
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--primary);
    font-weight: 500;
    margin-bottom: 16px;
    user-select: none;
}

/* Form Actions */
.form-actions {
    margin-top: 24px;
    display: flex;
    justify-content: flex-end;
}

.reset-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.reset-btn:hover {
    background: #ebecf0;
    color: var(--text-main);
}

/* Results Section */
.results-section {
    padding: 24px;
    background: #fafbfc;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.result-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    text-align: center;
    border: 1px solid var(--border-color);
}

.result-card h2 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.hero-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.sub-result {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Donut Chart */
.chart-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.donut-chart {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: conic-gradient(
        var(--color-principal) 0deg 200deg,
        var(--color-interest) 200deg 280deg,
        var(--color-tax) 280deg 360deg
    );
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.donut-chart::after {
    content: "";
    position: absolute;
    width: 140px;
    height: 140px;
    background: #fafbfc; /* Match section bg */
    border-radius: 50%;
}

.center-text {
    position: relative;
    z-index: 1;
    text-align: center;
}

.center-text .label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.center-text .value {
    display: block;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Legend */
.legend {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
}

.legend li {
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.dot.principal { background: var(--color-principal); }
.dot.interest { background: var(--color-interest); }
.dot.tax { background: var(--color-tax); }

.legend .val {
    font-weight: 600;
    margin-left: 4px;
}

/* Amortization Table */
.table-container {
    margin-top: 16px;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th, td {
    padding: 10px;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: #ebecf0;
    position: sticky;
    top: 0;
    font-weight: 600;
    color: var(--text-secondary);
}

th:first-child, td:first-child {
    text-align: left;
}

/* Utilities */
.hidden {
    display: none !important;
}

/* SEO Content Section */
.seo-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px 40px;
    color: var(--text-main);
}

.content-container h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 40px;
    margin-bottom: 16px;
    color: var(--primary);
}

.content-container h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-top: 24px;
    margin-bottom: 12px;
    color: var(--text-main);
}

.content-container p {
    margin-bottom: 16px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.content-container ul {
    margin-bottom: 16px;
    padding-left: 24px;
    color: var(--text-secondary);
}

.content-container li {
    margin-bottom: 8px;
}

.faq-item {
    margin-bottom: 24px;
}

/* Mobile Sticky Summary */
@media (max-width: 767px) {
    .sticky-summary {
        position: sticky;
        bottom: 0;
        z-index: 10;
        margin: 0 -24px -24px -24px; /* Bleed to edges */
        padding: 16px;
        background: var(--card-bg);
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
    }
    
    .result-card {
        box-shadow: none;
        border: none;
        padding: 0;
        background: transparent;
    }
    
    .hero-number {
        font-size: 2rem;
    }
    
    .results-section {
        padding-bottom: 0; /* Space is handled by sticky container */
    }
}

/* Subsections for H3 */
.subsection {
    margin-left: 20px;
    padding-left: 24px;
    border-left: 2px solid var(--border-color);
    margin-bottom: 32px;
}

.subsection h3 {
    margin-top: 0;
    color: var(--text-main);
}
