/* ============================================
   CreditPayCalc - Global Stylesheet
   Domain: creditpaycalc.com
   Primary: #2357b8 | Background: #f5f7fb | Text: #2a2a2a
   ============================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2357b8;
    --primary-dark: #1a4496;
    --primary-light: #e8f0fc;
    --bg: #f5f7fb;
    --bg-white: #ffffff;
    --text: #2a2a2a;
    --text-light: #666;
    --border: #dce3ee;
    --border-focus: #2357b8;
    --success: #1a8a5c;
    --warning: #c0392b;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(35, 87, 184, 0.08);
    --shadow-lg: 0 4px 20px rgba(35, 87, 184, 0.12);
    --max-width: 960px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* ---------- Navigation ---------- */
.navbar {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
}

.navbar-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.navbar-logo {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.5px;
}

.navbar-logo:hover {
    text-decoration: none;
}

.navbar-links {
    display: flex;
    gap: 24px;
    list-style: none;
}

.navbar-links a {
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 500;
}

.navbar-links a:hover {
    color: var(--primary);
    text-decoration: none;
}

.navbar-mobile-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text);
}

/* ---------- Page Container ---------- */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
}

/* ---------- Hero Section ---------- */
.hero {
    text-align: center;
    padding: 40px 20px 20px;
}

.hero h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -1px;
    margin-bottom: 12px;
}

.hero .subtitle {
    font-size: 1.05rem;
    color: var(--text-light);
    max-width: 640px;
    margin: 0 auto;
    line-height: 1.5;
}

/* ---------- Calculator Box (AdSense-shielded) ---------- */
.calculator-box {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 32px;
    margin: 24px auto;
    max-width: var(--max-width);
    position: relative;
    z-index: 5;
}

/* ---------- Minimum Payment Mode Toggle ---------- */
.min-pay-mode {
    display: flex;
    gap: 20px;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.min-pay-mode label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    color: var(--text);
}

.min-pay-mode input[type="radio"] {
    accent-color: var(--primary);
    cursor: pointer;
}

.min-pay-hint {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 20px;
    font-style: italic;
}

/* ---------- Credit Card Input Cards ---------- */
.card-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.card-row {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    position: relative;
}

.card-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.card-row-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary);
}

.card-remove-btn {
    background: none;
    border: none;
    color: var(--warning);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.card-remove-btn:hover {
    background: rgba(192, 57, 43, 0.08);
}

.card-fields {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.field-group label {
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 500;
}

.field-group input,
.field-group select {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 0.9rem;
    color: var(--text);
    background: var(--bg-white);
    transition: border-color 0.2s;
    font-family: var(--font);
}

.field-group input:focus,
.field-group select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px rgba(35, 87, 184, 0.12);
}

/* Percentage input (shown in percentage mode) */
.percent-input {
    display: none;
}

.percent-input.active {
    display: flex;
}

.min-input-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
}

.min-input-wrapper input {
    flex: 1;
}

.min-input-wrapper .percent-sign {
    font-size: 0.85rem;
    color: var(--text-light);
}

/* ---------- Add Card Button ---------- */
.add-card-btn {
    background: var(--primary-light);
    border: 1px dashed var(--primary);
    color: var(--primary);
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    margin-bottom: 20px;
}

.add-card-btn:hover {
    background: rgba(35, 87, 184, 0.12);
}

/* ---------- Extra Payment & Calculate ---------- */
.extra-payment-section {
    border-top: 1px solid var(--border);
    padding-top: 20px;
    margin-bottom: 20px;
}

.extra-payment-section .field-group {
    max-width: 320px;
}

.btn-calculate {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 14px 40px;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    width: 100%;
    font-family: var(--font);
}

.btn-calculate:hover {
    background: var(--primary-dark);
}

/* ---------- Results Section ---------- */
.results {
    display: none;
    margin-top: 32px;
    border-top: 2px solid var(--border);
    padding-top: 28px;
}

.results.active {
    display: block;
}

.results h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text);
}

.results-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.result-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
}

.result-card.highlight {
    border-color: var(--primary);
    background: var(--primary-light);
}

.result-label {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 4px;
}

.result-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.result-value.warning {
    color: var(--warning);
}

.result-value.success {
    color: var(--success);
}

.result-subtext {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 2px;
}

/* ---------- Strategy Comparison Table ---------- */
.strategy-comparison {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 24px;
    font-size: 0.875rem;
}

.strategy-comparison th {
    background: var(--primary);
    color: #fff;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
}

.strategy-comparison th:first-child {
    border-radius: 6px 0 0 0;
}

.strategy-comparison th:last-child {
    border-radius: 0 6px 0 0;
}

.strategy-comparison td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.strategy-comparison tr:nth-child(even) td {
    background: var(--bg);
}

.strategy-comparison .highlight-cell {
    color: var(--success);
    font-weight: 700;
}

/* ---------- CSS Bar Chart (No external library) ---------- */
.chart-container {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 8px;
}

.chart-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 20px;
    text-align: center;
}

.chart-bars {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 40px;
    height: 220px;
    padding: 0 20px;
    border-bottom: 2px solid var(--border);
    position: relative;
}

.chart-bar-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
    flex: 1;
    max-width: 120px;
}

.chart-bar {
    width: 60px;
    border-radius: 6px 6px 0 0;
    transition: height 0.8s ease;
    position: relative;
    min-height: 4px;
}

.chart-bar.base {
    background: linear-gradient(180deg, #6b8ec9 0%, #4a6fa8 100%);
}

.chart-bar.avalanche {
    background: linear-gradient(180deg, #2d6cdf 0%, #2357b8 100%);
}

.chart-bar.snowball {
    background: linear-gradient(180deg, #5a8de8 0%, #3a6dc8 100%);
}

.chart-bar-value {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
}

.chart-bar-label {
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-light);
    text-align: center;
    line-height: 1.3;
}

/* ---------- FAQ Accordion ---------- */
.faq-section {
    max-width: var(--max-width);
    margin: 48px auto;
    padding: 0 20px;
}

.faq-section h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--text);
}

.faq-category {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--primary);
    margin-top: 28px;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--border);
}

.faq-category:first-of-type {
    margin-top: 0;
}

.faq-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    background: var(--bg-white);
    overflow: hidden;
}

.faq-question {
    width: 100%;
    background: none;
    border: none;
    padding: 16px 20px;
    text-align: left;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font);
    transition: background 0.2s;
}

.faq-question:hover {
    background: var(--bg);
}

.faq-question .faq-icon {
    flex-shrink: 0;
    margin-left: 12px;
    font-size: 1.2rem;
    color: var(--primary);
    transition: transform 0.3s;
}

.faq-item.open .faq-icon {
    transform: rotate(45deg);
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    padding: 0 20px;
}

.faq-item.open .faq-answer {
    max-height: 500px;
    padding: 0 20px 16px;
}

.faq-answer p {
    font-size: 0.875rem;
    color: var(--text-light);
    line-height: 1.6;
}

/* ---------- State Guide Cards ---------- */
.state-cards {
    max-width: var(--max-width);
    margin: 0 auto 48px;
    padding: 0 20px;
}

.state-cards h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text);
}

.state-cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.state-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    transition: box-shadow 0.2s, transform 0.2s;
    text-decoration: none;
    color: inherit;
    display: block;
}

.state-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
    text-decoration: none;
}

.state-card h3 {
    font-size: 1.1rem;
    color: var(--primary);
    margin-bottom: 8px;
}

.state-card p {
    font-size: 0.85rem;
    color: var(--text-light);
    line-height: 1.5;
}

/* ---------- Footer ---------- */
.footer {
    background: var(--bg-white);
    border-top: 1px solid var(--border);
    padding: 24px 20px;
    text-align: center;
}

.footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
}

.footer p {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 4px;
}

.footer a {
    font-size: 0.8rem;
}

/* ---------- Breadcrumb ---------- */
.breadcrumb {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 12px 20px 0;
    font-size: 0.8rem;
    color: var(--text-light);
}

.breadcrumb a {
    color: var(--text-light);
}

.breadcrumb a:hover {
    color: var(--primary);
}

.breadcrumb span {
    margin: 0 6px;
    color: var(--border);
}

/* ---------- Guide Page Content ---------- */
.guide-content {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 40px 20px 60px;
}

.guide-content h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text);
}

.guide-content .guide-subtitle {
    font-size: 1rem;
    color: var(--text-light);
    margin-bottom: 32px;
}

.guide-content h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-top: 32px;
    margin-bottom: 12px;
    color: var(--primary);
}

.guide-content h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-top: 20px;
    margin-bottom: 8px;
    color: var(--text);
}

.guide-content p {
    font-size: 0.9rem;
    color: var(--text);
    line-height: 1.7;
    margin-bottom: 12px;
}

.guide-content ul {
    margin: 0 0 16px 20px;
}

.guide-content ul li {
    font-size: 0.9rem;
    color: var(--text);
    line-height: 1.7;
    margin-bottom: 4px;
}

.guide-content .callout {
    background: var(--primary-light);
    border-left: 4px solid var(--primary);
    padding: 16px 20px;
    border-radius: 0 8px 8px 0;
    margin: 20px 0;
}

.guide-content .callout p {
    margin-bottom: 0;
    font-size: 0.875rem;
}

.back-home {
    display: inline-block;
    margin-top: 32px;
    padding: 10px 24px;
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.2s;
}

.back-home:hover {
    background: var(--primary-dark);
    color: #fff;
    text-decoration: none;
}

/* ---------- Privacy Page ---------- */
.privacy-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px 60px;
}

.privacy-content h1 {
    font-size: 1.8rem;
    margin-bottom: 24px;
    color: var(--text);
}

.privacy-content h2 {
    font-size: 1.15rem;
    margin-top: 28px;
    margin-bottom: 10px;
    color: var(--primary);
}

.privacy-content p {
    font-size: 0.875rem;
    line-height: 1.7;
    margin-bottom: 12px;
    color: var(--text);
}

.privacy-content ul {
    margin: 0 0 12px 20px;
}

.privacy-content ul li {
    font-size: 0.875rem;
    line-height: 1.7;
    margin-bottom: 4px;
}

.privacy-updated {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 24px;
}

/* ---------- Responsive Design ---------- */
@media (max-width: 768px) {
    .hero h1 {
        font-size: 1.5rem;
    }

    .hero .subtitle {
        font-size: 0.95rem;
    }

    .calculator-box {
        padding: 20px 16px;
        margin: 16px auto;
        border-radius: 8px;
    }

    .card-fields {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .navbar-links {
        display: none;
    }

    .navbar-mobile-toggle {
        display: block;
    }

    .navbar-links.mobile-open {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: var(--bg-white);
        border-bottom: 1px solid var(--border);
        padding: 12px 20px;
        gap: 12px;
        z-index: 100;
    }

    .navbar {
        position: relative;
    }

    .state-cards-grid {
        grid-template-columns: 1fr;
    }

    .chart-bars {
        gap: 16px;
        height: 180px;
    }

    .chart-bar {
        width: 44px;
    }

    .chart-bar-value {
        font-size: 0.7rem;
    }

    .strategy-comparison {
        font-size: 0.8rem;
    }

    .strategy-comparison th,
    .strategy-comparison td {
        padding: 8px 6px;
    }

    .guide-content h1 {
        font-size: 1.4rem;
    }

    .faq-section h2,
    .state-cards h2 {
        font-size: 1.25rem;
    }

    .results-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .hero {
        padding: 24px 16px 12px;
    }

    .calculator-box {
        padding: 16px 12px;
    }

    .chart-bars {
        gap: 8px;
        padding: 0 8px;
    }

    .chart-bar {
        width: 36px;
    }

    .chart-bar-label {
        font-size: 0.65rem;
    }
}

/* ---------- Utility ---------- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.input-prefix {
    display: flex;
    align-items: center;
    gap: 4px;
}

.input-prefix .prefix-symbol {
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: 500;
}

.input-prefix input {
    flex: 1;
}

/* ============================================
   NEW: Dark Mode Toggle
   ============================================ */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    color: var(--text);
    transition: all 0.2s;
    flex-shrink: 0;
}

.theme-toggle:hover {
    background: var(--bg);
    border-color: var(--primary);
}

.theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-sun { display: block; }

/* Dark Mode */
body.dark-mode {
    --bg: #1a1a2e;
    --bg-white: #232342;
    --text: #e0e0e0;
    --text-light: #999;
    --border: #363656;
    --primary-light: #1a3060;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.4);
}

body.dark-mode .theme-toggle .icon-moon { display: block; }
body.dark-mode .theme-toggle .icon-sun { display: none; }
body.dark-mode .navbar { background: var(--bg-white); }
body.dark-mode .footer { background: var(--bg-white); }
body.dark-mode .faq-item { background: var(--bg-white); }
body.dark-mode .state-card { background: var(--bg-white); }
body.dark-mode .calculator-box { background: var(--bg-white); }
body.dark-mode .chart-bar.base { background: linear-gradient(180deg, #5566aa 0%, #445599 100%); }
body.dark-mode .guide-content p,
body.dark-mode .privacy-content p { color: #ccc; }
body.dark-mode .guide-content h1,
body.dark-mode .privacy-content h1 { color: #e0e0e0; }
body.dark-mode .guide-content ul li,
body.dark-mode .privacy-content ul li { color: #ccc; }
body.dark-mode .guide-content .callout { background: #1a3060; }
body.dark-mode .tool-card { background: var(--bg-white); }
body.dark-mode .amortization-table tr:nth-child(even) td { background: rgba(255,255,255,0.03); }
body.dark-mode .result-card { background: rgba(255,255,255,0.05); }
body.dark-mode .chart-card { background: rgba(255,255,255,0.05); }
body.dark-mode .chart-container { background: rgba(255,255,255,0.05); }
body.dark-mode .payoff-date-card { background: linear-gradient(135deg, #1a3060 0%, #232342 100%); }
body.dark-mode .pie-legend-color { opacity: 0.9; }

/* Dark mode: pie chart center circle + formula + gov */
body.dark-mode .pie-chart-center { fill: #232342 !important; }
body.dark-mode .pie-chart-text { fill: #e0e0e0 !important; }
body.dark-mode .pie-chart-sub { fill: #999 !important; }
body.dark-mode .formula-card { background: rgba(255,255,255,0.05); border-color: var(--border); }
body.dark-mode .formula-box { background: #1a1a2e; border-color: #363656; color: #e0e0e0; }
body.dark-mode .gov-card { background: var(--bg-white); }
body.dark-mode .what-if-table th { background: var(--primary); }
body.dark-mode .what-if-table tr:nth-child(even) td { background: rgba(255,255,255,0.03); }
body.dark-mode .per-card-row { background: rgba(255,255,255,0.03); }
body.dark-mode .results-empty-state svg { stroke: #363656; }
body.dark-mode .advanced-options { background: rgba(255,255,255,0.02); }
body.dark-mode .field-hint { color: #777; }

/* ============================================
   NEW: Breadcrumb Navigation
   ============================================ */
.breadcrumb {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 8px 20px;
    font-size: 0.78rem;
    color: var(--text-light);
}

.breadcrumb a {
    color: var(--text-light);
}

.breadcrumb a:hover {
    color: var(--primary);
}

.breadcrumb .sep {
    margin: 0 4px;
    color: var(--border);
}

/* ============================================
   NEW: Last Updated Badge
   ============================================ */
.last-updated {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 12px;
    opacity: 0.8;
}

/* ============================================
   NEW: Advanced Options (Collapsible)
   ============================================ */
.advanced-toggle {
    margin-bottom: 16px;
}

.advanced-toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 8px 16px;
    color: var(--text-light);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font);
    width: 100%;
    justify-content: center;
}

.advanced-toggle-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.advanced-toggle-btn svg {
    transition: transform 0.3s;
}

.advanced-toggle-btn.open svg {
    transform: rotate(180deg);
}

.advanced-options {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

.advanced-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.optional-tag {
    font-size: 0.65rem;
    color: var(--text-light);
    background: var(--border);
    border-radius: 3px;
    padding: 1px 5px;
    margin-left: 4px;
}

.field-hint {
    font-size: 0.7rem;
    color: var(--text-light);
    margin-top: 2px;
    font-style: italic;
}

/* ============================================
   NEW: Empty State
   ============================================ */
.results-empty-state {
    text-align: center;
    padding: 40px 20px;
}

.results-empty-state svg {
    margin-bottom: 16px;
}

.empty-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.empty-desc {
    font-size: 0.85rem;
    color: var(--text-light);
    max-width: 400px;
    margin: 0 auto;
    line-height: 1.5;
}

/* ============================================
   NEW: What-If Scenario Table
   ============================================ */
.what-if-section {
    margin-top: 24px;
}

.what-if-section h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.what-if-hint {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 12px;
}

.what-if-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.what-if-table th {
    background: var(--primary);
    color: #fff;
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.what-if-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.what-if-table tr:nth-child(even) td {
    background: var(--bg);
}

.what-if-table tr.current-row td {
    background: var(--primary-light);
    font-weight: 600;
}

.what-if-table .best-time {
    color: var(--success);
    font-weight: 600;
}

/* ============================================
   NEW: Per-Card Breakdown
   ============================================ */
.per-card-section {
    margin-top: 24px;
}

.per-card-section h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
}

.per-card-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.per-card-row {
    display: grid;
    grid-template-columns: 30px 1fr 1fr 1fr 1fr;
    gap: 8px;
    align-items: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 0.82rem;
}

.per-card-row.header {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.per-card-row.paid-off {
    border-color: var(--success);
}

.per-card-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.72rem;
    font-weight: 700;
}

.per-card-row.paid-off .per-card-badge {
    background: var(--success);
    color: #fff;
}

.per-card-row.header .per-card-badge {
    background: transparent;
    color: #fff;
}

/* ============================================
   NEW: Annual/Monthly Toggle for Amortization
   ============================================ */
.amortization-view-toggle {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.view-tab {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-white);
    color: var(--text-light);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font);
}

.view-tab.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Collapse long amortization tables */
.amortization-table-wrapper.collapsed {
    max-height: 500px;
}

.expand-schedule-btn {
    display: block;
    margin: 12px auto 0;
    padding: 6px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-white);
    color: var(--primary);
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font);
}

.expand-schedule-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

/* ============================================
   NEW: Formula Section
   ============================================ */
.formula-section {
    max-width: var(--max-width);
    margin: 0 auto 40px;
    padding: 0 20px;
}

.formula-section h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text);
}

.formula-intro {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 20px;
}

.formula-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 12px;
}

.formula-card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 8px;
}

.formula-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px 16px;
    font-family: 'Courier New', monospace;
    font-size: 0.88rem;
    color: var(--text);
    margin-bottom: 8px;
    line-height: 1.6;
}

.formula-card p {
    font-size: 0.82rem;
    color: var(--text-light);
    line-height: 1.5;
}

/* ============================================
   NEW: Government Resources
   ============================================ */
.gov-resources {
    max-width: var(--max-width);
    margin: 0 auto 48px;
    padding: 0 20px;
}

.gov-resources h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text);
}

.gov-intro {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 20px;
}

.gov-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.gov-card {
    display: block;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
}

.gov-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    text-decoration: none;
}

.gov-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.72rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.gov-card h3 {
    font-size: 0.88rem;
    color: var(--primary);
    margin-bottom: 6px;
    font-weight: 600;
}

.gov-card p {
    font-size: 0.78rem;
    color: var(--text-light);
    line-height: 1.4;
}

/* ============================================
   NEW: State Flag Badge
   ============================================ */
.state-flag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 10px;
    letter-spacing: 1px;
}

/* ============================================
   NEW: Footer Links
   ============================================ */
.footer-links {
    margin: 6px 0;
    line-height: 1.8;
}

.footer-links a {
    font-size: 0.78rem;
}

/* ============================================
   Responsive: New Components
   ============================================ */
@media (max-width: 768px) {
    .advanced-grid {
        grid-template-columns: 1fr;
    }

    .what-if-table {
        font-size: 0.75rem;
    }

    .what-if-table th,
    .what-if-table td {
        padding: 6px 6px;
    }

    .per-card-row {
        grid-template-columns: 24px 1fr 1fr;
        font-size: 0.75rem;
    }

    .per-card-row .col-hide-mobile {
        display: none;
    }

    .gov-grid {
        grid-template-columns: 1fr;
    }

    .formula-box {
        font-size: 0.78rem;
        padding: 10px 12px;
    }

    .state-cards-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   NEW: Trust Badges
   ============================================ */
.trust-badges {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.trust-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-light);
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 6px 14px;
    transition: all 0.2s;
}

.trust-badge:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.trust-badge svg {
    color: var(--success);
}

/* ============================================
   NEW: How To Use Guide
   ============================================ */
.how-to-use {
    max-width: var(--max-width);
    margin: 0 auto 8px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.how-to-step {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px;
    flex: 1;
    min-width: 200px;
    max-width: 280px;
}

.step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
}

.step-content h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}

.step-content p {
    font-size: 0.75rem;
    color: var(--text-light);
    line-height: 1.3;
}

.how-to-arrow {
    font-size: 1.2rem;
    color: var(--border);
    flex-shrink: 0;
}

/* ============================================
   NEW: Extra Payment Slider
   ============================================ */
.slider-section {
    margin-top: 12px;
}

.payment-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border);
    outline: none;
    margin-bottom: 6px;
}

.payment-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 3px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.payment-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 3px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-light);
}

/* ============================================
   NEW: Action Bar (Print, Save, Share, Export)
   ============================================ */
.action-bar {
    display: none;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 24px;
    justify-content: center;
    padding-top: 20px;
    border-top: 2px solid var(--border);
}

.action-bar.active {
    display: flex;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font);
}

.action-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.action-btn svg {
    flex-shrink: 0;
}

/* ============================================
   NEW: Amortization Schedule
   ============================================ */
.amortization-section {
    margin-top: 28px;
}

.amortization-section h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
}

.amortization-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.amortization-tab {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-white);
    color: var(--text-light);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font);
}

.amortization-tab.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.amortization-table-wrapper {
    max-height: none;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.amortization-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    table-layout: fixed;
}

.amortization-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.amortization-table th {
    background: var(--primary);
    color: #fff;
    padding: 8px 6px;
    text-align: left;
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.amortization-table td {
    padding: 7px 6px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.amortization-table tr:nth-child(even) td {
    background: var(--bg);
}

.amortization-table tr.payoff-row td {
    background: rgba(26, 138, 92, 0.08);
    font-weight: 600;
    color: var(--success);
}

/* ============================================
   NEW: SVG Charts (Line + Pie)
   ============================================ */
.chart-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.chart-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.chart-card-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
    text-align: center;
}

.svg-chart {
    width: 100%;
    height: auto;
}

.pie-legend {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 8px;
    font-size: 0.78rem;
    color: var(--text-light);
}

.pie-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pie-legend-color {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

/* ============================================
   NEW: Payoff Date Display
   ============================================ */
.payoff-date-card {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--bg) 100%);
    border: 1px solid var(--primary);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    margin-bottom: 20px;
}

.payoff-date-label {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 6px;
}

.payoff-date-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
}

.payoff-date-sub {
    font-size: 0.8rem;
    color: var(--success);
    margin-top: 4px;
    font-weight: 500;
}

/* ============================================
   NEW: Disclaimer
   ============================================ */
.disclaimer-section {
    max-width: var(--max-width);
    margin: 0 auto 40px;
    padding: 0 20px;
}

.disclaimer-section p {
    font-size: 0.78rem;
    color: var(--text-light);
    line-height: 1.6;
    background: var(--bg);
    border-left: 3px solid var(--border);
    padding: 12px 16px;
    border-radius: 0 6px 6px 0;
}

/* ============================================
   NEW: Related Tools
   ============================================ */
.related-tools {
    max-width: var(--max-width);
    margin: 0 auto 48px;
    padding: 0 20px;
}

.related-tools h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text);
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.tool-card {
    display: block;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
}

.tool-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    text-decoration: none;
}

.tool-card h3 {
    font-size: 0.9rem;
    color: var(--primary);
    margin-bottom: 6px;
    font-weight: 600;
}

.tool-card p {
    font-size: 0.78rem;
    color: var(--text-light);
    line-height: 1.4;
}

/* ============================================
   NEW: Print Styles
   ============================================ */
@media print {
    .navbar,
    .navbar-mobile-toggle,
    .theme-toggle,
    .breadcrumb,
    .how-to-use,
    .trust-badges,
    .faq-section,
    .state-cards,
    .related-tools,
    .disclaimer-section,
    .formula-section,
    .gov-resources,
    .footer,
    .action-bar,
    .add-card-btn,
    .card-remove-btn,
    .min-pay-mode,
    .min-pay-hint,
    .slider-section,
    .advanced-toggle,
    .saved-scenarios-panel,
    .expand-schedule-btn,
    .per-card-toggle,
    .amortization-toggle,
    .amortization-view-toggle,
    #calculateBtn {
        display: none !important;
    }

    .calculator-box {
        box-shadow: none;
        border: none;
        max-width: 100%;
        padding: 0;
    }

    body {
        background: #fff;
        color: #000;
        font-size: 11pt;
    }

    .results,
    .amortization-table-wrapper {
        display: block !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .chart-container,
    .chart-card,
    .chart-row,
    .result-card,
    .per-card-row,
    .what-if-section,
    .per-card-section {
        break-inside: avoid;
    }

    .amortization-table {
        font-size: 9pt;
    }

    .amortization-table th,
    .amortization-table td {
        border: 1px solid #ccc;
    }

    .hero h1 {
        font-size: 1.5rem;
    }

    .hero .subtitle {
        font-size: 0.9rem;
    }

    .results-grid {
        break-inside: avoid;
    }

    .strategy-comparison {
        break-inside: avoid;
    }

    .per-card-list {
        break-inside: avoid;
    }

    /* Show dark-mode SVG chart elements as black-on-white in print */
    .svg-chart text {
        fill: #333 !important;
    }

    .pie-chart-center {
        fill: #fff !important;
    }

    /* Ensure card input rows print for reference */
    .card-row {
        break-inside: avoid;
        border: 1px solid #ddd;
        padding: 8px;
        margin-bottom: 8px;
    }

    .card-fields {
        display: flex;
        gap: 16px;
    }

    .extra-payment-section {
        break-inside: avoid;
    }
}

/* ============================================
   Responsive: New Components
   ============================================ */
@media (max-width: 768px) {
    .trust-badges {
        gap: 8px;
    }

    .trust-badge {
        font-size: 0.72rem;
        padding: 5px 10px;
    }

    .how-to-use {
        flex-direction: column;
        gap: 8px;
    }

    .how-to-arrow {
        transform: rotate(90deg);
    }

    .how-to-step {
        max-width: 100%;
        width: 100%;
    }

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

    .tools-grid {
        grid-template-columns: 1fr;
    }

    .action-bar {
        gap: 8px;
    }

    .action-btn {
        font-size: 0.78rem;
        padding: 8px 12px;
    }

    .payoff-date-value {
        font-size: 1.4rem;
    }

    .navbar-inner {
        gap: 8px;
    }
}

/* ============================================
   NEW: Cross Links (State Guide Interlinking)
   ============================================ */
.cross-links {
    max-width: var(--max-width);
    margin: 0 auto 40px;
    padding: 0 20px;
}

.cross-links h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text);
}

.cross-links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.cross-link-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.cross-link-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--primary);
}

.cross-link-card .state-flag {
    width: 32px;
    height: 32px;
    font-size: 0.72rem;
    margin-bottom: 0;
}

@media (max-width: 768px) {
    .cross-links-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .cross-links-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   NEW: Warning Banner (unpayable debt)
   ============================================ */
.warning-banner {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 20px;
    font-size: 0.85rem;
    color: #856404;
    line-height: 1.5;
}

.warning-banner strong {
    font-size: 0.9rem;
}

body.dark-mode .warning-banner {
    background: #3d3210;
    border-color: #8a6d00;
    color: #ffd54f;
}

/* ============================================
   NEW: Per-Card Header with Strategy Toggle
   ============================================ */
.per-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.per-card-header h3 {
    margin-bottom: 0;
}

.per-card-toggle {
    display: flex;
    gap: 6px;
}

.per-card-tab {
    padding: 5px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-white);
    color: var(--text-light);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font);
}

.per-card-tab.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.per-card-tab:hover:not(.active) {
    border-color: var(--primary);
    color: var(--primary);
}

/* ============================================
   NEW: Saved Scenarios Panel
   ============================================ */
.saved-scenarios-panel {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-top: 16px;
    box-shadow: var(--shadow);
}

.saved-scenarios-panel h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
}

.saved-scenarios-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.saved-scenario-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    gap: 12px;
}

.saved-scenario-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.saved-scenario-date {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.saved-scenario-detail {
    font-size: 0.75rem;
    color: var(--text-light);
}

.saved-scenario-result {
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 500;
}

.saved-scenario-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.saved-scenario-load {
    padding: 6px 14px;
    border: 1px solid var(--primary);
    border-radius: 6px;
    background: var(--primary);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font);
}

.saved-scenario-load:hover {
    opacity: 0.9;
}

.saved-scenario-delete {
    padding: 6px 10px;
    border: 1px solid #e74c3c;
    border-radius: 6px;
    background: transparent;
    color: #e74c3c;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font);
}

.saved-scenario-delete:hover {
    background: #e74c3c;
    color: #fff;
}

.saved-scenarios-empty {
    text-align: center;
    padding: 24px;
    color: var(--text-light);
    font-size: 0.85rem;
}

body.dark-mode .saved-scenario-item {
    background: rgba(255,255,255,0.03);
}

@media (max-width: 768px) {
    .saved-scenario-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .per-card-header {
        flex-direction: column;
        align-items: flex-start;
    }
}
