:root {
    --primary-color: #4F46E5;
    --primary-hover: #4338ca;
    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --card-bg: rgba(255, 255, 255, 0.95);
    --text-main: #1f2937;
    --text-sub: #6b7280;
    --border-color: #e5e7eb;
    --accent-color: #10b981;
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-lg: 1rem;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    /* Fix vertical shift */
    padding-top: 5vh;
    /* Fixed top spacing */
    padding-bottom: 20px;
    padding-left: 10px;
    padding-right: 10px;
    font-size: 0.92rem;
    /* Reduced base font size */
}

.app-container {
    width: 100%;
    max-width: 700px;
}

.app-header {
    text-align: center;
    margin-bottom: 1rem;
    /* Reduced from 2rem */
}

.app-header h1 {
    font-size: 1.6rem;
    /* Reduced from 2rem */
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.3rem;
    /* Reduced from 0.5rem */
}

.app-header p {
    color: var(--text-sub);
}

.calculator-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 1.2rem;
    /* Reduced from 2rem */
    backdrop-filter: blur(10px);
}

.input-section {
    margin-bottom: 1.2rem;
    /* Reduced from 2rem */
}

.input-group {
    margin-bottom: 0.5rem;
    /* Reduced from 0.8rem */
}

.input-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

/* Number Input Spinner Removal */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    /* Gap between input and unit */
}

.input-wrapper input {
    width: 100%;
    padding: 0.6rem;
    /* padding-right: 3rem; Removed absolute padding */
    border: 2px solid var(--border-color);
    border-radius: 0.75rem;
    font-size: 1rem;
    transition: all 0.2s;
}

.unit {
    /* position: absolute; Removed absolute */
    /* right: 1.2rem; */
    color: var(--text-main);
    /* Darker for better visibility */
    font-weight: 500;
    white-space: nowrap;
    /* Prevent wrap */
}

.parents-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    /* Reduced Gap */
    margin-bottom: 0.8rem;
    /* Reduced from 2rem */
}

.parent-card {
    flex: 1;
    background: #f9fafb;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 0.8rem;
}

/* Horizontal Layout for Card Body */
.card-body-row {
    display: flex;
    gap: 1.5rem;
}

.card-body-row .input-group {
    flex: 1;
    min-width: 0;
    /* Prevent overflow */
}

@media (max-width: 600px) {
    .card-body-row {
        flex-direction: column;
        gap: 0;
    }
}

.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.card-header-row h3 {
    margin: 0;
}

.parent-card h3 {
    font-size: 0.95rem;
    color: var(--text-main);
    margin-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 0.5rem;
}

.date-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.date-row input {
    flex: 1;
    min-width: 0;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    font-family: 'Outfit', 'Pretendard', sans-serif;
    font-size: 1rem;
    background-color: #fff;
    color: var(--text-main);
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
    cursor: pointer;
}

.date-row input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* Flatpickr Customization */
.flatpickr-input {
    background-color: #fff !important;
    cursor: pointer !important;
    /* Ensure pointer cursor */
}

/* Hide native calendar picker to avoid dual icons if necessary, 
   though Flatpickr usually changes type to text */
.date-row input::-webkit-calendar-picker-indicator {
    display: none;
}

/* Range Slider (Restored & Custom) */
.range-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    /* Spacing from date row */
}

input[type=range] {
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    flex: 1 1 0%;
    background: rgb(229, 231, 235);
    border-radius: 5px;
    outline: none;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.range-value {
    min-width: 60px;
    text-align: right;
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1.1rem;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--primary-color);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

.card-content.disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* Checkbox */
.checkbox-group {
    margin-top: 1rem;
}

.checkbox-container {
    display: block;
    position: relative;
    padding-left: 30px;
    cursor: pointer;
    font-size: 0.95rem;
    user-select: none;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 20px;
    width: 20px;
    background-color: #eee;
    border-radius: 4px;
}

.checkbox-container:hover input~.checkmark {
    background-color: #ccc;
}

.checkbox-container input:checked~.checkmark {
    background-color: var(--primary-color);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked~.checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 7px;
    top: 3px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 3px 3px 0;
    -webkit-transform: rotate(45deg);
    -ms-transform: rotate(45deg);
    transform: rotate(45deg);
}

/* Results */
.result-section {
    background: #f9fafb;
    border-radius: 1rem;
    padding: 1rem;
    /* Reduced from 1.5rem */
    border: 1px solid var(--border-color);
}

.result-header {
    text-align: center;
    margin-bottom: 1rem;
    /* Reduced from 1.5rem */
    padding-bottom: 0.8rem;
    /* Reduced from 1rem */
    border-bottom: 1px solid var(--border-color);
}

.result-header h2 {
    font-size: 1.1rem;
    color: var(--text-sub);
    margin-bottom: 0.5rem;
}

.total-amount {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary-color);
}

.sub-total {
    font-size: 0.9rem;
    color: var(--text-sub);
    margin-top: 0.5rem;
}

.table-header {
    display: grid;
    grid-template-columns: 0.8fr 1.1fr 1.1fr;
    padding: 0.4rem 0;
    /* Reduced from 0.5rem */
    font-weight: 600;
    color: var(--text-sub);
    font-size: 0.9rem;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 0.4rem;
    /* Reduced from 0.5rem */
}

.breakdown-list {
    list-style: none;
    max-height: 400px;
    overflow-y: auto;
}

.breakdown-item {
    display: grid;
    grid-template-columns: 0.8fr 1.1fr 1.1fr;
    padding: 0.5rem 0;
    /* Reduced from 0.75rem */
    font-size: 0.9rem;
    border-bottom: 1px dashed var(--border-color);
    align-items: center;
}

.breakdown-item:last-child {
    border-bottom: none;
}

.period-col {
    display: flex;
    flex-direction: column;
}

.period-date {
    font-size: 0.8rem;
    color: #9ca3af;
}

.amount-col {
    font-weight: 600;
    color: var(--text-main);
}

.badge-retro {
    display: inline-block;
    padding: 2px 4px;
    background: #fffbeb;
    color: #b45309;
    font-size: 0.7rem;
    border-radius: 3px;
    margin-top: 2px;
    font-family: inherit;
}

.retro-text {
    font-size: 0.7rem;
    color: #059669;
    /* Green for positive retro */
    font-weight: 700;
    margin-top: 2px;
}

.helper-text {
    font-size: 0.8rem;
    color: var(--text-sub);
    margin-top: 0.4rem;
}

.helper-text-slider {
    font-size: 0.75rem;
    color: var(--text-sub);
    margin-top: 0.5rem;
    font-weight: 600;
    transition: all 0.3s;

    /* Badge Style */
    display: inline-block;
    padding: 0.3rem 0.8rem;
    background-color: #f3f4f6;
    /* Inactive Gray */
    border-radius: 2rem;
    text-align: center;
    cursor: pointer;
}

.helper-text-slider.active {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 2px 5px rgba(79, 70, 229, 0.3);
}

/* Calculate Button */
.btn-primary {
    width: 100%;
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 1rem;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 0.75rem;
    cursor: pointer;
    cursor: pointer;
    /* margin-top: 1rem; Removed to align with result card */
    transition: background-color 0.2s;
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.2);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-sub);
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    font-size: 0.9rem;
}

/* Summary Card Hover Interaction */
.input-summary-card {
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1rem;
    /* Back to normal padding for better button look */
    margin-bottom: 1rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    min-height: 3.5rem;
    /* Ensure height for button look */
    display: flex;
    align-items: center;
    justify-content: center;
}

.example-summary-card {
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1rem;
    /* Back to normal padding for better button look */
    margin-bottom: 1rem;
    font-size: 0.9rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    min-height: 3.5rem;
    /* Ensure height for button look */
    display: flex;
    align-items: center;
    justify-content: center;
}

.input-summary-card .summary-view,
.example-summary-card .summary-view {
    width: 100%;
    transition: opacity 0.2s;
    opacity: 1;
}

.input-summary-card .edit-view,
.example-summary-card .edit-view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--primary-color);
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    /* Let clicks pass through to container */
}

/* Hover State */
.input-summary-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.input-summary-card:hover .summary-view {
    opacity: 0;
}

.input-summary-card:hover .edit-view {
    opacity: 1;
}

.summary-data-line {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    color: var(--text-sub);
    font-size: 0.85rem;
    line-height: 1.4;
    text-align: center;
}

.summary-data-line strong {
    color: var(--text-main);
    font-weight: 600;
}

/* Visibility Utilities */
.hidden {
    display: none !important;
}

.mb-4 {
    margin-bottom: 1rem;
}

/* Reduce Calendar Size */
/* Reduce Calendar Size - Removed Transform as it causes glitches */
.flatpickr-calendar {
    /* transform: scale(0.85); Removed */
    font-family: 'Pretendard', sans-serif;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* Wage Input Width Control */
.input-wrapper input[id$="Wage"] {
    max-width: 140px;
    flex: 0 1 auto;
}

@media (min-width: 768px) {
    #resultSection {
        display: flex;
        flex-direction: column;
        /* Changed to Column */
    }

    .result-top-row {
        display: flex;
        flex-direction: column;
        /* Stack vertically */
        gap: 1rem;
        width: 100%;
    }

    .input-summary-card {
        width: 100%;
        /* Full width */
        flex: auto;
        margin-bottom: 0;
        height: auto;
    }

    .result-header {
        width: 100%;
        /* Full width */
        text-align: center;
        /* Center align like mobile */
        border-bottom: 1px solid var(--border-color);
        /* Restore border */
        padding-bottom: 0.8rem;
        margin-bottom: 0;
        display: block;
        /* Restore block */
        background: transparent;
        /* Remove background if it was card-like */
        padding: 0;
        border-radius: 0;
        box-shadow: none;
        border: none;
        /* Revert to card style but full width? */
        /* User said "Same size as Calculate Button". Button is standard block. */
        /* Let's keep card styling but full width below summary. */
        background: #fff;
        padding: 1rem;
        border-radius: 0.75rem;
        border: 1px solid var(--border-color);
    }

    .breakdown-container {
        width: 100%;
        margin-top: 1rem;
        /* Reduced from 1.5rem */
        background: #fff;
        padding: 1.2rem;
        /* Reduced from 1.5rem */
        border-radius: 1rem;
        border: 1px solid var(--border-color);
    }
}

/* Split Button - Polished */
.btn-split {
    background-color: #e0e7ff;
    /* Very Light Indigo */
    color: var(--primary-color);
    border: 1px solid transparent;
    padding: 0.4rem 0.9rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-split:hover {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
    transform: translateY(-1px);
}

.btn-split:active {
    transform: translateY(0);
}

/* Grouped Cards CSS (Restored & Polished) */
.period-list-container {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    /* Reserved Border for Max Usage */
    border: 2px solid transparent;
    border-radius: 0.75rem;
    padding: 0.5rem;
    position: relative;
    transition: border-color 0.3s ease;
}

/* User Requested Style Applied to the Card Container */
.period-card {
    font-size: 0.8rem;
    /* Slightly larger than 0.75rem for readability of dates */
    color: var(--text-sub);
    font-weight: 600;
    transition: all 0.3s;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;

    padding: 0.5rem 1rem;
    /* comfortable padding */
    background-color: #f3f4f6;
    border-radius: 2rem;
    /* Pill shape */

    /* Ensure full width usage */
    width: 100%;
    box-sizing: border-box;
}

.period-nav-badge {
    background-color: var(--primary-color);
    color: white;
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 1rem;
    white-space: nowrap;
}

.period-dates {
    flex: 1;
    /* Take up available space */
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 1rem;
    /* Gap between date and months */
}

.period-months {
    white-space: nowrap;
    color: var(--text-main);
    font-weight: 700;
    margin-right: 0.5rem;
    /* Gap before delete button */
}

.btn-delete-period {
    background: none;
    border: none;
    color: #ef4444;
    /* Red default for visibility */
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0.2rem;
    transition: all 0.2s;
    opacity: 0.6;
}

.btn-delete-period:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Locked Toggle State (Spouse) */
.toggle-switch.locked {
    cursor: not-allowed !important;
    position: relative;
    /* For tooltip */
}

.toggle-switch.locked input {
    pointer-events: none;
}

.toggle-switch.locked .slider {
    background-color: #94a3b8;
    /* Dimmed */
    opacity: 0.8;
}

/* Tooltip on Hover */
.toggle-switch.locked:hover::after {
    content: "총 13개월 이상 사용 시 해제 불가";
    position: absolute;
    bottom: 120%;
    /* Above */
    right: 0;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 100;
    pointer-events: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Dynamic Disabled State for Inputs when Quota Full */
.quota-full-disabled {
    opacity: 0.5;
    pointer-events: none;
    background-color: #f1f5f9 !important;
}

/* Parent Highlight Styles */
.period-list-container.max-usage-parent-highlight {
    border-color: #ef4444;
}

.period-list-container.max-usage-parent-highlight::after {
    content: "최대 사용";
    position: absolute;
    top: -12px;
    right: 15px;
    background: #ef4444;
    color: white;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 99px;
    font-weight: bold;
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

/* Split Max Highlight */
.period-list-container.split-max-parent-highlight {
    border-color: #ef4444;
}

.period-list-container.split-max-parent-highlight::after {
    content: "분할 최대";
    position: absolute;
    top: -12px;
    right: 15px;
    background: #ef4444;
    color: white;
    font-size: 11px;
    padding: 2px 8px;
    margin-top: 1rem;
    /* Reduced from 1.5rem */
    background: #fff;
    padding: 1.2rem;
    /* Reduced from 1.5rem */
    border-radius: 1rem;
    border: 1px solid var(--border-color);
}


/* Split Button - Polished */
.btn-split {
    background-color: #e0e7ff;
    /* Very Light Indigo */
    color: var(--primary-color);
    border: 1px solid transparent;
    padding: 0.4rem 0.9rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-split:hover {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
    transform: translateY(-1px);
}

.btn-split:active {
    transform: translateY(0);
}

/* Grouped Cards CSS (Restored & Polished) */
.period-list-container {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    /* Reserved Border for Max Usage */
    border: 2px solid transparent;
    border-radius: 0.75rem;
    padding: 0.5rem;
    position: relative;
    transition: border-color 0.3s ease;
}

/* User Requested Style Applied to the Card Container */
.period-card {
    font-size: 0.8rem;
    /* Slightly larger than 0.75rem for readability of dates */
    color: var(--text-sub);
    font-weight: 600;
    transition: all 0.3s;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;

    padding: 0.5rem 1rem;
    /* comfortable padding */
    background-color: #f3f4f6;
    border-radius: 2rem;
    /* Pill shape */

    /* Ensure full width usage */
    width: 100%;
    box-sizing: border-box;
}

.period-nav-badge {
    background-color: var(--primary-color);
    color: white;
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 1rem;
    white-space: nowrap;
}

.period-dates {
    flex: 1;
    /* Take up available space */
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 1rem;
    /* Gap between date and months */
}

.period-months {
    white-space: nowrap;
    color: var(--text-main);
    font-weight: 700;
    margin-right: 0.5rem;
    /* Gap before delete button */
}

.btn-delete-period {
    background: none;
    border: none;
    color: #ef4444;
    /* Red default for visibility */
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0.2rem;
    transition: all 0.2s;
    opacity: 0.6;
}

.btn-delete-period:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Locked Toggle State (Spouse) */
.toggle-switch.locked {
    cursor: not-allowed !important;
    position: relative;
    /* For tooltip */
}

.toggle-switch.locked input {
    pointer-events: none;
}

.toggle-switch.locked .slider {
    background-color: #94a3b8;
    /* Dimmed */
    opacity: 0.8;
}

/* Tooltip on Hover */
.toggle-switch.locked:hover::after {
    content: "총 13개월 이상 사용 시 해제 불가";
    position: absolute;
    bottom: 120%;
    /* Above */
    right: 0;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 100;
    pointer-events: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Dynamic Disabled State for Inputs when Quota Full */
.quota-full-disabled {
    opacity: 0.5;
    pointer-events: none;
    background-color: #f1f5f9 !important;
}

/* Parent Highlight Styles */
.period-list-container.max-usage-parent-highlight {
    border-color: #ef4444;
}

.period-list-container.max-usage-parent-highlight::after {
    content: "최대 사용";
    position: absolute;
    top: -12px;
    right: 15px;
    background: #ef4444;
    color: white;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 99px;
    font-weight: bold;
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

/* Split Max Highlight */
.period-list-container.split-max-parent-highlight {
    border-color: #ef4444;
}

.period-list-container.split-max-parent-highlight::after {
    content: "분할 최대";
    position: absolute;
    top: -12px;
    right: 15px;
    background: #ef4444;
    color: white;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 99px;
    font-weight: bold;
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

/* Slider Labels Styling */
.range-labels-wrapper span {
    color: var(--text-main);
    font-weight: 700;
    margin-right: 0.5rem;
    font-family: 'Outfit', sans-serif;
}

/* Restored Styles for Split & Breakdown */
.th-label {
    display: inline-block;
    min-width: 40px;
    font-weight: 700;
    color: var(--text-main);
    margin-right: 8px;
    font-size: 0.85rem;
}

.badge-retro {
    display: inline-block;
    background-color: #10b981;
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
    margin-left: 4px;
}

.badge-std {
    display: inline-block;
    background-color: #e2e8f0;
    color: #475569;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
    margin-left: 4px;
}

.retro-text {
    font-size: 0.7rem;
    color: #10b981;
    font-weight: bold;
    margin-top: 2px;
}


/* Updated Breakdown Layout for Round Separation */
.breakdown-item {
    display: grid !important;
    grid-template-columns: 60px 120px 1fr 1fr;
    gap: 0.5rem;
    align-items: center;
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid #f1f5f9;
}

.round-col {
    font-weight: 800;
    color: var(--primary-color);
    text-align: center;
    font-size: 0.9rem;
}

.period-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    color: var(--text-main);
    text-align: center;
}

.amount-col {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
    /* flex-wrap: wrap; Removed to force same line */
    gap: 0.2rem;
    font-weight: 700;
    color: var(--text-main);
    font-size: 0.9rem;
}

/* Mobile Adaptation for 4 columns */
@media (max-width: 480px) {
    .breakdown-item {
        grid-template-columns: 40px 1fr 1fr;
        font-size: 0.8rem;
    }

    .round-col {
        grid-row: span 2;
        align-self: start;
        padding-top: 0.2rem;
    }

    .period-col {
        grid-column: 2 / -1;
        margin-bottom: 0.2rem;
        flex-direction: row;
        gap: 0.5rem;
        align-items: baseline;
    }

    .amount-col {
        align-items: flex-end;
    }
}

/* Table Header - Aligned with Grid */
.table-header {
    display: grid !important;
    grid-template-columns: 60px 120px 1fr 1fr;
    gap: 0.5rem;
    padding: 0.75rem 0.5rem;
    background-color: #f8fafc;
    border-top: 1px solid #e2e8f0;
    border-bottom: 2px solid #e2e8f0;
    font-size: 0.8rem;
    color: #64748b;
}

/* New Layout for 2-line Result Cells */
.main-row-multi {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 2px;
}

.row-upper {
    display: flex;
    align-items: center;
    gap: 4px;
}

.row-lower {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Ensure stable width for usage badge (prevent layout shift for 9->10) */
.badge-std {
    display: inline-block;
    background-color: #e2e8f0;
    color: #475569;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
    min-width: 48px !important;
    /* Fixed width (~4-5 chars) */
    text-align: center;
}

.badge-retro {
    display: inline-block;
    background-color: #10b981;
    /* Green for 6+6 */
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
    min-width: 60px;
    /* Optional consistency */
    text-align: center;
}

/* Override previous simple display block if needed */
.main-row {
    display: none;
    /* Deprecated in favor of main-row-multi */
}

font-weight: 700;
text-align: right;
}

.table-header span:nth-child(1) {
    text-align: center;
}

/* Round */
.table-header span:nth-child(2) {
    text-align: center;
}

/* Period */
.table-header span:nth-child(3) {
    text-align: right;
}

/* My */
.table-header span:nth-child(4) {
    text-align: right;
}

/* Spouse */

/* Mobile Adaptation for Header */
@media (max-width: 480px) {
    .table-header {
        grid-template-columns: 40px 1fr 1fr;
    }

    .table-header span:nth-child(2) {
        display: none;
    }

    /* Hide Period Text in Header on Mobile */
}

/* Badge Styles */
.main-row,
.sub-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
}

.sub-row {
    margin-top: 2px;
}

/* Badge Styles */
.badge-std {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    padding: 2px 6px;
    background-color: #f1f5f9;
    color: #64748b;
    border-radius: 4px;
    margin-left: 4px;
    font-weight: normal;
    white-space: nowrap;
}

.badge-retro {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    padding: 2px 6px;
    background-color: #ecfdf5;
    /* Greenish for Retro/6+6 */
    color: #059669;
    border-radius: 4px;
    margin-left: 4px;
    font-weight: normal;
    white-space: nowrap;
}

.retro-text {
    font-size: 0.7rem;
    color: #e11d48;
    margin-left: 4px;
    white-space: nowrap;
}

/* Align H3 and Toggle in Spouse Header */
.card-header-row h3 {
    margin-bottom: 0 !important;
    margin-top: 0 !important;
    padding-bottom: 0;
}

.card-header-row {
    align-items: center;
}

/* Tooltip for Retro Badge/Text */
.retro-tooltip-trigger {
    cursor: help;
    position: relative;
    border-bottom: 1px dotted #059669;
}

.retro-tooltip-trigger:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    white-space: nowrap;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    pointer-events: none;
    font-weight: 500;
    line-height: 1.4;
}

.retro-tooltip-trigger:hover::before {
    content: "";
    position: absolute;
    bottom: 115%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
    z-index: 1000;
}

/* Guideline Section Styles */
.guide-section,
.example-section {
    margin-bottom: 2rem;
    background: #ffffff;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.guide-header,
.example-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.2rem;
    background: #f3f4f6;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}

.guide-header h2,
.example-header h2 {
    font-size: 1.1rem;
    margin: 0;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-toggle-guide,
.btn-toggle-example {
    background: none;
    border: none;
    font-size: 0.9rem;
    color: var(--text-sub);
    cursor: pointer;
    transition: transform 0.3s;
    font-weight: 600;
}

.guide-content {
    padding: 1.2rem;
    display: block;
    transition: all 0.3s ease;
}

.guide-content.hidden {
    display: none !important;
}

.guide-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.guide-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.8rem;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.guide-card h3 {
    font-size: 0.95rem;
    color: var(--primary-color);
    margin-bottom: 0.8rem;
    font-weight: 700;
    border-bottom: 1px dashed #e5e7eb;
    padding-bottom: 0.4rem;
}

.guide-card ul {
    list-style: none;
    padding: 5px;
    margin: 0;
}

.guide-card li {
    font-size: 0.85rem;
    color: var(--text-main);
    margin-bottom: 0.4rem;
    line-height: 1.4;
    position: relative;
    padding-left: 0.8rem;
}

.guide-card li::before {
    content: "\2022";
    color: var(--primary-color);
    position: absolute;
    left: 0;
    font-weight: bold;
}

.guide-card.full-width {
    grid-column: span 2;
}

.two-col-list {
    /* display: flex; */
    gap: 1rem;
}

.two-col-list ul {
    flex: 1;
}

.step-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.step-badges span {
    background: #e0e7ff;
    color: var(--primary-color);
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 1rem;
    font-weight: 600;
}

.highlight-bg {
    background: #f9fafb;
    padding: 0.6rem;
    border-radius: 0.5rem;
    margin-top: 0.5rem;
}

.sub-group h4 {
    font-size: 0.85rem;
    color: var(--text-sub);
    margin-bottom: 0.3rem;
}

.warning-list li::before {
    color: #ef4444;
}

.guide-disclaimer,
.example-disclaimer {
    margin-top: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-sub);
    text-align: center;
    background: #f9fafb;
    padding: 0.5rem;
    border-radius: 0.5rem;
}

@media (max-width: 640px) {
    .guide-grid {
        grid-template-columns: 1fr;
    }

    .guide-card.full-width {
        grid-column: auto;
    }

    .two-col-list {
        flex-direction: column;
    }
}