/* Calculator styles */
/* NB: no :root token block here on purpose. The design tokens (--primary*, --gray*,
   --shadow*) come from style.css and are overridden by the active theme's theme.css,
   which loads BEFORE this file. Re-declaring them here would clobber the theme on every
   calculator page (the accent + canvas would ignore the selected theme). Use the tokens,
   don't redefine them. */

/* .tool-header and .tool-form are core components (style.css).
   This file carried a byte-identical copy of both, as did rates.css -- the
   same component defined three times, so a change had to be made in three
   places or the families silently drifted apart. Core's .tool-header h1
   additionally carries overflow-wrap: break-word, which this copy lacked. */

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    /* Explicit: style.css's converter .form-grid sets align-items: end, which
       would otherwise leak in here and bottom-align fields whose hint text
       wraps differently. */
    align-items: start;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--gray-700);
    font-size: 0.9375rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--gray-300);
    border-radius: 0.5rem;
    font-size: 1rem;
    color: var(--gray-800);
    transition: all 0.2s ease;
}

.text-muted {
    color: var(--gray-600);
    font-size: 0.875rem;
    margin-top: 0.375rem;
    display: block;
}

/* Wrapper for tenure and date inputs */
.tenure-wrapper,
.date-wrapper {
    display: flex;
    gap: 0.75rem;
}

.tenure-wrapper .form-control,
.date-wrapper .form-control {
    flex: 1;
}

.tenure-wrapper select,
.date-wrapper select {
    width: auto;
    min-width: 120px;
}

/* Result Cards */
.calculator-result {
    margin-top: 2rem;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.result-card {
    text-align: center;
    padding: 1.75rem 1.5rem;
    background: var(--gray-50);
    border-radius: 0.75rem;
    border: 1px solid var(--gray-200);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    min-width: 0;
}

.result-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

.result-card h4 {
    color: var(--gray-700);
    margin-bottom: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
}

.result-card .amount {
    color: var(--primary);
    font-size: 1.875rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

/* Chart Section */
.chart-section {
    background: white;
    padding: 2rem;
    border-radius: 0.75rem;
    box-shadow: var(--shadow-md);
    margin: 2rem 0;
}

.chart-section h3 {
    margin-bottom: 1.5rem;
    color: var(--gray-900);
    font-size: 1.25rem;
    font-weight: 600;
}

.chart-container {
    height: 400px;
    position: relative;
}

.chart-legend {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 1.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--gray-700);
    font-size: 0.9375rem;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

/* Schedule Section */
.schedule-section {
    margin: 2rem 0;
}

.schedule-section h3 {
    margin-bottom: 1.5rem;
    color: var(--gray-900);
    font-size: 1.25rem;
    font-weight: 600;
}

.schedule-table {
    overflow-x: auto;
    background: white;
    border-radius: 0.75rem;
    box-shadow: var(--shadow-md);
}

.table-header {
    display: grid;
    grid-template-columns: repeat(var(--cols, 6), 1fr);
    padding: 1rem;
    background: var(--primary);
    color: white;
    border-radius: 0.75rem 0.75rem 0 0;
    font-weight: 600;
    text-align: center;
}

.text-center {
    text-align: center;
}

.year-row {
    display: grid;
    grid-template-columns: repeat(var(--cols, 6), 1fr);
    padding: 1rem;
    transition: all 0.2s ease;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    text-align: center;
}

.year-row > div:first-child {
    text-align: left;
    position: relative;
}

/* Only expandable rows (those followed by a month breakdown) get the pointer,
   the +/- affordance and the hover highlight. Static year rows (SWP/EPF/NSC/
   step-up SIP) reuse this class purely for its grid layout. */
.year-row:has(+ .month-details) {
    cursor: pointer;
}

.year-row:has(+ .month-details) > div:first-child {
    padding-left: 1.5rem;
}

.year-row:has(+ .month-details) > div:first-child::before {
    content: '+';
    position: absolute;
    left: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-weight: bold;
    color: var(--gray-700);
}

.year-row.expanded > div:first-child::before {
    content: '-';
}

.year-row > div:not(:first-child) {
    text-align: right;
    padding-right: 1rem;
}

.year-row:has(+ .month-details):hover {
    background: var(--gray-100);
}

.month-details {
    display: none;
    background: white;
}

.month-details.active {
    display: block;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.month-row {
    display: grid;
    grid-template-columns: repeat(var(--cols, 6), 1fr);
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.9375rem;
    background: white;
}

.month-row > div:first-child {
    text-align: left;
}

.month-row > div:not(:first-child) {
    text-align: right;
    padding-right: 1rem;
}

.month-row:last-child {
    border-bottom: none;
}

.month-row:hover {
    background: var(--gray-50);
}

/* Static breakdown rows that live directly under a .table-header inside a
   .breakdown-table (SCSS/POMIS summaries, XIRR cash-flow ledger). They share
   the header's column grid via --cols so cells stay aligned with their labels. */
.summary-row,
.cash-flow-data-row {
    display: grid;
    grid-template-columns: repeat(var(--cols, 6), 1fr);
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.9375rem;
    background: white;
    text-align: center;
}

.summary-row > div:first-child,
.cash-flow-data-row > div:first-child {
    text-align: left;
}

.summary-row > div:not(:first-child),
.cash-flow-data-row > div:not(:first-child) {
    text-align: right;
    padding-right: 1rem;
}

.summary-row:last-child,
.cash-flow-data-row:last-child {
    border-bottom: none;
}

.summary-row:hover,
.cash-flow-data-row:hover {
    background: var(--gray-50);
}

/* Breakdown Section */
.breakdown-section {
    margin: 2rem 0;
}

.breakdown-section h3 {
    margin-bottom: 1.5rem;
    color: var(--gray-900);
    font-size: 1.25rem;
    font-weight: 600;
}

.breakdown-table {
    overflow-x: auto;
    background: white;
    border-radius: 0.75rem;
    box-shadow: var(--shadow-md);
}

/* Calculation Section */
.calculation-section {
    background: white;
    padding: 1.75rem;
    border-radius: 0.75rem;
    box-shadow: var(--shadow-md);
    margin: 2rem 0;
}

.calculation-section h3 {
    color: var(--gray-900);
    font-size: 1.25rem;
    margin-bottom: 1.25rem;
    font-weight: 600;
}

.calculation-section h4 {
    color: var(--gray-900);
    font-size: 1.125rem;
    margin: 1.5rem 0 1rem;
    font-weight: 600;
}

/* Calculation Table */
.calculation-table {
    background: var(--gray-50);
    border-radius: 0.75rem;
    border: 1px solid var(--gray-200);
    overflow: hidden;
    margin-bottom: 1.25rem;
}

.table-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.9375rem;
}

.table-row:last-child {
    border-bottom: none;
}

.table-row.total {
    background-color: white;
    border-top: 1px solid var(--gray-200);
    font-weight: 600;
}

.table-label {
    color: var(--gray-700);
    font-weight: 500;
}

.table-value {
    color: var(--gray-900);
    font-weight: 500;
}

/* Annual Summary */
.annual-summary {
    margin-top: 1.5rem;
}

.annual-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
    margin-top: 0.75rem;
}

.annual-label {
    display: block;
    font-size: 0.8125rem;
    color: var(--gray-600);
    margin-bottom: 0.25rem;
}

.annual-value {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--gray-900);
}

/* Layout — .content-with-sidebar / .main-content / .sidebar-widget are the
   single-owner sidebar skeleton in style.css (shared by every tool family). */

/* .tool-links / .tool-link are core components (style.css) --
   the same sidebar pill core already documents .sidebar-widget-links as
   mirroring. Copy removed. */

/* The FAQ accordion is a core component (style.css). This file carried a
   byte-identical copy of all its rules, as did rates.css -- the same
   accordion defined three times over. */

/* About section: standard article treatment comes from style.css */

/* Features Grid */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin: 1.5rem 0 2rem;
}

.feature {
    background: white;
    padding: 1.75rem;
    border-radius: 0.75rem;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    border: 1px solid var(--gray-200);
    height: 100%;
}

.feature:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

.feature h4 {
    color: var(--primary);
    font-size: 1.125rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.feature p {
    color: var(--gray-700);
    font-size: 0.9375rem;
    line-height: 1.6;
    margin: 0;
}

/* Comparison Table */
.comparison-table {
    margin: 1.5rem 0;
    overflow-x: auto;
}

.comparison-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

.comparison-table th {
    background: var(--primary);
    color: white;
    text-align: left;
    padding: 0.875rem 1.25rem;
    font-weight: 600;
}

.comparison-table th:first-child {
    border-top-left-radius: 0.5rem;
}

.comparison-table th:last-child {
    border-top-right-radius: 0.5rem;
}

.comparison-table td {
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--gray-200);
    color: var(--gray-700);
}

.comparison-table tr:nth-child(even) {
    background: var(--gray-50);
}

.comparison-table tr:last-child td:first-child {
    border-bottom-left-radius: 0.5rem;
}

.comparison-table tr:last-child td:last-child {
    border-bottom-right-radius: 0.5rem;
}

/* Code blocks */
pre {
    background: var(--gray-50);
    padding: 1.25rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    font-family: monospace;
    margin: 1.25rem 0;
    border: 1px solid var(--gray-200);
    font-size: 0.875rem;
    color: var(--gray-800);
}

/* Utility classes */
.mt-4 {
    margin-top: 1.5rem;
}

.text-center {
    text-align: center;
}

/* Hide columns on mobile */
.hide-mobile {
    display: block;
}

/* Responsive Design */
@media (max-width: 1024px) {
    /* .content-with-sidebar / .sidebar collapse handled centrally in style.css */
    .features-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

@media (max-width: 768px) {
    .tool-header h1 {
        font-size: 1.75rem;
    }
    
    .tool-header p {
        font-size: 1rem;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .result-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    /* Headline amounts at the input limits run to 15+ digits; shrink with
       the screen, and wrap rather than push the card past the page edge. */
    .result-card .amount {
        font-size: clamp(1.25rem, 6vw, 1.875rem);
    }

    .tenure-wrapper,
    .date-wrapper {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .tenure-wrapper select,
    .date-wrapper select {
        width: 100%;
        min-width: 100%;
    }
    
    /* Each row is its own grid, so `1fr` tracks sized themselves from their
       own content and a row of long amounts drifted out of line with the
       header. A fixed per-column minimum gives every row the same tracks; the
       matching row min-width makes the rows scroll together inside the
       .schedule-table / .breakdown-table scroller instead of spilling out of
       their own box. overflow-wrap is the backstop for amounts at the input
       limits, which wrap inside their cell rather than into the next one. */
    .table-header,
    .year-row,
    .month-row,
    .summary-row,
    .cash-flow-data-row {
        --col-min: 6rem;
        grid-template-columns: repeat(var(--cols-m, 4), minmax(var(--col-min), 1fr));
        min-width: calc(var(--cols-m, 4) * var(--col-min) + (var(--cols-m, 4) - 1) * 0.5rem + 1.5rem);
        gap: 0.5rem;
        font-size: 0.875rem;
        padding: 0.75rem;
    }

    .table-header > div,
    .year-row > div,
    .month-row > div,
    .summary-row > div,
    .cash-flow-data-row > div {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .hide-mobile {
        display: none;
    }

    .year-row > div:not(:first-child),
    .month-row > div:not(:first-child),
    .summary-row > div:not(:first-child),
    .cash-flow-data-row > div:not(:first-child) {
        text-align: right;
        padding-right: 0.5rem;
    }

    .schedule-table {
        margin: 0 -1rem;
        padding: 0 1rem;
        width: calc(100% + 2rem);
    }
    
    .annual-grid {
        grid-template-columns: 1fr;
    }
    
    .chart-legend {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
    }
    
    .faq-grid {
        grid-template-columns: 1fr;
    }
    
}

/* Calculators Index Page Styles */
.calculators-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.calculator-card {
    background: white;
    border-radius: 0.75rem;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid var(--gray-200);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.calculator-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.calculator-card-header {
    padding: 1.5rem;
    background: var(--primary-light);
    color: white;
}

.calculator-card-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.calculator-card-body {
    padding: 1.5rem;
    flex: 1;
}

.calculator-card-body p {
    color: var(--gray-700);
    margin: 0;
    line-height: 1.6;
    font-size: 0.9375rem;
}

.calculator-card-footer {
    padding: 1.25rem 1.5rem;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
}

.calculator-card-footer a {
    display: inline-flex;
    align-items: center;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9375rem;
    transition: all 0.2s ease;
}

.calculator-card-footer a:hover {
    color: var(--primary-dark);
}

.calculator-card-footer a svg {
    margin-left: 0.5rem;
}

/* Category Section */
.category-section {
    margin: 3rem 0;
}

.category-section h2 {
    font-size: 1.75rem;
    margin-bottom: 1rem;
    color: var(--gray-900);
    font-weight: 700;
}

.category-section p {
    color: var(--gray-700);
    margin-bottom: 1.5rem;
    font-size: 1.0625rem;
}

/* Search Box */
.calculator-search-container {
    max-width: 600px;
    margin: 2rem auto;
}

.calculator-search-wrapper {
    position: relative;
    border-radius: 0.75rem;
    background: white;
    box-shadow: var(--shadow-md);
    padding: 0.25rem;
}

.calculator-search-input {
    width: 100%;
    padding: 1rem 1.25rem;
    border: 1px solid var(--gray-300);
    border-radius: 0.5rem;
    font-size: 1.0625rem;
    color: var(--gray-800);
    transition: all 0.3s ease;
}

.calculator-search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-glow);
}

.calculator-search-results {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    background: white;
    border-radius: 0.75rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-200);
    z-index: 9999;
    display: none;
    overflow: hidden;
}

.calculator-search-result-item {
    display: block;
    padding: 1rem 1.25rem;
    color: var(--gray-800);
    text-decoration: none;
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--gray-200);
}

.calculator-search-result-item:last-child {
    border-bottom: none;
}

.calculator-search-result-item:hover {
    background-color: var(--gray-50);
    color: var(--primary);
}

.calculator-search-result-title {
    font-weight: 500;
    font-size: 1rem;
}

/* Tax Regime Selector */
.tax-regime-selector {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    background: var(--gray-50);
    padding: 1.25rem;
    border-radius: 0.75rem;
    border: 1px solid var(--gray-200);
}

.regime-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.regime-option label {
    font-weight: 500;
    cursor: pointer;
    color: var(--gray-800);
}

.regime-option input {
    cursor: pointer;
    width: 1.25rem;
    height: 1.25rem;
}

/* Form Sections */
.form-section {
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--gray-200);
    padding-bottom: 1.5rem;
}

.form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.form-section h3 {
    margin-bottom: 1.25rem;
    color: var(--gray-900);
    font-size: 1.125rem;
    font-weight: 600;
}

/* Tax Slabs Table */
.tax-slabs-table {
    background: var(--gray-50);
    border-radius: 0.75rem;
    border: 1px solid var(--gray-200);
    overflow: hidden;
    margin: 1.5rem 0;
}

.tax-slab-header {
    display: grid;
    grid-template-columns: 3fr 1fr;
    background: var(--primary);
    color: white;
    padding: 0.875rem 1.25rem;
    font-weight: 600;
    font-size: 0.9375rem;
}

.tax-slab-row {
    display: grid;
    grid-template-columns: 3fr 1fr;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.9375rem;
    color: var(--gray-700);
}

.tax-slab-row:last-child {
    border-bottom: none;
}

.tax-slab-row:nth-child(even) {
    background: rgba(0, 0, 0, 0.02);
}

/* Regime Comparison */
.regime-comparison-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
    margin-top: 1rem;
}

.regime-card {
    background: var(--gray-50);
    border-radius: 0.75rem;
    border: 1px solid var(--gray-200);
    padding: 1.5rem;
    text-align: center;
    position: relative;
    transition: all 0.3s ease;
    min-width: 0;
}

.regime-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

.regime-card h5 {
    font-size: 1.0625rem;
    color: var(--gray-800);
    margin-bottom: 1rem;
    font-weight: 600;
}

.regime-amount {
    font-size: 1.625rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
    overflow-wrap: anywhere;
}

.regime-savings {
    background: color-mix(in srgb, var(--primary) 5%, transparent);
    border-color: var(--primary);
}

.recommended-badge {
    position: absolute;
    top: -10px;
    right: -10px;
    background: var(--primary);
    color: white;
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

/* Income-tax / salary point the badge at the side of the regime it favours. */
.recommended-badge.badge-left {
    right: auto;
    left: -10px;
}

/* Cash Flows Container */
.cash-flows-container {
    margin-bottom: 2rem;
}

.cash-flows-container h3 {
    margin-bottom: 0.75rem;
    color: var(--gray-900);
    font-size: 1.125rem;
    font-weight: 600;
}

.cash-flow-header {
    display: grid;
    grid-template-columns: 1fr 1fr 2fr 40px;
    gap: 1rem;
    margin-bottom: 0.75rem;
    font-weight: 500;
    color: var(--gray-700);
    padding: 0 0.5rem;
    font-size: 0.9375rem;
}

.cash-flow-row {
    display: grid;
    grid-template-columns: 1fr 1fr 2fr 40px;
    gap: 1rem;
    margin-bottom: 1rem;
    align-items: center;
}

.remove-cash-flow {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--gray-200);
    border: none;
    color: var(--gray-700);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-cash-flow:hover {
    background: #ff4d4f;
    color: white;
}

.cash-flow-actions {
    margin-top: 1.25rem;
}

.add-cash-flow {
    background: var(--gray-100);
    color: var(--gray-800);
    border: 1px dashed var(--gray-300);
    padding: 0.625rem 1.25rem;
    border-radius: 0.5rem;
    font-size: 0.9375rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
}

.add-cash-flow:hover {
    background: var(--gray-200);
    border-color: var(--gray-400);
}

.form-actions {
    margin-top: 2rem;
    text-align: center;
}

/* When the actions row lives inside the field grid (the common calculator
   pattern), span the full row so the submit button gets a dedicated line
   instead of masquerading as a label-less field. The grid gap provides the
   spacing, so the standalone margin is dialled back. */
.form-grid .form-actions {
    grid-column: 1 / -1;
    margin-top: 0.25rem;
}

/* Exchange Button */
.exchange-button {
    background: var(--primary);
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 150px;
}

.exchange-button:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.exchange-button:active {
    transform: translateY(0);
}

/* Calculators Index Page Hero */
.calculators-hero {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 4rem 0;
    text-align: center;
    position: relative;
    z-index: 1;
}

.calculators-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    z-index: -1;
}

.calculators-hero h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.calculators-hero p {
    font-size: 1.125rem;
    opacity: 0.9;
    margin-bottom: 2rem;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

/* Responsive adjustments */
@media (max-width: 576px) {
    .calculators-hero h1 {
        font-size: 2rem;
    }
    
    .calculators-hero p {
        font-size: 1rem;
    }
    
    .calculator-card-header h3 {
        font-size: 1.125rem;
    }
}

/* ── Compact on small screens (N5) ──────────────────────────────────────────
 *
 * Density only. The mobile TYPOGRAPHY is deliberately untouched: the existing
 * 768px block already sizes headings and body text, and it reads well — the
 * complaint was never that the text was wrong, it was that a calculator page
 * on a phone is mostly whitespace, so the answer sits below the fold and the
 * working below that.
 *
 * These paddings were chosen for a desktop card sitting in a 1200px grid. On a
 * 375px screen the same 1.75rem inset costs about a sixth of the usable width
 * on each side, and the vertical rhythm — 2rem between every section — pushes
 * the result off screen entirely. Tightened, not removed: the cards still read
 * as cards, and touch targets are untouched.
 */
@media (max-width: 640px) {
    /* .tool-form and .rate-notice are NOT here, though a calculator page is
       where you notice them: `.tool-form` is a core design-system class and
       `.rate-notice` is shared by three or more modules. Tightening either one
       from this sheet would tighten it on calculator pages alone and leave a
       gold or currency page roomy — the same rule rendering two ways
       depending on which module happened to own the page. They are in core's
       block instead. */
    .form-section {
        margin-bottom: 1.25rem;
        padding-bottom: 1rem;
    }

    /* The answer. This is the thing the reader came for, so it is the thing
       most worth lifting up the page. */
    .calculator-result {
        margin-top: 1.25rem;
    }

    .result-card {
        padding: 1.1rem 1rem;
    }

    /* The working. Long by nature, and the least served by generous insets. */
    .calculation-section {
        padding: 1.15rem;
        margin: 1.25rem 0;
    }

    .calculation-table {
        margin-bottom: 0.9rem;
    }

    .regime-card {
        padding: 1rem;
    }

    .regime-comparison-grid {
        gap: 0.75rem;
    }
}

/* Regime comparison + XIRR ledger on phones. This block has to come after the
   base `.regime-*` / `.cash-flow-*` rules above: inside the 768px block near
   the top of the file, those later base rules won the cascade and the phone
   layout never applied. */
@media (max-width: 768px) {
    /* Three cards side by side need ~600px, so the comparison stacks; the
       badge moves inside its card, where `-10px` no longer hangs it past
       the edge of the page. */
    .regime-comparison-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .recommended-badge {
        top: 0.5rem;
        right: 0.5rem;
    }

    .recommended-badge.badge-left {
        left: 0.5rem;
    }

    .regime-card:has(.recommended-badge) {
        padding-top: 2.25rem;
    }

    .regime-amount {
        font-size: 1.375rem;
    }

    /* XIRR: date and amount share a line, the description takes the next
       one; `1fr 1fr 2fr 40px` could not fit three inputs on a phone. */
    .cash-flow-header,
    .cash-flow-row {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 40px;
        gap: 0.5rem;
    }

    .cash-flow-header > div:nth-child(3) {
        display: none;
    }

    .cash-flow-row > div:nth-child(3) {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .cash-flow-row .form-control {
        min-width: 0;
        width: 100%;
    }
}
