/* Prevent horizontal scroll on mobile */
html {
    overflow-x: hidden;
    width: 100%;
}

:root {
    /* Apple Design System Colors */
    --apple-background: #ffffff;
    --apple-surface: #f5f5f7;
    --apple-card: #ffffff;
    --apple-border: rgba(0, 0, 0, 0.04);
    --apple-border-strong: rgba(0, 0, 0, 0.08);
    --apple-text-primary: #1d1d1f;
    --apple-text-secondary: #86868b;
    --apple-text-tertiary: #515154;
    --apple-blue: #0071e3;
    --apple-blue-hover: #0077ed;
    --apple-blue-light: rgba(0, 113, 227, 0.08);
    --apple-green: #34c759;
    --apple-red: #ff3b30;
    --apple-orange: #ff9500;
    --apple-purple: #af52de;
    --apple-teal: #5ac8fa;
    --apple-shadow-sm: 0 2px 5px rgba(0, 0, 0, 0.05);
    --apple-shadow-md: 0 4px 20px rgba(0, 0, 0, 0.08);
    --apple-shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);
    --apple-shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.15);
    --apple-radius-sm: 8px;
    --apple-radius-md: 12px;
    --apple-radius-lg: 16px;
    --apple-radius-xl: 20px;
    --apple-transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --apple-transition-fast: all 0.15s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", "Helvetica", "Arial", "PingFang TC", "Microsoft JhengHei", sans-serif;
    background: linear-gradient(180deg, #ffffff 0%, #f5f5f7 100%);
    min-height: 100vh;
    padding: 0;
    margin: 0;
    color: var(--apple-text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 16px;
    line-height: 1.5;
    width: 100%;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    font-weight: 400;
    letter-spacing: -0.022em;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loader {
    text-align: center;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--apple-blue);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Sidebar Styles */
.no-files {
    padding: 20px;
    text-align: center;
    color: #999;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #e0e0e0;
    cursor: pointer;
    transition: background 0.2s;
}

.file-item:hover {
    background: #f5f5f7;
}

.file-info {
    flex: 1;
}

.file-name {
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
}

.file-date {
    font-size: 12px;
    color: #999;
}

.file-actions {
    display: flex;
    gap: 8px;
}

.file-action-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    font-size: 16px;
}

.file-action-btn:hover {
    background: #e0e0e0;
}
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 300px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-right: 0.5px solid var(--apple-border-strong);
    z-index: 100;
    display: flex;
    flex-direction: column;
    transform: translateX(0);
    transition: var(--apple-transition);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header {
    padding: 32px 24px 24px;
    background: transparent;
    border-bottom: 1px solid var(--apple-border);
}

/* Larger buttons in sidebar */
.sidebar .btn,
.sidebar button {
    font-size: 16px;
    min-height: 42px;
    padding: 10px 18px;
}

.new-save-btn {
    font-size: 16px !important;
    min-height: 44px !important;
    padding: 12px 20px !important;
}

.sidebar-title {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--apple-text-primary);
    letter-spacing: -0.02em;
}

/* Mobile Navigation (Hidden by default on desktop) */
.mobile-nav {
    display: none;
}

/* Floating record manager toggle */
.sidebar-toggle {
    position: fixed;
    top: 12px;
    left: 12px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid var(--apple-border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 150;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 0;
    color: #333;
}

.sidebar-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.sidebar-toggle svg {
    width: 24px;
    height: 24px;
}

.desktop-sidebar-toggle {
    display: flex;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

/* Settings Icon in Top Right */
.settings-icon {
    position: fixed;
    top: 12px;
    right: 12px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid var(--apple-border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 150;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.settings-icon:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.settings-icon svg {
    width: 24px;
    height: 24px;
    color: #333;
}

/* Settings Modal */
.settings-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.settings-modal.active {
    display: flex;
}

.settings-content {
    background: white;
    border-radius: 20px;
    padding: 32px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    border: 1px solid var(--apple-border);
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--apple-border);
}

.settings-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--apple-text-primary);
}

.settings-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f0f0f0;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.settings-close:hover {
    background: #e0e0e0;
}

.settings-section {
    margin-bottom: 24px;
}

.settings-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #666;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.settings-select {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    border: 1px solid var(--apple-border);
    border-radius: 10px;
    background: white;
    color: var(--apple-text-primary);
    cursor: pointer;
    transition: border-color 0.2s;
}

.settings-select:focus {
    outline: none;
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.saved-files {
    padding: 20px;
}

.saved-file-item {
    background: var(--apple-card);
    border: 1px solid var(--apple-border);
    border-radius: var(--apple-radius-sm);
    padding: 14px;
    margin-bottom: 8px;
    transition: var(--apple-transition);
    cursor: pointer;
    box-shadow: var(--apple-shadow-sm);
}

.saved-file-item:hover {
    background: var(--apple-surface);
    box-shadow: var(--apple-shadow-md);
    transform: translateY(-2px);
}

.saved-file-item.active {
    border: 2px solid #FFC107;
    box-shadow: 0 0 10px rgba(255, 193, 7, 0.3);
    background: rgba(255, 193, 7, 0.05);
}

.file-name {
    font-weight: 500;
    color: var(--apple-text-primary);
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.file-date {
    font-size: 12px;
    color: var(--apple-text-secondary);
    font-weight: 400;
}

.file-actions {
    display: flex;
    gap: 5px;
    margin-top: 8px;
}

.file-action-btn {
    padding: 6px 12px;
    font-size: 12px;
    border: none;
    border-radius: var(--apple-radius-sm);
    cursor: pointer;
    transition: var(--apple-transition);
    font-weight: 500;
}

.btn-load-file {
    background: var(--apple-blue);
    color: white;
}

.btn-rename-file {
    background: var(--apple-surface);
    color: var(--apple-text-primary);
    border: 1px solid var(--apple-border);
}

.btn-delete-file {
    background: transparent;
    color: var(--apple-red);
    border: 1px solid var(--apple-red);
}

.new-save-btn {
    width: 100%;
    background: var(--apple-blue);
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: var(--apple-radius-sm);
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    margin-bottom: 16px;
    transition: var(--apple-transition);
    letter-spacing: -0.01em;
}

.new-save-btn:hover {
    background: var(--apple-blue-hover);
    transform: scale(1.02);
}

/* Main Content */
.main-content {
    margin-left: 300px;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
    min-height: 100vh;
    max-width: 1400px;
    margin-right: auto;
}

/* Header */
.header {
    max-width: 980px;
    margin: 0 auto;
    padding: 40px 20px 30px;
}

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

h1 {
    font-size: 42px;
    font-weight: 600;
    color: var(--apple-text-primary);
    letter-spacing: -0.005em;
    line-height: 1.1;
    font-family: "SF Pro Display", -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Mode Selector */
.mode-selector {
    display: flex;
    gap: 0;
    background: rgba(0, 0, 0, 0.04);
    padding: 2px;
    border-radius: 10px;
    margin: 20px auto;
    width: fit-content;
}

.mode-btn {
    padding: 10px 24px;
    border: none;
    background: transparent;
    color: var(--apple-text-primary);
    font-size: 15px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--apple-transition-fast);
    position: relative;
    font-family: "SF Pro Text", -apple-system, BlinkMacSystemFont, sans-serif;
}

.mode-btn:hover:not(.active) {
    background: rgba(0, 0, 0, 0.03);
}

.mode-btn.active {
    background: white;
    color: var(--apple-text-primary);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* Cash Input */
.cash-input-container {
    max-width: 500px;
    margin: 30px auto;
    background: var(--apple-card);
    padding: 24px;
    border-radius: var(--apple-radius-xl);
    box-shadow: var(--apple-shadow-lg);
    text-align: center;
    border: 0.5px solid var(--apple-border);
}

.cash-input-container label {
    display: block;
    font-size: 16px;
    font-weight: 500;
    color: var(--apple-text-secondary);
    margin-bottom: 12px;
}

.cash-input {
    padding: 12px 16px;
    font-size: 20px;
    font-weight: 600;
    border: 0.5px solid var(--apple-border-strong);
    border-radius: var(--apple-radius-md);
    width: 200px;
    text-align: center;
    color: var(--apple-text-primary);
    transition: var(--apple-transition-fast);
    background: white;
}

.cash-input:focus {
    outline: none;
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 4px var(--apple-blue-light);
}

/* Main Container */
.main-container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    margin-bottom: 40px;
    padding: 0 24px;
}

.column {
    background: var(--apple-card);
    border-radius: var(--apple-radius-xl);
    padding: 36px;
    box-shadow: var(--apple-shadow-lg);
    border: 0.5px solid var(--apple-border);
    transition: var(--apple-transition);
}

.column:hover {
    box-shadow: var(--apple-shadow-xl);
}

.column-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0;
    margin-bottom: 32px;
    font-size: 28px;
    font-weight: 600;
    padding-bottom: 16px;
    border-bottom: 0.5px solid var(--apple-border);
}

.income-header {
    color: var(--apple-green);
    border-bottom-color: var(--apple-green);
}

.expense-header {
    color: var(--apple-red);
    border-bottom-color: var(--apple-red);
}

.total-amount {
    font-size: 20px;
    font-weight: 500;
}

/* Sections */
.section {
    margin-bottom: 30px;
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 20px;
    font-weight: 600;
    color: var(--apple-text-primary);
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--apple-border);
}

.section-total {
    font-size: 16px;
    font-weight: 500;
}

/* Item Rows */
.items-container {
    margin-bottom: 16px;
}

.item-row {
    display: flex;
    gap: 0;
    margin-bottom: 10px;
    background: var(--apple-surface);
    border-radius: var(--apple-radius-md);
    align-items: center;
    transition: var(--apple-transition-fast);
    border: 0.5px solid var(--apple-border);
    animation: slideIn 0.3s ease;
    position: relative;
    overflow: hidden;
}

.item-row:hover {
    background: white;
    box-shadow: var(--apple-shadow-sm);
    border-color: var(--apple-border-strong);
}

/* Status indicator (left side dot) - Hidden on all platforms */
.item-status-indicator {
    display: none;
}

/* Wrapper that slides */
.item-row-wrapper {
    display: flex;
    gap: 8px;
    padding: 14px 10px 14px 6px;
    align-items: center;
    flex: 1;
    background: inherit;
    transition: transform 0.3s ease;
    z-index: 2;
}

.item-row-wrapper input:not([type="checkbox"]) {
    flex: 1;
    padding: 12px 16px;
    border: 0.5px solid var(--apple-border-strong);
    border-radius: var(--apple-radius-sm);
    font-size: 15px;
    transition: var(--apple-transition-fast);
    background: white;
    min-width: 0;
    font-weight: 400;
    color: var(--apple-text-primary);
}

/* Checkbox for desktop */
.item-checkbox {
    display: none; /* Hide by default on all devices */
    width: 16px !important;
    height: 16px !important;
    min-width: 16px !important;
    max-width: 16px !important;
    flex: 0 0 16px !important;
    flex-shrink: 0;
    cursor: pointer;
    margin-right: 6px;
    margin-left: 2px;
}

/* Desktop delete button (trash icon) */
.btn-delete-desktop {
    display: none; /* Hide by default */
    background: transparent;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 6px;
    margin-left: 2px;
    transition: color 0.2s ease;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-delete-desktop:hover {
    color: var(--apple-red);
}

/* 顯示刪除按鈕和 checkbox（桌面和手機都顯示）*/
.btn-delete-desktop {
    display: flex;
}

.item-checkbox {
    display: block;
}

/* Mobile: show all buttons directly (no swipe) */
@media (max-width: 768px) {
    /* Hide right-side action buttons */
    .item-row-actions {
        display: none !important;
    }

    /* Remove extra padding */
    .item-row {
        padding: 0 !important;
    }

    .item-row-wrapper {
        /* Normal layout - no hidden buttons */
        padding: 10px 6px !important;
        display: flex !important;
        gap: 6px !important;
        align-items: center !important;
    }

    /* Make all inputs scale proportionally */
    .item-row-wrapper input:not([type="checkbox"]),
    .item-row-wrapper button {
        flex-shrink: 1;
        min-width: 0;
    }

    /* Checkbox size - 正方形 */
    .item-checkbox {
        width: 20px !important;
        height: 20px !important;
        min-width: 20px !important;
        max-width: 20px !important;
        flex-shrink: 0 !important;
        margin: 0 !important;
        cursor: pointer !important;
        -webkit-appearance: checkbox !important;
        appearance: checkbox !important;
    }

    /* Delete button size - 更大 */
    .btn-delete-desktop {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        max-width: 36px !important;
        padding: 6px !important;
        flex-shrink: 0 !important;
        border-radius: 6px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .btn-delete-desktop svg {
        width: 18px !important;
        height: 18px !important;
    }
}

/* Disabled state */
.item-row.disabled {
    opacity: 0.5;
}

.item-row.disabled .item-row-wrapper input:not([type="checkbox"]) {
    text-decoration: line-through;
    color: var(--apple-text-secondary);
}

.item-row-wrapper input:not([type="checkbox"]):focus {
    outline: none;
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 4px var(--apple-blue-light);
}

/* Income Section Specific */
.platform-name {
    flex: 3 1 auto;
    min-width: 80px;
}

.revenue {
    flex: 2 1 auto;
    min-width: 70px;
    max-width: 150px;
}

.margin {
    flex: 1 0 auto;
    min-width: 50px;
    max-width: 80px;
}

.gross-profit {
    flex: 0 0 auto;
    background: rgba(52, 199, 89, 0.1);
    color: var(--apple-green);
    padding: 8px 12px;
    border-radius: var(--apple-radius-sm);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    min-width: 60px;
    max-width: 90px;
    text-align: center;
    border: 1px solid rgba(52, 199, 89, 0.2);
}

.income-source {
    flex: 3 1 auto;
    min-width: 80px;
}

.income-amount {
    flex: 2 1 auto;
    min-width: 60px;
    max-width: 150px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 980px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--apple-transition-fast);
    letter-spacing: -0.01em;
    font-family: "SF Pro Text", -apple-system, BlinkMacSystemFont, sans-serif;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Removed - btn-remove is replaced by swipe actions */

.btn-add {
    background: transparent;
    color: var(--apple-blue);
    width: 100%;
    margin-top: 16px;
    padding: 14px;
    font-size: 15px;
    border: 1.5px solid var(--apple-blue);
    border-radius: var(--apple-radius-md);
    font-weight: 600;
}

.btn-add:hover {
    background: var(--apple-blue);
    color: white;
}

.btn-primary {
    background: var(--apple-blue);
    color: white;
    padding: 16px 32px;
    font-size: 17px;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0, 113, 227, 0.2);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Add line chart icon before calculate button text */
.btn-primary#calculateBtn::before {
    content: "📈";
    font-size: 18px;
}

.btn-primary:hover {
    background: var(--apple-blue-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 113, 227, 0.3);
}

.btn-secondary {
    background: rgba(0, 0, 0, 0.04);
    color: var(--apple-text-primary);
    border: none;
    padding: 14px 28px;
    font-weight: 500;
}

.btn-secondary:hover {
    background: rgba(0, 0, 0, 0.08);
}

.btn-danger {
    background: transparent;
    color: var(--apple-red);
    border: 1.5px solid var(--apple-red);
    padding: 14px 28px;
    font-weight: 500;
}

.btn-danger:hover {
    background: var(--apple-red);
    color: white;
}

.btn-info {
    background: transparent;
    color: var(--apple-teal, #5AC8FA);
    border: 1.5px solid var(--apple-teal, #5AC8FA);
    padding: 14px 28px;
    font-weight: 500;
}

.btn-info:hover {
    background: var(--apple-teal, #5AC8FA);
    color: white;
}

/* Action Buttons Container */
.action-buttons {
    max-width: 980px;
    margin: 40px auto;
    display: flex;
    justify-content: center;
    gap: 16px;
    padding: 0 24px;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal.closing {
    animation: fadeOutBackground 0.2s ease forwards;
}

.modal.closing .modal-content {
    animation: slideDown 0.2s ease forwards;
}

.modal-content {
    background: var(--apple-card);
    border-radius: var(--apple-radius-lg);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 32px 64px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s;
    border: 1px solid var(--apple-border);
}

.modal-header {
    padding: 32px;
    background: linear-gradient(135deg, var(--apple-blue) 0%, #0051a2 100%);
    color: white;
    border-radius: var(--apple-radius-lg) var(--apple-radius-lg) 0 0;
    position: relative;
}

.modal-title {
    font-size: 28px;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 32px;
    color: white;
    cursor: pointer;
    background: none;
    border: none;
    opacity: 0.8;
    transition: all 0.2s;
}

.modal-close:hover {
    opacity: 1;
    transform: scale(1.1);
}

.modal-body {
    padding: 30px;
}


.projection-table-container {
    width: 100%;
    overflow-x: auto;
}

.projection-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    min-width: 520px;
}

.projection-table th,
.projection-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
    text-align: right;
    white-space: nowrap;
}

.projection-table th:first-child,
.projection-table td:first-child {
    text-align: left;
}

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



.modal-footer {
    padding: 20px 30px;
    background: #f7fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    border-radius: 0 0 16px 16px;
}

.modal-footer .btn {
    margin-left: 20px;
}

.modal-footer .btn:first-child {
    margin-left: 0;
}

/* Floating Calculate Button */
.floating-calculate-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 16px 24px;
    background: var(--apple-blue);
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 125, 250, 0.3);
    z-index: 190;
    transition: all 0.2s ease;
}

/* Add line chart icon before text on desktop */
.floating-calculate-btn::before {
    content: "📈";
    font-size: 18px;
    margin-right: 8px;
}

.floating-calculate-btn:hover {
    background: var(--apple-blue-dark, #0051C3);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 125, 250, 0.4);
}

/* Floating Ask AI Button */
.floating-ask-ai-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: 96px;
    right: 24px;
    padding: 14px 22px;
    background: var(--apple-purple);
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(175, 82, 222, 0.3);
    z-index: 190;
    transition: all 0.2s ease;
    gap: 8px;
}

.floating-ask-ai-btn:hover {
    background: #9932cc;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(175, 82, 222, 0.4);
}

.floating-ask-ai-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Ask AI Modal */
.ask-ai-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.ask-ai-modal.active {
    display: flex;
}

.ask-ai-content {
    background: white;
    border-radius: 20px;
    padding: 0;
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    border: 1px solid var(--apple-border);
    animation: slideUp 0.3s ease;
}

.ask-ai-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 28px;
    background: linear-gradient(135deg, var(--apple-purple) 0%, #9932cc 100%);
    color: white;
    border-radius: 20px 20px 0 0;
}

.ask-ai-title {
    font-size: 24px;
    font-weight: 600;
    margin: 0;
}

.ask-ai-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    color: white;
    font-size: 20px;
}

.ask-ai-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.ask-ai-body {
    padding: 24px 28px;
}

.ask-ai-section {
    margin-bottom: 24px;
}

.ask-ai-section:last-child {
    margin-bottom: 0;
}

.ask-ai-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #666;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ask-ai-textarea {
    width: 100%;
    min-height: 150px;
    padding: 14px;
    border: 1px solid var(--apple-border);
    border-radius: 10px;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
    resize: vertical;
    background: var(--apple-surface);
    color: var(--apple-text-primary);
    cursor: pointer;
    transition: border-color 0.2s;
    line-height: 1.5;
}

.ask-ai-textarea:focus {
    outline: none;
    border-color: var(--apple-purple);
    box-shadow: 0 0 0 3px rgba(175, 82, 222, 0.1);
}

.ask-ai-textarea:hover {
    border-color: var(--apple-border-strong);
}

/* AI Service Links */
.ai-service-links {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.ai-service-link {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 12px 14px;
    background: var(--apple-surface);
    border: 1px solid var(--apple-border);
    border-radius: 12px;
    text-decoration: none;
    color: var(--apple-text-primary);
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.ai-service-btn {
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
    text-align: left;
    white-space: nowrap;
}

.ai-service-link:hover {
    background: white;
    border-color: var(--apple-purple);
    box-shadow: 0 2px 8px rgba(175, 82, 222, 0.1);
    transform: translateY(-2px);
}

.ai-service-icon {
    margin-right: 8px;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Locale Selectors */
.locale-selectors {
    display: flex;
    gap: 10px;
}

.locale-select {
    padding: 8px 12px;
    border: 1px solid var(--apple-border-strong);
    border-radius: var(--apple-radius-sm);
    background: white;
    color: var(--apple-text-primary);
    font-size: 14px;
    cursor: pointer;
    min-width: 100px;
}

.locale-select:focus {
    outline: none;
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 3px var(--apple-blue-light);
}

/* Top Controls Navigation Bar */
.top-controls {
    position: fixed;
    top: 0;
    left: 300px;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    padding: 15px 24px;
    z-index: 90;
    border-bottom: 0.5px solid var(--apple-border);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 12px;
    align-items: center;
    overflow-x: auto;
}

.top-controls .btn {
    flex: 0 0 auto;
    white-space: nowrap;
    min-width: fit-content;
}

/* Result Container Styles */
.result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e0e0e0;
}

.summary-info {
    flex: 1;
}

.summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.summary-label {
    font-weight: 500;
    color: #666;
    margin-right: 12px;
    min-width: auto;
    white-space: nowrap;
}

.summary-value {
    font-size: 18px;
    font-weight: bold;
    text-align: right;
}

.summary-value.positive {
    color: #34c759;
}

.summary-value.negative {
    color: #ff3b30;
}

.period-selector-panel {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    min-width: 0;
    margin-bottom: 16px;
}

.period-label {
    font-weight: 500;
    color: #666;
    margin-bottom: 4px;
}

.period-select {
    width: 100px;
    min-width: 90px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

.custom-period {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.custom-period-input {
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    width: 80px;
    text-align: right;
}

.chart-click-info {
    pointer-events: none;
}

/* Notifications */
.notifications-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
}

.notification {
    background: white;
    border-radius: var(--apple-radius-md);
    padding: 16px 20px;
    margin-bottom: 10px;
    box-shadow: var(--apple-shadow-lg);
    animation: slideInRight 0.3s ease;
    min-width: 300px;
}

.notification.success {
    border-left: 4px solid var(--apple-green);
}

.notification.error {
    border-left: 4px solid var(--apple-red);
}

.notification.info {
    border-left: 4px solid var(--apple-blue);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

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

/* Modal Result Styles */
.result-container {
    padding: 20px;
}

.period-selector-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding: 15px;
    background: var(--apple-background-secondary);
    border-radius: 10px;
}

.period-select {
    padding: 8px 12px;
    border: 1px solid var(--apple-border);
    border-radius: 6px;
    background: white;
    font-size: 14px;
    cursor: pointer;
}

.custom-period-input {
    padding: 8px 12px;
    border: 1px solid var(--apple-border);
    border-radius: 6px;
    background: white;
    font-size: 14px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.summary-card {
    background: var(--apple-background-secondary);
    border-radius: 12px;
    padding: 14px 18px;
    border: 1px solid var(--apple-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.card-label {
    font-size: 13px;
    color: var(--apple-text-secondary);
    margin-bottom: 8px;
}

.card-value {
    font-size: 24px;
    font-weight: 600;
    color: var(--apple-text);
}

.card-value.positive {
    color: var(--apple-green);
}

.card-value.negative {
    color: var(--apple-red);
}

.chart-container {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--apple-border);
    height: 400px;
}

.projection-details {
    background: var(--apple-background-tertiary);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--apple-border);
}

.projection-details h3 {
    font-size: 18px;
    margin-bottom: 12px;
    color: var(--apple-text);
}

.projection-note {
    font-size: 14px;
    line-height: 1.6;
    color: var(--apple-text-secondary);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* 自動儲存動畫 */
@keyframes fadeInOut {
    0% {
        opacity: 0;
        transform: translateY(-10px);
    }
    20% {
        opacity: 1;
        transform: translateY(0);
    }
    80% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* 旋轉載入動畫 */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* 滑下動畫 */
@keyframes slideDown {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(30px);
        opacity: 0;
    }
}

/* 背景淡出動畫 */
@keyframes fadeOutBackground {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}