:root {
    --primary: #2c3e50;
    --secondary: #ff6b6b;
    --accent: #3d5a80;
    --light-bg: #f8f9fa;
    --teal: #4ecdc4;
    --border-color: #e0e0e0;
    --text-color: #000000;
    --text-light: #666;
    --shadow: 0 4px 12px rgba(0,0,0,0.08);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Times New Roman', Times, serif;
    font-size: 1rem;
    line-height: 1.6;
    color: #000;
    background-color: #f0f4f8;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    width: 100%;
}

/* Main Content */
.container {
    max-width: 1400px;
    margin: 0px auto;
    flex: 1;
    width: 100%;
    padding: 0px 10px;
}

.content-wrapper {
    display: grid;
    gap: 25px;
}

/* Calculator Styles */
.calculator-card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
    /* Added for horizontal scrolling */
    overflow-x: auto;
    max-width: 100%;
}

.calculator-header {
    background: white;
    color: var(--primary);
    padding: 1.5rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

h1 {
    font-size: 1.5rem;
    color: #000;
}

h2 {
    font-size: 1.375rem;
    color: #ff6b6b;
}

h3 {
    font-size: 1.25rem;
    color: #000;
}

h4 {
    font-size: 1.125rem;
    color: #000;
}

.calculator-description {
    font-size: 1rem;
    max-width: 800px;
    margin: 0 auto;
    color: #000;
}

.calculator-body {
    padding: 2rem;
    /* Added for horizontal scrolling */
    min-width: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #000;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: inherit;
    font-size: 1rem;
    color: #000;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(61, 90, 128, 0.2);
}

/* Toggle Button Styles */
.toggle-container {
    display: flex;
    align-items: center;
    margin-top: 0.5rem;
    background: var(--light-bg);
    border-radius: 30px;
    padding: 2px;
    height: 44px;
}

.toggle-option {
    flex: 1;
    text-align: center;
    padding: 10px;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 1rem;
    color: #000;
}

.toggle-option.active {
    background: var(--accent);
    color: white;
}

.percentage-indicator {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-weight: 500;
    pointer-events: none;
    font-size: 1rem;
}

.input-wrapper {
    position: relative;
}

.form-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.btn {
    padding: 0.85rem 1.75rem;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 1rem;
    color: #000;
}

.btn-primary {
    background: linear-gradient(to right, var(--accent), var(--primary));
    color: white;
    flex: 1;
}

.btn-secondary {
    background: linear-gradient(to right, var(--secondary), #e55c5c);
    color: white;
    flex: 1;
}

.btn-export {
    background: linear-gradient(to right, #4ecdc4, #2a9d8f);
    color: white;
    padding: 0.75rem 1.5rem;
    margin: 0 5px;
    font-size: 1rem;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.1);
}

/* Results Section */
.results-section {
    margin-top: 2.5rem;
    display: none;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.export-options {
    display: flex;
    gap: 0.75rem;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.result-card {
    background-color: white;
    border-radius: 8px;
    padding: 1.25rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: transform 0.3s ease;
    min-width: 0; /* Fix for container expansion */
}

.result-card:hover {
    transform: translateY(-5px);
}

.result-value {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--accent);
    margin: 0.5rem 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.result-label {
    color: var(--text-light);
    font-size: 1rem;
}

.visualization {
    margin-top: 2rem;
    padding: 1.5rem;
    background-color: var(--light-bg);
    border-radius: 8px;
}

.chart-container {
    height: 200px; /* Reduced from 250px */
    margin-top: 1rem;
    position: relative;
}

/* Calculation Options Section */
.calculation-options-section {
    margin-top: 2rem;
    background-color: white;
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

.options-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.option-card {
    padding: 1.5rem;
    border-radius: 8px;
    background-color: var(--light-bg);
    transition: all 0.3s ease;
}

.option-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
}

.option-card h3 {
    color: #000;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
}

.option-card ul {
    padding-left: 1.5rem;
    margin-top: 0.75rem;
    color: #000;
}

.option-card li {
    margin-bottom: 0.5rem;
    font-size: 1rem;
    color: #000;
}

.option-card .highlight {
    background-color: rgba(78, 205, 196, 0.2);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    color: #000;
}

.option-card .value {
    font-weight: 600;
    color: var(--accent);
}

/* Amortization Table Styles */
.amortization-section {
    margin-top: 2rem;
    padding: 1.5rem;
    background-color: var(--light-bg);
    border-radius: 8px;
}

.amortization-table-container {
    max-height: 400px;
    overflow-y: auto;
    margin-top: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    /* Added for horizontal scrolling */
    overflow-x: auto;
}

.amortization-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.amortization-table th {
    background-color: var(--accent);
    color: white;
    padding: 12px 15px;
    text-align: left;
    position: sticky;
    top: 0;
    font-size: 1rem;
}

.amortization-table td {
    padding: 10px 15px;
    border-bottom: 1px solid var(--border-color);
    color: #000;
    font-size: 1rem;
}

.amortization-table tr:nth-child(even) {
    background-color: var(--light-bg);
}

.amortization-table tr:hover {
    background-color: rgba(78, 205, 196, 0.1);
}

.amortization-table .amount {
    text-align: right;
    font-family: monospace;
}

.amortization-table .date {
    white-space: nowrap;
}

/* Export buttons container below amortization table */
.amortization-export {
    display: flex;
    justify-content: center;
    margin-top: 20px;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Ad Styles */
.ad-container {
    background-color: #f0f5ff;
    border: 1px dashed #a0b8e0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin: 0 auto;
    position: relative;
}

.ad-label {
    position: absolute;
    top: 0;
    right: 0;
    background-color: rgba(0,0,0,0.3);
    color: white;
    font-size: 1rem;
    padding: 0.25rem 0.5rem;
    border-bottom-left-radius: 6px;
}

.ad-content {
    padding: 1.5rem;
    text-align: center;
    color: #4a6fc9;
    font-weight: 500;
    font-size: 1rem;
}

#ad-left, #ad-right {
    width: 100%;
    height: 250px;
}

#ad-tablet {
    width: 300px;
    height: 250px;
    margin: 10px auto 0;
}

#ad-mobile {
    width: 320px;
    height: 100px;
    margin: 0 auto;
}

/* Sidebar Styling */
.sidebar-sticky-container {
    position: sticky;
    top: 20px;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

/* Related Tools */
.related-tools {
    background-color: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.related-tools h2,
.related-tools h3 {
    color: #ff6b6b;
}

.tools-list {
    list-style: none;
}

.tools-list li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    color: #000;
}

.tools-list li:last-child {
    border-bottom: none;
}

.tools-list a {
    color: #000;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
}

.tools-list a:hover {
    color: var(--teal);
}

/* Custom Days Input */
.custom-days-container {
    display: none;
    margin-top: 10px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Loading indicator */
.pdf-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    display: none;
}

.pdf-loading .spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(61, 90, 128, 0.3);
    border-top: 5px solid #3d5a80;
    border-radius: 3px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.pdf-loading p {
    font-size: 1.5rem;
    color: #3d5a80;
    font-weight: bold;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Add breadcrumb styles */
.breadcrumb {
    padding: 0px 10px;
    color: #000;
    margin-bottom: 5px;
    font-size: 1rem;
}

.breadcrumb a {
    color: #000;
    text-decoration: none;
    transition: color 0.3s;
}

.breadcrumb a:hover {
    color: var(--secondary);
    text-decoration: underline;
}

/* Responsive Design - Mobile First Approach */
@media (max-width: 767px) {
    h1 { 
        font-size: 1.25rem;
        color: #000;
    }
    
    h2 {
        font-size: 1.125rem;
        color: #ff6b6b;
    }
    
    h3 {
        font-size: 1rem;
        color: #000;
    }
    
    h4 {
        font-size: 0.9375rem;
        color: #000;
    }
    
    html {
        overflow-x: hidden;
        width: 100%;
    }
    
    body { 
        padding: 0;
        margin: 0;
        width: 100%;
        min-width: 0;
        overflow-x: hidden;
    }
    
    .container {
        width: calc(100%);
        max-width: calc(100%);
        min-width: 0;
        margin: 0 auto;
      
    }
    
    .content-wrapper {
        display: block;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
    
    .calculator-container {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .calculator-card {
        width: 100%;
        min-width: 100%;
        margin: 0 0 20px 0;
        overflow: hidden;
    }
    
    .calculator-header {
        padding: 1rem;
        width: 100%;
        min-width: 0;
    }
    
    .calculator-body { 
        padding: 1rem;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow: hidden;
    }
    
    .form-grid { 
        display: flex;
        flex-direction: column;
        gap: 1rem;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
    
    .form-group {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        flex-shrink: 1;
        margin-bottom: 1rem;
    }
    
    .form-group label {
        display: block;
        width: 100%;
        margin-bottom: 0.5rem;
        color: #000;
        font-size: 1rem;
    }
    
    .form-group input, 
    .form-group select {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        font-size: 1rem;
        padding: 0.75rem;
        border: 1px solid var(--border-color);
        border-radius: 6px;
    }
    
    .input-wrapper {
        position: relative;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
    
    .percentage-indicator {
        position: absolute;
        right: 8px;
        top: 50%;
        transform: translateY(-50%);
        color: var(--text-light);
        font-weight: 500;
        pointer-events: none;
        font-size: 1rem;
        z-index: 1;
    }
    
    .toggle-container {
        display: flex;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        background: var(--light-bg);
        border-radius: 30px;
        padding: 2px;
        height: 44px;
        margin-top: 0.5rem;
    }
    
    .toggle-option {
        flex: 1 1 50%;
        text-align: center;
        padding: 8px 4px;
        border-radius: 30px;
        cursor: pointer;
        transition: all 0.3s ease;
        font-weight: 500;
        font-size: 0.875rem;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        color: #000;
    }
    
    .toggle-option.active {
        background: var(--accent);
        color: white;
    }
    
    .form-buttons { 
        display: flex;
        flex-direction: column;
        width: 100%;
        max-width: 100%;
        gap: 0.75rem;
        margin-top: 1.5rem;
        min-width: 0;
    }
    
    .btn {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        padding: 0.85rem;
        font-size: 1rem;
        margin: 0;
        flex-shrink: 0;
    }
    
    .results-section {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        margin-top: 2rem;
        overflow: hidden;
    }
    
    .results-header {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
    
    .export-options {
        display: flex;
        width: 100%;
        max-width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.5rem;
        min-width: 0;
    }
    
    .btn-export {
        flex: 1 1 calc(50% - 0.25rem);
        min-width: 0;
        max-width: calc(50% - 0.25rem);
        padding: 0.7rem 0.5rem;
        font-size: 1rem;
        text-align: center;
    }
    
    .results-grid { 
        display: flex;
        flex-direction: column;
        width: 100%;
        max-width: 100%;
        gap: 1rem;
        margin-top: 1.5rem;
        min-width: 0;
    }
    
    .result-card {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        margin: 0;
        padding: 1rem;
        flex-shrink: 1;
        overflow: hidden;
    }
    
    .result-value {
        font-size: 1.25rem;
        word-break: break-word;
        overflow-wrap: break-word;
        max-width: 100%;
        text-align: center;
        line-height: 1.3;
        white-space: normal;
    }
    
    .result-label {
        color: var(--text-light);
        font-size: 1rem;
        text-align: center;
        margin-top: 0.5rem;
    }
    
    .calculation-options-section {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        margin-top: 2rem;
        padding: 1rem;
        overflow: hidden;
    }
    
    .options-grid-container { 
        display: flex;
        flex-direction: column;
        width: 100%;
        max-width: 100%;
        gap: 1.5rem;
        margin-top: 1rem;
        min-width: 0;
    }
    
    .option-card {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        padding: 1.5rem;
        margin: 0;
        overflow: hidden;
    }
    
    .option-card h3 {
        font-size: 1rem;
        color: #000;
    }
    
    .option-card li {
        font-size: 1rem;
    }
    
    .visualization {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        margin-top: 2rem;
        padding: 1rem;
        overflow: hidden;
    }
    
    .chart-container {
        height: 160px;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow: hidden;
        position: relative;
    }
    
    .amortization-section {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        margin-top: 2rem;
        padding: 1rem;
        overflow: hidden;
    }
    
    .amortization-table-container {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow-x: auto;
        overflow-y: auto;
        max-height: 400px;
        margin-top: 1rem;
        -webkit-overflow-scrolling: touch;
    }
    
    .amortization-table {
        min-width: 500px;
        width: max-content;
        border-collapse: collapse;
    }
    
    .amortization-table th,
    .amortization-table td {
        padding: 8px 10px;
        font-size: 1rem;
        white-space: nowrap;
    }
    
    .amortization-export {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
        max-width: 100%;
        gap: 0.5rem;
        margin-top: 20px;
        min-width: 0;
    }
    
    .custom-days-container {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        margin-top: 10px;
    }
    
    #ad-left, #ad-right, #ad-tablet { 
        display: none; 
    }
    
    #ad-mobile { 
        display: block; 
        margin: 20px auto;
        width: 100%;
        max-width: 320px;
        min-width: 0;
    }
    
    .ad-container {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow: hidden;
    }
    
    .non-desktop { 
        display: block; 
    }
    
    .desktop-only { 
        display: none; 
    }
    
    .mobile-tools { 
        display: block; 
        margin-top: 20px;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
    
    .related-tools {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        margin-top: 10px;
        padding: 1rem;
        overflow: hidden;
    }
    
    .tools-list {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
    
    .tools-list li {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow: hidden;
    }
    
    .tools-list a {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 1rem;
    }
}

@media (min-width: 768px) and (max-width: 1024px) {
    h1 { 
        font-size: 1.25rem;
        color: #000;
    }
    
    h2 { 
        font-size: 1.25rem;
        color: #ff6b6b;
    }
    
    h3 {
        font-size: 1.125rem;
        color: #000;
    }
    
    h4 {
        font-size: 1rem;
        color: #000;
    }
    
    .content-wrapper { grid-template-columns: 1fr; }
    #ad-left, #ad-right, #ad-mobile { display: none; }
    #ad-tablet { display: block; margin: 10px auto 20px; }
    .non-desktop { display: flex; flex-direction: column; align-items: center; }
    .desktop-only { display: none; }
    .mobile-tools { display: block; width: 100%; margin-top: 20px; }
    .related-tools {
        position: static;
    }
    .chart-container {
        height: 180px;
    }
}

@media (min-width: 1025px) {
    h1 {
        font-size: 1.5rem;
        color: #000;
    }
    
    h2 { 
        font-size: 1.375rem;
        color: #ff6b6b;
    }
    
    h3 { 
        font-size: 1.25rem;
        color: #000;
    }
    
    h4 { 
        font-size: 1.125rem;
        color: #000;
    }
    
    .content-wrapper {
        grid-template-columns: 300px 1fr 300px;
    }
    #ad-tablet, #ad-mobile { display: none; }
    .non-desktop { display: none; }
    .desktop-only { display: block; }
    .mobile-tools { display: none; }
    .sidebar-sticky-container {
        position: sticky;
        top: 20px;
        height: calc(100vh - 40px);
        overflow-y: auto;
    }
    .sidebar-sticky-container::-webkit-scrollbar {
        width: 6px;
    }
    .sidebar-sticky-container::-webkit-scrollbar-thumb {
        background-color: var(--accent);
        border-radius: 3px;
    }
}

.mobile-table {
    overflow-x: auto;
    margin: 20px 0;
    border: 1px solid #eee;
    border-radius: 8px;
}

.mobile-table table {
    width: 100%;
    min-width: 600px;
    border-collapse: collapse;
}

.mobile-table th, .mobile-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
    color: #000;
    font-size: 1rem;
}

.mobile-table th {
    background-color: #4ecdc4;
    font-weight: bold;
    font-size: 1rem;
    color: #000;
}

.mobile-table td {
    font-size: 1rem;
}

.mobile-table tr:nth-child(even) {
    background-color: #fafafa;
}