/* =================================================================
   ACCESSIBILITY & SCREEN READER UTILITIES
   ================================================================= */

/* Screen reader only content - visually hidden but accessible */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* =================================================================
   TABLE TOOLTIPS & ANIMATIONS
   ================================================================= */

/* Row enter animation */
.payment-schedule-table tbody tr {
    opacity: 0;
    transform: translateY(8px);
    animation: fadeInUp 360ms cubic-bezier(.2,.9,.2,1) forwards;
}

@keyframes fadeInUp {
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

/* Floating tooltip system - appended to body to avoid clipping */
.floating-debt-tooltip {
    position: absolute;
    display: none;
    z-index: 9999;
    background: var(--gray-900);
    color: white;
    border-radius: var(--radius-lg);
    padding: 0;
    font-size: 0.875rem;
    line-height: 1.4;
    font-weight: 400;
    pointer-events: none;
    max-width: 280px;
    min-width: 200px;
    white-space: normal;
    box-shadow: var(--shadow-xl), 0 0 0 1px rgba(255, 255, 255, 0.1);
    transition: var(--transition-fast);
    backdrop-filter: blur(8px) saturate(120%);
    
    /* Subtle gradient overlay for depth */
    background: linear-gradient(135deg, 
        var(--gray-900) 0%, 
        rgba(17, 24, 39, 0.95) 50%,
        var(--gray-800) 100%
    );
}

.floating-debt-tooltip[role="active"] {
    pointer-events: auto;
}

/* Positioning-aware styles */
.floating-debt-tooltip.tooltip-above {
    transform-origin: bottom center;
}

.floating-debt-tooltip.tooltip-below {
    transform-origin: top center;
}

.floating-debt-tooltip.tooltip-left {
    transform-origin: top right;
}

.floating-debt-tooltip.tooltip-right {
    transform-origin: top left;
}

/* Add subtle directional indicators with CSS pseudo-elements */
.floating-debt-tooltip::before {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border: 6px solid transparent;
    z-index: 1;
}

/* Arrow pointing up when tooltip is below target */
.floating-debt-tooltip.tooltip-below::before {
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    border-bottom-color: var(--gray-900);
}

/* Arrow pointing down when tooltip is above target */
.floating-debt-tooltip.tooltip-above::before {
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    border-top-color: var(--gray-900);
}

/* Arrow pointing left when tooltip is to the right */
.floating-debt-tooltip.tooltip-right::before {
    top: 20px;
    left: -12px;
    border-right-color: var(--gray-900);
}

/* Arrow pointing right when tooltip is to the left */
.floating-debt-tooltip.tooltip-left::before {
    top: 20px;
    right: -12px;
    border-left-color: var(--gray-900);
}

/* Special case: when tooltip is repositioned to edges, adjust arrow position */
.floating-debt-tooltip.tooltip-below.tooltip-left::before {
    left: calc(100% - 30px);
}

.floating-debt-tooltip.tooltip-below.tooltip-right::before {
    left: 30px;
}

.floating-debt-tooltip.tooltip-above.tooltip-left::before {
    left: calc(100% - 30px);
}

.floating-debt-tooltip.tooltip-above.tooltip-right::before {
    left: 30px;
}

/* Tooltip header for context */
.floating-debt-tooltip .tooltip-header {
    background: linear-gradient(135deg, var(--accent-color), var(--accent-color-dark));
    color: white;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Tooltip body content */
.floating-debt-tooltip .tooltip-body {
    padding: var(--space-md);
}

/* Enhanced structured tooltip rows */
.floating-debt-tooltip .tt-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-xs) 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    transition: var(--transition-fast);
}

.floating-debt-tooltip .tt-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.floating-debt-tooltip .tt-row:hover {
    background: rgba(255, 255, 255, 0.03);
    margin: 0 calc(var(--space-md) * -1);
    padding-left: var(--space-md);
    padding-right: var(--space-md);
    border-radius: var(--radius-sm);
}

/* Row labels */
.floating-debt-tooltip .tt-row .tt-label {
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
    font-size: 0.8rem;
    min-width: 0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

/* Row values */
.floating-debt-tooltip .tt-row .tt-value {
    color: white;
    font-weight: 600;
    text-align: right;
    font-variant-numeric: tabular-nums;
    min-width: 0;
    flex-shrink: 1;
}

/* Special styling for different value types */
.floating-debt-tooltip .tt-row .tt-value.currency {
    color: var(--success-light);
}

.floating-debt-tooltip .tt-row .tt-value.interest {
    color: #fca5a5; /* Light red for interest */
}

.floating-debt-tooltip .tt-row .tt-value.percentage {
    color: #a78bfa; /* Light purple for percentages */
}

.floating-debt-tooltip .tt-row .tt-value.split {
    font-size: 0.75rem;
    line-height: 1.3;
    color: rgba(255, 255, 255, 0.8);
}

/* Tooltip sections for grouping related info */
.floating-debt-tooltip .tt-section {
    margin-bottom: var(--space-sm);
    padding-bottom: var(--space-sm);
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.floating-debt-tooltip .tt-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.floating-debt-tooltip .tt-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-xs);
    padding-left: 2px;
}

/* Icons in tooltips */
.floating-debt-tooltip .tt-icon {
    width: 14px;
    height: 14px;
    opacity: 0.7;
    flex-shrink: 0;
}

/* Priority indicator in tooltips */
.floating-debt-tooltip .priority-indicator {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    background: linear-gradient(135deg, var(--accent-color-light), var(--accent-color));
    color: white;
    padding: 2px var(--space-xs);
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* Promotional balance indicator */
.floating-debt-tooltip .promo-indicator {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    background: linear-gradient(135deg, #fef3c7, #f6ad55);
    color: #92400e;
    padding: 2px var(--space-xs);
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 700;
}

/* Tooltip footer for additional context */
.floating-debt-tooltip .tooltip-footer {
    padding: var(--space-sm) var(--space-md) 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: var(--space-sm);
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
    text-align: center;
}

/* Enhanced responsive behavior */
@media (max-width: 768px) {
    .floating-debt-tooltip {
        max-width: 260px;
        min-width: 180px;
        font-size: 0.8rem;
        /* Ensure tooltip is above touch interactions */
        z-index: 10000;
    }
    
    .floating-debt-tooltip .tooltip-header {
        padding: var(--space-xs) var(--space-sm);
        font-size: 0.75rem;
    }
    
    .floating-debt-tooltip .tooltip-body {
        padding: var(--space-sm);
    }
    
    .floating-debt-tooltip .tt-row {
        gap: var(--space-sm);
        padding: var(--space-xs) 0;
    }
    
    .floating-debt-tooltip .tt-section-title {
        font-size: 0.7rem;
    }
    
    .floating-debt-tooltip .tt-section {
        margin-bottom: var(--space-xs);
        padding-bottom: var(--space-xs);
    }
}

@media (max-width: 480px) {
    .floating-debt-tooltip {
        max-width: calc(100vw - 16px);
        min-width: calc(100vw - 32px);
        font-size: 0.75rem;
        left: 8px !important; /* Force center on very small screens */
        transform: none !important;
    }
    
    .floating-debt-tooltip .tooltip-header {
        padding: 6px var(--space-xs);
        font-size: 0.7rem;
    }
    
    .floating-debt-tooltip .tooltip-body {
        padding: var(--space-xs);
    }
    
    .floating-debt-tooltip .tt-row {
        flex-direction: column;
        gap: 2px;
        align-items: flex-start;
        padding: 4px 0;
    }
    
    .floating-debt-tooltip .tt-label,
    .floating-debt-tooltip .tt-value {
        font-size: 0.7rem;
        text-align: left;
    }
    
    /* Hide arrows on very small screens to reduce clutter */
    .floating-debt-tooltip::before {
        display: none;
    }
}

/* Animation for tooltip appearance */
@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.floating-debt-tooltip[style*="display: block"] {
    animation: tooltipFadeIn var(--transition-fast) ease-out;
}

/* High contrast mode support for tooltips */
@media (prefers-contrast: high) {
    .floating-debt-tooltip {
        background: var(--gray-900);
        border: 2px solid white;
        box-shadow: var(--shadow-lg);
    }
    
    .floating-debt-tooltip .tooltip-header {
        background: white;
        color: var(--gray-900);
    }
    
    .floating-debt-tooltip .tt-value.currency {
        color: #00ff00;
    }
    
    .floating-debt-tooltip .tt-value.interest {
        color: #ff4444;
    }
}

/* Focus states for accessibility */
[data-debt-tooltip]:focus-visible {
    outline: 3px solid var(--accent-color);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Table cell tooltip triggers */
[data-debt-tooltip] {
    outline: none;
    position: relative;
}

[data-debt-tooltip]:focus {
    box-shadow: 0 0 0 3px rgba(96,165,250,0.25);
    border-radius: 4px;
}

/* Hide inline tooltips - only use floating system */
.payment-column .debt-tooltip,
.interest-column .debt-tooltip,
.principal-column .debt-tooltip,
.balance-column .debt-tooltip,
.debt-column .debt-tooltip {
    display: none !important;
}
/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Brand Colors */
    --accent-color: #667eea;
    --accent-color-light: #96a4ea;
    --accent-color-dark: #4c51bf;
    
    /* Semantic Colors */
    --success-color: #10b981;
    --success-light: #6ee7b7;
    --danger-color: #ef4444;
    --danger-light: #f87171;
    --warning-color: #f59e0b;
    --warning-light: #fbbf24;
    
    /* Neutral Colors */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Transitions */
    --transition-fast: 150ms ease-in-out;
    --transition-normal: 250ms ease-in-out;
    --transition-slow: 350ms ease-in-out;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.save-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    opacity: 0.8;
    margin-top: 10px;
}

.save-status i {
    color: #38a169;
}

/* Main Content */
.main-content {
    display: grid;
    gap: 12px;
}

/* Ensure each section has a touch of vertical margin so shadows don't butt up against each other */
section {
    margin: 6px 0;
}

/* Sections */
section {
    background: white;
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

section:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.15);
}

section h2 {
    color: #2d3748; /* darker heading color for improved readability */
    margin-bottom: 20px;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Make sure section headers with right-aligned controls leave space on small screens */
.payment-settings h2 { padding-right: 180px; }
.payment-settings h2 .btn { height: 40px; }

/* Fix mobile overlap for payment settings header */
@media (max-width: 768px) {
    .payment-settings h2 {
        padding-right: 0;
        padding-bottom: 60px;
        position: relative;
    }
    
    .payment-settings h2 > div {
        position: absolute !important;
        right: 0 !important;
        top: 40px !important;
        transform: none !important;
        flex-wrap: wrap;
        max-width: 100%;
        gap: 6px !important;
    }
    
    .payment-settings h2 .btn {
        padding: 6px 8px;
        font-size: 0.8rem;
        height: auto;
    }
}

@media (max-width: 480px) {
    .payment-settings h2 {
        padding-bottom: 70px;
    }
    
    .payment-settings h2 > div {
        top: 45px !important;
        flex-wrap: wrap;
        width: 100%;
        justify-content: flex-start;
    }
    
    .payment-settings h2 .btn {
        width: auto;
        min-width: auto;
        padding: 8px 10px;
        font-size: 0.75rem;
    }
}

/* Forms */
.debt-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Compact form improvements */
.compact-form {
    gap: 16px;
}

.compact-form .form-section {
    background: #f9fafb;
    border: 1px solid #f3f4f6;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 8px;
}

.compact-form .form-section:first-child {
    background: #fefeff;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
}

.compact-form .form-section h4 {
    margin: 0 0 12px 0;
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 8px;
}

.compact-form .form-group input,
.compact-form .form-group select {
    padding: 10px 12px;
    font-size: 0.95rem;
}

.compact-form .form-group label {
    font-size: 0.9rem;
    margin-bottom: 6px;
}

.compact-form .form-group small {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 4px;
    display: block;
}

/* Ultra compact variant for add/edit modals */
.dense-form { gap: 12px !important; }
.dense-form .form-section { padding: 12px 14px; margin-bottom: 4px; }
.dense-form .form-section h4 { margin: 0 0 8px 0; font-size: 0.9rem; }
.dense-form .form-row { gap: 14px !important; }
.dense-form.three-cols, .dense-form .three-cols { gap: 12px !important; }
.dense-form .form-group label { margin-bottom: 4px !important; font-size: 0.8rem; }
.dense-form .form-group input, .dense-form .form-group select { padding: 8px 10px; font-size: 0.85rem; }
.dense-form .field-help { font-size: 0.68rem; margin-top: 2px; }
.dense-form .radio-group { gap: 10px; margin-bottom: 4px; }
.dense-form .payment-inputs { gap: 6px; }
.dense-form .payment-inputs input { padding: 8px 10px; }
.dense-form .modal-actions .btn { padding: 10px 16px; font-size: 0.85rem; }
/* Slightly reduce modal body padding when containing a dense form */
.modal-body:has(.dense-form) { padding: 12px 18px 4px 18px; }

@media (max-width: 768px) {
    .dense-form .form-row { gap: 10px !important; }
    .dense-form .form-group input, .dense-form .form-group select { padding: 8px 9px; font-size: 0.83rem; }
    .dense-form .form-section { padding: 10px 12px; }
}

/* Section headers with toggle buttons */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.toggle-section {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
}

.toggle-section:hover {
    background: #f3f4f6;
    color: #374151;
}

.toggle-section i {
    transition: transform 0.2s ease;
}

.toggle-section.active i {
    transform: rotate(180deg);
}

/* Collapsible sections */
.collapsible-section {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.2s ease;
    max-height: 200px;
    opacity: 1;
}

.collapsible-section.collapsed {
    max-height: 0;
    opacity: 0;
}

/* Three column layout for key fields */
.three-cols {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

/* Payment type styling */
.payment-type-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.radio-group {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 8px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
}

.radio-option input[type="radio"] {
    margin: 0;
}

.payment-inputs {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.payment-inputs input {
    transition: all 0.2s ease;
}

.payment-inputs input:not([style*="display: none"]) {
    animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 600;
    margin-block-end: var(--space-sm);
    color: var(--gray-600);
}

.form-group input {
    padding: 12px 15px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: var(--transition-fast);
    background: white;
    
    &:focus {
        outline: none;
        border-color: var(--success-color);
        box-shadow: 0 0 0 3px rgba(16,185,129,0.1);
    }
    
    &:hover:not(:focus) {
        border-color: var(--gray-300);
    }
}

/* Input validation states - handled via JavaScript */
.form-group input:invalid,
.form-group input.error {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.06);
}

.form-group input:focus:valid:not([value=""]) {
    /* Only show the green border when the valid field is focused. When
       not focused, leave the neutral border so valid fields don't appear
       highlighted unless being actively edited. */
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16,185,129,0.06);
}

/* Custom validation message styling */
.validation-message {
    font-size: 0.8rem;
    color: #ef4444;
    margin-top: 4px;
    display: block;
}

/* Validation helper text */
.validation-helper {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 4px;
    display: block;
}

.validation-warning {
    font-size: 0.8rem;
    color: #f59e0b;
    margin-top: 4px;
    display: block;
}

/* Budget input invalid state */
.budget-invalid {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.06);
}

#budget-warning {
    display: none;
}

.budget-help {
    display: block;
    margin-top: 5px;
    font-size: 0.85rem;
    color: #718096;
    line-height: 1.4;
}

/* Budget warning when monthly budget is less than total minimum payments */
.budget-warning {
    margin-top: 8px;
    color: #7f1d1d;
    background: #fff5f5;
    border: 1px solid #feb2b2;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.9rem;
}

/* Budget meter showing min vs extra */
.budget-meter { margin-top:10px; }
.budget-meter-labels { display:flex; justify-content:space-between; font-size:0.9rem; color:#4a5568; margin-bottom:6px; }
.budget-meter-bar { height:14px; background:#f1f5f9; border-radius:8px; overflow:hidden; position:relative; }
.budget-meter-bar .min-bar { background: linear-gradient(90deg,#f6ad55,#f56565); height:100%; width:0%; position:absolute; left:0; top:0; }
.budget-meter-bar .extra-bar { background: linear-gradient(90deg,#68d391,#38a169); height:100%; width:0%; position:absolute; top:0; }

/* Ensure the left-most and right-most rounded corners are preserved by clipping the inner bars slightly
    and relying on the container's border-radius. This avoids a small transparent gap between segments. */
.budget-meter-bar .min-bar,
.budget-meter-bar .extra-bar { border-radius: 0; }

/* Small P pill for promotional balances in schedule table */
.promo-pill-small {
    display: inline-block;
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #f6e05e;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.7rem;
    vertical-align: middle;
    margin-left: 4px;
    line-height: 1;
}

/* Promo badge for debt cards */
.promo-badge { display:inline-block; background:#fff7c0; color:#92400e; border:1px dashed #f6e05e; padding:3px 8px; border-radius:12px; font-weight:600; margin-left:8px; font-size:0.85rem; }

/* Floor applied pill - shows when minimum floor value is being used */
.floor-applied-pill {
    display: inline-block;
    background: #e6fffa;
    color: #285e61;
    border: 1px solid #81e6d9;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
    margin-left: 6px;
    font-size: 0.75rem;
    vertical-align: middle;
    cursor: help;
}

/* Fixed minimum pill */
.fixed-pill {
    display: inline-block;
    background: #ebf8ff;
    color: #075985;
    border: 1px solid #7dd3fc;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
    margin-left: 6px;
    font-size: 0.75rem;
    vertical-align: middle;
}

/* Priority pill shown next to the debt name for the active priority debt */
.priority-pill {
    display: inline-block;
    background: linear-gradient(135deg, #bfdbfe 0%, #60a5fa 100%);
    color: white;
    padding: 4px 8px;
    border-radius: 999px;
    font-weight: 700;
    margin-left: 8px;
    font-size: 0.8rem;
    box-shadow: 0 6px 18px rgba(96,165,250,0.12);
}

/* Highlight table cells that contain an active promotional balance */
.promo-debt {
    background: linear-gradient(180deg, rgba(250,204,21,0.08), rgba(250,204,21,0.02));
    border: 2px dashed rgba(250,204,21,0.18) !important;
}

/* Priority debt highlighting - should override promo styling when both apply */
.priority-debt {
    border: 2px solid #60a5fa !important; /* Light blue */
    box-shadow: 0 0 0 2px #e0f2fe !important;
}

/* When a debt is both priority and has promo balance, combine the highlighting */
.priority-debt.promo-debt {
    background: linear-gradient(135deg, rgba(96,165,250,0.12), rgba(250,204,21,0.08)) !important;
    border: 2px solid #60a5fa !important;
    box-shadow: 0 0 0 2px #e0f2fe, inset 0 0 0 1px rgba(250,204,21,0.3) !important;
}
.promo-pill { display:flex; gap:6px; align-items:center; }
.promo-pill .promo-remaining { background:#fff7c0; padding:4px 6px; border-radius:6px; font-size:0.85rem; color:#92400e; border:1px solid rgba(250,204,21,0.2); }
.promo-pill .std-remaining { background:transparent; padding:4px 6px; border-radius:6px; font-size:0.85rem; color:#2d3748; }

/* Legacy tooltip rows - now handled by enhanced system above */

.debts-help {
    display: block;
    margin-top: 5px;
    font-size: 0.85rem;
    color: #718096;
    line-height: 1.4;
}

/* =================================================================
   BUTTON SYSTEM
   ================================================================= */

.btn {
    padding: var(--space-sm) var(--space-md);
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    text-decoration: none;
    min-height: 2.5rem;
    
    /* Prevent button text from wrapping */
    white-space: nowrap;
    
    /* Better focus states for accessibility */
    &:focus {
        outline: 2px solid var(--accent-color);
        outline-offset: 2px;
    }
    
    &:disabled {
        opacity: 0.6;
        cursor: not-allowed;
        transform: none !important;
    }
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-color-dark) 100%);
    color: white;
    box-shadow: var(--shadow-sm);
    
    &:hover:not(:disabled) {
        transform: translateY(-1px);
        box-shadow: var(--shadow-md);
    }
    
    &:active {
        transform: translateY(0);
    }
}

.btn-secondary {
    background: var(--gray-50);
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
    
    &:hover:not(:disabled) {
        background: var(--gray-100);
        border-color: var(--accent-color);
        transform: translateY(-1px);
    }
}

.btn-danger {
    background: var(--danger-color);
    color: white;
    
    &:hover:not(:disabled) {
        background: #d1b0b0;
        transform: translateY(-1px);
    }
}

.btn-success {
    background: var(--success-color);
    color: white;
    
    &:hover:not(:disabled) {
        background: #79a094;
        transform: translateY(-1px);
    }
}

/* Button sizes */
.btn-sm {
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.875rem;
    min-height: 2rem;
}

.btn-lg {
    padding: var(--space-md) var(--space-lg);
    font-size: 1.125rem;
    min-height: 3rem;
}

/* Hide the manual "Save Data" button — user requested it removed from the UI. */
#save-data {
    display: none !important;
}

/* Payment Settings */
.method-toggle-section {
    margin-bottom: 15px;
    padding: 10px;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border-radius: 12px;
    border: 2px solid #e2e8f0;
}

.toggle-container {
    display: flex;
    align-items: center;
    gap: 20px;
}

.toggle-label {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
    cursor: pointer;
}

.toggle-label input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e0;
    transition: 0.3s;
    border-radius: 30px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .toggle-slider {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

input:checked + .toggle-slider:before {
    transform: translateX(30px);
}

.method-info h3 {
    margin: 0 0 5px 0;
    color: #2d3748;
    font-size: 1.2rem;
}

.method-info p {
    margin: 0;
    color: #718096;
    font-size: 0.9rem;
}

.settings-row {
    display: flex;
    gap: 20px;
    align-items: end;
}

/* Inline calculate button next to budget input */
.budget-row input[type="number"] { flex: 1 1 auto; }
.calculate-inline { height: 44px; align-self: center; padding: 8px 14px; }

@media (max-width: 768px) {
    .budget-row { width: 100%; }
    .budget-row > div { 
        flex-direction: row; 
        align-items: center; 
        gap: 8px; 
    }
    .calculate-inline { 
        width: auto;
        min-width: auto;
        flex-shrink: 0;
        padding: 8px 12px;
        font-size: 0.9rem;
    }
}

.settings-row .form-group {
    flex: 1;
}

/* Debts List */
.debts-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.no-debts {
    text-align: center;
    padding: 20px;
    color: #a0aec0;
}

.no-debts i {
    font-size: 3rem;
    margin-bottom: 15px;
    display: block;
}

.debt-item {
    background: #f7fafc;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px;
    transition: all 0.3s ease;
    position: relative;
}

.debt-item:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.1);
}

.debt-item.priority {
    /* Softer, lighter background for priority items for better readability */
    border-color: rgba(229,62,62,0.22);
    background: linear-gradient(135deg, #fff5f5 0%, #fff1f1 100%);
}

/* Inline priority icon next to the debt name */
.priority-icon {
    margin-left: 10px;
    font-size: 1.1rem;
    vertical-align: middle;
    display: inline-block;
}

/* Numeric priority badge (1,2,3...) shown before the debt name */
.priority-badge {
    display: inline-block;
    min-width: 30px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-color) 0%, #5865d6 100%);
    color: white;
    font-weight: 700;
    margin-right: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    font-size: 0.95rem;
}

.debt-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    gap: 12px;
}

/* Ensure the debt name takes remaining space so buttons sit on the right */
.debt-name {
    flex: 1 1 auto;
    min-width: 0; /* allow truncation if necessary */
}

/* Push the actions to the far right */
.debt-header .debt-actions {
    margin-left: auto;
}

.debt-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: #2d3748;
}

.debt-actions {
    display: flex;
    gap: 10px;
}

/* Less emphasised delete button: outline icon style */
.delete-debt-btn {
    background: transparent;
    color: #e53e3e;
    border: 1px solid rgba(229,62,62,0.12);
    padding: 8px 10px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
}
.delete-debt-btn i { font-size: 16px; }
.delete-debt-btn:hover {
    background: rgba(229,62,62,0.06);
    border-color: rgba(229,62,62,0.22);
    transform: translateY(-1px);
}

.debt-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.debt-detail {
    display: flex;
    flex-direction: column;
}

.debt-detail-label {
    font-size: 0.9rem;
    color: #718096;
    margin-bottom: 5px;
}

.debt-detail-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2d3748;
}

.debt-progress {
    margin-top: 15px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 5px;
}

/* Segmented progress bar: composed of used (standard + promo) and free portions */
.progress-bar.segmented {
    display: flex;
    align-items: stretch;
    background: #e2e8f0;
}

.progress-bar.segmented > div {
    height: 100%;
    float: left; /* lay segments side-by-side */
    transition: width 0.3s ease;
}

.progress-standard {
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%); /* primary used color */
}

.progress-promo {
    background: linear-gradient(90deg, #fef3c7 0%, #f6ad55 100%); /* promo highlight */
}

.progress-free {
    background: linear-gradient(90deg, #e6fffa 0%, #c6f6d5 100%); /* available credit */
}

/* Fallback single fill (used when segmentation fails) */
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s ease;
}

/* Tooltip shown when hovering the segmented progress bar */
.progress-seg-tooltip {
    position: absolute;
    display: none;
    z-index: 9999;
    background: #111827;
    color: #fff;
    border-radius: 8px;
    padding: 8px 10px;
    box-shadow: 0 8px 28px rgba(2,6,23,0.4);
    font-size: 0.9rem;
    min-width: 120px;
}
.progress-seg-tooltip .ps-row { display:flex; justify-content:space-between; gap:12px; padding:2px 0; }
.progress-seg-tooltip .ps-row strong { font-weight:700; color:#e6edf3; }

/* Small rounded indicators inside the bar for clearer segmentation on narrow bars */
.progress-standard, .progress-promo, .progress-free { border-radius: 0; }
/* Apply rounded corners to the left-most and right-most visible segments */
.progress-bar.segmented > div:first-child { border-top-left-radius: 4px; border-bottom-left-radius: 4px; }
.progress-bar.segmented > div:last-child { border-top-right-radius: 4px; border-bottom-right-radius: 4px; }

.progress-text {
    font-size: 0.9rem;
    color: #718096;
    text-align: center;
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.summary-card {
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    transition: all 0.3s ease;
}

.summary-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.summary-card h3 {
    color: #4a5568;
    margin-bottom: 10px;
    font-size: 1rem;
}

.summary-card span {
    font-size: 1rem;
    font-weight: 700;
    color: #2d3748;
}

/* Schedule legend */
.schedule-legend {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    color: #4a5568;
}
.legend-swatch {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    display: inline-block;
    box-shadow: 0 2px 8px rgba(2,6,23,0.08);
}
.priority-swatch {
    background: linear-gradient(135deg, #bfdbfe 0%, #60a5fa 100%);
    border: 1px solid #93c5fd;
}
.promo-swatch {
    background: linear-gradient(135deg, #fef3c7 0%, #f6ad55 100%);
    border: 1px solid #facc15;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(2,6,23,0.48);
    backdrop-filter: blur(6px) saturate(120%);
}

/* Header floating add button */
.header-add-btn {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
    padding: 0 10px;
}

/* Generate schedule button when placed in the debts section header */
.header-generate-btn {
    width: auto;
    height: 40px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 12px;
}

.header-generate-btn:hover {
    box-shadow: inset 0 0 0 9999px rgba(0,0,0,0.04) ;
    background: rgba(0,0,0,0.06);
    transform: translateY(-2px);
}

.modal { z-index: 2000; }

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 15px;
    width: 90%;
    max-width: 800px; /* Increased width for better form layout */
    /* Ensure modal never exceeds viewport height and allow internal scrolling */
    max-height: calc(100vh - 64px);
    box-shadow: 0 24px 80px rgba(2,6,23,0.25);
    animation: modalPopIn 220ms cubic-bezier(.2,.9,.2,1);
    transform-origin: 50% 10%;
    overflow: hidden;
}

@keyframes modalPopIn {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.992);
    }
    60% {
        transform: translateY(2px) scale(1.002);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;

    /* Narrow budget input so it visually matches control sizes and doesn't stretch too wide */
    .budget-input {
        width: 72px; /* tighter width for up to 4 digits */
        flex: 0 0 72px; /* prevent flex container from stretching it */
        box-sizing: border-box;
        padding: 8px 10px;
        border-radius: 8px;
        border: 1px solid #e2e8f0;
        font-size: 1rem;
        text-align: left;
    }

    /* Stronger clamp animation: quick shake + orange highlight */
    .budget-clamped {
        animation: clampShake 650ms cubic-bezier(.2,.8,.2,1);
        border-color: #f97316 !important; /* orange highlight */
        box-shadow: 0 6px 18px rgba(249,115,22,0.12);
    }

    @keyframes clampShake {
        0% { transform: translateX(0); }
        12% { transform: translateX(-6px); }
        24% { transform: translateX(6px); }
        36% { transform: translateX(-4px); }
        48% { transform: translateX(4px); }
        60% { transform: translateX(-2px); }
        72% { transform: translateX(2px); }
        100% { transform: translateX(0); }
    }
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #f1f5f9;
}

/* Transient helper that appears when budget input is clamped */
.budget-clamp-helper {
    background: rgba(2,6,23,0.95);
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    box-shadow: 0 6px 18px rgba(2,6,23,0.12);
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 220ms ease, transform 220ms ease;
    z-index: 3000;
}
.budget-clamp-helper.visible { opacity: 1; transform: translateY(0); }

.modal-header h3 {
    color: var(--accent-color);
    font-size: 1.4rem;
    margin: 0;
}

.close {
    color: #6b7280;
    font-size: 22px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
}

.close:hover {
    background: #fff5f5;
    color: #c53030;
    transform: translateY(-1px);
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin: 0;
    padding: 16px 24px 20px 24px;
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(250,250,250,0));
    border-top: 1px solid #f1f5f9;
}

/* Modal body/content area */
.modal-body {
    padding: 18px 24px 8px 24px;
    /* Allow the body to scroll when modal content is tall. Keep header/footer fixed. */
    overflow: auto;
    max-height: calc(100vh - 200px);
}

/* Footer alias for older markup */
.modal-footer { padding: 12px 24px 20px 24px; }

/* Tighter, more consistent form layout inside modals */
.modal .form-row { gap: 18px; }
.modal .form-group label { margin-bottom: 10px; }
.modal .form-group input { padding: 14px 16px; font-size: 1rem; }
.modal .form-group select { padding: 12px 14px; }

/* Make action buttons slightly larger and more prominent in dialogs */
.modal .btn { padding: 12px 20px; }

/* Modal error display */
.modal-errors {
    background: #fed7d7;
    border: 1px solid #feb2b2;
    color: #9b2c2c;
    padding: 12px 16px;
    border-radius: 6px;
    margin: 16px 0;
    font-size: 0.9rem;
}

.modal-errors ul {
    margin: 0;
    padding-left: 10px;
}

.modal-errors li {
    margin: 4px 0;
}

/* Improve visual separation for field groups inside dialogs */
.modal .field-group { padding: 10px 0; border-bottom: 1px solid #f1f5f9; }
.modal .field-group:last-child { border-bottom: none; }

/* Confirm modal specific tweaks */
#confirm-modal .modal-content { max-width: 520px; }
#confirm-modal .modal-body { font-size: 1rem; color: #374151; padding-top: 12px; padding-bottom: 12px; }
#confirm-modal .btn-danger { background: #e53e3e; }

/* Slightly round the modal content corners for a softer look */
.modal-content { border-radius: 14px; }

/* =================================================================
   RESPONSIVE DESIGN WITH MODERN APPROACHES
   ================================================================= */

/* Container queries for payment schedule */
.schedule-container {
    container-type: inline-size;
    max-height: 105vh;
    overflow-y: auto;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-xl);
    background: var(--gray-50);
}

/* Use container queries when supported */
@container (max-width: 600px) {
    .payment-schedule-table {
        font-size: 0.75rem;
    }
    
    .payment-schedule-table th,
    .payment-schedule-table td {
        padding: 6px 4px;
    }
}

/* Fallback media queries */
@media (max-width: 768px) {
    .container {
        padding: var(--space-md);
    }

    /* Make sure the add button inside the Your Debts header doesn't overlap on small screens */
    .debts-section h2 { 
        padding-right: 160px; 
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }
    
    /* Stack three-column layout on mobile */
    .three-cols {
        grid-template-columns: 1fr;
        gap: var(--space-sm);
    }
    
    /* Simplify payment type group on mobile */
    .radio-group {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }
    
    .settings-row {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-md);
    }
    
    .debt-details {
        grid-template-columns: 1fr;
    }
    
    .summary-cards {
        grid-template-columns: 1fr;
    }
    
    .debt-actions {
        flex-wrap: wrap;
    }
    
    .modal-content {
        margin: 6% auto;
        width: 95%;
        max-height: calc(100vh - 40px);
    }
    
    /* Schedule table mobile optimizations */
    .schedule-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .schedule-info {
        flex: 1 1 auto;
        margin-left: 0;
        text-align: left;
    }
    
    .payment-schedule-table {
        font-size: 0.8rem;
    }
    
    .payment-schedule-table th,
    .payment-schedule-table td {
        padding: 8px 4px;
    }
    
    .payment-schedule-table .month-column {
        min-width: 80px;
    }
    
    .payment-schedule-table .debt-column {
        min-width: 60px;

/* === FORM FIELD INDICATORS === */
.field-indicator {
    font-size: 0.75rem;
    font-weight: 500;
    margin-left: 4px;
    display: inline-block;
}


.field-indicator.required {
    color: #dc2626 !important;
    font-weight: bold !important;
    margin-left: 2px;
    vertical-align: middle;
    font-size: 1.1em;
}

.field-indicator.optional {
    color: #6b7280;
}

/* Add visual indicator to required field labels */

label.required::after,
.form-group label.required::after {
    content: " *";
    color: #dc2626 !important;
    font-weight: bold !important;
}

/* Style for small help text under labels */
.field-help {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 2px;
    display: block;
    line-height: 1.3;
}
        font-size: 0.7rem;
    }
}

@media (max-width: 480px) {
    .debt-form {
        gap: var(--space-md);
    }
    
    section {
        padding: var(--space-lg);
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn-primary {
        background: var(--gray-900);
        border: 2px solid var(--gray-900);
    }
    
    .debt-item:hover {
        border-color: var(--gray-900);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.debt-item {
    animation: fadeIn 0.5s ease;
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.text-success {
    color: #38a169;
}

.text-danger {
    color: #e53e3e;
}

.text-warning {
    color: #d69e2e;
}

.mb-0 {
    margin-bottom: 0;
}

.mt-20 {
    margin-top: 20px;
}

/* Monthly Payment Schedule */
.schedule-section {
    background: white;
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.schedule-section:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.15);
}

.schedule-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 15px;
}

.schedule-info {
    /* Keep the legend on the left and push this info to the right */
    flex: 0 0 auto;
    margin-left: auto;
    min-width: 200px;
    text-align: right;
}

.schedule-info span {
    color: #4a5568;
    font-weight: 500;
}

.schedule-container {
    /* allow the schedule to use more of the viewport height so more rows show by default */
    max-height: 105vh;
    overflow-y: auto;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: #f7fafc;
}

/* Chart visuals removed */

.no-schedule {
    text-align: center;
    padding: 40px;
    color: #a0aec0;
}

.no-schedule i {
    font-size: 3rem;
    margin-bottom: 15px;
    display: block;
}

.payment-schedule-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    /* slightly smaller font to allow more rows to fit comfortably */
    font-size: 0.88rem;
}

.payment-schedule-table th {
    /* simplified header: single accent color for better contrast and readability */
    background: var(--accent-color-light);
    color: #ffffff;
    padding: 10px 6px; /* slightly tighter */
    text-align: center;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

.payment-schedule-table td {
    padding: 8px 6px; /* denser rows so more fit on screen */
    text-align: center;
    border-bottom: 1px solid #e2e8f0;
}

.payment-schedule-table tr:nth-child(even) {
    background: #f7fafc;
}

.payment-schedule-table tr:hover {
    background: #edf2f7;
}

.payment-schedule-table .month-column {
    font-weight: 600;
    color: #2d3748;
    min-width: 100px;
}

.payment-schedule-table .debt-column {
    min-width: 80px;
    font-size: 0.8rem;
}

.payment-schedule-table .balance-column {
    font-weight: 600;
    color: #2d3748;
}

.payment-schedule-table .payment-column {
    font-weight: 600;
    color: #38a169;
}

.payment-schedule-table .interest-column {
    color: #e53e3e;
}

.payment-schedule-table .principal-column {
    color: #052c50;
}

.payment-schedule-table .paid-off {
    background: #c6f6d5 !important;
    color: #22543d;
    font-weight: 600;
}

.payment-schedule-table .current-month {
    background: #fef5e7 !important;
    border: 2px solid #f6ad55;
}

.schedule-summary {
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px; /* slightly reduced padding for compactness */
    margin-bottom: 20px;
}

.schedule-summary h3 {
    color: #2d3748;
    margin-bottom: 8px;
    font-size: 1rem; /* smaller heading */
}

.schedule-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.schedule-summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0; /* reduced vertical padding */
    border-bottom: 1px solid #e2e8f0;
    font-size: 1rem; /* smaller font size */
}

.schedule-summary-item:last-child {
    border-bottom: none;
}

.schedule-summary-label {
    color: #4a5568;
    font-weight: 500;
    font-size: 0.92rem; /* reduced label size */
}

.schedule-summary-value {
    color: #2d3748;
    font-weight: 600;
    font-size: 0.95rem; /* slightly smaller value text */
}

/* Responsive table */
@media (max-width: 768px) {
    /* Fix schedule header button overlap */
    .schedule-section h2 {
        padding-right: 0;
        padding-bottom: 50px;
        position: relative;
    }
    
    .schedule-section h2 > div {
        position: absolute !important;
        right: 0 !important;
        top: 40px !important;
        transform: none !important;
    }
    
    .schedule-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    /* On small screens, let schedule-info sit full width and align left for readability */
    .schedule-info {
        flex: 1 1 auto;
        margin-left: 0;
        text-align: left;
    }
    
    .payment-schedule-table {
        font-size: 0.8rem;
    }
    
    .payment-schedule-table th,
    .payment-schedule-table td {
        padding: 8px 4px;
    }
    
    .payment-schedule-table .month-column {
        min-width: 80px;
    }
    
    .payment-schedule-table .debt-column {
        min-width: 60px;
        font-size: 0.7rem;
    }
}
