        .markdown-body {
            box-sizing: border-box;
            min-width: 200px;
            max-width: 100%;
            margin: 0;
            padding: 15px;
            background: transparent;
        }

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

        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
            background: #f4f7f6;
            color: #333;
            line-height: 1.6;
            height: 100vh;
            display: flex;
            overflow: hidden;
        }

        /* Sidebar Styles - Light Theme */
        .sidebar {
            width: 280px;
            background: #ffffff;
            color: #1f2937;
            display: flex;
            flex-direction: column;
            border-right: 1px solid #e5e7eb;
            flex-shrink: 0;
        }

        .sidebar-header {
            padding: 20px;
            border-bottom: 1px solid #e5e7eb;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .sidebar-header h2 {
            font-size: 18px;
            font-weight: 600;
            color: #1f2937;
        }

        .btn-new-chat {
            background: #3498db;
            color: #ffffff;
            border: none;
            padding: 8px 12px;
            border-radius: 4px;
            cursor: pointer;
            font-size: 13px;
            transition: background 0.2s;
        }

        .btn-new-chat:hover {
            background: #2980b9;
        }

        .history-list {
            flex: 1;
            overflow-y: auto;
            padding: 10px;
            background: #ffffff;
        }

        .history-item {
            padding: 12px;
            border-radius: 6px;
            cursor: pointer;
            margin-bottom: 5px;
            transition: all 0.2s;
            font-size: 14px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            color: #374151;
            background: transparent;
        }

        .history-item:hover {
            background: #f3f4f6;
            color: #1f2937;
        }

        .history-item.active {
            background: #3498db;
            color: #ffffff;
            border-left: 3px solid #2980b9;
        }

        .history-item-date {
            font-size: 11px;
            color: #6b7280;
            margin-top: 4px;
        }

        .history-item.active .history-item-date {
            color: rgba(255, 255, 255, 0.8);
        }


        .btn-delete-session,
        .btn-edit-session {
            opacity: 0;
            color: #6b7280;
            padding: 4px 6px;
            border-radius: 4px;
            transition: all 0.2s;
            margin-left: 4px;
            font-size: 13px;
            cursor: pointer;
        }

        .history-item:hover .btn-delete-session,
        .history-item:hover .btn-edit-session {
            opacity: 1;
        }

        .history-item.active .btn-delete-session,
        .history-item.active .btn-edit-session {
            opacity: 1;
            color: rgba(255, 255, 255, 0.7);
        }

        .btn-delete-session:hover {
            background: #e74c3c;
            color: white;
        }

        .btn-edit-session:hover {
            background: #f39c12;
            color: white;
        }

        /* Main Content Styles */
        .main-content {
            flex: 1;
            padding: 20px;
            display: flex;
            flex-direction: column;
            overflow-y: auto;
            position: relative;
        }

        .container {
            max-width: 100%;
            width: 100%;
            margin: 0;
            background: white;
            border-radius: 0;
            box-shadow: none;
            padding: 30px 40px;
            flex: 1;
            display: flex;
            flex-direction: column;
        }

        h1 {
            color: #2c3e50;
            font-size: 24px;
            margin-bottom: 20px;
            text-align: center;
        }

        .action-bar {
            display: flex;
            justify-content: flex-end;
            gap: 10px;
            margin-bottom: 20px;
        }

        .btn-export {
            background: white;
            border: 1px solid #ddd;
            padding: 6px 12px;
            border-radius: 4px;
            cursor: pointer;
            font-size: 13px;
            display: flex;
            align-items: center;
            gap: 5px;
            transition: all 0.2s;
        }

        .btn-export:hover {
            background: #f8f9fa;
            border-color: #bbb;
        }

        .btn-export:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        .btn-email {
            background: #27ae60;
            color: white;
            border: 1px solid #27ae60;
        }

        .btn-email:hover {
            background: #219a52;
            border-color: #219a52;
        }

        /* Email Modal Styles */
        .modal-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.5);
            z-index: 1000;
            justify-content: center;
            align-items: center;
        }

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

        .modal-content {
            background: white;
            border-radius: 12px;
            width: 90%;
            max-width: 600px;
            max-height: 80vh;
            overflow-y: auto;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
        }

        .modal-header {
            padding: 20px;
            border-bottom: 1px solid #eee;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .modal-header h3 {
            margin: 0;
            color: #2c3e50;
        }

        .modal-close {
            background: none;
            border: none;
            font-size: 24px;
            cursor: pointer;
            color: #666;
        }

        .modal-close:hover {
            color: #333;
        }

        .modal-body {
            padding: 20px;
        }

        .modal-body .form-group {
            margin-bottom: 15px;
        }

        .modal-body label {
            display: block;
            margin-bottom: 5px;
            font-weight: 600;
            color: #555;
        }

        .modal-body input[type="text"],
        .modal-body input[type="email"],
        .modal-body textarea {
            width: 100%;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 6px;
            font-size: 14px;
        }

        .modal-body textarea {
            height: 200px;
            resize: vertical;
            font-family: inherit;
        }

        .modal-footer {
            padding: 15px 20px;
            border-top: 1px solid #eee;
            display: flex;
            justify-content: flex-end;
            gap: 10px;
        }

        .btn-modal {
            padding: 10px 20px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 14px;
            transition: all 0.2s;
        }

        .btn-modal-cancel {
            background: #f8f9fa;
            border: 1px solid #ddd;
            color: #333;
        }

        .btn-modal-cancel:hover {
            background: #e9ecef;
        }

        .btn-modal-send {
            background: #27ae60;
            border: none;
            color: white;
        }

        .btn-modal-send:hover {
            background: #219a52;
        }

        .btn-modal-send:disabled {
            background: #95a5a6;
            cursor: not-allowed;
        }

        /* AI 處理中 Overlay */
        .ai-loading-overlay {
            display: none;
            position: absolute;
            inset: 0;
            background: rgba(255, 255, 255, 0.92);
            border-radius: 12px;
            z-index: 20;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 18px;
        }

        .ai-loading-overlay.active {
            display: flex;
        }

        .ai-spinner {
            width: 52px;
            height: 52px;
            border: 4px solid #e8eaf6;
            border-top-color: #3f51b5;
            border-radius: 50%;
            animation: spin 0.9s linear infinite;
        }

        .ai-loading-label {
            font-size: 15px;
            font-weight: 600;
            color: #3f51b5;
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .ai-loading-sub {
            font-size: 12px;
            color: #888;
            margin-top: -10px;
        }

        .ai-dots {
            display: inline-flex;
            gap: 5px;
        }

        .ai-dots span {
            width: 6px;
            height: 6px;
            background: #3f51b5;
            border-radius: 50%;
            animation: bounce 1.4s infinite ease-in-out both;
        }

        .ai-dots span:nth-child(1) {
            animation-delay: -0.32s;
        }

        .ai-dots span:nth-child(2) {
            animation-delay: -0.16s;
        }

        .ai-dots span:nth-child(3) {
            animation-delay: 0s;
        }

        .email-info-box {
            background: #f8f9fa;
            border: 1px solid #e9ecef;
            border-radius: 6px;
            padding: 12px;
            margin-bottom: 15px;
        }

        .email-info-box h4 {
            margin: 0 0 8px 0;
            font-size: 14px;
            color: #495057;
        }

        .email-info-box p {
            margin: 0;
            font-size: 13px;
            color: #6c757d;
        }

        .email-products {
            display: flex;
            flex-wrap: wrap;
            gap: 5px;
            margin-top: 8px;
        }

        .email-product-tag {
            background: #e3f2fd;
            color: #1976d2;
            padding: 3px 8px;
            border-radius: 4px;
            font-size: 12px;
        }

        .loading-spinner {
            display: inline-block;
            width: 16px;
            height: 16px;
            border: 2px solid #fff;
            border-radius: 50%;
            border-top-color: transparent;
            animation: spin 1s linear infinite;
            margin-right: 8px;
        }

        @keyframes spin {
            to {
                transform: rotate(360deg);
            }
        }

        .controls {
            background: #eef2f5;
            padding: 20px;
            border-radius: 8px;
            margin-bottom: 20px;
            flex-shrink: 0;
        }

        .form-group {
            margin-bottom: 15px;
        }

        label {
            display: block;
            margin-bottom: 5px;
            font-weight: 600;
            color: #555;
        }

        select,
        input[type="number"],
        textarea,
        input[type="text"] {
            width: 100%;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 6px;
            font-size: 14px;
        }

        textarea {
            resize: vertical;
            height: 80px;
        }

        .btn-run {
            display: block;
            width: 100%;
            padding: 12px;
            background: #007bff;
            color: white;
            border: none;
            border-radius: 6px;
            font-size: 16px;
            cursor: pointer;
            transition: background 0.2s;
        }

        .btn-run:hover {
            background: #0056b3;
        }

        .btn-run:disabled {
            background: #ccc;
            cursor: not-allowed;
        }

        .config-section {
            display: none;
            margin-top: 10px;
            padding: 10px;
            background: white;
            border-radius: 6px;
            border: 1px solid #ddd;
        }

        .config-section.active {
            display: block;
        }

        .output-area {
            border-top: 2px solid #eee;
            margin-top: 30px;
            padding-top: 20px;
            flex: 1;
            display: flex;
            flex-direction: column;
        }


        .report-container {
            background: #fff;
            padding: 20px;
            border: 1px solid #ddd;
            border-radius: 6px;
            flex: 1;
            overflow-y: auto;
            min-height: 200px;
        }

        .report-placeholder {
            color: #888;
            text-align: center;
            padding-top: 80px;
        }

        /* 執行中跳動動畫 */
        .loading-text {
            display: flex;
            justify-content: center;
            align-items: center;
            padding-top: 80px;
            font-size: 18px;
            color: #3498db;
            font-weight: 600;
        }

        .loading-text span {
            animation: bounce 1.4s infinite ease-in-out both;
        }

        .loading-text span:nth-child(1) {
            animation-delay: -0.32s;
        }

        .loading-text span:nth-child(2) {
            animation-delay: -0.16s;
        }

        .loading-text span:nth-child(3) {
            animation-delay: 0s;
        }

        .loading-dots {
            display: inline-flex;
            margin-left: 4px;
        }

        .loading-dots span {
            width: 8px;
            height: 8px;
            margin: 0 3px;
            background-color: #3498db;
            border-radius: 50%;
            animation: bounce 1.4s infinite ease-in-out both;
        }

        .loading-dots span:nth-child(1) {
            animation-delay: -0.32s;
        }

        .loading-dots span:nth-child(2) {
            animation-delay: -0.16s;
        }

        .loading-dots span:nth-child(3) {
            animation-delay: 0s;
        }

        @keyframes bounce {

            0%,
            80%,
            100% {
                transform: scale(0);
                opacity: 0.5;
            }

            40% {
                transform: scale(1);
                opacity: 1;
            }
        }

        /* Chat History View in Main Area */
        .chat-history {
            margin-bottom: 20px;
            max-height: 300px;
            overflow-y: auto;
            border-bottom: 1px solid #eee;
            padding-bottom: 20px;
        }

        .msg {
            margin-bottom: 15px;
            padding: 10px 15px;
            border-radius: 8px;
            max-width: 80%;
        }

        .msg.user {
            background: #e3f2fd;
            margin-left: auto;
            border-bottom-right-radius: 0;
        }

        .msg.agent {
            background: #f1f8e9;
            margin-right: auto;
            border-bottom-left-radius: 0;
        }

        .msg-role {
            font-size: 12px;
            font-weight: bold;
            margin-bottom: 4px;
            color: #555;
        }

        /* 產品主體篩選按鈕樣式 */
        .subject-filter-btn {
            padding: 8px 16px;
            border: 2px solid #ddd;
            border-radius: 20px;
            background: white;
            color: #555;
            font-size: 14px;
            cursor: pointer;
            transition: all 0.2s ease;
            user-select: none;
        }

        .subject-filter-btn:hover {
            border-color: #3498db;
            color: #3498db;
            background: #f0f8ff;
        }

        .subject-filter-btn.active {
            border-color: #3498db;
            background: #3498db;
            color: white;
        }

        .subject-filter-btn.active:hover {
            background: #2980b9;
            border-color: #2980b9;
        }

        /*Tab 切換樣式*/
        .tab-container {
            margin-bottom: 20px;
        }

        .tab-nav {
            display: flex;
            gap: 10px;
            margin-bottom: 20px;
            border-bottom: 2px solid #e9ecef;
            padding-bottom: 10px;
        }

        .tab-btn {
            padding: 12px 24px;
            border: 2px solid #e9ecef;
            border-radius: 8px;
            background: white;
            color: #6c757d;
            font-size: 15px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .tab-btn:hover {
            border-color: #3498db;
            color: #3498db;
            background: #f0f8ff;
        }

        .tab-btn.active {
            border-color: #3498db;
            background: #3498db;
            color: white;
        }

        /* 內容區塊 */
        .tab-content {
            display: none;
        }

        .tab-content.active {
            display: block;
        }

        /*產品卡片網格*/
        .product-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
            gap: 20px;
            margin: 20px 0;
        }

        /* 選中計數 */
        .selection-info {
            text-align: center;
            margin: 15px 0;
            padding: 10px;
            background: #e8f4fd;
            border-radius: 8px;
            color: #1976d2;
            font-size: 14px;
        }

        /*產品結果區塊*/
        .product-result-section {
            margin-top: 30px;
            border: 1px solid #e9ecef;
            border-radius: 12px;
            overflow: hidden;
        }

        .product-result-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 15px 20px;
            background: #f8f9fa;
            border-bottom: 1px solid #e9ecef;
        }

        .product-result-title {
            font-size: 16px;
            font-weight: 600;
            color: #2c3e50;
        }

        .btn-toggle-charts {
            padding: 8px 16px;
            background: #6c757d;
            color: white;
            border: none;
            border-radius: 6px;
            font-size: 13px;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .btn-toggle-charts:hover {
            background: #5a6268;
        }

        .btn-toggle-charts.hidden {
            background: #28a745;
        }

        .product-charts-container {
            padding: 20px;
        }

        .product-charts-container.collapsed {
            display: none;
        }

        /*圖表區域*/
        .chart-section {
            margin-top: 30px;
            padding: 20px;
            background: #f8f9fa;
            border-radius: 12px;
        }

        .chart-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
            gap: 20px;
            margin-top: 15px;
        }

        .chart-card {
            background: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
            min-height: 450px;
        }

        .chart-card h4 {
            margin: 0 0 10px 0;
            color: #495057;
            font-size: 15px;
            font-weight: 600;
        }

        /* Plotly 圖表容器 */
        .chart-card [id^="plotly-chart-"] {
            width: 100%;
            height: 400px;
        }

        /*分析按鈕*/
        .analysis-action {
            text-align: center;
            margin: 25px 0;
        }

        .btn-analyze {
            padding: 14px 40px;
            background: linear-gradient(135deg, #3498db, #2980b9);
            color: white;
            border: none;
            border-radius: 8px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .btn-analyze:hover:not(:disabled) {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
        }

        .btn-analyze:disabled {
            background: #bdc3c7;
            cursor: not-allowed;
        }

        /*報告區域*/
        .report-section {
            margin-top: 30px;
            padding: 20px;
            background: #fff;
            border: 1px solid #e9ecef;
            border-radius: 12px;
        }

        .report-section h3 {
            margin: 0 0 15px 0;
            color: #2c3e50;
        }

        /*空狀態與載入*/
        .empty-state {
            text-align: center;
            padding: 40px;
            color: #6c757d;
        }

        .spreadsheet-subtitle {
            text-align: center;
            color: #6c757d;
            margin-bottom: 20px;
        }

        .input-label {
            display: block;
            margin-bottom: 10px;
            font-weight: 600;
            color: #495057;
            font-size: 14px;
        }

        .sub-products-list {
            display: flex;
            flex-wrap: wrap;
            gap: 12px;
        }

        .sub-product-option {
            display: flex;
            align-items: center;
            padding: 12px 16px;
            background: #f8f9fa;
            border: 2px solid #e9ecef;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .sub-product-option:hover {
            border-color: #3498db;
            background: #f0f8ff;
        }

        .sub-product-option.selected {
            border-color: #3498db;
            background: #e3f2fd;
        }

        .sub-product-checkbox {
            width: 18px;
            height: 18px;
            margin-right: 12px;
            cursor: pointer;
            accent-color: #3498db;
        }

        .sub-product-label {
            display: flex;
            flex-direction: column;
        }

        .sub-product-label strong {
            color: #2c3e50;
            font-size: 16px;
        }

        .growth-rate {
            color: #27ae60;
            font-size: 13px;
            margin-top: 2px;
        }

        .principal-input-container {
            margin-top: 20px;
        }

        .principal-input {
            width: 100%;
            max-width: 300px;
            padding: 12px 16px;
            border: 2px solid #e9ecef;
            border-radius: 8px;
            font-size: 16px;
            transition: border-color 0.2s ease;
        }

        .principal-input:focus {
            outline: none;
            border-color: #3498db;
            box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
        }

        /*結果摘要樣式*/
        .result-summary {
            margin: 30px 0;
            padding: 20px;
            background: #f8f9fa;
            border-radius: 12px;
        }

        .result-summary h3 {
            margin: 0 0 20px 0;
            color: #2c3e50;
        }

        .summary-cards-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 20px;
        }

        .summary-card {
            background: white;
            border-radius: 10px;
            padding: 20px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
        }

        .summary-card h4 {
            margin: 0 0 16px 0;
            color: #2c3e50;
            font-size: 18px;
            padding-bottom: 10px;
            border-bottom: 2px solid #e9ecef;
        }

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

        .summary-item {
            display: flex;
            flex-direction: column;
        }

        .summary-label {
            font-size: 12px;
            color: #6c757d;
            margin-bottom: 4px;
        }

        .summary-value {
            font-size: 16px;
            font-weight: 600;
            color: #2c3e50;
        }

        .summary-value.highlight {
            color: #27ae60;
            font-size: 18px;
        }

        /*Slider 樣式*/
        .slider-input {
            -webkit-appearance: none;
            appearance: none;
            height: 8px;
            background: #e9ecef;
            border-radius: 4px;
            outline: none;
        }

        .slider-input::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 20px;
            height: 20px;
            background: #3498db;
            border-radius: 50%;
            cursor: pointer;
            transition: background 0.2s;
        }

        .slider-input::-webkit-slider-thumb:hover {
            background: #2980b9;
        }

        .slider-input::-moz-range-thumb {
            width: 20px;
            height: 20px;
            background: #3498db;
            border-radius: 50%;
            cursor: pointer;
            border: none;
        }

        /* Slider 數字輸入框 */
        .slider-number-input {
            -moz-appearance: textfield;
            appearance: textfield;
        }

        .slider-number-input::-webkit-outer-spin-button,
        .slider-number-input::-webkit-inner-spin-button {
            -webkit-appearance: none;
            appearance: none;
            margin: 0;
        }

        .slider-number-input:focus {
            outline: none;
            border-color: #3498db;
        }

        /*產品 Tab 按鈕*/
        .product-tabs {
            display: flex;
            gap: 10px;
            margin-bottom: 20px;
            flex-wrap: wrap;
        }

        /*輸入欄位容器*/
        .input-fields-container {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
            gap: 15px;
        }

        .input-field-group {
            padding: 15px;
            background: #f8f9fa;
            border-radius: 8px;
        }

        /*Dashboard 風格資產配置*/
        .dashboard-container {
            display: flex;
            flex-direction: column;
            gap: 20px;
            background: #f0f2f5;
            padding: 20px;
            border-radius: 12px;
            min-height: calc(100vh - 200px);
        }

        /* 頂部控制欄 */
        .dashboard-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 20px 25px;
            background: linear-gradient(135deg, #1e3a5f 0%, #2c5282 100%);
            border-radius: 12px;
            color: white;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
        }

        .dashboard-header-left {
            display: flex;
            align-items: center;
            gap: 30px;
        }

        .dashboard-title {
            font-size: 22px;
            font-weight: 700;
            margin: 0;
        }

        .principal-input-wrapper {
            display: flex;
            align-items: center;
            gap: 12px;
            background: rgba(255, 255, 255, 0.15);
            padding: 8px 16px;
            border-radius: 8px;
        }

        .principal-input-wrapper label {
            font-size: 13px;
            color: rgba(255, 255, 255, 0.8);
            margin: 0;
        }

        .principal-input-wrapper input {
            background: white;
            border: none;
            border-radius: 6px;
            padding: 10px 15px;
            font-size: 18px;
            font-weight: 700;
            width: 180px;
            text-align: right;
            color: #1e3a5f;
        }

        .dashboard-header-right {
            display: flex;
            align-items: center;
            gap: 15px;
        }

        .btn-calculate-dashboard {
            background: #48bb78;
            color: white;
            border: none;
            padding: 12px 28px;
            border-radius: 8px;
            font-size: 15px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .btn-calculate-dashboard:hover:not(:disabled) {
            background: #38a169;
            transform: translateY(-1px);
        }

        .btn-calculate-dashboard:disabled {
            background: #718096;
            cursor: not-allowed;
        }

        /* KPI 卡片區 */
        .kpi-cards {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 15px;
        }

        .kpi-card {
            background: white;
            border-radius: 12px;
            padding: 20px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
            transition: all 0.2s;
        }

        .kpi-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
        }

        .kpi-card-label {
            font-size: 13px;
            color: #718096;
            margin-bottom: 8px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .kpi-card-value {
            font-size: 28px;
            font-weight: 700;
            color: #1e3a5f;
        }

        .kpi-card-value.positive {
            color: #38a169;
        }

        .kpi-card-value.negative {
            color: #e53e3e;
        }

        .kpi-card-sub {
            font-size: 12px;
            color: #a0aec0;
            margin-top: 5px;
        }

        /* 主體區域：左側產品 + 右側圖表 */
        .dashboard-body {
            display: grid;
            grid-template-columns: 380px 1fr;
            gap: 20px;
            flex: 1;
            align-items: start;
        }

        /* 左側產品面板 */
        .product-panel {
            background: white;
            border-radius: 12px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
            display: flex;
            flex-direction: column;
            height: 500px;
            transition: height 0.3s ease;
        }

        .product-panel-header {
            padding: 18px 20px;
            border-bottom: 1px solid #e2e8f0;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .product-panel-title {
            font-size: 16px;
            font-weight: 600;
            color: #2d3748;
            margin: 0;
        }

        .allocation-status {
            font-size: 13px;
            padding: 5px 12px;
            border-radius: 20px;
            background: #edf2f7;
            color: #4a5568;
        }

        .allocation-status.complete {
            background: #c6f6d5;
            color: #22543d;
        }

        .allocation-status.warning {
            background: #fed7d7;
            color: #c53030;
        }

        /* 預設投資組合按鈕 */
        .preset-portfolio-container {
            display: flex;
            gap: 10px;
            padding: 0 20px 15px 20px;
            flex-wrap: wrap;
        }

        .preset-portfolio-btn {
            padding: 8px 16px;
            border: 2px solid #4299e1;
            border-radius: 20px;
            background: transparent;
            color: #4299e1;
            font-size: 13px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .preset-portfolio-btn:hover {
            background: #4299e1;
            color: white;
        }

        .preset-portfolio-btn:active {
            transform: scale(0.98);
        }

        .preset-portfolio-btn .icon {
            font-size: 14px;
        }

        .product-list {
            flex: 1;
            overflow-y: auto;
            padding: 10px;
        }

        .product-item {
            border: 2px solid #e2e8f0;
            border-radius: 10px;
            margin-bottom: 10px;
            transition: all 0.2s;
            overflow: hidden;
        }

        .product-item:hover {
            border-color: #4299e1;
        }

        .product-item.selected {
            border-color: #4299e1;
            background: #ebf8ff;
        }

        .product-item-header {
            display: flex;
            align-items: center;
            padding: 12px 15px;
            cursor: pointer;
            gap: 12px;
        }

        .product-checkbox {
            width: 20px;
            height: 20px;
            border: 2px solid #cbd5e0;
            border-radius: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s;
            flex-shrink: 0;
        }

        .product-item.selected .product-checkbox {
            background: #4299e1;
            border-color: #4299e1;
        }

        .product-checkbox::after {
            content: '✓';
            color: white;
            font-size: 12px;
            font-weight: bold;
            opacity: 0;
            transition: opacity 0.2s;
        }

        .product-item.selected .product-checkbox::after {
            opacity: 1;
        }

        .product-item-info {
            flex: 1;
            min-width: 0;
        }

        .product-item-name {
            font-size: 14px;
            font-weight: 600;
            color: #2d3748;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .product-item-desc {
            font-size: 11px;
            color: #718096;
            margin-top: 2px;
            min-width: 0;
            word-break: break-word;
            white-space: normal;
            overflow-wrap: break-word;
            line-height: 1.4;
        }

        .product-item-config {
            display: none;
            padding: 15px;
            background: #f7fafc;
            border-top: 1px solid #e2e8f0;
        }

        .product-item.selected .product-item-config {
            display: block;
        }

        .config-row {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-bottom: 12px;
        }

        .config-row:last-child {
            margin-bottom: 0;
        }

        .config-row label {
            font-size: 12px;
            color: #4a5568;
            min-width: 10px;
            white-space: nowrap;
            margin: 0;
            flex-shrink: 0;
        }

        .config-row input,
        .config-row select {
            flex: 1;
            padding: 8px 12px;
            border: 1px solid #e2e8f0;
            border-radius: 6px;
            font-size: 14px;
        }

        .config-row input:focus,
        .config-row select:focus {
            outline: none;
            border-color: #4299e1;
        }

        /* 金額百分比輸入群組 */
        .allocation-input-group {
            display: flex;
            align-items: center;
            gap: 8px;
            flex: 1;
        }

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

        .allocation-input-wrapper input {
            width: 100%;
            padding-right: 35px;
        }

        .allocation-input-wrapper .input-suffix {
            position: absolute;
            right: 10px;
            color: #718096;
            font-size: 12px;
            pointer-events: none;
        }

        .allocation-separator {
            color: #a0aec0;
            font-size: 14px;
        }

        .allocation-percentage-input {
            width: 70px !important;
            flex: none !important;
            text-align: center;
        }

        /* 右側圖表區 */
        .chart-panel {
            background: white;
            border-radius: 12px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
            display: flex;
            flex-direction: column;
            overflow: hidden;
            min-height: 500px;
        }

        .chart-panel-header {
            padding: 15px 20px;
            border-bottom: 1px solid #e2e8f0;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .chart-tabs {
            display: flex;
            gap: 5px;
        }

        .chart-tab {
            padding: 8px 16px;
            border: none;
            background: #edf2f7;
            color: #4a5568;
            border-radius: 6px;
            font-size: 13px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s;
        }

        .chart-tab:hover {
            background: #e2e8f0;
        }

        .chart-tab.active {
            background: #4299e1;
            color: white;
        }

        .chart-area {
            flex: 1;
            padding: 20px;
            min-height: 400px;
            display: flex;
            flex-direction: column;
        }

        .chart-placeholder {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            flex: 1;
            color: #a0aec0;
        }

        .chart-placeholder-icon {
            font-size: 48px;
            margin-bottom: 15px;
        }

        /* 個別產品小圖區 */
        .individual-charts-row {
            display: grid;
            gap: 15px;
            padding: 20px;
            background: #f7fafc;
            border-top: 1px solid #e2e8f0;
        }

        .individual-charts-row.cols-2 {
            grid-template-columns: repeat(2, 1fr);
        }

        .individual-charts-row.cols-3 {
            grid-template-columns: repeat(3, 1fr);
        }

        .individual-charts-row.cols-4 {
            grid-template-columns: repeat(4, 1fr);
        }

        .mini-chart-card {
            background: white;
            border-radius: 8px;
            padding: 12px;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
        }

        .mini-chart-card .chart-container {
            height: 180px;
        }

        /* 底部數據表區 */
        .data-panel {
            background: white;
            border-radius: 12px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
            overflow: hidden;
        }

        .data-panel-header {
            padding: 18px 20px;
            border-bottom: 1px solid #e2e8f0;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .data-panel-title {
            font-size: 16px;
            font-weight: 600;
            color: #2d3748;
            margin: 0;
        }

        .data-panel-content {
            max-height: 350px;
            overflow: auto;
        }

        .allocation-input-group {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-bottom: 15px;
        }

        .allocation-input-group label {
            font-size: 14px;
            color: #495057;
            white-space: nowrap;
            margin: 0;
        }

        .allocation-input {
            width: 80px;
            padding: 8px 12px;
            border: 2px solid #e9ecef;
            border-radius: 6px;
            font-size: 16px;
            font-weight: 600;
            text-align: center;
        }

        .allocation-input:focus {
            outline: none;
            border-color: #3498db;
        }

        .allocation-amount-input {
            width: 150px;
            padding: 8px 12px;
            border: 2px solid #e9ecef;
            border-radius: 6px;
            font-size: 16px;
            font-weight: 600;
            text-align: right;
        }

        .allocation-amount-input:focus {
            outline: none;
            border-color: #3498db;
        }

        .allocation-slider {
            flex: 1;
            height: 6px;
            -webkit-appearance: none;
            background: #e9ecef;
            border-radius: 3px;
            cursor: pointer;
        }

        .allocation-slider::-webkit-slider-thumb {
            -webkit-appearance: none;
            width: 18px;
            height: 18px;
            background: #3498db;
            border-radius: 50%;
            cursor: pointer;
        }


        .individual-result-card {
            background: white;
            border: 1px solid #e9ecef;
            border-radius: 12px;
            padding: 20px;
            margin-bottom: 15px;
        }

        .individual-result-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
        }

        .individual-result-title {
            font-size: 16px;
            font-weight: 600;
            color: #2c3e50;
        }

        .individual-result-badge {
            background: #3498db;
            color: white;
            padding: 4px 12px;
            border-radius: 20px;
            font-size: 13px;
        }

        /* ========== 年度數據表 ========== */
        .yearly-data-section {
            margin-top: 30px;
            padding: 20px;
            background: #f8f9fa;
            border-radius: 12px;
        }

        .yearly-data-section h3 {
            margin: 0 0 15px 0;
            color: #2c3e50;
            font-size: 18px;
        }

        .yearly-data-table-wrapper {
            overflow-x: auto;
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
        }

        .yearly-data-table {
            width: 100%;
            border-collapse: collapse;
            background: white;
            font-size: 13px;
            min-width: 600px;
        }

        .yearly-data-table thead {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
        }

        .yearly-data-table th {
            padding: 12px 10px;
            text-align: right;
            font-weight: 600;
            white-space: nowrap;
            position: sticky;
            top: 0;
        }

        .yearly-data-table th:first-child {
            text-align: center;
            position: sticky;
            left: 0;
            z-index: 2;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }

        .yearly-data-table td {
            padding: 10px;
            text-align: right;
            border-bottom: 1px solid #e9ecef;
        }

        .yearly-data-table td:first-child {
            text-align: center;
            font-weight: 600;
            background: #f8f9fa;
            position: sticky;
            left: 0;
            z-index: 1;
        }

        .yearly-data-table tbody tr:hover {
            background: #f0f8ff;
        }

        .yearly-data-table tbody tr:nth-child(5n) {
            background: #fafafa;
        }

        .yearly-data-table tbody tr:nth-child(5n):hover {
            background: #f0f8ff;
        }

        .yearly-data-table .col-combined {
            background: rgba(52, 152, 219, 0.08);
            font-weight: 600;
        }

        .yearly-data-table .col-irr {
            background: rgba(231, 76, 60, 0.08);
            color: #e74c3c;
            font-weight: 600;
        }

        .yearly-data-table .col-irr.negative {
            background: rgba(46, 204, 113, 0.08);
            color: #27ae60;
        }

        .yearly-data-table tfoot {
            background: #2c3e50;
            color: white;
            font-weight: 600;
        }

        .yearly-data-table tfoot td {
            border-bottom: none;
            padding: 12px 10px;
        }

        .yearly-data-table tfoot td:first-child {
            background: #2c3e50;
        }

        /* 組合圖表切換按鈕 */
        .portfolio-chart-tabs {
            display: flex;
            gap: 8px;
            margin-bottom: 15px;
            flex-wrap: wrap;
        }

        .portfolio-chart-tab {
            padding: 8px 16px;
            border: 1px solid #e9ecef;
            border-radius: 8px;
            background: white;
            color: #6c757d;
            cursor: pointer;
            font-size: 13px;
            transition: all 0.2s ease;
        }

        .portfolio-chart-tab:hover {
            border-color: #3498db;
            color: #3498db;
        }

        /* 個別產品圖表網格 */
        .individual-charts-section {
            margin-top: 30px;
            padding: 20px;
            background: #f8f9fa;
            border-radius: 12px;
        }

        .individual-charts-section h4 {
            margin: 0 0 15px 0;
            color: #2c3e50;
            font-size: 16px;
        }

        .individual-charts-grid {
            display: grid;
            gap: 15px;
        }

        /* 根據產品數量自動調整 grid */
        .individual-charts-grid.cols-1 {
            grid-template-columns: 1fr;
        }

        .individual-charts-grid.cols-2 {
            grid-template-columns: repeat(2, 1fr);
        }

        .individual-charts-grid.cols-3 {
            grid-template-columns: repeat(3, 1fr);
        }

        .individual-charts-grid.cols-4 {
            grid-template-columns: repeat(4, 1fr);
        }

        .individual-chart-card {
            background: white;
            border: 1px solid #e9ecef;
            border-radius: 8px;
            padding: 10px;
            min-height: 250px;
        }

        .individual-chart-card .chart-container {
            width: 100%;
            height: 220px;
        }

        .portfolio-chart-tab.active {
            background: #3498db;
            color: white;
            border-color: #3498db;
        }

        /* ========== 漢堡選單按鈕 ========== */
        .hamburger-btn {
            display: none;
            position: fixed;
            top: 15px;
            left: 15px;
            z-index: 1001;
            width: 45px;
            height: 45px;
            background: #3498db;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            padding: 10px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        }

        .hamburger-btn span {
            display: block;
            width: 25px;
            height: 3px;
            background: white;
            margin: 5px auto;
            border-radius: 2px;
            transition: all 0.3s ease;
        }

        .hamburger-btn.active span:nth-child(1) {
            transform: rotate(45deg) translate(6px, 6px);
        }

        .hamburger-btn.active span:nth-child(2) {
            opacity: 0;
        }

        .hamburger-btn.active span:nth-child(3) {
            transform: rotate(-45deg) translate(6px, -6px);
        }

        /* Sidebar 遮罩層 */
        .sidebar-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.5);
            z-index: 999;
        }

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

        /* === 側邊欄折疊按鈕 === */
        .sidebar-toggle-btn {
            position: fixed;
            top: 50%;
            transform: translateY(-50%);
            left: 280px;
            z-index: 101;
            width: 24px;
            height: 64px;
            background: #4a5568;
            border: none;
            border-radius: 0 8px 8px 0;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 14px;
            transition: all 0.3s ease;
            box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
        }

        .sidebar-toggle-btn:hover {
            background: #3498db;
            transform: translateY(-50%) scale(1.05);
        }

        .sidebar-toggle-btn svg {
            width: 18px;
            height: 18px;
            transition: transform 0.3s ease;
        }

        /* 側邊欄折疊狀態 */
        .sidebar.collapsed {
            width: 0;
            min-width: 0;
            overflow: hidden;
            padding: 0;
            border: none;
        }

        .sidebar.collapsed+.sidebar-toggle-btn {
            left: 0;
        }

        .sidebar.collapsed+.sidebar-toggle-btn svg {
            transform: rotate(180deg);
        }

        /* 過渡動畫 */
        .sidebar {
            transition: width 0.3s ease, min-width 0.3s ease, padding 0.3s ease;
        }

        .sidebar-toggle-btn {
            transition: left 0.3s ease, background 0.2s ease;
        }

        /* ========== RWD 響應式設計 ========== */

        /* 平板裝置 (768px - 1024px) */
        @media screen and (max-width: 1024px) {
            .container {
                max-width: 100%;
                padding: 20px;
            }

            .product-grid {
                grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
            }

            .chart-grid {
                grid-template-columns: 1fr;
            }

            .chart-card {
                min-height: 350px;
            }

            .chart-card [id^="plotly-chart-"] {
                height: 320px;
            }

            .summary-cards-grid {
                grid-template-columns: 1fr;
            }
        }

        /* 手機及小平板 (768px 以下) */
        @media screen and (max-width: 768px) {
            .hamburger-btn {
                display: block;
            }

            .sidebar-toggle-btn {
                display: none;
            }

            .sidebar {
                position: fixed;
                top: 0;
                left: -280px;
                height: 100vh;
                z-index: 1000;
                transition: left 0.3s ease;
                width: 280px !important;
                min-width: 280px !important;
            }

            .sidebar.active {
                left: 0;
            }

            .sidebar.collapsed {
                width: 280px !important;
                min-width: 280px !important;
            }

            .main-content {
                padding: 70px 15px 15px 15px;
            }

            .container {
                padding: 15px;
                border-radius: 8px;
            }

            /* Dashboard 響應式 */
            .dashboard-container {
                padding: 10px;
            }

            .dashboard-header {
                flex-direction: column;
                gap: 15px;
                padding: 15px;
            }

            .dashboard-header-left {
                flex-direction: column;
                gap: 12px;
                width: 100%;
            }

            .dashboard-title {
                font-size: 18px;
            }

            .principal-input-wrapper {
                width: 100%;
            }

            .principal-input-wrapper input {
                width: 100%;
            }

            .dashboard-header-right {
                width: 100%;
                justify-content: space-between;
            }

            .kpi-cards {
                grid-template-columns: repeat(2, 1fr);
                gap: 10px;
            }

            .kpi-card {
                padding: 15px;
            }

            .kpi-card-value {
                font-size: 20px;
            }

            .dashboard-body {
                grid-template-columns: 1fr;
            }

            .product-panel {
                max-height: 300px;
            }

            .chart-tabs {
                overflow-x: auto;
                flex-wrap: nowrap;
            }

            .chart-tab {
                white-space: nowrap;
                flex-shrink: 0;
            }

            .individual-charts-row.cols-3,
            .individual-charts-row.cols-4 {
                grid-template-columns: repeat(2, 1fr);
            }

            h1 {
                font-size: 20px;
                margin-bottom: 15px;
            }

            .tab-nav {
                flex-wrap: wrap;
                gap: 8px;
            }

            .tab-btn {
                padding: 10px 16px;
                font-size: 14px;
                flex: 1;
                min-width: 120px;
                text-align: center;
            }

            .action-bar {
                flex-wrap: wrap;
            }

            .btn-export {
                flex: 1;
                min-width: 120px;
                justify-content: center;
            }

            .controls {
                padding: 15px;
            }

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

            .product-grid {
                grid-template-columns: 1fr;
                gap: 15px;
            }

            .chart-grid {
                grid-template-columns: 1fr;
                gap: 15px;
            }

            .chart-card {
                padding: 15px;
                min-height: 300px;
            }

            .chart-card [id^="plotly-chart-"] {
                height: 280px;
            }

            .summary-cards-grid {
                grid-template-columns: 1fr;
            }

            .summary-grid {
                grid-template-columns: 1fr;
            }

            .input-fields-container {
                grid-template-columns: 1fr;
            }

            .product-result-header {
                flex-direction: column;
                gap: 10px;
                align-items: flex-start;
            }

            .btn-toggle-charts {
                width: 100%;
            }

            .individual-result-header {
                flex-direction: column;
                align-items: flex-start;
                gap: 10px;
            }

            .portfolio-chart-tabs {
                overflow-x: auto;
                flex-wrap: nowrap;
                padding-bottom: 10px;
            }

            .portfolio-chart-tab {
                white-space: nowrap;
                flex-shrink: 0;
            }

            /* 個別產品圖表響應式 */
            .individual-charts-grid.cols-3,
            .individual-charts-grid.cols-4 {
                grid-template-columns: repeat(2, 1fr);
            }

            .individual-chart-card {
                min-height: 200px;
            }

            .individual-chart-card .chart-container {
                height: 180px;
            }

            .sub-products-list {
                flex-direction: column;
            }

            .sub-product-option {
                width: 100%;
            }

            .allocation-input-group {
                flex-wrap: wrap;
            }

            .allocation-slider {
                width: 100%;
                order: 3;
            }

            .msg {
                max-width: 95%;
            }

            /* Modal 響應式 */
            .modal-content {
                width: 95%;
                max-height: 90vh;
            }

            .modal-footer {
                flex-direction: column;
            }

            .btn-modal {
                width: 100%;
            }

            /* 分析按鈕響應式 */
            .btn-analyze {
                padding: 12px 30px;
                font-size: 15px;
                width: 100%;
            }

            /* 年度數據表響應式 */
            .yearly-data-section {
                padding: 15px;
                margin-top: 20px;
            }

            .yearly-data-section h3 {
                font-size: 16px;
            }

            .yearly-data-table {
                font-size: 12px;
            }

            .yearly-data-table th,
            .yearly-data-table td {
                padding: 8px 6px;
            }
        }

        /* 小型手機 (480px 以下) */
        @media screen and (max-width: 480px) {
            .main-content {
                padding: 65px 10px 10px 10px;
            }

            .container {
                padding: 12px;
            }

            h1 {
                font-size: 18px;
            }

            .tab-btn {
                padding: 8px 12px;
                font-size: 13px;
                min-width: 100px;
            }

            .btn-export {
                padding: 8px 10px;
                font-size: 12px;
            }

            .controls {
                padding: 12px;
            }

            .chart-card {
                padding: 10px;
                min-height: 260px;
            }

            .chart-card [id^="plotly-chart-"] {
                height: 240px;
            }

            .chart-card h4 {
                font-size: 13px;
            }

            .summary-card {
                padding: 15px;
            }

            .summary-value {
                font-size: 14px;
            }

            .summary-value.highlight {
                font-size: 16px;
            }

            .sidebar-header {
                padding: 15px;
            }

            .sidebar-header h2 {
                font-size: 16px;
            }

            .history-item {
                padding: 10px;
                font-size: 13px;
            }

            .report-container {
                padding: 15px;
            }

            /* 年度數據表響應式 - 小型手機 */
            .yearly-data-section {
                padding: 10px;
            }

            .yearly-data-section h3 {
                font-size: 14px;
            }

            .yearly-data-table {
                font-size: 11px;
            }

            .yearly-data-table th,
            .yearly-data-table td {
                padding: 6px 4px;
            }
        }