/* ===== CSS Variables ===== */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #f59e0b;
    --accent: #ec4899;
    --success: #10b981;
    --danger: #ef4444;
    
    /* 护眼浅色背景 */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --bg-muted: #f1f5f9;
    
    /* 高对比度文字 */
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --border-color: #e2e8f0;
    --border-radius: 16px;
    --border-radius-sm: 10px;
    --border-radius-lg: 24px;
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.15);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ===== Animated Background - 更柔和的装饰 ===== */
.bg-shapes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.15;
    animation: float 20s ease-in-out infinite;
}

.shape-1 {
    width: 500px;
    height: 500px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    top: -150px;
    right: -150px;
    animation-delay: 0s;
}

.shape-2 {
    width: 400px;
    height: 400px;
    background: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
    bottom: -100px;
    left: -100px;
    animation-delay: -7s;
}

.shape-3 {
    width: 300px;
    height: 300px;
    background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
    top: 40%;
    left: 30%;
    animation-delay: -14s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(20px, -20px) scale(1.02); }
    50% { transform: translate(-15px, 15px) scale(0.98); }
    75% { transform: translate(15px, 20px) scale(1.01); }
}

/* ===== Container ===== */
.container {
    position: relative;
    z-index: 1;
    max-width: 1000px;
    margin: 0 auto;
    padding: 40px 20px;
    min-height: 100vh;
}

/* ===== Header ===== */
.header {
    text-align: center;
    margin-bottom: 40px;
}

.logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    border-radius: 20px;
    margin-bottom: 20px;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.3);
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
}

/* ===== Main Card ===== */
.main-card {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    padding: 32px;
    box-shadow: var(--shadow-lg);
}

/* ===== Tabs ===== */
.tabs-container {
    margin-bottom: 32px;
}

.tabs {
    display: flex;
    gap: 8px;
    background: var(--bg-muted);
    padding: 6px;
    border-radius: var(--border-radius);
}

.tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab:hover {
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.08);
}

.tab.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.tab-icon {
    font-size: 1.1rem;
}

/* ===== Form Section ===== */
.form-section {
    margin-bottom: 32px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    margin-bottom: 28px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.label-icon {
    font-size: 1rem;
}

.label-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper input {
    width: 100%;
    padding: 14px 16px;
    padding-right: 50px;
    background: var(--bg-muted);
    border: 2px solid transparent;
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.input-wrapper input::placeholder {
    color: var(--text-muted);
}

.input-wrapper input:focus {
    outline: none;
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.input-suffix {
    position: absolute;
    right: 16px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
}

.select-wrapper {
    position: relative;
}

.select-wrapper select {
    width: 100%;
    padding: 14px 16px;
    padding-right: 40px;
    background: var(--bg-muted);
    border: 2px solid transparent;
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    appearance: none;
    transition: all 0.3s ease;
}

.select-wrapper select:focus {
    outline: none;
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.select-wrapper::after {
    content: '';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--text-secondary);
    pointer-events: none;
}

/* ===== Calculate Button ===== */
.calculate-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 18px 32px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}

.calculate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
}

.calculate-btn:active {
    transform: translateY(0);
}

.btn-icon {
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

.calculate-btn:hover .btn-icon {
    transform: translateX(4px);
}

/* ===== Summary Section - 重要指标突出显示 ===== */
.summary-section {
    margin-bottom: 32px;
    animation: fadeInUp 0.5s ease;
}

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

.summary-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.summary-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 24px 20px;
    background: var(--bg-muted);
    border-radius: var(--border-radius);
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

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

.summary-card.highlight {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border: none;
    transform: scale(1.02);
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.35);
}

.summary-card.highlight:hover {
    transform: scale(1.04) translateY(-4px);
}

.summary-icon {
    font-size: 2rem;
    margin-bottom: 12px;
}

.summary-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.summary-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.summary-card.highlight .summary-label {
    color: rgba(255, 255, 255, 0.85);
}

.summary-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    word-break: break-all;
}

.summary-card.highlight .summary-value {
    color: white;
    font-size: 1.6rem;
}

/* ===== Charts Section ===== */
.charts-section {
    margin-bottom: 32px;
    animation: fadeInUp 0.5s ease 0.1s backwards;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.chart-card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

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

.chart-box {
    height: 280px;
    position: relative;
}

/* ===== Table Section ===== */
.table-section {
    animation: fadeInUp 0.5s ease 0.2s backwards;
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.table-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.export-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-muted);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.export-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.table-wrapper {
    max-height: 400px;
    overflow: auto;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.table-wrapper::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.table-wrapper::-webkit-scrollbar-track {
    background: var(--bg-muted);
    border-radius: 4px;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    position: sticky;
    top: 0;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    padding: 14px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
    z-index: 10;
}

tbody tr {
    transition: all 0.2s ease;
}

tbody tr:nth-child(even) {
    background: var(--bg-muted);
}

tbody tr:hover {
    background: rgba(99, 102, 241, 0.08);
}

tbody td {
    padding: 12px;
    font-size: 0.9rem;
    color: var(--text-primary);
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

tbody tr:last-child td {
    border-bottom: none;
}

.period-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 26px;
    padding: 0 8px;
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 6px;
}

.prepay-tag {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 6px;
    background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
    color: white;
    font-size: 0.7rem;
    font-weight: 500;
    border-radius: 4px;
    vertical-align: middle;
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .container {
        padding: 20px 16px;
    }
    
    .header h1 {
        font-size: 1.8rem;
    }
    
    .main-card {
        padding: 20px;
    }
    
    .tabs {
        flex-direction: column;
    }
    
    .tab {
        justify-content: flex-start;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .summary-cards {
        grid-template-columns: 1fr;
    }
    
    .summary-card.highlight {
        transform: scale(1);
    }
    
    .summary-card.highlight:hover {
        transform: translateY(-4px);
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .chart-box {
        height: 240px;
    }
    
    .table-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .export-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ===== Dark Mode Optimizations ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== Print Styles ===== */
@media print {
    .bg-shapes,
    .calculate-btn,
    .export-btn {
        display: none;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .main-card {
        background: white;
        border: 1px solid #ddd;
        box-shadow: none;
    }
}
