/* 所得稅模組樣式 - 完全獨立命名空間 */
.income-tax-content {
    padding: 0;
}

/* 稅額計算公式容器 */
.income-tax-formula-container {
    width: 100%;
    overflow-x: auto;
    padding: 10px 0;
}

.income-tax-calc-row {
    display: flex;
    align-items: end; /* 底部對齊，讓所有元素在同一基準線 */
    gap: 15px; /* 增加從8px到15px */
    padding: 15px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    border: 1px solid #dee2e6;
    min-width: fit-content;
    flex-wrap: nowrap; /* 確保所有元素在同一行 */
    overflow-x: auto; /* 如果內容過寬則允許水平滾動 */
    justify-content: flex-start; /* 從左對齊 */
}

/* 計算項目 */
.income-tax-calc-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px; /* 減少標籤和輸入框之間的間距 */
    min-width: 90px; /* 增加從80px到90px */
    max-width: 120px; /* 增加從110px到120px */
    flex-shrink: 0; /* 防止項目被壓縮 */
}

.income-tax-calc-item label {
    font-size: 11px;
    font-weight: 600;
    color: #495057;
    text-align: center;
    white-space: nowrap;
    margin: 0;
    line-height: 1.2;
    height: auto; /* 讓標籤高度自適應 */
}

.income-tax-calc-item input {
    width: 100%;
    height: 28px; /* 稍微減少高度 */
    padding: 4px 6px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 11px;
    text-align: center;
    background: white;
    transition: all 0.2s ease;
    flex-shrink: 0; /* 防止輸入框被壓縮 */
}

.income-tax-calc-item input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.income-tax-calc-item input[readonly] {
    background: #f8f9fa !important;
    color: #6c757d;
    cursor: not-allowed;
}

/* 結果項目特殊樣式 */
.income-tax-calc-item.result {
    min-width: 120px; /* 增加從100px到120px */
}

.income-tax-calc-item.result input {
    background: #e8f4fd !important;
    color: #0066cc;
    font-weight: bold;
    border-color: #007bff;
}

/* 運算符號 */
.income-tax-operator {
    font-size: 16px;
    font-weight: bold;
    color: #6c757d;
    margin: 0 8px; /* 增加從4px到8px */
    display: flex;
    align-items: center;
    height: 28px; /* 匹配輸入框高度 */
    flex-shrink: 0; /* 防止符號被壓縮 */
    line-height: 1;
}

.income-tax-bracket {
    font-size: 18px;
    font-weight: bold;
    color: #6c757d;
    margin: 0 8px; /* 增加從4px到8px */
    display: flex;
    align-items: center;
    height: 28px; /* 匹配輸入框高度 */
    flex-shrink: 0; /* 防止括號被壓縮 */
    line-height: 1;
}

/* 帶按鈕的標籤容器 */
.income-tax-label-with-button {
    display: flex;
    align-items: center;
    gap: 3px;
    justify-content: center;
    height: auto; /* 讓容器高度自適應 */
}

.income-tax-setting-btn {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 3px;
    width: 16px;
    height: 16px;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
    flex-shrink: 0; /* 防止按鈕被壓縮 */
}

.income-tax-setting-btn:hover {
    background: #0056b3;
    transform: scale(1.1);
}

/* 百分比輸入框 */
.income-tax-percentage-input {
    text-align: center !important;
}

/* 金額輸入框 */
.income-tax-money-input {
    text-align: right !important;
}

/* 模態視窗樣式 - 獨立命名空間 */
.income-tax-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.income-tax-modal-content {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    min-width: 300px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
}

.income-tax-modal-header {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #dee2e6;
}

.income-tax-modal-header h3 {
    margin: 0;
    color: #333;
    font-size: 18px;
}

.income-tax-modal-body {
    margin-bottom: 15px;
}

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

/* 免稅額設定 - 獨立命名空間 */
.income-tax-exemption-setting {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.income-tax-exemption-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
}

.income-tax-exemption-row label {
    font-weight: 500;
    margin: 0;
}

.income-tax-exemption-row input {
    width: 60px;
    padding: 5px;
    text-align: center;
    border: 1px solid #ced4da;
    border-radius: 4px;
}

.income-tax-exemption-row .amount {
    font-weight: 600;
    color: #007bff;
}

.income-tax-exemption-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #e8f4fd;
    border-radius: 4px;
    border: 1px solid #007bff;
    font-weight: bold;
}

/* 稅率表格 - 獨立命名空間 */
.income-tax-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}

.income-tax-table th,
.income-tax-table td {
    padding: 8px 12px;
    text-align: center;
    border: 1px solid #dee2e6;
}

.income-tax-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
}

.income-tax-table tr.current-bracket {
    background: #fff3cd;
    border-color: #ffc107;
}

.income-tax-table tr.current-bracket td {
    font-weight: bold;
    color: #856404;
}

/* 按鈕樣式 - 獨立命名空間 */
.income-tax-modal-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.income-tax-modal-btn.primary {
    background: #007bff;
    color: white;
}

.income-tax-modal-btn.primary:hover {
    background: #0056b3;
}

.income-tax-modal-btn.secondary {
    background: #6c757d;
    color: white;
}

.income-tax-modal-btn.secondary:hover {
    background: #545b62;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .income-tax-calc-row {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
        padding: 15px 10px;
        flex-wrap: nowrap; /* 即使在小螢幕也保持結構 */
    }
    
    .income-tax-calc-item {
        min-width: unset;
        max-width: unset;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    
    .income-tax-calc-item label {
        text-align: left;
        white-space: normal;
        margin-right: 10px;
    }
    
    .income-tax-calc-item input {
        width: 120px;
        flex-shrink: 0;
    }
    
    .income-tax-operator,
    .income-tax-bracket {
        align-self: center;
        font-size: 14px;
    }
    
    .income-tax-modal-content {
        margin: 10px;
        min-width: unset;
        width: calc(100vw - 20px);
    }
    
    .income-tax-exemption-row {
        flex-direction: column;
        gap: 8px;
        align-items: stretch;
        text-align: center;
    }
    
    .income-tax-exemption-row input {
        width: 100%;
        max-width: 100px;
        margin: 0 auto;
    }
}

@media (max-width: 480px) {
    .income-tax-calc-item input {
        width: 100px;
        font-size: 10px;
    }
    
    .income-tax-calc-item label {
        font-size: 10px;
    }
    
    .income-tax-setting-btn {
        width: 14px;
        height: 14px;
        font-size: 9px;
    }
}

/* 重設舊樣式的相關類別，確保不會衝突 */
.tax-formula-section,
.formula-display,
.form-group,
.standard-input,
.input-with-button,
.calculate-btn,
.tax-rate-group,
.result-section,
.tax-result,
.modal-overlay,
.modal-content,
.modal-header,
.modal-body,
.modal-footer,
.modal-btn,
.exemption-setting,
.exemption-row,
.exemption-total,
.tax-table {
    /* 這些樣式已被新的獨立命名空間設計取代 */
} 
:root {
    --card-bg-color: #edf2f7;
    /* 修改：從 #f8fafc 變為較深的顏色 */
    --card-border-radius: 6px;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    --card-padding: 10px;
    --card-margin-bottom: 15px;
    --form-gap: 10px;
    --form-margin-bottom: 12px;
    --button-bg-color: #42a5f5;
    --button-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    --query-btn-color: #4285f4;
    --query-btn-hover-color: #2a75f3;
    --primary-text-color: #2c3e50;
    --bg-color-light: #f0f7ff;
    --hover-bg-color: #e3f2fd;
    --danger-color: #ff4444;
    --button-text-color: white;
    --primary-color: #3498db;
    --primary-color-rgb: 52, 152, 219;
    --border-color: #e2e8f0;
    --border-color-light: #cbd5e0;
    --input-bg-color: #ffffff;
    /* 新增變量，用於不同級別的容器 */
    --sub-container-bg: #e2e8f0;
    /* 子容器背景色 */
    --sub-item-bg: #f0f7ff;
    /* 項目背景色 */
    --content-card-bg: #f8fafc;
    /* 內容卡片背景色 */
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #e6e6e6;
    /* 修改：從 #f9f9f9 變為較深的灰色 #e6e6e6 */
    color: #333;
}

.main-content {
    margin-top: 80px;
    padding: 2rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    margin-top: 80px;
    /* 增加上邊距為按鈕預留空間 */
    overflow-x: hidden;
    /* 防止水平溢出 */
    padding: 0 15px;
    /* 添加左右內邊距 */
    padding-top: 40px;
    /* 頂部內邊距為按鈕預留空間 */
}

/* 頂部按鈕容器 - 使用 flexbox 自動佈局 */
.top-action-buttons {
    position: absolute !important;
    top: 5px !important;
    left: 30px !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px 10px !important;
    /* row-gap: 8px, column-gap: 10px */
    z-index: 500 !important;
    max-width: calc(100% - 300px) !important;
    /* 預留右側空間給其他元素 */
    align-items: flex-start !important;
}

/* 通用按鈕基本樣式 */
.container .action-btn,
#resetButton,
#guideButton,
#guidedSetupButton,
#open-visual-canvas-btn {
    position: relative !important;
    padding: 10px 18px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    color: white !important;
    border: none !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: auto !important;
    height: auto !important;
    text-align: center !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "微軟正黑體", sans-serif !important;
    margin: 0 !important;
    transform: translateY(0) !important;
    white-space: nowrap !important;
    /* 不換行，保持按鈕寬度自適應 */
    z-index: 500 !important;
    /* 大幅降低層級，確保絕對不覆蓋側邊欄 (990) */
}

/* 智能導引按鈕 - 保持漸變設計 */
#guidedSetupButton {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3) !important;
}

#guidedSetupButton:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6b5b95 100%) !important;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4) !important;
    transform: translateY(-2px) !important;
}

#guidedSetupButton:active {
    transform: translateY(0) !important;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3) !important;
}

/* 恢復預設和新手導引按鈕 - 使用網站藍色單一色 */
#resetButton,
#guideButton {
    background: #1e88e5 !important;
    box-shadow: 0 4px 12px rgba(30, 136, 229, 0.3) !important;
}

#open-visual-canvas-btn {
    background: #1a237e !important;
    box-shadow: 0 4px 12px rgba(26, 35, 126, 0.3) !important;
}

#resetButton:hover,
#guideButton:hover {
    background: #1565c0 !important;
    box-shadow: 0 6px 20px rgba(30, 136, 229, 0.4) !important;
    transform: translateY(-2px) !important;
}

#open-visual-canvas-btn:hover {
    background: #0d1440 !important;
    box-shadow: 0 6px 20px rgba(26, 35, 126, 0.4) !important;
    transform: translateY(-2px) !important;
}

#resetButton:active,
#guideButton:active,
#open-visual-canvas-btn:active {
    transform: translateY(0) !important;
    box-shadow: 0 2px 8px rgba(30, 136, 229, 0.3) !important;
}

.container .action-btn i,
#resetButton i,
#guideButton i,
#guidedSetupButton i,
#open-visual-canvas-btn i {
    margin-right: 8px !important;
    font-size: 14px !important;
    opacity: 0.9 !important;
}

/* 按鈕位置設定 - 使用 flexbox 自動佈局，無需固定位置 */
/* 個別按鈕樣式已在通用樣式中定義 */

/* 確保sidebar顯示時按鈕容器位置保持不變 */
.sidebar.show~.container .top-action-buttons {
    transition: all 0.3s ease !important;
}

/* 響應式設計 - 768px以下 */
@media screen and (max-width: 768px) {

    .top-action-buttons {
        left: 20px !important;
        gap: 6px 8px !important;
        max-width: calc(100% - 200px) !important;
    }

    #resetButton,
    #guideButton,
    #guidedSetupButton,
    #open-visual-canvas-btn {
        padding: 8px 14px !important;
        font-size: 12px !important;
    }
}

/* 響應式設計 - 480px以下 */
@media screen and (max-width: 480px) {

    .top-action-buttons {
        left: 15px !important;
        gap: 5px 6px !important;
        max-width: calc(100% - 120px) !important;
    }

    #resetButton,
    #guideButton,
    #guidedSetupButton,
    #open-visual-canvas-btn {
        font-size: 11px !important;
        padding: 6px 10px !important;
        border-radius: 6px !important;
    }
}

/* 版本號位置 */
.version {
    right: 250px !important;
}

/* 基礎容器樣式 */
.content-card {
    background-color: var(--content-card-bg);
    border-radius: var(--card-border-radius);
    box-shadow: var(--card-shadow);
    padding: var(--card-padding);
    margin-bottom: var(--card-margin-bottom);
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--border-color);
}

/* 特殊容器樣式 */
.special-content-card {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    overflow-x: hidden;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e2e8f0;
}

.card-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: #2c3e50;
    flex: 1;
    text-align: center;
    /* 讓標題居中 */
}

.card-content {
    padding: 5px 0;
}

/* 旧版全域 .form-row/.form-group 樣式已移除，改由通用網格規則接管 */

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

.delete-btn {
    background-color: #f56565;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background-color 0.3s;
}

.delete-btn:hover {
    background-color: #e53e3e;
}

.tooltip-container {
    position: relative;
}

h1 {
    text-align: center;
    color: var(--gradient-start);
    margin: 0 auto 2rem;
    font-size: 2rem;
    font-weight: 600;
    width: fit-content;
    position: relative;
}

/* 保留原有的按鈕樣式 */
.button-container {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 2rem;
}

.button-container button {
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
    font-weight: 500;
    border-radius: 8px;
    background: linear-gradient(45deg, var(--gradient-start), var(--gradient-end));
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(30, 136, 229, 0.2);
}

.button-container button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(30, 136, 229, 0.3);
}

/* 資產區塊樣式 */
.asset-section {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
    text-align: center;
}

.add-asset-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(45deg, var(--gradient-start), var(--gradient-end));
    color: white;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(30, 136, 229, 0.2);
}

.add-asset-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(30, 136, 229, 0.3);
}

/* 模組選擇視窗樣式 - 獨立完整定義，避免受其他樣式影響 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1001;
}

.modal-content {
    position: relative;
    background-color: white;
    margin: 5% auto;
    padding: 2rem;
    width: 60%;
    /* 調整為合適寬度 */
    max-width: 650px;
    /* 調整最大寬度 */
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    max-height: 85vh;
    overflow-y: auto;
    border-top: 4px solid #3498db;
}

/* 改善模組網格樣式 */
.module-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 15px;
    align-items: center;
    text-align: center;
}

/* 改善模組類別樣式 */
.module-category {
    margin-bottom: 15px;
    text-align: center;
    width: 100%;
}

.module-category h3 {
    color: #2c3e50;
    font-size: 16px;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #e9ecef;
    text-align: center;
}

/* 改善模組項目樣式 */
.module-item {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    text-align: center;
    width: 200px;
    margin: 0 auto 6px auto;
    font-size: 0.9rem;
    color: #2c3e50;
    font-weight: 500;
}

.module-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border-color: #3498db;
    background-color: #f0f8ff;
}

/* 媒體查詢優化 */
@media screen and (max-width: 768px) {
    .modal-content {
        width: 85%;
        padding: 1.5rem;
    }

    .module-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }

    #moduleModal .modal-content {
        width: 70%;
        max-width: 400px;
    }
}

@media screen and (max-width: 480px) {
    .modal-content {
        width: 95%;
        padding: 1rem;
    }

    .module-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px;
    }

    #moduleModal .modal-content {
        width: 90%;
        max-width: 350px;
    }
}

.close-modal {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    line-height: 1;
}

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

/* 適配移動設備 */
@media screen and (max-width: 768px) {
    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }

    .module-category {
        padding: 1rem;
    }

    .module-item {
        padding: 0.8rem;
        margin-bottom: 0.6rem;
    }
}

@media screen and (max-width: 480px) {
    .modal-content {
        width: 95%;
        padding: 1rem;
    }

    .module-category {
        padding: 0.8rem;
    }

    .module-item {
        padding: 0.7rem;
        margin-bottom: 0.5rem;
        font-size: 0.85rem;
    }
}

.module-item {
    background: white;
    padding: 1rem;
    margin-bottom: 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid #eee;
    color: #333;
    font-weight: 500;
}

.module-item:hover {
    transform: translateX(10px);
    border-color: var(--gradient-start);
    box-shadow: 0 2px 8px rgba(30, 136, 229, 0.2);
}

.modal-content {
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.2rem;
}

.finance-sections {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    width: 100%;
    margin-bottom: 20px;
    max-width: calc(1700px - 200px);
    /* 最大寬度減去側邊欄寬度 */
    margin: 0 auto;
    padding: 0;
    margin-top: 55px;
    /* 從70px減少到55px，內容更往上移 */
    padding-top: 10px;
    overflow: visible;
    width: 100%;
    box-sizing: border-box;
}

.finance-section {
    flex: 1 1 calc(50% - 10px);
    min-width: 300px;
    margin-bottom: 0;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 15px;
}

.finance-section h2 {
    color: #2c3e50;
    font-size: 1.5rem;
    margin-top: 0;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
    text-align: center;
    /* 讓標題居中 */
}

.item-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    margin-bottom: 10px;
}

/* 移除舊的按鈕樣式 */
.add-button-container {
    display: flex;
    justify-content: center;
    /* 改為居中顯示，原本是 flex-end */
    margin-top: 10px;
    width: 100%;
}

/* 更新添加按鈕樣式 */
.add-button {
    background-color: #42a5f5;
    /* 修改為更淡的藍色 */
    color: white;
    border: none;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    margin: 5px auto;
    /* 使其居中 */
    position: relative;
    z-index: 2;
}

.add-button:hover {
    background-color: #2c3e50;
    transform: scale(1.05);
}

.add-button i {
    font-size: 18px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* 確保+號圖標正確顯示 */
.add-button i.fa-plus::before {
    content: "+";
    font-size: 18px;
    line-height: 1;
    position: relative;
    top: -1px;
}

/* 調整工具按鈕位置和樣式，使其與側邊欄切換按鈕一致 */
.tools-button {
    display: none;
    /* 完全隱藏工具按鈕 */
}

.tools-menu {
    display: none;
    /* 同時隱藏工具選單 */
}

.return-calc-form {
    padding: 20px;
}

.return-input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.return-input-group input {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: right;
}

.calc-button {
    width: 100%;
    padding: 10px;
    background: linear-gradient(45deg, var(--gradient-start), var(--gradient-end));
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    margin-bottom: 20px;
}

.result-display {
    background: #f8fafc;
    padding: 15px;
    border-radius: 5px;
    font-size: 1.1em;
}

.result-display div {
    margin: 5px 0;
}

/* 旧版通用 .form-row/.form-group 樣式移除（由通用網格規則接管） */

/* 按鈕樣式 */
.card-actions {
    display: flex;
    gap: 0.5rem;
}

.save-btn,
.delete-btn {
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.save-btn {
    background: #4CAF50;
    color: white;
}

.delete-btn {
    background: #ff4444;
    color: white;
}

/* 響應式調整 */
@media screen and (max-width: 768px) {
    .container {
        margin-left: 0;
        width: 100%;
        padding: 10px;
    }

    /* 旧版通用 .form-row/.form-group 響應式已移除（由通用網格規則接管） */

    /* 調整輸入框寬度 */
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="password"],
    select,
    .standard-input,
    .standard-select {
        width: 100% !important;
    }

    /* 調整金額顯示位置 */
    [id$="-display"] {
        position: static;
        margin-left: 5px;
        font-size: 0.8rem;
    }

    /* 調整導航欄在手機版的樣式 */
    .nav-links {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 60px;
        right: 0;
        background: white;
        width: 200px;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        display: none;
        /* 預設隱藏 */
    }

    .nav-links.active {
        display: flex;
    }

    .nav-links a {
        padding: 15px 20px;
        border-bottom: 1px solid #eee;
        width: 100%;
        text-align: left;
    }

    /* 添加漢堡選單按鈕 */
    .menu-toggle {
        display: block;
        position: absolute;
        right: 20px;
        top: 50%;
        transform: translateY(-50%);
        cursor: pointer;
        padding: 10px;
    }

    /* 調整側邊欄在手機版的樣式 */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        width: 80%;
        max-width: 300px;
        top: 0;
        /* 確保與藍色條高度一致 */
    }

    .sidebar.show {
        transform: translateX(0);
    }

    /* 添加側邊欄切換按鈕 */
    .sidebar-toggle {
        position: fixed;
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
        background-color: #1e88e5;
        /* 使用 --gradient-start 顏色 */
        color: white;
        border: none;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 975;
        /* 調整 z-index 不遮擋側邊欄 */
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
        transition: all 0.2s ease;
    }

    .sidebar-toggle:hover {
        background-color: #1565c0;
        transform: scale(1.05);
    }

    @media screen and (max-width: 768px) {
        .sidebar-toggle {
            width: 45px;
            height: 45px;
            bottom: 15px;
            right: 15px;
        }

        .container,
        .finance-sections {
            padding: 0.5rem;
        }
    }

    @media screen and (max-width: 480px) {
        .sidebar-toggle {
            width: 40px;
            height: 40px;
            bottom: 10px;
            right: 10px;
        }
    }

    /* 調整側邊欄在手機版的樣式 */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        width: 80%;
        max-width: 300px;
        top: 0;
        /* 確保與藍色條高度一致 */
    }

    .sidebar.show {
        transform: translateX(0);
    }

    /* 添加側邊欄切換按鈕 */
    .sidebar-toggle {
        display: block;
        position: fixed;
        left: 20px;
        bottom: 80px;
        background: var(--gradient-start);
        color: white;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
        z-index: 980;
    }

    .sidebar-toggle i {
        font-size: 1.5rem;
    }

    /* 顯示側邊欄關閉按鈕 */
    .sidebar-close {
        top: 30px;
        right: 15px;
        width: 40px;
        height: 40px;
    }

    /* 顯示側邊欄遮罩層 */
    .sidebar-overlay.show {
        display: block;
    }

    .sidebar-section:first-child {
        margin-top: 60px !important;
        /* 加入上邊距以避免被頂部藍色條覆蓋 */
        padding-top: 0;
        /* 移除頂部內邊距 */
    }

    .sidebar {
        padding-top: 40px;
    }
}

/* 智慧排版容器 */
.smart-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    width: 100%;
}

@media screen and (max-width: 576px) {
    .smart-grid-container {
        grid-template-columns: 1fr;
    }
}

/* 優化滾動條樣式 */
.content-card::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.content-card::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.content-card::-webkit-scrollbar-track {
    background: #f0f0f0;
}

/* 卡片內容布局 */
.card-header {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
    /* 減少與內容的間距 */
    padding-bottom: 0.5rem;
    /* 減少底部內邊距 */
    border-bottom: 1px solid #eee;
}

.card-content {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

/* 修改左側導覽列樣式 */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    /* 修改：從48px改為0，使其延伸至頁面頂部 */
    bottom: 0;
    /* 保持延伸到底部 */
    width: 200px;
    background-color: white;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    z-index: 990;
    /* 確保在大多數元素之上，但在 header 和 footer 之下 */
}

/* 確保 header 和 footer 在最上層 */
.gradient-header {
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    /* 確保藍色條在最上層 */
    height: 52px;
    /* 減少整體高度 */
    padding: 4px 1rem;
    /* 增加上下間距，減少左右間距 */
    display: flex;
    align-items: center;
    /* 垂直置中 */
    box-sizing: border-box;
}

/* 調整 logo 容器 */
.gradient-header .logo {
    display: flex;
    align-items: center;
    height: 100%;
    margin-left: 10px;
    /* 微調 logo 的左側間距 */
    padding: 0;
    /* 移除內邊距 */
}

.gradient-header .logo img {
    height: 40px;
    width: auto;
    padding: 0;
    /* 移除內邊距 */
}

.gradient-footer {
    z-index: 999;
    /* 確保 footer 在側邊欄之上 */
    position: relative;
    /* 確保 z-index 生效 */
}

.sidebar-section {
    padding: 10px 0;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-direction: column;
}

/* 調整第一個 sidebar-section 的位置 */
.sidebar-section:first-child {
    margin-top: 60px !important;
    /* 加入上邊距以避免被頂部藍色條覆蓋 */
    padding-top: 0;
    /* 移除頂部內邊距 */
}

.sidebar-title {
    padding: 10px 15px;
    color: #666;
    font-weight: bold;
    font-size: 0.9rem;
}

.sidebar-item {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #333;
}

.sidebar-item i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
    color: #666;
}

.sidebar-item:hover {
    background: #f0f7ff;
    color: var(--gradient-start);
}

.sidebar-item:hover i {
    color: var(--gradient-start);
}

.sidebar-item.active {
    background: #e3f2fd;
    color: var(--gradient-start);
    border-right: 3px solid var(--gradient-start);
}

.sidebar-item.active i {
    color: var(--gradient-start);
}

/* 在標題下方添加裝飾線 */
.container h1:after {
    content: '';
    display: block;
    width: 100%;
    height: 3px;
    background: linear-gradient(45deg, var(--gradient-start), var(--gradient-end));
    margin-top: 0.5rem;
    border-radius: 2px;
}

/* 響應式調整 */
@media screen and (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.show {
        transform: translateX(0);
    }
}

/* 修改底部導航欄的樣式 */
.gradient-footer {
    position: relative;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(45deg, var(--gradient-start), var(--gradient-end));
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.footer-content {
    display: flex;
    gap: 2rem;
}

.footer-content a {
    color: white;
    text-decoration: none;
    font-size: 0.9rem;
    transition: opacity 0.3s;
}

.footer-content a:hover {
    opacity: 0.8;
}

/* 標題區域樣式 */
.title-section {
    display: flex;
    justify-content: flex-end;
    /* 將按鈕靠右對齊 */
    margin-bottom: 2rem;
}

.guide-button {
    padding: 0.8rem 1.5rem;
    /* 稍微加大按鈕 */
    background: linear-gradient(45deg, var(--gradient-start), var(--gradient-end));
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    /* 稍微加大字體 */
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.guide-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.guide-button i {
    font-size: 1.3rem;
}

/* 統一輸入框和下拉選單的樣式 */
.standard-input,
.standard-select {
    /* 舊規格固定寬度移除，改由通用寬度型態接管 */
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    text-align: right;
    background-color: #ffffff;
    /* 保持輸入框為白色背景 */
    height: 36px;
    /* 統一高度，便於與標籤垂直置中對齊 */
    line-height: 36px;
    /* 保持內文字垂直置中 */
}

.standard-select {
    text-align: center;
    padding-right: 24px;
    /* 為下拉箭頭留空間 */
}

/* 旧版 label/問號定位與 flex 版面調整移除（由通用網格與新版 label 規則接管） */

/* 小型輸入框樣式 */
.small-input {
    width: 80px;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    text-align: right;
    background-color: white;
}

/* 金額輸入框樣式 */
.amount-input {
    width: 140px;
}

.simulation-section {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 2rem;
    padding: 1rem;
}

/* 模擬按鈕容器樣式 */
.simulation-button-container {
    display: flex;
    justify-content: center;
    width: 100%;
    margin: 30px 0;
    /* 增加上下間距 */
}

/* 開始模擬按鈕樣式 */
.simulation-btn {
    padding: 1.2rem 3rem;
    /* 增大按鈕大小 */
    font-size: 1.4rem;
    /* 增大字體 */
    font-weight: 600;
    /* 加粗字體 */
    background: linear-gradient(45deg, #1a73e8, #64b5f6);
    /* 藍色漸變 */
    color: white;
    border: none;
    border-radius: 50px;
    /* 圓角更大 */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    transition: all 0.3s ease;
    box-shadow: 0 6px 15px rgba(26, 115, 232, 0.3);
    /* 更明顯的陰影 */
    position: relative;
    overflow: hidden;
    min-width: 250px;
    /* 保證最小寬度 */
}

/* 按鈕懸停效果 */
.simulation-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(26, 115, 232, 0.4);
    background: linear-gradient(45deg, #1565c0, #42a5f5);
    /* 懸停時顏色變深 */
}

/* 按鈕點擊效果 */
.simulation-btn:active {
    transform: translateY(1px);
    box-shadow: 0 4px 10px rgba(26, 115, 232, 0.3);
}

/* 按鈕圖標樣式 */
.simulation-btn i {
    font-size: 1.2rem;
}

/* 統一所有輸入框的基本樣式 */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
select,
.standard-input,
.standard-select,
.small-input,
.amount-input {
    padding: 8px 10px;
    /* 增加內部填充，使輸入框更高 */
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    /* 增加字體大小 */
    background-color: #ffffff;
    box-sizing: border-box;
    /* 確保寬度包含border和padding */
    height: 36px;
    /* 固定高度 */
    line-height: 20px;
    /* 調整行高 */
}

/* 下拉選單特殊處理 */
select,
.standard-select {
    text-align: center;
    padding-right: 30px;
    /* 為下拉箭頭預留更多空間 */
    appearance: none;
    /* 移除預設的下拉箭頭樣式 */
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%2712%27 height=%2712%27 viewBox=%270 0 12 12%27%3E%3Cpath fill=%27%23333%27 d=%27M6 8L2 4h8z%27/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

/* 設置統一的 hover 和 focus 狀態 */
input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus,
.standard-input:focus,
.standard-select:focus {
    outline: none;
    border-color: var(--gradient-start);
    box-shadow: 0 0 0 2px rgba(30, 136, 229, 0.2);
}

/* 內聯 width 不再強制覆蓋，改由通用寬度型態規則處理 */

/* 分析模式區塊的樣式 */
.analysis-modes {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 1rem;
}

.analysis-mode-section {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
}

.mode-header {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.mode-header h4 {
    color: #2d3748;
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 600;
}

.mode-description {
    color: #718096;
    margin: 0;
    font-size: 0.875rem;
}

.mode-content {
    padding: 0.5rem 0;
}

/* 保持原有的表單樣式 */
.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.form-group {
    flex: 1;
}

/* 修改右側導覽列樣式 */
.right-sidebar {
    position: fixed;
    right: 0;
    top: 0;
    /* 改為 0，延伸到頂部 */
    bottom: 0;
    /* 改為 0，延伸到底部 */
    width: 200px;
    background-color: white;
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    z-index: 990;
    /* 確保在大多數元素之上，但在 header 和 footer 之下 */
}

/* 確保 header 和 footer 在最上層 */
.gradient-header {
    z-index: 1000;
    /* 確保 header 在右側導覽列之上 */
}

.gradient-footer {
    z-index: 1000;
    /* 確保 footer 在右側導覽列之上 */
}

/* 手機版本的響應式設計 */
@media screen and (max-width: 768px) {

    /* 基本容器樣式 */
    .container {
        margin-left: 0;
        width: 100%;
        padding: 10px;
    }

    /* 縮小標題和欄位名稱 */
    h1 {
        font-size: 1.4rem;
        margin-bottom: 0.7rem;
    }

    h2 {
        font-size: 1.2rem;
        margin-bottom: 0.5rem;
    }

    h3 {
        font-size: 1rem;
        margin-bottom: 0.4rem;
    }

    h4 {
        font-size: 0.9rem;
        margin-bottom: 0.3rem;
    }

    /* 縮小欄位標籤 */
    .form-group label {
        font-size: 0.8rem;
        margin-bottom: 0.15rem;
    }

    /* 調整表單排版 */
    .form-row {
        flex-direction: column;
        gap: 0.4rem;
        margin-bottom: 0.4rem;
    }

    .form-group {
        width: 100%;
        margin-bottom: 0.4rem;
    }

    /* 縮小輸入框 */
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="password"],
    select,
    .standard-input,
    .standard-select {
        padding: 0.3rem 0.5rem;
        font-size: 0.8rem;
        height: 30px;
        width: 100% !important;
    }

    /* 調整金額顯示位置 */
    [id$="-display"] {
        position: static;
        margin-left: 5px;
        font-size: 0.8rem;
    }

    /* 縮小卡片內邊距 */
    .content-card {
        padding: 0.7rem;
        margin-bottom: 0.7rem;
    }

    .card-header {
        padding: 0.5rem 0.7rem;
        margin-bottom: 0.5rem;
    }

    .card-content {
        padding: 0 0.5rem 0.5rem;
    }

    /* 縮小分析模式區塊 */
    .analysis-mode-section {
        padding: 0.5rem;
        margin-bottom: 0.5rem;
    }

    .mode-header {
        margin-bottom: 0.3rem;
    }

    .mode-description {
        font-size: 0.75rem;
        margin-bottom: 0.25rem;
    }

    /* 縮小模組項目 */
    .module-item {
        width: calc(50% - 5px);
        /* 兩列佈局，減少間距 */
        padding: 0.5rem;
        margin-bottom: 5px;
        font-size: 0.8rem;
    }

    .module-category h3 {
        font-size: 0.9rem;
        margin-bottom: 0.4rem;
        padding-bottom: 0.2rem;
    }

    /* 縮小按鈕 */
    .simulation-btn,
    .add-button,
    .tools-button {
        padding: 0.4rem 0.7rem;
        font-size: 0.85rem;
    }

    /* 縮小模態框內容 */
    .modal-content {
        padding: 0.8rem;
    }

    /* 縮小財務區塊間距 */
    .finance-section {
        margin-bottom: 0.8rem;
    }

    /* 縮小內容區塊間距 */
    .content-section {
        margin-bottom: 0.8rem;
    }

    /* 縮小模擬按鈕容器 */
    .simulation-button-container {
        margin: 0.6rem 0;
    }

    /* 調整導航欄在手機版的樣式 */
    .nav-links {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 60px;
        right: 0;
        background: white;
        width: 200px;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        display: none;
        /* 預設隱藏 */
    }

    .nav-links.active {
        display: flex;
    }

    .nav-links a {
        padding: 15px 20px;
        border-bottom: 1px solid #eee;
        width: 100%;
        text-align: left;
    }

    /* 添加漢堡選單按鈕 */
    .menu-toggle {
        display: block;
        position: absolute;
        right: 20px;
        top: 50%;
        transform: translateY(-50%);
        cursor: pointer;
        padding: 10px;
    }

    /* 調整側邊欄在手機版的樣式 */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        width: 80%;
        max-width: 300px;
        top: 0;
        /* 確保與藍色條高度一致 */
    }

    .sidebar.show {
        transform: translateX(0);
    }

    /* 添加側邊欄切換按鈕 */
    .sidebar-toggle {
        display: block;
        position: fixed;
        left: 20px;
        bottom: 80px;
        background: var(--gradient-start);
        color: white;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
        z-index: 980;
    }

    .sidebar-toggle i {
        font-size: 1.5rem;
    }

    /* 投資理財知識下拉選單專用樣式 */
    .investment-knowledge-select {
        min-width: 400px !important;
        width: 100% !important;
        max-width: 500px !important;
    }

    /* 確保在不同螢幕尺寸下都有適當寬度 */
    @media screen and (max-width: 768px) {
        .investment-knowledge-select {
            min-width: 300px !important;
            max-width: 100% !important;
        }
    }

    @media screen and (max-width: 480px) {
        .investment-knowledge-select {
            min-width: 250px !important;
            max-width: 100% !important;
        }
    }
}

@media screen and (max-width: 480px) {
    .container {
        margin-left: 0;
        width: 100%;
        padding: 10px;
    }

    .modal-content {
        width: 95%;
        padding: 1rem;
    }

    .module-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px;
    }

    .module-category {
        padding: 0.8rem;
    }

    .module-card {
        padding: 0.7rem;
        margin-bottom: 0.5rem;
    }

    .module-card h4 {
        font-size: 0.85rem;
    }

    .form-group label {
        font-size: 0.75rem;
    }

    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="password"],
    select,
    .standard-input,
    .standard-select {
        padding: 0.25rem 0.4rem;
        font-size: 0.75rem;
        height: 28px;
    }

    .content-card {
        padding: 0.6rem;
        margin-bottom: 0.6rem;
    }

    .card-header {
        padding: 0.4rem 0.6rem;
    }

    .card-content {
        padding: 0 0.4rem 0.4rem;
    }

    .sidebar-toggle {
        width: 40px;
        height: 40px;
        left: 15px;
        bottom: 70px;
    }

    .sidebar-toggle i {
        font-size: 1.2rem;
    }

    .tools-button {
        bottom: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
    }

    .tools-button span {
        font-size: 11px;
    }
}

/* 統一所有容器樣式 */
.finance-section,
.content-section,
.simulation-output,
.chart-item {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 15px;
    padding: 12px;
    width: 100%;
    box-sizing: border-box;
}

.finance-section h2,
.content-section .section-header h2,
.simulation-output h2,
.chart-item h3 {
    color: #2c3e50;
    font-size: 1.5rem;
    margin-top: 0;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: none;
}

/* 調整子容器樣式 */
.content-card,
.module-container,
.item-container,
.analysis-mode-section {
    background-color: #f8fafc;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    padding: 10px;
    margin-bottom: 15px;
    width: 100%;
    box-sizing: border-box;
}

/* 確保所有.content-card選擇器都使用相同的樣式 */
.content-card {
    background-color: #f8fafc;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    padding: 10px;
    margin-bottom: 15px;
    width: 100%;
    box-sizing: border-box;
}

/* 卡片頭部和內容區域樣式 */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.card-content {
    padding: 5px 0;
}

/* 調整財務區塊容器 */
.finance-sections {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    width: 100%;
    margin-bottom: 20px;
}

.finance-section {
    flex: 1 1 calc(50% - 10px);
    min-width: 300px;
    margin-bottom: 0;
}

/* 調整圖表容器 */
.charts-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 20px;
    width: 100%;
}

.chart-item {
    flex: 1 1 calc(50% - 10px);
    min-width: 300px;
    margin-bottom: 0;
}

/* 調整圖表容器內的畫布容器 */
.chart-canvas-container {
    width: 100%;
    height: 300px;
    margin: 10px 0;
    position: relative;
}

@media screen and (max-width: 768px) {

    .finance-section,
    .simulation-output,
    .chart-item {
        padding: 10px;
    }

    .content-section {
        padding: 10px 10px 5px 10px;
    }

    .module-card {
        flex: 1 1 calc(50% - 5px);
        padding: 8px;
    }

    .card-header {
        padding: 0 0 6px 0;
        margin-bottom: 6px;
    }

    /* 大幅增加側邊欄頂部空間 */
    .sidebar-section:first-child {
        margin-top: 160px;
        /* 進一步增加頂部空間 */
    }

    .sidebar-close {
        top: 40px;
    }
}

@media screen and (max-width: 480px) {

    .finance-section,
    .simulation-output,
    .chart-item {
        padding: 8px;
    }

    .content-section {
        padding: 8px 8px 4px 8px;
    }

    .module-card {
        flex: 1 1 100%;
        padding: 7px;
        margin-bottom: 6px;
    }

    .card-header {
        padding: 0 0 5px 0;
        margin-bottom: 5px;
    }

    /* 小螢幕進一步調整側邊欄頂部空間 */
    .sidebar-section:first-child {
        margin-top: 200px;
        /* 再增加頂部空間 */
    }

    .sidebar-close {
        top: 45px;
        width: 52px;
        height: 52px;
    }

    .sidebar-close i {
        font-size: 24px;
    }
}

/* 調整側邊欄切換按鈕 */
.sidebar-toggle,
.tools-button {
    position: fixed;
    width: 42px;
    height: 42px;
    background-color: #1e88e5;
    /* 使用 --gradient-start 顏色 */
    color: white;
    border: none;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 975;
    /* 調整 z-index 不遮擋側邊欄 */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}

/* 在側邊欄顯示時調整按鈕位置，確保不被側邊欄擋住 */
.sidebar.show~.sidebar-toggle,
.sidebar.show~.tools-button {
    right: 20px;
    /* 改為 right 定位，不再使用 left */
}

.sidebar-toggle {
    right: 20px;
    /* 改為右下角 */
    bottom: 20px;
}

.tools-button {
    right: 20px;
    /* 改為右下角 */
    bottom: 75px;
}

.sidebar-toggle:hover,
.tools-button:hover {
    background-color: #1565c0;
    /* 使用 --dark-blue 顏色 */
    transform: scale(1.05);
}

.sidebar-toggle i,
.tools-button i {
    font-size: 20px;
    /* 增大圖標字體 從18px到20px */
}

/* 顯示工具按鈕文字 */
.tools-button {
    width: auto;
    padding: 0 10px;
}

.tools-button span {
    display: block;
    font-size: 15px;
    /* 增大文字字體 從13px到15px */
    margin-left: 5px;
}

@media screen and (max-width: 768px) {

    /* 調整側邊欄切換按鈕 */
    .sidebar-toggle,
    .tools-button {
        right: 15px;
        /* 改為 right 定位 */
        width: 40px;
        height: 40px;
    }

    .sidebar.show~.sidebar-toggle,
    .sidebar.show~.tools-button {
        right: 15px;
        /* 改為 right 定位，維持位置不變 */
    }

    .tools-button {
        width: auto;
        padding: 0 8px;
    }

    .tools-button span {
        font-size: 14px;
        /* 增大手機版文字字體 從12px到14px */
    }

    .sidebar-toggle {
        bottom: 15px;
    }

    .tools-button {
        bottom: 65px;
    }
}

@media screen and (max-width: 480px) {

    /* 調整側邊欄切換按鈕 */
    .sidebar-toggle,
    .tools-button {
        right: 10px;
        /* 改為 right 定位 */
        width: 36px;
        height: 36px;
    }

    .sidebar.show~.sidebar-toggle,
    .sidebar.show~.tools-button {
        right: 10px;
        /* 改為 right 定位，維持位置不變 */
    }

    .tools-button {
        width: auto;
        padding: 0 5px;
    }

    .tools-button span {
        font-size: 13px;
        /* 增大小螢幕文字字體 從11px到13px */
    }

    .sidebar-toggle {
        bottom: 10px;
    }

    .tools-button {
        bottom: 55px;
    }

    .sidebar-toggle i,
    .tools-button i {
        font-size: 18px;
        /* 增大小螢幕圖標字體 從16px到18px */
    }
}

/* 調整 content-section 特定樣式 */
.content-section {
    margin-bottom: 20px;
    position: relative;
    /* 添加相對定位 */
}

.content-section .section-header {
    margin: 0 0 5px 0;
    padding-bottom: 5px;
    border-bottom: none;
    text-align: center;
    /* 讓整個標題區域居中 */
}

.content-section .section-header h2 {
    margin: 0;
    font-size: 1.4rem;
    color: #2c3e50;
    text-align: center;
    /* 讓h2標題文本居中 */
}

/* 移除模組容器的間距 */
.module-container {
    margin: 0;
    padding: 0;
    background: transparent;
    box-shadow: none;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* 調整模組卡片 */
.module-card {
    background-color: white;
    border-radius: 5px;
    padding: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    margin: 0;
    flex: 1 1 calc(33.333% - 4px);
    min-width: 130px;
}

.module-card h4 {
    margin: 0 0 5px 0;
    font-size: 1rem;
    text-align: center;
    /* 確保標題居中 */
}

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

/* 調整添加按鈕位置和樣式 */
.add-button {
    background-color: #42a5f5;
    /* 修改為更淡的藍色 */
    color: white;
    border: none;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    margin: 5px auto;
    /* 使其居中 */
    position: relative;
    z-index: 2;
}

.add-button:hover {
    background-color: #2c3e50;
    transform: scale(1.05);
}

.add-button i {
    font-size: 18px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* 更細緻的容器間距調整 */
.finance-section,
.content-section,
.simulation-output,
.chart-item {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 15px;
    width: 100%;
    box-sizing: border-box;
}

/* 基本資料和環境參數容器 */
.finance-section {
    padding: 12px;
}

/* 模擬輸出容器 */
.simulation-output {
    padding: 12px;
}

/* 圖表容器調整 */
.chart-item {
    padding: 12px;
}

/* 圖表容器內的畫布容器 */
.chart-canvas-container {
    margin: 5px 0;
}

/* 卡片頭部和內容 */
.card-header {
    padding: 0 0 8px 0;
    margin-bottom: 8px;
    border-bottom: 1px solid #e2e8f0;
}

.card-content {
    padding: 0;
}

@media screen and (max-width: 768px) {

    /* 調整側邊欄切換按鈕 */
    .sidebar-toggle,
    .tools-button {
        right: 15px;
        /* 改為 right 定位 */
        width: 40px;
        height: 40px;
    }

    .sidebar-toggle {
        bottom: 15px;
    }

    .tools-button {
        bottom: 65px;
    }

    .finance-section,
    .simulation-output,
    .chart-item {
        padding: 10px;
    }

    .content-section {
        padding: 10px 10px 5px 10px;
    }

    .module-card {
        flex: 1 1 calc(50% - 5px);
        padding: 8px;
    }

    /* 大幅增加側邊欄頂部空間 */
    .sidebar-section:first-child {
        margin-top: 160px;
        /* 進一步增加頂部空間 */
    }

    .sidebar-close {
        top: 40px;
    }
}

@media screen and (max-width: 480px) {

    /* 調整側邊欄切換按鈕 */
    .sidebar-toggle,
    .tools-button {
        right: 10px;
        /* 改為 right 定位 */
        width: 38px;
        height: 38px;
    }

    .sidebar-toggle {
        bottom: 10px;
    }

    .tools-button {
        bottom: 58px;
    }

    .finance-section,
    .simulation-output,
    .chart-item {
        padding: 8px;
    }

    .content-section {
        padding: 8px 8px 4px 8px;
    }

    .module-card {
        flex: 1 1 100%;
        padding: 7px;
        margin-bottom: 6px;
    }

    .card-header {
        padding: 0 0 5px 0;
        margin-bottom: 5px;
    }

    /* 小螢幕進一步調整側邊欄頂部空間 */
    .sidebar-section:first-child {
        margin-top: 200px;
        /* 再增加頂部空間 */
    }

    .sidebar-close {
        top: 50px;
        width: 52px;
        height: 52px;
    }

    .sidebar-close i {
        font-size: 24px;
    }
}

/* 按鈕定位 */
.sidebar-toggle {
    bottom: 20px;
}

.tools-button {
    bottom: 75px;
}

/* 通用容器樣式，減少邊距增加空間利用率 */
.finance-section,
.content-section,
.simulation-output {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 12px;
    padding: 10px;
    width: 100%;
    box-sizing: border-box;
}

/* 圖表容器樣式優化 */
.charts-container {
    padding: 0;
    margin: 0 0 12px 0;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    /* 減小間距 */
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 8px;
    /* 減小內邊距 */
}

/* 移除單個圖表的容器樣式，減少多層嵌套 */
.chart-item {
    flex: 1 1 calc(50% - 4px);
    min-width: 300px;
    margin: 0 0 5px 0;
    /* 減小間距 */
    padding: 0;
    background: transparent;
    box-shadow: none;
    position: relative;
    /* 為放大按鈕定位 */
}

/* 直接設置圖表畫布樣式 */
.chart-canvas-container {
    background-color: #f8fafc;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 8px;
    width: 100%;
    height: 300px;
    margin: 0;
    position: relative;
}

/* 圖表標題 */
.chart-item h3 {
    margin: 0 0 3px 0;
    /* 減小間距 */
    padding: 5px 8px;
    font-size: 1.1rem;
    color: #2c3e50;
    background-color: #f8fafc;
    border-radius: 6px 6px 0 0;
    border-bottom: 1px solid #e2e8f0;
}

/* 添加圖表放大按鈕 */
.chart-expand-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: rgba(30, 136, 229, 0.9);
    border: 1px solid #1e88e5;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 5;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    font-size: 14px;
}

.chart-expand-btn:hover {
    background-color: rgba(21, 101, 192, 1);
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

.chart-expand-btn i {
    font-size: 14px;
}

.chart-expand-btn i:nth-child(2) {
    display: inline-block;
    /* 更改為inline-block使第二個圖標默認顯示 */
}

/* 不再需要這個選擇器，因為我們希望兩個圖標都顯示 */
.chart-expand-btn i.fas.fa-expand:not(:before)+i {
    display: inline-block;
}

/* 修改全螢幕圖表模態框樣式，使其充分利用整個視窗空間 */
.chart-fullscreen-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.chart-fullscreen-container {
    width: 95%;
    height: 90%;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow: hidden;
}

.chart-fullscreen-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.1);
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    z-index: 10;
    font-size: 20px;
}

.chart-fullscreen-close:hover {
    background-color: rgba(0, 0, 0, 0.2);
    transform: scale(1.1);
}

.chart-fullscreen-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: calc(100% - 50px);
    overflow: hidden;
    position: relative;
}

.chart-fullscreen-title {
    font-size: 1.8rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 20px;
    text-align: center;
    padding: 0 40px;
}

#fullscreenCanvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
}

@media screen and (max-width: 768px) {
    .chart-expand-btn {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }

    .chart-fullscreen-container {
        width: 98%;
        height: 95%;
        padding: 15px;
    }

    .chart-fullscreen-title {
        font-size: 1.4rem;
        margin-bottom: 15px;
    }

    .chart-fullscreen-close {
        width: 35px;
        height: 35px;
        top: 10px;
        right: 10px;
    }
}

@media screen and (max-width: 480px) {
    .chart-expand-btn {
        width: 28px;
        height: 28px;
        top: 8px;
        right: 8px;
        font-size: 10px;
    }

    .chart-fullscreen-container {
        width: 100%;
        height: 100%;
        border-radius: 0;
        padding: 10px;
    }

    .chart-fullscreen-title {
        font-size: 1.2rem;
        margin-bottom: 10px;
    }

    .chart-fullscreen-close {
        width: 30px;
        height: 30px;
        top: 8px;
        right: 8px;
        font-size: 18px;
    }
}

/* 添加字符計數樣式 */
.character-count {
    font-size: 0.8rem;
    color: #666;
    text-align: right;
    margin-top: 5px;
}

/* 確保AI設置區塊樣式與其他區塊一致 */
#ai-settings-card {
    width: 100%;
    box-sizing: border-box;
    padding: 1rem;
    border-radius: 8px;
    background-color: var(--content-card-bg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

#ai-settings-card .card-header {
    border-bottom: 1px solid #eee;
    margin-bottom: 15px;
    padding-bottom: 10px;
}

#ai-settings-card .card-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#ai-settings-card.disabled-section {
    opacity: 0.7;
    pointer-events: none;
}

#ai-settings-card.disabled-section input,
#ai-settings-card.disabled-section select,
#ai-settings-card.disabled-section textarea {
    background-color: #f5f5f5;
    cursor: not-allowed;
}

/* 媒體查詢適配 */
@media screen and (max-width: 768px) {
    #ai-settings-card {
        padding: 0.8rem;
    }

    .character-count {
        font-size: 0.7rem;
    }
}

@media screen and (max-width: 480px) {
    #ai-settings-card {
        padding: 0.6rem;
    }
}

/* 容器基本樣式 */
.container {
    margin-left: 200px;
    /* 與側邊欄寬度相同 */
    padding: 15px;
    width: calc(100% - 200px);
    /* 減去側邊欄寬度 */
    box-sizing: border-box;
    transition: margin-left 0.3s ease, width 0.3s ease;
    max-width: 1700px;
}

/* 模組容器樣式，確保所有容器有一致的行為 */
.module-container,
.content-section,
.finance-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-sizing: border-box;
}

/* 確保所有卡片有一致的佈局 */
.content-card {
    width: 100%;
    box-sizing: border-box;
    padding: 1rem;
    border-radius: 8px;
    background-color: var(--content-card-bg);
    /* 使用變量 */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    overflow-x: hidden;
    border: 1px solid var(--border-color);
}

/* AI設定相關樣式調整 */
.textarea-container {
    position: relative;
    width: 100%;
    max-width: 100%;
}

.standard-textarea {
    width: 100%;
    max-width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    box-sizing: border-box;
}

.char-counter {
    position: absolute;
    right: 10px;
    bottom: 10px;
    font-size: 12px;
    color: #666;
}

/* 響應式設計 */
@media screen and (max-width: 768px) {
    .container {
        margin-left: 0;
        width: 100%;
        padding: 10px;
    }

    .sidebar.show~.container {
        margin-left: 0;
        width: 100%;
    }

    .content-section,
    .finance-section {
        padding: 0.5rem;
    }
}

/* AI設定卡片特定樣式 */
#ai-settings-card {
    width: 100%;
    margin-bottom: 1.5rem;
}

#ai-settings-card .card-content {
    padding: 1rem;
}

#ai-settings-card .form-row {
    margin-bottom: 1rem;
}

#ai-settings-card .textarea-container {
    width: 100%;
    max-width: 100%;
}

#ai-settings-card .standard-textarea {
    width: 100%;
    box-sizing: border-box;
}

/* 確保AI設定在移動設備上正確顯示 */
@media screen and (max-width: 768px) {
    #ai-settings-card {
        width: 100%;
    }

    #ai-settings-card .form-row {
        margin-bottom: 0.8rem;
    }

    #ai-settings-card .form-group {
        width: 100%;
    }
}

/* AI分析建議區塊樣式 */
.ai-advice,
#ai-advice-section {
    background: #f8f9fa;
    border-left: 4px solid #4285f4;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
    position: relative;
    transition: all 0.3s ease;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.ai-advice:hover,
#ai-advice-section:hover {
    box-shadow: 0 5px 15px rgba(66, 133, 244, 0.2);
    transform: translateY(-2px);
}

.ai-advice::before,
#ai-advice-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #4285f4, #34a853, #fbbc05, #ea4335);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ai-advice:hover::before,
#ai-advice-section:hover::before {
    opacity: 1;
}

.ai-advice h4,
#ai-advice-section h4 {
    color: #4285f4;
    margin-bottom: 20px;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    font-weight: 600;
}

.ai-advice h4::before,
#ai-advice-section h4::before {
    content: '\f075';
    /* FontAwesome 聊天圖標 */
    font-family: 'Font Awesome 5 Free';
    margin-right: 10px;
    color: #4285f4;
}

.ai-advice-content {
    font-size: 1rem;
    line-height: 1.6;
    color: #333;
    max-height: none;
    overflow: visible;
    transition: max-height 0.5s ease;
}

.ai-advice-content h5 {
    font-size: 1rem;
    color: #1a73e8;
    margin-top: 20px;
    margin-bottom: 10px;
    font-weight: 600;
}

.ai-advice-content p {
    margin-bottom: 15px;
}

.ai-advice-content strong {
    font-weight: 600;
    color: #202124;
}

.ai-advice-content ul {
    padding-left: 20px;
    margin-bottom: 15px;
}

.ai-advice-content li {
    margin-bottom: 5px;
}

.ai-advice-footer {
    margin-top: 20px;
    padding-top: 10px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
}

.ai-advice-time {
    font-size: 0.85rem;
    color: #70757a;
    font-style: italic;
}

/* 手機版適配 */
@media (max-width: 768px) {

    .ai-advice,
    #ai-advice-section {
        margin: 15px 0;
    }

    .ai-advice h4,
    #ai-advice-section h4 {
        font-size: 1.1rem;
    }

    .ai-advice-content {
        padding: 10px;
    }

    .ai-advice-content h5 {
        font-size: 1rem;
    }

}

/* 在content-section中的添加按鈕居中顯示 */
.content-section .add-button {
    display: block;
    margin: 10px auto;
    position: relative;
    left: 0;
    right: 0;
}

/* 統一所有模態窗口樣式，確保寬度增加50% */
@media screen and (max-width: 768px) {
    .modal-content {
        width: 75%;
        max-width: 600px;
        /* 保持一致 */
        padding: 15px;
    }
}

@media screen and (max-width: 480px) {
    .modal-content {
        width: 90%;
        max-width: 380px;
        /* 保持合理大小 */
        padding: 10px;
    }
}

/* 確保moduleModal的內容也有合適寬度 - 縮小視窗並置中 */
#moduleModal .modal-content {
    width: 45%;
    max-width: 500px;
    text-align: center;
}

/* 確保returnCalcModal的內容也有足夠寬度 */
#returnCalcModal .modal-content {
    max-width: 750px !important;
    /* 從500px增加50% */
}

/* 更強制地使藍色＋按鈕居中顯示 */
.content-section .add-button,
.add-button[data-type] {
    display: block !important;
    width: 40px !important;
    height: 40px !important;
    margin: 15px auto !important;
    position: relative !important;
    left: 0 !important;
    right: 0 !important;
    float: none !important;
    transform: none !important;
    text-align: center !important;
}

/*特殊樣式最高優先級覆蓋*/
body .version {
    position: absolute !important;
    top: 10px !important;
    right: 120px !important;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.3s ease;
    font-size: 1rem;
    font-weight: bold;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    position: absolute !important;
    top: 10px !important;
    right: 210px !important;
    margin-bottom: 0 !important;
    margin-top: 0 !important;
    z-index: 99 !important;
    display: block !important;
}

/* 強制執行所有藍色＋按鈕的居中顯示，不被其他樣式覆蓋 */
body .content-section .add-button,
body button.add-button[data-type] {
    display: block !important;
    width: 40px !important;
    height: 40px !important;
    margin: 15px auto !important;
    position: relative !important;
    left: 0 !important;
    right: 0 !important;
    float: none !important;
    transform: none !important;
    text-align: center !important;
    /* Chart-related styles have been moved to chart.css */
    flex-direction: column;
    min-height: 0;
    /* 確保 flex 容器可以正確縮小 */
    margin-bottom: 60px;
    /* 為底部導航欄留出空間 */
}

/* 在標題下方添加裝飾線 */

/* 模擬紀錄項目樣式 */
.record-item {
    padding: 10px 12px;
    /* Adjusted padding to match file items */
    margin-bottom: 8px;
    background: white;
    border-radius: 4px;
    font-size: 0.8rem;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    cursor: pointer;
    /* border-left: 3px solid #42a5f5; */
    /* Removed blue left border */
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    position: relative;
    width: calc(100% - 10px);
    /* Added width calculation like file items */
    box-sizing: border-box;
    min-height: 60px;
    /* Added minimum height for consistency */
}

/* Add delete button style */
.record-delete-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 18px;
    height: 18px;
    background-color: #b6d9fa;
    color: #6495ED;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
    opacity: 0; /* 預設隱藏 */
    border: 1px solid #e1f0ff;
}

/* 滑鼠移到紀錄項目時顯示刪除按鈕 */
.record-item:hover .record-delete-btn {
    opacity: 0.7;
}

.record-delete-btn:hover {
    opacity: 1 !important;
    transform: scale(1.1);
    background-color: #90c3f9;
    color: white;
}

.record-item:hover {
    transform: translateX(5px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    background-color: #f0f7ff;
}

.record-date {
    color: #666;
    font-size: 0.7rem;
}

.record-name {
    color: #2c3e50;
    /* 記錄名稱顏色 */
    font-weight: bold;
    margin-bottom: 3px;
}

/* 添加模擬記錄狀態樣式 */
.record-status {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.75rem;
}

.status-0 {
    background: #ffd700;
    /* 黃色 - 等待處理 */
    color: #000;
}

.status-1 {
    background: #87ceeb;
    /* 藍色 - 處理中 */
    color: #000;
}

.status-2 {
    background: #90ee90;
    /* 綠色 - 已完成 */
    color: #000;
}

.status-3 {
    background: #ff6347;
    /* 紅色 - 錯誤 */
    color: #fff;
}

.tooltip-title {
    font-weight: bold;
    margin-bottom: 8px;
    color: #2874A6;
    /* 更深的藍色 */
    font-size: 16px;
    border-bottom: 1px solid #BDE0F7;
    /* 淺藍色底線 */
    padding-bottom: 5px;
    text-align: center;
    /* 讓tooltip標題居中 */
}

/* 資產查詢相關樣式已移至 asset_query.css */

/* 子容器樣式（基本投資、基本收入等） */
.sub-container {
    background-color: var(--sub-container-bg);
    /* 使用新變量 */
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 1.5rem;
    padding: 1.2rem;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.sub-container:hover {
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

.sub-container-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--border-color);
}

.sub-container-header h3 {
    font-size: 1.2rem;
    color: var(--primary-text-color);
    margin: 0;
    font-weight: 500;
}

.sub-container-content {
    padding: 0.5rem 0;
}

.sub-container-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 1rem;
    gap: 10px;
}

.sub-container-item {
    background-color: var(--sub-item-bg);
    /* 使用新變量 */
    border-radius: 8px;
    padding: 0.8rem;
    margin-bottom: 0.8rem;
    border: 1px solid var(--border-color-light);
    transition: all 0.2s ease;
}

.sub-container-item:hover {
    background-color: var(--hover-bg-color);
}

.sub-container-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.sub-container-item-header h4 {
    font-size: 1rem;
    margin: 0;
    color: var(--primary-text-color);
}

/* 子容器內的表單樣式 */
.sub-container .form-row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -10px 10px;
}

.sub-container .form-group {
    flex: 1 1 250px;
    padding: 0 10px;
    margin-bottom: 0.8rem;
}

.sub-container input,
.sub-container select,
.sub-container textarea {
    width: 100%;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: var(--input-bg-color);
    color: var(--primary-text-color);
    transition: all 0.3s ease;
}

.sub-container input:focus,
.sub-container select:focus,
.sub-container textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(var(--primary-color-rgb), 0.2);
    outline: none;
}

/* 子容器內的按鈕 */
.sub-container-btn {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
    background-color: var(--button-bg-color);
    color: var(--button-text-color);
}

.sub-container-btn.primary {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.sub-container-btn.danger {
    background-color: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
}

.sub-container-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.sub-container-btn i {
    margin-right: 6px;
    font-size: 0.9rem;
}

/* 響應式設計 */
@media screen and (max-width: 768px) {
    .sub-container {
        padding: 1rem;
    }

    .sub-container-header h3 {
        font-size: 1.1rem;
    }

    .sub-container .form-row {
        flex-direction: column;
    }

    .sub-container .form-group {
        flex: 1 1 100%;
    }
}

@media screen and (max-width: 480px) {
    .sub-container {
        padding: 0.8rem;
    }

    .sub-container-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .sub-container-header h3 {
        margin-bottom: 0.5rem;
        font-size: 1rem;
    }

    .sub-container-actions {
        flex-direction: column;
    }

    .sub-container-btn {
        width: 100%;
        justify-content: center;
        margin-bottom: 0.5rem;
    }
}

/* 新手導引視窗樣式 */
.guide-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    overflow-y: auto;
}

.guide-video-container {
    position: relative;
    width: 100%;
    padding-bottom: 75%;
    /* 較高的高度比例 */
    margin-bottom: 30px;
    margin-top: 30px;
    /* 為標題留空間 */
    overflow: hidden;
    background-color: #000;
    /* 黑色背景 */
}

.guide-video-container::before {
    content: "操作和基本介紹";
    position: absolute;
    top: -30px;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 24px;
    font-weight: bold;
    color: #333;
    z-index: 5;
}

.guide-video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    max-width: 80%;
    /* 兩邊留黑色邊框 */
    left: 10%;
    /* 水平居中 */
}

.guide-steps::before {
    content: "操作步驟說明";
    display: block;
    width: 100%;
    text-align: center;
    font-size: 24px;
    font-weight: bold;
    color: #333;
    margin-bottom: 20px;
}

.guide-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 20px 40px 40px 40px;
    border-radius: 10px;
    width: 90%;
    max-width: 850px;
    position: relative;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    padding-top: 50px;
}

.close-guide {
    position: absolute;
    right: 15px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    line-height: 1;
    padding: 5px;
    transition: color 0.3s ease, transform 0.3s ease;
    z-index: 10;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-guide:hover {
    color: #fff;
    background-color: #dc3545;
    transform: scale(1.1);
}

.guide-steps {
    margin-top: 15px;
    padding-top: 10px;
}

.guide-step {
    margin-bottom: 30px;
    padding: 15px;
    border-radius: 8px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
}

.guide-step h3 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 1.2em;
}

.guide-step p {
    color: #666;
    line-height: 1.6;
    margin: 0;
}

/* 隱藏舊的導覽按鈕 */
.guide-navigation,
.prev-step,
.next-step,
.step-indicators,
.step-dot {
    display: none !important;
}

.prev-step,
.next-step {
    padding: 8px 20px;
    background: linear-gradient(45deg, var(--gradient-start), var(--gradient-end));
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.prev-step:hover,
.next-step:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.prev-step:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.step-indicators {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
}

.step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #ddd;
    cursor: pointer;
    transition: all 0.3s ease;
}

.step-dot.active {
    background-color: var(--gradient-start);
    transform: scale(1.2);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.close-modal {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 24px;
    font-weight: bold;
    color: #666;
    cursor: pointer;
    transition: color 0.3s ease;
}

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

/* AI評估容器樣式 */
.ai-advice {
    margin: 20px 0;
    font-family: 'Noto Sans TC', sans-serif;
}

/* 確保AI評估內容與其他分析部分風格一致 */
.ai-advice-content {
    margin: 15px 0;
    line-height: 1.6;
    font-family: 'Noto Sans TC', sans-serif;
}

.ai-advice-content p {
    margin-bottom: 10px;
    font-family: 'Noto Sans TC', sans-serif;
}

.ai-advice-footer {
    font-size: 0.85em;
    color: #888;
    text-align: right;
    margin-top: 15px;
    font-family: 'Noto Sans TC', sans-serif;
}

/* Toast notification styles */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 10px 20px;
    border-radius: 4px;
    color: white;
    font-size: 14px;
    z-index: 9999;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s, transform 0.3s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-info {
    background-color: #2196F3;
}

.toast-success {
    background-color: #4CAF50;
}

.toast-error,
.error-toast {
    background-color: #F44336;
}

.toast-warning {
    background-color: #FF9800;
}

/* 移動自 main_simulation.html 的 CSS 樣式開始 */

/* 標題全部居中 */
.finance-section h2,
.card-header h3,
.mode-header h4 {
    text-align: center;
}

/* 禁用狀態樣式 */
.disabled-section {
    opacity: 0.7;
    pointer-events: none;
}

/* 會員權限提示樣式 */
.premium-notice {
    display: flex;
    align-items: center;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 10px;
    margin-top: 15px;
    color: #6c757d;
}

.premium-notice i {
    margin-right: 10px;
    color: #ffc107;
}

/* 確保內容不被藍色條擋住 */
body {
    margin-top: 0;
    /* 移除 margin-top，讓藍色條固定在最上方 */
}

/* 已存在於CSS中的 .gradient-header 選擇器，只添加尚未定義的屬性 */
.gradient-header {
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    /* 確保藍色條在最上層 */
}

/* 展開按鈕樣式 */
.expand-records-btn {
    display: block;
    width: 100%;
    padding: 8px;
    margin: 5px 0;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    text-align: center;
    font-size: 14px;
    color: #888;
}

/* 隱藏基礎單位欄位 - 使用直接的選擇器 */
#base-unit {
    display: none !important;
}

/* 隱藏基礎單位的標籤和tooltip */
label[for="base-unit"],
label[for="base-unit"]+.tooltip-content,
label[for="base-unit"]~.tooltip-content {
    display: none !important;
}

/* 隱藏整個基礎單位的容器 */
.form-group:has(#base-unit) {
    display: none !important;
}

/* membership-level 已存在於CSS中，將關鍵屬性設定添加到已有樣式 */
/* .membership-level {
    position: absolute;
    top: 6px;
    right: 130px;
    background-color: rgba(255, 255, 255, 0.8);
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 14px;
    color: #333;
    z-index: 900;
} */

/* 添加 AI 額度獨立樣式控制，固定位置 */
/* .ai-quota {
    position: absolute;
    top: 6px;
    right: 90px;
    background-color: rgba(255, 255, 255, 0.8);
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 14px;
    color: #333;
    z-index: 900;
} */

.version {
    position: absolute;
    top: 6px;
    right: 10px;
    background-color: rgba(255, 255, 255, 0.8);
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 14px;
    color: #333;
}

/* AI 開關切換按鈕樣式 */
.ai-toggle-container {
    display: flex;
    align-items: center;
    margin-left: 0;
}

.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked+.slider {
    background-color: #2196F3;
}

input:focus+.slider {
    box-shadow: 0 0 1px #2196F3;
}

input:checked+.slider:before {
    transform: translateX(26px);
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

.toggle-label {
    margin-left: 10px;
    font-size: 14px;
    white-space: normal;
    /* 允許換行 */
}

/* 檔案設定區塊舊 flex 版面與間距移除：改由通用網格與欄位節奏處理 */

/* 標準按鈕樣式 */
.standard-button {
    padding: 8px 15px;
    background-color: #2196F3;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.standard-button:hover {
    background-color: #0b7dda;
}

.standard-button i {
    margin-right: 5px;
}

/* 複選框樣式 */
.standard-checkbox {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkbox-label {
    position: relative;
    padding-left: 28px;
    cursor: pointer;
    font-size: 14px;
    line-height: 24px;
    display: inline-block;
}

.checkbox-label:before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 20px;
    height: 20px;
    border: 1px solid #ccc;
    background-color: #fff;
    border-radius: 3px;
}

.standard-checkbox:checked+.checkbox-label:before {
    background-color: #2196F3;
    border-color: #2196F3;
}

.standard-checkbox:checked+.checkbox-label:after {
    content: '';
    position: absolute;
    left: 7px;
    top: 3px;
    width: 6px;
    height: 12px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* 旧版 full-width 規則保留（被通用網格覆蓋時不影響） */

/* AI設定相關樣式補充 */
#advanced-params-card {
    margin-bottom: 20px;
}

/* 移動自 main_simulation.html 的 CSS 樣式結束 */

/* 移動自 main_simulation.html 的 CSS 樣式補充 */

/* 調整子容器樣式 */
.content-card,
.module-container,
.item-container,
.analysis-mode-section {
    background-color: #f8fafc;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    padding: 10px;
    margin-bottom: 15px;
    width: 100%;
    box-sizing: border-box;
}

/* 確保欄位名稱不被縮短 */
.module-container .field-name,
.item-container .field-name {
    white-space: normal;
    /* 允許換行 */
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* 增加容器頂部間距，避免按鈕重疊 */
.finance-sections {
    margin-top: 55px;
    /* 增加更多間距，避免與頂部按鈕重疊 */
    padding-top: 15px;
    overflow: visible;
    /* 確保內容不會被裁剪 */
    width: 100%;
    /* 確保寬度正確 */
    box-sizing: border-box;
    /* 確保內邊距不增加總寬度 */
}

/* 確保側邊欄顯示正確 */
.sidebar {
    z-index: 90;
    /* 比按鈕低，但比一般內容高 */
}

/* 卡片標題容器水平排列 - 補充 */
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* 更新完整的 #ai-settings-card 樣式 */
#ai-settings-card {
    width: 100%;
    box-sizing: border-box;
    padding: 1rem;
    border-radius: 8px;
    background-color: var(--content-card-bg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

#ai-settings-card .card-header {
    border-bottom: 1px solid #eee;
    margin-bottom: 15px;
    padding-bottom: 10px;
}

#ai-settings-card .card-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#ai-settings-card select.standard-select {
    max-width: 500px;
    width: 100%;
}

/* 補充textarea樣式，確保設定相同 */
.textarea-container {
    position: relative;
    width: 100%;
}

.standard-textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
}

.char-counter {
    position: absolute;
    right: 10px;
    bottom: 10px;
    font-size: 12px;
    color: #666;
}

/* 移動自 main_simulation.html 的 CSS 樣式補充結束 */

.form-group.full-width {
    width: 100%;
}

/* --- i18n: 防止英文標籤過長導致排版跑掉（桌機） --- */
.form-group label {
    min-width: 150px;
    /* 保留最小寬度，但允許換行 */
    white-space: normal;
    /* 允許多行顯示 */
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* 旧版問號絕對定位移除，改由通用規則微調（與標籤文字同列） */

/* 手機/窄螢幕下恢復自動換行，維持原本一行一欄版型 */
@media (max-width: 768px) {
    .form-group label {
        min-width: 0;
        white-space: normal;
        display: block;
        /* 窄螢幕下回到區塊排列，避免上下不對齊 */
        margin-bottom: 4px;
        height: auto;
        /* 手機上允許多行 */
        padding-right: 0;
        /* 手機不保留空間 */
    }

    .form-group label>span:not(.help-popup-btn-inline) {
        overflow: visible;
        text-overflow: clip;
        white-space: normal;
    }

    .form-group label .help-popup-btn-inline {
        position: static;
        /* 手機讓問號跟隨文字 */
        transform: none;
        margin-left: 6px;
        vertical-align: middle;
    }
}

/* 調整檔案設定切換按鈕和標籤樣式 */
.ai-toggle-container {
    display: flex;
    align-items: center;
    margin-top: 5px;
}

.toggle-label {
    margin-right: 10px;
    font-size: 14px;
    color: var(--primary-text-color);
    font-weight: 500;
}

/* 修正切換開關太寬的問題 */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
    margin-right: 8px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked+.slider {
    background-color: var(--primary-color);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--primary-color);
}

input:checked+.slider:before {
    transform: translateX(24px);
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

/* 檔案名稱行特殊樣式 */
.file-name-row {
    width: 100%;
    display: flex;
    flex-direction: row;
    margin-bottom: 15px;
}

/* 旧版 file-name-row flex 規則移除，改由通用網格的跨欄規則處理 */

/* 切換開關容器樣式 */
.toggle-switch-container {
    display: flex;
    align-items: center;
}

/* 創建全新的、完全獨立的檔案設定切換按鈕樣式 - 不受任何其他樣式影響 */
.file-settings-toggle-row {
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
    /* 允許換行 */
    gap: 20px;
    /* 統一使用gap控制間距 */
    margin-top: 10px;
    margin-bottom: 10px;
    width: 100%;
    box-sizing: border-box;
    padding: 5px 0;
}

.file-settings-toggle-group {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    min-width: 120px;
    /* 設定最小寬度確保按鈕組不會太擠 */
    position: relative;
    z-index: 5;
    /* 確保按鈕在上層 */
    margin-bottom: 8px;
    /* 換行時的垂直間距 */
}

/* 響應式佈局 - 中等屏幕 */
@media (max-width: 1024px) and (min-width: 769px) {
    .file-settings-toggle-row {
        gap: 15px;
    }

    .file-settings-toggle-group {
        min-width: 110px;
    }

    .file-settings-toggle-label {
        font-size: 13px;
        min-width: 60px;
    }
}

/* 響應式佈局 - 小屏幕 */
@media (max-width: 768px) {
    .file-settings-toggle-row {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .file-settings-toggle-group {
        min-width: auto;
        width: 100%;
        justify-content: space-between;
        padding: 8px 12px;
        background: rgba(240, 240, 240, 0.5);
        border-radius: 8px;
        margin-bottom: 4px;
    }

    .file-settings-toggle-label {
        font-size: 14px;
        min-width: auto;
        flex: 1;
    }
}

/* 響應式佈局 - 超小屏幕 */
@media (max-width: 480px) {
    .file-settings-toggle-group {
        padding: 10px 8px;
    }

    .file-settings-toggle-label {
        font-size: 13px;
    }

    .file-settings-switch {
        width: 50px;
    }

    .file-settings-switch input:checked+.file-settings-slider:before {
        transform: translateX(26px);
    }
}

.file-settings-toggle-label {
    min-width: 65px;
    margin-right: 12px;
    font-weight: 500;
    font-size: 14px;
    white-space: nowrap;
    color: #333;
}

.file-settings-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    /* Increased from 52px to 60px to make the button wider */
    height: 24px;
    flex-shrink: 0;
    margin: 0;
    box-sizing: content-box;
    /* 確保尺寸不受padding影響 */
    vertical-align: middle;
}

.file-settings-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
}

.file-settings-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
    box-sizing: border-box;
}

.file-settings-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-sizing: border-box;
}

.file-settings-switch input:checked+.file-settings-slider {
    background-color: #2196F3;
}

.file-settings-switch input:checked+.file-settings-slider:before {
    transform: translateX(36px);
    /* Adjusted from 32px to 36px to match the wider button */
}

/* 模擬紀錄資訊佈局 */
.record-info {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding-right: 20px;
    /* 防止與刪除按鈕重疊 */
}

/* 模擬紀錄底部信息行 */
.record-item-footer {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    margin-top: 4px;
}

.record-date {
    color: #666;
    font-size: 0.7rem;
    margin-bottom: 4px;
}

.record-name {
    font-weight: 500;
    color: #333;
    margin-bottom: 8px;
    position: relative;
    width: 100%;
    max-width: 100%;
    padding-right: 15px;
    white-space: normal;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
}

@media screen and (max-width: 768px) {
    .guide-content {
        width: 90%;
        padding: 15px;
    }

    .guide-video-container {
        margin-bottom: 15px;
    }
}

@media screen and (max-width: 480px) {
    .guide-content {
        width: 95%;
        padding: 10px;
    }

    .guide-video-container {
        margin-bottom: 10px;
    }
}

/* 確保moduleModal的內容也有足夠寬度 - 縮小視窗並置中 */
#moduleModal .modal-content {
    width: 45%;
    max-width: 500px;
    text-align: center;
}

/* 擴大模組選擇器彈出窗口的寬度，並確保自適應變化 - 縮小視窗並置中 */
#moduleModal .modal-content {
    width: 45%;
    max-width: 500px;
    margin: 3% auto;
    overflow-y: auto;
    max-height: 90vh;
    text-align: center;
}

/* 確保模組選擇器在不同設備上都能適當顯示 - 縮小視窗並置中 */
@media screen and (max-width: 992px) {
    #moduleModal .modal-content {
        width: 280px;
        max-width: 300px;
        text-align: center;
    }
}

@media screen and (max-width: 768px) {
    #moduleModal .modal-content {
        width: 260px;
        max-width: 280px;
        padding: 1.2rem;
        text-align: center;
    }

    .module-card {
        width: 180px;
    }
}

@media screen and (max-width: 480px) {
    #moduleModal .modal-content {
        width: 240px;
        max-width: 260px;
        padding: 1rem;
        text-align: center;
    }

    .module-card {
        width: 160px;
        padding: 6px 8px;
    }

    .module-card h4 {
        font-size: 0.8rem;
    }
}

/* 禁用狀態樣式 */
.disabled-section {
    opacity: 0.7;
    pointer-events: none;
}

/* 禁用模組樣式 */
.disabled-module {
    opacity: 0.7;
    position: relative;
    cursor: not-allowed !important;
    background-color: rgba(249, 249, 249, 0.8) !important;
    border: 1px solid #e0e0e0 !important;
}

.disabled-module h4 {
    color: #888 !important;
}

.disabled-module:hover {
    transform: none !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1) !important;
}

.disabled-module .lock-icon {
    position: absolute;
    top: 10px;
    right: 10px;
    color: #ffc107;
    font-size: 16px;
}

/* 會員權限提示樣式 */
.premium-notice {
    display: flex;
    align-items: center;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 10px;
    margin-top: 15px;
    color: #6c757d;
}

.premium-notice i {
    margin-right: 10px;
    color: #ffc107;
}

/* 添加或修改 index.html 的影片容器樣式 */
.video-container {
    position: relative !important;
    overflow: hidden !important;
    width: 100% !important;
    height: 60vh !important;
    margin-top: 0 !important;
}

.video-bg {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 100vw !important;
    /* 設置為視窗寬度 */
    height: 56.25vw !important;
    /* 保持 16:9 的比例 (9/16 = 0.5625) */
    min-height: 100% !important;
    min-width: 177.77vh !important;
    /* 保持 16:9 的比例 (16/9 = 1.7777) */
}

.video-bg iframe {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
}

/* 【新增】圖表控制區域容器 */
.chart-controls-area {
    margin: 10px 0 5px 0;
    display: flex;
    justify-content: flex-start;
    position: relative;
}

/* 【新增】圖表切換按鈕容器 */
.chart-toggle-container {
    display: flex;
    align-items: center;
    gap: 8px;
    /* 切換按鈕和說明按鈕之間的間距 */
    margin-left: 10px;
    /* 靠左一點，避免和放大按鈕重疊 */
}

/* 【新增】圖表切換按鈕樣式 */
.chart-toggle-btn {
    background-color: #e3f2fd;
    /* 更淡的藍色背景 */
    color: #1976d2;
    /* 柔和的藍色文字 */
    border: 1px solid #bbdefb;
    /* 極淡的藍色邊框 */
    border-radius: 5px;
    padding: 6px 12px;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    /* 更輕的陰影 */
    z-index: 5;
    white-space: normal;
    /* 允許換行 */
    min-width: 70px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
}

.chart-toggle-btn:hover {
    background-color: #bbdefb;
    /* 懸停時稍微深一點但仍然很淡 */
    color: #1565c0;
    /* 稍深的藍色文字 */
    border-color: #90caf9;
    transform: scale(1.01);
    /* 更小的縮放效果 */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    /* 更輕的陰影 */
}

.chart-toggle-btn:active {
    transform: scale(0.95);
}

/* 響應式設計 - 小螢幕調整 */
@media screen and (max-width: 768px) {
    .chart-controls-area {
        justify-content: center;
        margin: 10px 0;
    }

    .chart-toggle-container {
        margin-left: 0;
    }
}

@media screen and (max-width: 480px) {
    .chart-toggle-btn {
        padding: 5px 10px;
        font-size: 0.8em;
        min-width: 60px;
        height: 28px;
    }
}

/* 確保主要圖表顯示正確 */
#area-chart-container .chart-canvas-container,
#median-group-chart-container .chart-canvas-container,
#mdd-chart-container .chart-canvas-container {
    background-color: #f8fafc !important;
    border-radius: 6px !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
    padding: 8px !important;
    width: 100% !important;
    height: 800px !important;
    /* Increased from 560px */
    margin: 0 !important;
    position: relative !important;
}

/* 確保圖表在容器內正確顯示 */
#areaChart,
#medianGroupChart,
#mddHistogram {
    width: 100% !important;
    height: 100% !important;
    max-height: 800px !important;
    /* Increased from 560px */
}

/* 修改主要圖表容器樣式，確保垂直堆疊 */
.charts-container {
    padding: 0 !important;
    margin: 0 0 12px 0 !important;
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    /* 垂直堆疊 */
    gap: 15px !important;
    /* 增加垂直間距 */
    background-color: white !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
    padding: 8px !important;
}

/* 修改各圖表項目樣式確保垂直堆疊 */
.chart-item,
#area-chart-container,
#median-group-chart-container,
#mdd-chart-container {
    flex: 1 1 100% !important;
    /* 佔據全寬 */
    width: 100% !important;
    min-width: 100% !important;
    margin: 0 0 15px 0 !important;
    /* 底部間距 */
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    position: relative !important;
}

/* 確保圖表標題顯示正確 */
#area-chart-container h4,
#median-group-chart-container h4,
#mdd-chart-container h4 {
    text-align: center !important;
    font-size: 1.2em !important;
    margin-bottom: 10px !important;
    padding: 0 !important;
}

/* 會員訂閱提示樣式 */
.premium-feature-notice {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    backdrop-filter: blur(2px);
}

.premium-notice-content {
    text-align: center;
    padding: 20px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-width: 80%;
}

.premium-notice-content i {
    color: #ffc107;
    font-size: 32px;
    margin-bottom: 15px;
}

.premium-notice-content p {
    margin-bottom: 15px;
    font-size: 16px;
    line-height: 1.5;
    color: #333;
}

.upgrade-button {
    display: inline-block;
    padding: 8px 16px;
    background-color: #4285f4;
    color: white;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.upgrade-button:hover {
    background-color: #2a75f3;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* 確保相對定位的容器能正確顯示絕對定位的元素 */
.content-card {
    position: relative;
}

/* 增加對應的禁用樣式 */
.disabled-section {
    opacity: 0.7;
    pointer-events: none;
}

.disabled-section input,
.disabled-section select,
.disabled-section textarea {
    background-color: #f5f5f5 !important;
    cursor: not-allowed !important;
}

/* 會員標籤樣式 */
.premium-tag {
    display: inline-flex;
    align-items: center;
    background-color: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 3px 8px;
    margin-left: 10px;
    font-size: 12px;
    color: #757575;
}

.premium-tag i {
    color: #ffc107;
    margin-right: 5px;
    font-size: 11px;
}

/* 修改禁用樣式，保持可見但無法交互 */
.disabled-section {
    opacity: 0.6;
    pointer-events: none;
}

.disabled-section input,
.disabled-section select,
.disabled-section textarea {
    background-color: #f5f5f5 !important;
    cursor: not-allowed !important;
}

/* 移除不需要的覆蓋樣式 */
.premium-feature-notice {
    display: none;
}

/* 在大螢幕尺寸時隱藏側邊欄切換按鈕 */
@media screen and (min-width: 992px) {
    .sidebar-toggle {
        display: none !important;
        /* 在大螢幕尺寸時完全隱藏側邊欄切換按鈕 */
    }
}

/* 鎖定icon樣式 - 強制覆蓋所有樣式 */
.lock-icon {
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    color: #e74c3c !important;
    font-size: 16px !important;
    z-index: 10 !important;
    pointer-events: none !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* 禁用的模組卡片樣式 - 強制覆蓋所有樣式 */
.module-card.disabled-module,
.module-card[onclick*="此模組僅限等級2及以上會員使用"] {
    cursor: not-allowed !important;
    opacity: 0.7 !important;
    background-color: rgba(249, 249, 249, 0.8) !important;
    color: #999 !important;
    position: relative !important;
    border: 1px solid #e0e0e0 !important;
}

.module-card.disabled-module:hover,
.module-card[onclick*="此模組僅限等級2及以上會員使用"]:hover {
    transform: none !important;
    box-shadow: none !important;
    background-color: rgba(249, 249, 249, 0.8) !important;
    border-color: #e0e0e0 !important;
}

.module-card.disabled-module h4,
.module-card[onclick*="此模組僅限等級2及以上會員使用"] h4 {
    color: #999 !important;
}

/* 確保鎖定模組的所有子元素都顯示為禁用狀態 */
.module-card[onclick*="此模組僅限等級2及以上會員使用"] * {
    color: #999 !important;
}

/* 確保模組選擇器的基本樣式 */
.module-card {
    position: relative;
    background: white;
    padding: 8px 12px;
    margin: 0 auto 6px auto;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid #eee;
    width: 200px;
    box-sizing: border-box;
    text-align: center;
}

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

.module-card h4 {
    margin: 0;
    text-align: center;
    font-size: 0.9rem;
    color: #2c3e50;
}

/* 確保模組選擇器modal的樣式 */
#moduleModal .modal-content {
    position: relative;
    background-color: white;
    margin: 5% auto;
    padding: 1.5rem;
    width: 280px;
    max-width: 320px;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    max-height: 85vh;
    overflow-y: auto;
    text-align: center;
}

#moduleModal .modal-content h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: #2c3e50;
}

#moduleModal .module-permission-notice {
    background-color: #e8f4f8;
    border: 1px solid #b8daff;
    border-radius: 4px;
    padding: 8px;
    margin-bottom: 1rem;
    font-size: 0.8rem;
    color: #004085;
    text-align: left;
}

#moduleModal .module-permission-notice i {
    margin-right: 4px;
    color: #0066cc;
}

#moduleModal .module-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: center;
    align-items: center;
}

/* 快速跳轉按鈕樣式 - 在所有設備上顯示 */
.quick-nav-container {
    position: fixed;
    top: 90px;
    /* 往上移動 */
    right: 10px;
    /* 更靠右 */
    z-index: 400;
    /* 降低層級，確保不覆蓋側邊欄 (990) 和其他重要UI元素 */
    display: flex;
    /* 改為預設顯示 */
    flex-direction: column;
    align-items: flex-end;
    /* 右對齊 */
    gap: 8px;
    /* 增加間距 */
    transition: all 0.3s ease;
    /* 修正：確保按鈕只在實際按鈕區域響應點擊，不阻擋其他元素 */
    pointer-events: none;
}

/* 修正：只有按鈕本身響應點擊事件 */
.quick-nav-container .quick-nav-btn,
.quick-nav-container .quick-nav-toggle {
    pointer-events: auto;
}

/* 導航 wrapper：讓面板定位永遠以導航按鈕為基準（類似圖表設定） */
.quick-nav-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* 快速跳轉按鈕列表容器 - 改為向左展開 */
.quick-nav-list {
    position: absolute;
    top: 0;
    right: 100%;
    margin-right: 8px;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    width: 220px;
    /* 確保兩列布局：105px + 5px + 105px = 215px，加上邊框等設為220px */
    gap: 5px;
    /* 保持間距 */
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: right center;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.98) 100%);
    border: 1px solid rgba(200, 200, 200, 0.4);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(12px);
    padding: 10px;
    z-index: 401;
}

/* 收縮狀態 */
.quick-nav-list.collapsed {
    max-height: 0;
    opacity: 0;
    transform: scaleX(0);
    margin-right: 0;
    padding: 0;
    pointer-events: none;
}

/* 展開狀態 */
.quick-nav-list.expanded {
    max-height: 500px;
    /* 增加高度適應更大按鈕 */
    opacity: 1;
    transform: scaleX(1);
    margin-right: 8px;
    padding: 10px;
    /* 修正：展開時確保列表區域響應點擊事件 */
    pointer-events: auto;
}

/* 主展開按鈕樣式 */
.quick-nav-toggle {
    position: relative;
}

.quick-nav-toggle i {
    transition: transform 0.3s ease;
}

/* 展開時主按鈕圖標旋轉 - 只有懸停在導航按鈕時才旋轉 */
.quick-nav-container.expanded .quick-nav-toggle i,
.quick-nav-toggle:hover i {
    transform: rotate(90deg);
}

/* 滑鼠懸停自動展開 - 只有懸停在導航按鈕或下拉列表時才觸發（向左展開） */
.quick-nav-toggle:hover~.quick-nav-list,
.quick-nav-list:hover {
    max-height: 500px !important;
    opacity: 1 !important;
    transform: scaleX(1) !important;
    margin-right: 8px !important;
    padding: 10px !important;
    pointer-events: auto !important;
}

/* 防止懸停時意外收縮 */
.quick-nav-toggle:hover~.quick-nav-list.collapsed,
.quick-nav-list:hover.collapsed {
    max-height: 500px !important;
    opacity: 1 !important;
    transform: scaleX(1) !important;
    margin-right: 8px !important;
    padding: 10px !important;
    pointer-events: auto !important;
}

/* 確保幫助按鈕獨立，不觸發導航下拉 */
.help-toggle-standalone {
    position: relative;
    z-index: 400;
    /* 與導航容器保持相同層級 */
}

/* 當懸停在幫助按鈕時，不展開導航下拉 */
.help-toggle-standalone:hover~.quick-nav-wrapper .quick-nav-list {
    max-height: 0 !important;
    opacity: 0 !important;
    transform: scaleX(0) !important;
    margin-right: 0 !important;
    padding: 0 !important;
}

.quick-nav-btn {
    background-color: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(200, 200, 200, 0.3);
    border-radius: 8px;
    padding: 6px 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    color: rgba(100, 100, 100, 0.8);
    font-size: 12px;
    font-weight: 500;
    width: 105px;
    min-width: 105px;
    max-width: 105px;
    /* 確保按鈕寬度固定，不會超出導致無法換行 */
    box-sizing: border-box;
    /* 包含邊框和內邊距在寬度計算內 */
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
    /* 防止按鈕被壓縮 */
}

.quick-nav-btn:hover {
    background-color: rgba(66, 165, 245, 0.3);
    /* 懸停時藍色背景 */
    border-color: rgba(66, 165, 245, 0.6);
    /* 懸停時藍色邊框 */
    color: rgba(66, 165, 245, 1);
    /* 懸停時藍色文字 */
    /* 移除移動效果，只保留變色 */
    box-shadow: 0 4px 12px rgba(66, 165, 245, 0.15);
    /* 懸停時淡藍色陰影 */
}

.quick-nav-btn i {
    font-size: 12px;
    opacity: 0.7;
}

.quick-nav-btn:hover i {
    opacity: 1;
}

.quick-nav-btn span {
    font-size: 11px;
    white-space: normal;
}

/* 手機版快速導航位置調整 - 保持原本按鈕尺寸 */
@media (max-width: 767px) {
    .quick-nav-container {
        top: 80px;
        /* 手機版往上移動 */
        right: 8px;
        /* 稍微往左移 */
        z-index: 400;
        /* 降低層級，避免覆蓋側邊欄 (990) 和其他重要UI元素 */
        /* 修正：確保按鈕只在實際按鈕區域響應點擊，不阻擋其他元素 */
        pointer-events: none;
    }

    /* 修正：手機版只有按鈕本身響應點擊事件 */
    .quick-nav-container .quick-nav-btn,
    .quick-nav-container .quick-nav-toggle {
        pointer-events: auto;
    }

    /* 手機版大幅縮小導航列表寬度 */
    .quick-nav-list {
        width: 100px !important;
        /* 大幅縮小寬度，避免覆蓋其他UI元素 */
        right: 0;
        /* 確保右對齊 */
    }

    /* 手機版隱藏按鈕文字 */
    .quick-nav-btn span {
        display: none !important;
    }

    /* 手機版調整所有導航按鈕寬度 */
    .quick-nav-btn {
        width: 40px !important;
        /* 統一縮小所有按鈕 */
        min-width: 40px !important;
        padding: 8px !important;
        /* 調整內邊距為方形 */
        justify-content: center !important;
        /* 圖標居中 */
    }

    /* 手機版隱藏按鈕文字，只顯示圖標 */
    #helpToggleText {
        display: none;
    }

    .quick-nav-toggle span {
        display: none;
    }

    /* 手機版調整按鈕寬度，只針對主要的兩個按鈕（顯示說明和導航） */
    #help-toggle-btn,
    #quick-nav-toggle {
        width: 45px;
        /* 縮小為只容納圖標的寬度 */
        min-width: 45px;
        padding: 8px;
        /* 調整內邊距為方形 */
        justify-content: center;
        /* 圖標居中 */
    }

    /* 禁用手機版的懸停展開功能，避免意外觸發（向左展開） */
    .quick-nav-toggle:hover~.quick-nav-list,
    .quick-nav-list:hover {
        max-height: 0 !important;
        opacity: 0 !important;
        transform: scaleX(0) !important;
        margin-right: 0 !important;
        padding: 0 !important;
    }

    /* 手機版只能通過點擊展開（向左展開） */
    .quick-nav-list.expanded {
        max-height: 400px !important;
        /* 適應較小的按鈕高度 */
        opacity: 1 !important;
        transform: scaleX(1) !important;
        margin-right: 8px !important;
        padding: 10px !important;
        /* 修正：手機版展開時確保列表區域響應點擊事件 */
        pointer-events: auto !important;
    }

    /* 手機版優化點擊區域，確保不會意外觸發其他元素 */
    /* 移除這個樣式，因為我們已經在容器層級設置了 pointer-events: none */
    /* .quick-nav-container * {
        pointer-events: auto;
    } */

    /* 手機版確保展開區域不會影響其他元素的點擊 */
    .quick-nav-list.collapsed {
        pointer-events: none !important;
        /* 收縮時完全禁用點擊 */
    }

    .quick-nav-list.expanded {
        pointer-events: auto !important;
        /* 展開時啟用點擊 */
    }
    
    /* 手機版開始模擬按鈕 - 與其他按鈕尺寸一致 */
    #quick-start-simulation-btn {
        width: 45px !important;
        min-width: 45px !important;
        padding: 8px !important;
        justify-content: center !important;
    }
    
    #quick-start-simulation-btn span {
        display: none !important;
    }
}

/* 在更大的螢幕上調整位置和大小 */
@media (min-width: 1200px) {
    .quick-nav-container {
        right: 15px;
        /* 更靠右 */
        top: 95px;
        /* 往上移動 */
        gap: 10px;
        /* 增加間距 */
    }

    .quick-nav-list {
        width: 220px;
        /* 確保兩列布局：105px + 5px + 105px = 215px，加上邊框等設為220px */
    }

    .quick-nav-btn {
        padding: 6px 8px;
        width: 105px;
        min-width: 105px;
        max-width: 105px;
        box-sizing: border-box;
        flex-shrink: 0;
        font-size: 15px;
    }

    .quick-nav-btn span {
        font-size: 14px;
    }

    .quick-nav-btn i {
        font-size: 16px;
    }
}

/* 在超大螢幕上進一步調整 */
@media (min-width: 1600px) {
    .quick-nav-container {
        right: 20px;
        /* 適度靠右 */
        top: 100px;
        /* 往上移動 */
        gap: 12px;
        /* 進一步增加間距 */
    }

    .quick-nav-list {
        width: 220px;
        /* 確保兩列布局：105px + 5px + 105px = 215px，加上邊框等設為220px */
    }

    .quick-nav-btn {
        padding: 6px 8px;
        width: 105px;
        min-width: 105px;
        max-width: 105px;
        box-sizing: border-box;
        flex-shrink: 0;
        font-size: 16px;
    }

    .quick-nav-btn span {
        font-size: 15px;
    }

    .quick-nav-btn i {
        font-size: 18px;
    }
}

/* 快速圖表設定面板樣式 */
.chart-settings-toggle-standalone {
    position: relative;
    z-index: 400;
}

/* wrapper：讓面板定位永遠以圖表設定按鈕為基準（不受導航展開影響） */
.quick-chart-settings-wrapper{
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* 獨立開始模擬按鈕樣式 - 與導航、圖表設定按鈕保持一致 */
.start-simulation-standalone {
    position: relative;
    z-index: 400;
    transition: all 0.3s ease;
}

/* 圖表設定按鈕基礎樣式（縮小/展開效果由下方 @media 的 #chart-settings-toggle-btn 控制）*/
.chart-settings-toggle-standalone {
    transition: all 0.3s ease;
}

/* 圖表設定面板 - 往左顯示 */
.quick-chart-settings-panel {
    position: absolute;
    top: 0;
    right: 100%;
    margin-right: 8px;
    width: 300px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.98) 100%);
    border: 1px solid rgba(200, 200, 200, 0.4);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(12px);
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: right center;
    pointer-events: auto;
    z-index: 401;
}

.quick-chart-settings-panel.collapsed {
    max-height: 0;
    opacity: 0;
    transform: scaleX(0);
    margin-right: 0;
    pointer-events: none;
}

.quick-chart-settings-panel.expanded {
    max-height: 600px;
    opacity: 1;
    transform: scaleX(1);
    margin-right: 8px;
    pointer-events: auto;
}

.quick-chart-settings-content {
    padding: 20px;
}

.quick-settings-section {
    margin-bottom: 12px;
}

.quick-settings-section:last-child {
    margin-bottom: 0;
}

.quick-settings-title {
    margin: 0 0 12px 0;
    font-size: 13px;
    font-weight: 600;
    color: rgba(60, 60, 60, 0.95);
    text-align: left;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.quick-settings-title i {
    font-size: 12px;
    color: rgba(66, 165, 245, 0.8);
}

.quick-settings-divider {
    height: 1px;
    background-color: rgba(200, 200, 200, 0.3);
    margin: 12px 0;
}

.quick-settings-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* 單位按鈕（5 個）排版：第一行 3 個，第二行 2 個並置中 */
/* 單位按鈕（5 個）排版：第一排 3 個（各 1/3），第二排 2 個（各 1/2 吃滿整排）*/
.unit-quick-options{
    display: grid;
    grid-template-columns: repeat(6, 1fr); /* 6 欄系統 */
    gap: 8px;
}
.unit-quick-options .quick-option-btn{
    width: 100%;
    max-width: none;
}
/* 第一排：每個按鈕佔 2 欄（2+2+2=6）*/
.unit-quick-options .quick-option-btn:nth-child(1){ grid-column: 1 / 3; }
.unit-quick-options .quick-option-btn:nth-child(2){ grid-column: 3 / 5; }
.unit-quick-options .quick-option-btn:nth-child(3){ grid-column: 5 / 7; }
/* 第二排：每個按鈕佔 3 欄（3+3=6），平均吃滿整排 */
.unit-quick-options .quick-option-btn:nth-child(4){ grid-column: 1 / 4; }
.unit-quick-options .quick-option-btn:nth-child(5){ grid-column: 4 / 7; }

/* X 軸按鈕（3 個）排版：同一排三等分 */
.xaxis-quick-options {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
}
.xaxis-quick-options .quick-option-btn {
    width: 100%;
    max-width: none;
}

.quick-option-btn {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(250, 252, 255, 0.95) 100%);
    border: 1.5px solid rgba(200, 210, 220, 0.4);
    border-radius: 10px;
    padding: 12px 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    backdrop-filter: blur(8px);
    position: relative;
    overflow: hidden;
}

.quick-option-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(66, 165, 245, 0.05) 0%, rgba(100, 181, 246, 0.05) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.quick-option-btn:hover::before {
    opacity: 1;
}

.quick-option-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 6px 16px rgba(66, 165, 245, 0.15), 0 2px 8px rgba(0, 0, 0, 0.1);
    border-color: rgba(66, 165, 245, 0.7);
    background: linear-gradient(135deg, rgba(66, 165, 245, 0.12) 0%, rgba(100, 181, 246, 0.12) 100%);
    z-index: 1;
}

.quick-option-btn.active {
    background: linear-gradient(135deg, rgba(66, 165, 245, 0.2) 0%, rgba(100, 181, 246, 0.2) 100%);
    border-color: rgba(66, 165, 245, 0.9);
    box-shadow: 0 4px 12px rgba(66, 165, 245, 0.25), inset 0 1px 2px rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
    z-index: 1;
}

.quick-option-btn.active::before {
    opacity: 1;
}

.quick-option-icon {
    font-size: 18px;
    height: 36px;
    width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    background: linear-gradient(135deg, rgba(247, 250, 252, 0.9) 0%, rgba(237, 242, 247, 0.9) 100%);
    border-radius: 50%;
    color: rgba(44, 62, 80, 0.85);
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.quick-option-btn.active .quick-option-icon {
    background: linear-gradient(135deg, rgba(66, 165, 245, 0.25) 0%, rgba(100, 181, 246, 0.25) 100%);
    color: rgba(66, 165, 245, 1);
    box-shadow: 0 3px 8px rgba(66, 165, 245, 0.2);
    transform: scale(1.1);
}

.quick-option-label {
    font-size: 11px;
    color: rgba(80, 80, 80, 0.85);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    position: relative;
    z-index: 1;
    transition: color 0.3s ease;
}

.quick-option-btn.active .quick-option-label {
    color: rgba(66, 165, 245, 1);
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(66, 165, 245, 0.1);
}

.quick-option-btn:hover .quick-option-label {
    color: rgba(66, 165, 245, 0.9);
}

/* 懸停時展開圖表設定面板 - 延遲關閉機制 */
.chart-settings-toggle-standalone {
    position: relative;
}

.chart-settings-toggle-standalone:hover ~ .quick-chart-settings-panel,
.quick-chart-settings-panel:hover {
    max-height: 600px !important;
    opacity: 1 !important;
    transform: scaleX(1) !important;
    margin-right: 8px !important;
    pointer-events: auto !important;
    transition-delay: 0s !important;
}

.chart-settings-toggle-standalone:hover ~ .quick-chart-settings-panel.collapsed,
.quick-chart-settings-panel:hover.collapsed {
    max-height: 600px !important;
    opacity: 1 !important;
    transform: scaleX(1) !important;
    margin-right: 8px !important;
    pointer-events: auto !important;
    transition-delay: 0s !important;
}

/* 延遲關閉 - 增加延遲時間讓用戶有時間移動滑鼠 */
.quick-chart-settings-panel:not(.collapsed) {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) 0.1s;
}

.quick-chart-settings-panel.collapsed {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) 0.3s;
}

/* 手機版快速圖表設定面板 */
@media (max-width: 767px) {
    .quick-chart-settings-panel {
        width: 200px;
        right: 100%;
        top: 0;
    }
    
    .chart-settings-toggle-standalone .chart-settings-text {
        display: none; /* 手機版完全隱藏文字 */
    }
    
    /* 手機版：外框尺寸跟其他按鈕一致（40px icon-only） */
    .chart-settings-toggle-standalone{
        width: 40px !important;
        min-width: 40px !important;
        padding: 8px !important;
        justify-content: center !important;
        gap: 0 !important;
    }

    /* 手機版：單位按鈕回到 2 欄，避免太擠；重設所有 grid-column */
    .unit-quick-options .quick-option-btn{
        width: 100%;
        grid-column: auto !important;
    }
    .unit-quick-options{
        grid-template-columns: repeat(2, 1fr);
    }
    
    .quick-option-btn {
        flex: 1 1 calc(50% - 4px);
        padding: 8px 6px;
    }
    
    .quick-option-icon {
        font-size: 16px;
        height: 28px;
        width: 28px;
        margin-bottom: 4px;
    }
    
    .quick-option-label {
        font-size: 10px;
    }
    
    .quick-settings-title {
        font-size: 12px;
    }
    
    /* 禁用手機版的懸停展開功能 */
    .chart-settings-toggle-standalone:hover ~ .quick-chart-settings-panel,
    .quick-chart-settings-panel:hover {
        max-height: 0 !important;
        opacity: 0 !important;
        transform: scaleX(0) !important;
        margin-right: 0 !important;
    }
    
    /* 手機版只能通過點擊展開 */
    .quick-chart-settings-panel.expanded {
        max-height: 550px !important;
        opacity: 1 !important;
        transform: scaleX(1) !important;
        margin-right: 8px !important;
        pointer-events: auto !important;
    }
}

/* 分析結果樣式 */
.analysis-results {
    padding: 20px;
    width: 100%;
    box-sizing: border-box;
    font-family: '微軟正黑體', sans-serif;
}

.analysis-results h3 {
    color: var(--gradient-start);
    border-bottom: 2px solid var(--gradient-start);
    padding-bottom: 10px;
    margin-bottom: 20px;
}

/* 新添加的容器樣式 */
.text-analysis-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 30px;
}

.text-analysis {
    background-color: #f9fbfe;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
    margin-bottom: 25px;
    flex: 1;
    min-width: 400px;
    border: 1px solid #e6eef7;
    transition: all 0.2s ease;
}

.text-analysis:hover {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

/* 近期目標區域樣式 */
.short-term-goals {
    border-radius: 12px;
    border: 1px solid #e6eef7;
    background-color: #f9fbfe;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.short-term-goals h4 {
    color: #3498db;
    margin-top: 0;
    display: flex;
    align-items: center;
    padding-bottom: 10px;
    border-bottom: 1px solid #e6eef7;
    font-size: 1.25rem;
    font-weight: 600;
}

.short-term-goals h4:before {
    content: '\f05a';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    margin-right: 10px;
    color: #3498db;
}

/* 最終結果區域樣式 */
.final-results {
    border-radius: 12px;
    border: 1px solid #e6eef7;
    background-color: #f9fbfe;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.final-results h4 {
    color: #2c3e50;
    margin-top: 0;
    display: flex;
    align-items: center;
    padding-bottom: 10px;
    border-bottom: 1px solid #e6eef7;
    font-size: 1.25rem;
    font-weight: 600;
}

.final-results h4:before {
    content: '\f201';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    margin-right: 10px;
    color: #2c3e50;
}

.text-analysis h4 {
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.analysis-item {
    margin-bottom: 15px;
    padding: 16px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid #f0f4f8;
    transition: all 0.2s ease;
}

.analysis-item:hover {
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
    border-color: #e6eef7;
}

.analysis-label {
    font-weight: 600;
    margin-bottom: 10px;
    color: #2c3e50;
    display: flex;
    align-items: center;
    font-size: 1.05rem;
}

.analysis-label:before {
    content: '\f054';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    margin-right: 8px;
    color: #3498db;
    font-size: 0.8rem;
}

.analysis-content {
    line-height: 1.5;
}

.analysis-note {
    font-size: 0.85rem;
    color: #6c757d;
    margin-top: 8px;
    font-style: italic;
}

.highlight-value {
    font-weight: 600;
    color: #3498db;
    background-color: rgba(52, 152, 219, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
    margin: 0 2px;
}

.analysis-content ul {
    padding-left: 20px;
    margin: 10px 0;
}

.percentile {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.9em;
    margin-right: 8px;
    color: white;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.top-percentile {
    background-color: #4caf50;
    background-image: linear-gradient(135deg, #4caf50, #2e7d32);
}

.median-percentile {
    background-color: #2196f3;
    background-image: linear-gradient(135deg, #2196f3, #1565c0);
}

.bottom-percentile {
    background-color: #ff9800;
    background-image: linear-gradient(135deg, #ff9800, #e65100);
}

.worst-percentile {
    background-color: #f44336;
    background-image: linear-gradient(135deg, #f44336, #b71c1c);
}

.success-rate-high {
    color: #4caf50;
}

.success-rate-medium {
    color: #ff9800;
}

.success-rate-low {
    color: #f44336;
}

.bankruptcy-rate-low {
    color: #4caf50;
}

.bankruptcy-rate-medium {
    color: #ff9800;
}

.bankruptcy-rate-high {
    color: #f44336;
}

/* 響應式設計 */
@media (max-width: 992px) {
    .text-analysis {
        min-width: 100%;
    }
}

.global-chart-controls {
    width: 100%;
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 10px;
}

.controls-group {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.scale-controls,
.unit-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-label {
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.control-buttons {
    display: flex;
    gap: 10px;
}

.control-btn {
    padding: 8px 15px;
    border: 1px solid #ddd;
    background: #f5f5f5;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    height: 36px;
    line-height: 20px;
}

.control-btn.active {
    background: #2196F3;
    color: white;
    font-weight: bold;
    border-color: #1976D2;
}

.control-btn:hover {
    background: #e0e0e0;
}

.control-btn.active:hover {
    background: #1976D2;
}

.chart-item-half {
    width: calc(50% - 10px);
}

.chart-canvas-container-pie {
    padding-bottom: 100%;
    /* 圓餅圖使用1:1比例 */
}

.chart-canvas-container canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
}

@media (max-width: 768px) {
    .chart-item-half {
        width: 100%;
    }

    .analysis-label {
        width: 100%;
        margin-bottom: 5px;
    }

    .analysis-content {
        width: 100%;
    }

    .controls-group {
        flex-direction: column;
    }
}

/* 被迫賣房率樣式 */
.forced-sale-rate-low {
    color: #4caf50;
}

.forced-sale-rate-medium {
    color: #ff9800;
}

.forced-sale-rate-high {
    color: #f44336;
}

/* 風險指標區域響應式設計 */
.risk-indicators-container {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .risk-indicators-container {
        flex-direction: column;
        gap: 15px;
    }
}

/* AI 報告容器樣式 */
.ai-report-container {
    border-top: 1px solid #eee;
    margin-top: 20px;
    padding-top: 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    /* 水平置中內部元素 */
    min-height: 150px;
    /* 設定最小高度，確保容器有足夠空間 */
}

.ai-report-title {
    color: #4285f4;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    /* 防止標題被壓縮 */
    justify-content: center;
    /* 標題（含問號icon）置中 */
    text-align: center;
}



.ai-report-buttons {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
    flex-shrink: 0;
    /* 防止按鈕被壓縮 */
    justify-content: center;
    /* 按鈕置中 */
}

.ai-report-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    width: auto;
}

.ai-report-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.ai-report-btn.copy-btn {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    border: 2px solid transparent;
}

.ai-report-btn.copy-btn:hover:not(:disabled) {
    background: linear-gradient(45deg, #5a73e0, #6b4190);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
}

.ai-report-btn.copy-btn:active:not(:disabled) {
    background: linear-gradient(45deg, #4a63d0, #5b3180);
    transform: translateY(1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}



.ai-report-btn .btn-text {
    transition: opacity 0.3s ease;
}

.ai-report-btn .btn-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    white-space: nowrap;
}

.ai-report-btn.loading .btn-text {
    opacity: 0;
}

.ai-report-btn.loading .btn-loading {
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
}

.ai-report-status {
    padding: 10px 15px;
    border-radius: 6px;
    font-size: 14px;
    margin-top: 10px;
    flex-shrink: 0;
    /* 防止狀態訊息被壓縮 */
}

.ai-report-status.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.ai-report-status.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.ai-report-status.info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* 響應式設計 */
@media screen and (max-width: 768px) {
    .ai-report-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .ai-report-btn {
        min-height: 44px;
        font-size: 13px;
    }

    .ai-report-title {
        font-size: 15px;
    }
}

@media screen and (max-width: 480px) {
    .ai-report-container {
        margin-top: 15px;
        padding-top: 12px;
    }

    .ai-report-btn {
        min-height: 40px;
        padding: 10px 16px;
        font-size: 12px;
    }

    .ai-report-title {
        font-size: 14px;
        margin-bottom: 12px;
    }
}

/* =============================================
   通用表單版型（基本資料 / 進階資料）
   - 不改 HTML/JS，以選擇器範圍化覆蓋
   - 自動 1/2/3 欄，RWD 收斂
   - 優化 label 與內聯藍色問號對齊
   - 先針對檔案名稱列 (file-name-row) 強制單欄
============================================= */
.finance-sections .content-card .card-content .form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: var(--ws-gap, 16px);
    align-items: start;
}

/* 欄位標籤與輸入：統一對齊與節奏 */
.finance-sections .form-group label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    font-weight: 500;
    line-height: 1.3;
}

.finance-sections .form-group :where(input[type="text"], input[type="number"], select, textarea) {
    width: 100%;
    height: 40px;
    padding: 8px 12px;
    border-radius: 6px;
    box-sizing: border-box;
}

/* 說明小問號對齊（僅限標籤內的內聯按鈕） */
.finance-sections .form-group label .help-popup-btn-inline {
    margin-left: 6px;
    /* 與標籤文字保留間距 */
    vertical-align: middle;
    transform: translateY(-1px);
    /* 微調基線，避免上下跳動 */
}

/* 卡片之間的垂直節奏（避免不同段落間距不一） */
.finance-sections .content-card+.content-card {
    margin-top: 16px;
}

/* 檔案名稱列：強制單欄以驗證通用樣式效果 */
.finance-sections .content-card .card-content .form-row.file-name-row .form-group {
    grid-column: 1 / -1;
}

/* RWD：窄螢幕時單欄與較大點觸目標 */
@media (max-width: 768px) {
    .finance-sections .content-card .card-content .form-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .finance-sections .form-group :where(input[type="text"], input[type="number"], select, textarea) {
        height: 44px;
    }
}

/* =============================================
   通用輸入寬度型態（百分比/金額/一般文字）
   - 不改 HTML 的前提下先用型別與已知 ID 規則覆蓋
   - 可透過 CSS 變數調整寬度
============================================= */
:root {
    --ws-width-compact: 100px;
    /* 百分比/短數值，例如 基準利率(%) */
    --ws-width-amount: 180px;
    /* 金額類，較長，例如 目標金額 */
    --ws-width-text: 340px;
    /* 一般文字輸入，例如 檔案名稱 */
    --ws-width-select: 200px;
    /* 下拉選單預設寬度 */
}

/* 1) 百分比/短數值（數字型） */
.finance-sections .form-group input[type="number"] {
    max-width: var(--ws-width-compact);
    width: min(100%, var(--ws-width-compact));
    text-align: center;
    /* 置中顯示短數值/百分比 */
}

/* 2) 金額類（已知 ID 與常見命名；若日後加上 .amount-input 也一併覆蓋） */
.finance-sections .form-group input[id*="target-net-asset"],
.finance-sections .form-group input.amount-input,
.finance-sections .form-group input[id*="amount" i] {
    max-width: var(--ws-width-amount);
    width: min(100%, var(--ws-width-amount));
    text-align: center;
    /* 置中顯示金額輸入 */
}

/* 3) 一般文字輸入：預設給 text 輸入較寬（再讓特例覆蓋） */
.finance-sections .form-group input[type="text"] {
    max-width: var(--ws-width-text);
    width: min(100%, var(--ws-width-text));
}

/* 4) 下拉選單：預設 200px（可用 --ws-width-select 調整） */
.finance-sections .form-group select {
    max-width: var(--ws-width-select);
    width: min(100%, var(--ws-width-select));
}

/* 5) 金額欄位容器（有 wrapper 的情況）與百分比一致：標籤與輸入同列顯示 */
/* 說明：目標金額欄位外層有一個 div（inline style: display:flex），預設是區塊級元素。
   這裡將其改為 inline-flex，讓它可以與 label 同行顯示，並覆蓋 inline style。 */
.finance-sections .form-group:has(> div > input[id*="target-net-asset"]),
.finance-sections .form-group:has(> div > input[id*="amount" i]) {
    display: flex;
    align-items: center;
    column-gap: 6px;
    /* 縮小標題與輸入距離 */
    row-gap: 4px;
    flex-wrap: wrap;
}

.finance-sections .form-group>div:has(> input[id*="target-net-asset"]) {
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
}

.finance-sections .form-group>div:has(> input[id*="amount" i]) {
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
}

/* 同時移除該情境下 label 的底部間距避免被擠到新行 */
.finance-sections .form-group:has(> div > input[id*="target-net-asset"]) label,
.finance-sections .form-group:has(> div > input[id*="amount" i]) label {
    margin-bottom: 0;
    min-width: auto;
    /* 取消 150px 最小寬度，避免被撐開 */
}

/* 5-2) 金額欄位（無 wrapper 的情況）：與百分比一致，標籤與輸入同列 */
.finance-sections .form-group:has(> input[id*="target-net-asset"]) {
    display: flex;
    align-items: center;
    column-gap: 6px;
    row-gap: 4px;
    flex-wrap: wrap;
}

.finance-sections .form-group:has(> input[id*="target-net-asset"]) label {
    margin-bottom: 0;
    min-width: auto;
}

/* 6) 百分比/年齡等數值欄位：與金額一致，標籤與輸入同列且距離縮小 */
.finance-sections .form-group:has(> input[type="number"]) {
    display: flex;
    align-items: center;
    column-gap: 6px;
    /* 縮小標題與輸入距離 */
    row-gap: 4px;
    flex-wrap: wrap;
}

.finance-sections .form-group:has(> input[type="number"]) label {
    margin-bottom: 0;
    min-width: auto;
    /* 取消 150px 最小寬度 */
}

/* 檔案名稱：更寬一些，便於顯示 */
.finance-sections .form-group #file-name {
    max-width: 420px;
}

/* 問題輸入（textarea）維持全寬，已由現有規則處理；此處保險一次 */
.finance-sections .form-group textarea#ai-question {
    width: 100%;
    max-width: 100%;
}

/* 手機優先全寬避免擠壓 */
@media (max-width: 768px) {
    .finance-sections .form-group :where(input[type="text"], input[type="number"], select) {
        max-width: 100%;
    }
}

/* =============================================
   Member Settings 專屬樣式隔離（不吃通用表單規則）
   交由 js/member-settings.js 的內嵌樣式為主，這裡只做保險覆蓋
============================================= */
#member-settings-card .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    column-gap: 12px;
    row-gap: 6px;
    align-items: center;
}

#member-settings-card .form-group label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
    min-width: auto;
}

#member-settings-card .form-group :where(input[type="text"], input[type="number"], select) {
    width: 100% !important;
    max-width: 100% !important;
}

#member-settings-card .form-group input[type="number"] {
    text-align: center;
}

#member-settings-card .form-group select {
    text-align-last: center;
}

#member-settings-card .help-popup-btn-inline {
    margin-left: 4px;
}

/* ==========================================================================
   修復：將幫助引導和導航按鈕預設改為僅圖標，懸停時展開
   Fix: Minimize Help and Nav toggle buttons to icon-only by default, expand on hover
   ========================================================================== */
@media screen and (min-width: 768px) {

    /* 預設縮小狀態 - 僅顯示圖標 */
    #help-toggle-btn,
    #chart-settings-toggle-btn,
    #quick-nav-toggle,
    #quick-start-simulation-btn {
        width: 44px !important;
        min-width: 44px !important;
        padding: 10px 0 !important;
        justify-content: center !important;
        gap: 0 !important;
        overflow: hidden;
    }

    /* 隱藏文字 */
    #help-toggle-btn span,
    #chart-settings-toggle-btn span,
    #quick-nav-toggle span,
    #quick-start-simulation-btn span {
        max-width: 0;
        opacity: 0;
        overflow: hidden;
        white-space: nowrap;
        display: none;
    }

    /* 懸停或展開狀態 - 恢復原始樣式 */
    #help-toggle-btn:hover,
    #chart-settings-toggle-btn:hover,
    #chart-settings-toggle-btn.expanded,
    .quick-chart-settings-wrapper:hover #chart-settings-toggle-btn,
    #quick-nav-toggle:hover,
    #quick-nav-toggle.expanded,
    .quick-nav-wrapper:hover #quick-nav-toggle,
    #quick-start-simulation-btn:hover {
        width: 125px !important;
        min-width: 125px !important;
        padding: 10px 12px !important;
        justify-content: flex-start !important;
        gap: 6px !important;
    }

    /* 懸停或展開時恢復文字 */
    #help-toggle-btn:hover span,
    #chart-settings-toggle-btn:hover span,
    #chart-settings-toggle-btn.expanded span,
    .quick-chart-settings-wrapper:hover #chart-settings-toggle-btn span,
    #quick-nav-toggle:hover span,
    #quick-nav-toggle.expanded span,
    .quick-nav-wrapper:hover #quick-nav-toggle span,
    #quick-start-simulation-btn:hover span {
        display: block;
        max-width: 100%;
        opacity: 1;
        animation: fadeIn 0.3s ease;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* 1200px 以上螢幕的懸停/展開寬度調整 */
@media screen and (min-width: 1200px) {

    #help-toggle-btn:hover,
    #chart-settings-toggle-btn:hover,
    #chart-settings-toggle-btn.expanded,
    .quick-chart-settings-wrapper:hover #chart-settings-toggle-btn,
    #quick-nav-toggle:hover,
    #quick-nav-toggle.expanded,
    .quick-nav-wrapper:hover #quick-nav-toggle,
    #quick-start-simulation-btn:hover {
        width: 135px !important;
        min-width: 135px !important;
        padding: 12px 14px !important;
    }
}

/* 1600px 以上螢幕的懸停/展開寬度調整 */
@media screen and (min-width: 1600px) {

    #help-toggle-btn:hover,
    #chart-settings-toggle-btn:hover,
    #chart-settings-toggle-btn.expanded,
    .quick-chart-settings-wrapper:hover #chart-settings-toggle-btn,
    #quick-nav-toggle:hover,
    #quick-nav-toggle.expanded,
    .quick-nav-wrapper:hover #quick-nav-toggle,
    #quick-start-simulation-btn:hover {
        width: 145px !important;
        min-width: 145px !important;
        padding: 14px 16px !important;
    }
}

/* ========== 最終覆蓋：間距調整 (2026-01-22) ========== */
.container {
    margin-top: 70px !important;
    padding-top: 0px !important;
    padding: 0px 15px 20px 15px !important;
}
#resetButton, #guideButton, #guidedSetupButton, #open-visual-canvas-btn {
    top: 0px !important;
}
.finance-sections {
    margin-top: 90px !important;
    padding-top: 0px !important;
}
@media screen and (max-width: 768px) {
    .container {
        margin-top: 70px !important;
        padding-top: 0px !important;
        padding: 0px 10px 10px 10px !important;
    }
    .finance-sections {
        margin-top: 100px !important;
        padding-top: 0px !important;
    }
}

/* 計算環境資訊卡片 */
.computation-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
}
.comp-info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
}
.comp-info-label {
    color: #6b7280;
    font-size: 13px;
}
.comp-info-value {
    font-size: 13px;
    font-weight: 500;
    color: #1f2937;
}
.computation-info-divider {
    border-top: 1px solid #e5e7eb;
    margin-top: 8px;
    padding-top: 8px;
}
.comp-info-section-title {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #9ca3af;
    margin-bottom: 6px;
}
@media screen and (max-width: 768px) {
    .computation-info-grid {
        grid-template-columns: 1fr;
    }
}
/* ========== i18n 載入前隱藏頁面，避免語言閃爍 ========== */
body:not(.i18n-ready) {
    opacity: 0;
}
body.i18n-ready {
    opacity: 1;
    transition: opacity 0.15s ease-in;
}

/* i18n: 與 main_simulation 表單統一的輸入高度，避免不同瀏覽器造成垂直位移 */
.standard-input,
.standard-select {
  height: 36px;
}

/* ========== 按鈕與間距修正 (2026-01-22) ========== */
.container {
    margin-top: 70px !important;
    padding-top: 0px !important;
}
#resetButton, #guideButton, #guidedSetupButton, #open-visual-canvas-btn {
    top: 0px !important;
}
/* 基本資料/進階資料區塊與按鈕的間距 */
.finance-sections {
    margin-top: 70px !important;
    padding-top: 0px !important;
}
@media screen and (max-width: 768px) {
    .container {
        margin-top: 70px !important;
        padding-top: 0px !important;
    }
    .finance-sections {
        margin-top: 80px !important;
        padding-top: 0px !important;
    }
}
/* 通用樣式（不與頁頭頁尾重複） */

.contact-container {
    max-width: 800px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.contact-form {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #1565c0; /* 使用相同的深藍色 */
    font-weight: bold;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.form-group textarea {
    resize: vertical;
    min-height: 150px;
}

.submit-btn {
    background: #1e88e5; /* 使用相同的主藍色 */
    color: white;
    padding: 1rem 2rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.3s;
}

.submit-btn:hover {
    background: #1565c0; /* 使用相同的深藍色 */
}

@media (max-width: 768px) {
    .contact-container {
        margin: 1rem;
    }
    
    .contact-form {
        padding: 1rem;
    }
}

/* 圖表相關樣式 */

/* 圖表容器樣式 */
.charts-container {
    padding: 0 !important;
    margin: 0 0 12px 0 !important;
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 15px !important;
    background-color: white !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
    padding: 8px !important;
}

/* 圖表項目樣式 */
.chart-item {
    flex: 1 1 100% !important;
    width: 100% !important;
    min-width: 100% !important;
    margin: 0 0 15px 0 !important;
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    position: relative !important;
}

/* 圖表標題 */
.chart-item h3 {
    margin: 0 0 3px 0 !important;
    padding: 5px 8px !important;
    font-size: 1.1rem !important;
    color: #2c3e50 !important;
    background-color: #f8fafc !important;
    border-radius: 6px 6px 0 0 !important;
    border-bottom: 1px solid #e2e8f0 !important;
}

/* 圖表容器內的畫布容器 */
.chart-canvas-container {
    background-color: #f8fafc !important;
    border-radius: 6px !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
    padding: 8px !important;
    width: 100% !important;
    height: 560px !important;
    margin: 0 !important;
    position: relative !important;
}

/* 圖表項目樣式 - 特別針對三張主要圖表 */
#area-chart-container, #median-group-chart-container, #mdd-chart-container {
    flex: 1 1 100% !important;
    width: 100% !important;
    min-width: 100% !important;
    margin: 0 0 25px 0 !important;
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    position: relative !important;
}

/* 主要三張圖表的標題 */
#area-chart-container h4, #median-group-chart-container h4, #mdd-chart-container h4 {
    text-align: center !important;
    font-size: 1.2em !important;
    margin-bottom: 10px !important;
}

/* 特別強化淨資產全景圖的顯示 */
#areaChart, #medianGroupChart, #mddHistogram {
    width: 100% !important;
    height: 100% !important;
    max-height: 800px !important;
}

/* 資訊提示樣式 */
.info-note {
    margin: 0 0 15px 0;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #3498db;
    color: #6c757d;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-note i {
    color: #3498db;
    font-size: 16px;
}

.info-note small {
    font-size: inherit;
}

/* 圖表分頁容器樣式 */
.chart-tabs-container {
    margin-top: 30px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow: hidden;
    width: 100%;
}

.chart-tabs-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #ddd;
    padding: 0;
}

.chart-tab-buttons {
    display: flex;
    flex-wrap: wrap;
    overflow-x: auto;
    gap: 5px;
}

.chart-tab-btn {
    padding: 12px 20px;
    background-color: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    color: #555;
    transition: all 0.3s;
    flex: 1;
    text-align: center;
    white-space: nowrap;
}

.chart-tab-btn:hover {
    background-color: rgba(0,0,0,0.03);
}

.chart-tab-btn.active {
    color: #2e86de;
    border-bottom-color: #2e86de;
    background-color: rgba(46, 134, 222, 0.05);
}

.chart-tabs-content {
    padding: 20px;
}

.chart-tab-panel {
    display: none;
}

.chart-tab-panel.active {
    display: block;
}

/* 圖表組容器樣式 */
.chart-group-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

/* 修改為上下排列的佈局 */
.chart-group-container.vertical-layout {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 25px;
}

/* 圖表項目內部樣式 - 用於分頁容器內的圖表 */
.chart-tab-panel .chart-item {
    position: relative;
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 15px;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    width: 100%;
    margin-bottom: 20px;
}

.chart-tab-panel .chart-item h4 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 16px;
    color: #333;
    text-align: center;
}

.chart-tab-panel .chart-item canvas {
    flex: 1;
    width: 100% !important;
    height: auto !important;
    min-height: 250px;
}

/* 圖表擴展按鈕 */
.chart-expand-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.9);
    border: 1px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 5;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.chart-expand-btn:hover {
    background-color: white;
    transform: scale(1.1);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* 添加圖標樣式 */
.chart-expand-btn i {
    font-size: 14px;
    color: #3498db;
}

.chart-expand-btn i:first-child {
    display: none;
}

.chart-expand-btn i:nth-child(2) {
    display: block;
    font-size: 15px;
}

/* 全屏圖表樣式已移至 main_simulation.css 以避免重複定義 */

/* 圖表設定容器樣式 */
.chart-settings-container {
    margin: 15px 0;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

/* 設定頭部 */
.chart-settings-header {
    padding: 15px 20px;
    background-color: #f8fafb;
    border-bottom: 1px solid #eaedf0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chart-settings-header h4 {
    margin: 0;
    font-size: 18px;
    color: #2c3e50;
    font-weight: 600;
}

/* 設定標籤按鈕 */
.chart-settings-tabs {
    display: flex;
    gap: 8px;
}

.chart-settings-tabs .tab-btn {
    padding: 8px 16px;
    border: none;
    background-color: transparent;
    color: #6c757d;
    font-weight: 500;
    font-size: 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chart-settings-tabs .tab-btn i {
    font-size: 14px;
}

.chart-settings-tabs .tab-btn:hover {
    background-color: rgba(0, 123, 255, 0.05);
    color: #0056b3;
}

.chart-settings-tabs .tab-btn.active {
    background-color: rgba(0, 123, 255, 0.1);
    color: #0056b3;
}

/* 設定內容 */
.chart-settings-content {
    padding: 20px;
}

/* 設定面板 */
.settings-panel {
    display: none;
}

.settings-panel.active {
    display: block;
}

/* 設定選項 */
.settings-options {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

/* 強制圖表設定中的按鈕為固定卡片，不平均撐滿 */
.chart-settings-container .settings-options .option-btn {
    flex: 0 0 auto !important;
    width: var(--chart-option-size, 120px) !important;
    max-width: var(--chart-option-max, 160px) !important;
    aspect-ratio: 1 / 1; /* 儘量保持正方形 */
}

/* 針對由 JS 產生的圖表設定（使用 .control-btn 與 .button-group）做強制覆蓋 */
#chart-settings-container .button-group, #chart-settings-in-output .button-group { flex-wrap: wrap !important; justify-content: flex-start !important; }
#chart-settings-container .button-group .control-btn, #chart-settings-in-output .button-group .control-btn {
    flex: 0 0 var(--chart-option-size, 120px) !important;
    width: var(--chart-option-size, 120px) !important;
    max-width: var(--chart-option-max, 160px) !important;
    aspect-ratio: 1 / 1 !important;
}

/* 選項按鈕 */
.option-btn {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
}

.option-btn.large {
    /* 避免平均撐滿整列，改為固定尺寸並盡量維持正方形 */
    flex: 0 0 auto;
    width: var(--chart-option-size, 120px);
    max-width: var(--chart-option-max, 160px);
    padding: 15px 10px;
    aspect-ratio: 1 / 1; /* 盡量保持正方形 */
}

.option-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #cbd5e0;
}

.option-btn.active {
    background-color: #ebf5ff;
    border-color: #3498db;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.15);
}

.option-icon {
    font-size: 22px;
    height: 40px;
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    background-color: #f7fafc;
    border-radius: 50%;
    color: #2c3e50;
}

.option-btn.active .option-icon {
    background-color: #3498db;
    color: white;
}

.option-label {
    font-weight: 600;
    font-size: 15px;
    color: #2d3748;
    margin-bottom: 4px;
}

.option-desc {
    font-size: 12px;
    color: #718096;
}

.option-btn.active .option-label {
    color: #2c3e50;
}

.option-btn.active .option-desc {
    color: #4a5568;
}

/* 設定分隔線 */
.settings-divider {
    height: 1px;
    background-color: #edf2f7;
    margin: 15px 0;
    width: 100%;
}

/* 比例尺選項 */
.scale-options {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

/* 響應式調整 */
@media (max-width: 768px) {
    .chart-group-container {
        grid-template-columns: 1fr;
        flex-direction: column;
    }
    
    .chart-item {
        width: 100%;
        margin-bottom: 15px;
    }
    
    .chart-item canvas {
        height: 250px !important;
    }
    
    .chart-tab-buttons {
        flex-wrap: wrap;
    }
    
    .chart-tab-btn {
        flex: 1;
        min-width: 100px;
        text-align: center;
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .chart-settings-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .chart-settings-tabs {
        width: 100%;
    }
    
    .chart-settings-tabs .tab-btn {
        flex: 1;
        justify-content: center;
    }
    
    .option-btn.large,
    .chart-settings-container .settings-options .option-btn {
        flex: 0 0 calc(50% - 8px); /* 手機兩欄，避免吃滿整列 */
        width: calc(50% - 8px);
        max-width: none;
        aspect-ratio: 1 / 1;
    }

    /* JS 產生版本的手機佈局 */
    #chart-settings-container .button-group .control-btn, #chart-settings-in-output .button-group .control-btn {
        flex: 0 0 calc(50% - 4px) !important;
        width: calc(50% - 4px) !important;
        max-width: none !important;
        aspect-ratio: 1 / 1 !important;
        min-height: 70px !important;
    }
    
    .chart-expand-btn {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .settings-options {
        flex-direction: column;
    }
    
    .option-btn.large,
    .chart-settings-container .settings-options .option-btn {
        flex: 0 0 calc(50% - 8px); /* 極小螢幕也維持兩欄正方形 */
        width: calc(50% - 8px);
        max-width: none;
        aspect-ratio: 1 / 1;
    }

    #chart-settings-container .button-group .control-btn, #chart-settings-in-output .button-group .control-btn {
        flex: 0 0 calc(50% - 4px) !important;
        width: calc(50% - 4px) !important;
        max-width: none !important;
        aspect-ratio: 1 / 1 !important;
        min-height: 64px !important;
    }
    
    .chart-item canvas {
        height: 250px !important;
    }
}

/* 特別加大三張主要圖表的高度 */
#area-chart-container .chart-canvas-container,
#median-group-chart-container .chart-canvas-container,
#mdd-chart-container .chart-canvas-container {
    height: 800px !important;
}

/* 為圖表容器內所有按鈕統一設置樣式 */
.chart-settings-container .control-btn,
.chart-settings-container .option-btn {
    padding: 8px 15px;
    border: 1px solid #d1d5db;
    background-color: #f9fafb;
    color: #4b5563;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    position: relative;
}

/* 按鈕活動狀態 - 用於切換時的視覺反饋 */
.chart-settings-container .control-btn.active,
.chart-settings-container .option-btn.active {
    background-color: #ebf5ff;
    color: #2376cf;
    border-color: #93c5fd;
    box-shadow: 0 2px 5px rgba(52, 152, 219, 0.1);
    font-weight: 600;
}

/* 單位和比例尺按鈕中的圖標樣式 */
.chart-settings-container .option-icon {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: #e5e7eb;
    color: #4b5563;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 5px;
    transition: all 0.2s ease;
}

/* 懸停效果 */
.chart-settings-container .control-btn:hover,
.chart-settings-container .option-btn:hover {
    background-color: #ebf5ff;
    border-color: #93c5fd;
}

/* 圖表鎖定覆蓋層樣式 */
.chart-lock-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(245, 247, 250, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 6px;
    text-align: center;
    padding: 20px;
}

.chart-lock-overlay i {
    font-size: 40px;
    color: #f39c12;
    margin-bottom: 15px;
}

.chart-lock-overlay p {
    font-size: 16px;
    color: #2c3e50;
    margin-bottom: 20px;
    max-width: 300px;
    line-height: 1.5;
}

.chart-lock-overlay .upgrade-button {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.chart-lock-overlay .upgrade-button:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* 動畫控制面板樣式 */
.animation-control-panel {
    margin: 15px 0;
    padding: 15px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    border: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.animation-control-panel:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* 播放控制按鈕區域 */
.animation-control-panel .control-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
}

.animation-control-panel button {
    background: #28a745;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 80px;
    justify-content: center;
}

.animation-control-panel button:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.animation-control-panel button:active {
    transform: translateY(0);
}

.animation-control-panel button#area-chart-play-btn {
    background: #28a745;
}

.animation-control-panel button#area-chart-play-btn:hover {
    background: #218838;
}

.animation-control-panel button#area-chart-play-btn.playing {
    background: #dc3545;
}

.animation-control-panel button#area-chart-play-btn.playing:hover {
    background: #c82333;
}

.animation-control-panel button#area-chart-reset-btn {
    background: #6c757d;
}

.animation-control-panel button#area-chart-reset-btn:hover {
    background: #5a6268;
}

/* 速度控制區域 */
.animation-speed-control {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 200px;
    background: white;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #ced4da;
}

.animation-speed-control label {
    font-size: 14px;
    color: #495057;
    white-space: nowrap;
    font-weight: 500;
}

.animation-speed-control input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.animation-speed-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.animation-speed-control input[type="range"]::-webkit-slider-thumb:hover {
    background: #0056b3;
    transform: scale(1.1);
}

.animation-speed-control input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.animation-speed-control input[type="range"]::-moz-range-thumb:hover {
    background: #0056b3;
    transform: scale(1.1);
}

.animation-speed-value {
    font-size: 14px;
    color: #495057;
    min-width: 60px;
    text-align: center;
    font-weight: 600;
    background: #e9ecef;
    padding: 4px 8px;
    border-radius: 4px;
}

/* 年份顯示區域 */
.animation-year-display {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #ced4da;
}

.animation-year-display span {
    font-size: 14px;
    color: #495057;
}

.animation-year-display .current-year {
    font-weight: 600;
    color: #495057;
    min-width: 60px;
    text-align: center;
    background: #f8f9fa;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #e9ecef;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.animation-year-display .separator {
    font-size: 14px;
    color: #6c757d;
    font-weight: normal;
}

.animation-year-display .max-year {
    font-size: 14px;
    color: #6c757d;
    font-weight: normal;
}

/* 響應式設計 */
/* 速度滑桿範圍說明：100ms = 10x, 1000ms = 1x, 3000ms = 0.33x */
@media (max-width: 768px) {
    .animation-control-panel {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 12px;
    }
    
    .animation-control-panel .control-buttons {
        justify-content: center;
    }
    
    .animation-speed-control {
        min-width: auto;
        width: 100%;
    }
    
    .animation-year-display {
        justify-content: center;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .animation-control-panel {
        margin: 10px 0;
        padding: 10px;
        gap: 10px;
    }
    
    .animation-control-panel button {
        padding: 6px 12px;
        font-size: 13px;
        min-width: 70px;
    }
    
    .animation-speed-control {
        padding: 6px 10px;
    }
    
    .animation-speed-control label {
        font-size: 13px;
    }
    
    .animation-year-display {
        padding: 6px 10px;
    }
    
    .animation-year-display span {
        font-size: 13px;
    }
} 
/* 存檔功能樣式 */
.saved-files-container,
.records-container {
    overflow-y: visible; /* 改為 visible，使用外層容器的滾動條 */
    margin-top: 8px;
    width: 100%;
    box-sizing: border-box;
    padding: 0 5px;
}

/* 共享檔案禁用的存檔設定樣式 */
.disabled-for-shared {
    opacity: 0.5;
    pointer-events: none;
    position: relative;
}

.disabled-for-shared::after {
    content: '(共享檔案)';
    font-size: 10px;
    color: #999;
    margin-left: 4px;
}

/* 篩選面板樣式 */
.file-filter-panel {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 10px;
    margin: 0 5px 8px 5px;
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
    overflow: hidden;
    display: none;
}

/* 只有當 sidebar-section 展開且面板未收起時才顯示 */
.sidebar-section.expanded .file-filter-panel:not(.collapsed) {
    display: block;
}

.file-filter-panel.collapsed {
    display: none !important;
}

.filter-row {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
    align-items: center;
}

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

.filter-input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    background: #fff;
    transition: border-color 0.2s;
    height: 34px;
    box-sizing: border-box;
}

.filter-input:focus {
    outline: none;
    border-color: #667eea;
}

.filter-input::placeholder {
    color: #aaa;
}

/* 日期範圍選擇器樣式 - 繼承 .filter-input，只加日曆圖標 */
.filter-date-range-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%2714%27 height=%2714%27 viewBox=%270 0 24 24%27 fill=%27none%27 stroke=%27%23667eea%27 stroke-width=%272%27%3E%3Crect x=%273%27 y=%274%27 width=%2718%27 height=%2718%27 rx=%272%27/%3E%3Cline x1=%2716%27 y1=%272%27 x2=%2716%27 y2=%276%27/%3E%3Cline x1=%278%27 y1=%272%27 x2=%278%27 y2=%276%27/%3E%3Cline x1=%273%27 y1=%2710%27 x2=%2721%27 y2=%2710%27/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 14px 14px;
    cursor: pointer;
}

/* Flatpickr 主題客製化 */
.flatpickr-calendar {
    font-family: 'Noto Sans TC', sans-serif;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid #e0e0e0;
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
    background: #667eea;
    border-color: #667eea;
}

.flatpickr-day.inRange {
    background: rgba(102, 126, 234, 0.2);
    border-color: transparent;
    box-shadow: none;
}

.flatpickr-day:hover {
    background: rgba(102, 126, 234, 0.1);
    border-color: #667eea;
}

.flatpickr-months .flatpickr-month {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px 8px 0 0;
}

.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year {
    color: white;
}

.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
    fill: white;
}

.flatpickr-months .flatpickr-prev-month:hover,
.flatpickr-months .flatpickr-next-month:hover {
    fill: rgba(255, 255, 255, 0.8);
}

.filter-actions {
    justify-content: flex-end;
}

.filter-btn-apply,
.filter-btn-clear {
    padding: 5px 12px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn-apply {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.filter-btn-apply:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.filter-btn-clear {
    background: #e9ecef;
    color: #666;
}

.filter-btn-clear:hover {
    background: #dee2e6;
}

/* 篩選按鈕啟用狀態 */
.filter-btn.active {
    background: #667eea;
    color: #fff;
}

/* 篩選結果提示 */
.filter-result-info {
    font-size: 11px;
    color: #888;
    text-align: center;
    padding: 4px;
    background: #fff3cd;
    border-radius: 4px;
    margin-bottom: 8px;
}

/* 存檔功能樣式 */
.saved-files-container {
    /* 所有共享樣式已移到上面 */
}

/* 檔案名稱輸入框寬度交由通用樣式管理（移除強制寬度） */
.file-name-input {
    font-size: 14px !important;
    text-align: center !important;
}

/* 自定義滾動條 */
.saved-files-container::-webkit-scrollbar {
    width: 5px;
}

.saved-files-container::-webkit-scrollbar-thumb {
    background-color: rgba(136, 176, 222, 0.7);
    border-radius: 3px;
}

.saved-files-container::-webkit-scrollbar-track {
    background-color: rgba(0, 0, 0, 0.05);
}

/* 存檔數量顯示 */
.save-count-info {
    font-size: 0.75rem;
    color: #666;
    text-align: right;
    margin-bottom: 8px;
    padding: 2px 5px;
    background-color: #f8f9fa;
    border-radius: 3px;
    font-weight: 500;
}

/* 存檔已滿時的警告樣式 */
.save-count-info.save-count-full {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
    font-weight: 600;
    animation: gentle-pulse 3s ease-in-out infinite;
}

@keyframes gentle-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

/* 存檔類型區分 - 統一使用藍色 */
.file-item {
    border-left: 3px solid #42a5f5; /* 普通檔案使用藍色邊框 */
}

/* 置頂關注檔案樣式 */
.file-item-pinned {
    /* 置頂檔案 - 簡潔深色背景 */
    background: #d4e4f7 !important;
    border-radius: 6px !important;
}

.file-item-pinned:hover {
    background: #c5d9f1 !important;
    transform: translateX(8px) !important;
}

/* 置頂圖標樣式 */
.pinned-icon {
    color: #1565c0;
    margin-right: 6px;
    font-size: 0.8rem;
    transform: rotate(45deg);
    display: inline-block;
    animation: gentle-glow 2s ease-in-out infinite alternate;
}

@keyframes gentle-glow {
    0% { 
        opacity: 0.8; 
        transform: rotate(45deg) scale(1);
    }
    100% { 
        opacity: 1; 
        transform: rotate(45deg) scale(1.1);
    }
}

/* 置頂標籤樣式 */
.pinned-label {
    background: linear-gradient(135deg, #1565c0, #0d47a1);
    color: white;
    font-size: 0.65rem;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 3px;
    margin-right: 6px;
    vertical-align: top;
    box-shadow: 0 1px 3px rgba(21, 101, 192, 0.4);
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
    animation: subtle-pulse 3s ease-in-out infinite;
}

@keyframes subtle-pulse {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 1px 3px rgba(21, 101, 192, 0.4);
    }
    50% { 
        transform: scale(1.05);
        box-shadow: 0 2px 6px rgba(21, 101, 192, 0.6);
    }
}

/* 檔案項目樣式調整，統一與紀錄區塊匹配 */
.file-item {
    padding: 10px 12px;
    margin-bottom: 8px;
    background: white;
    border-radius: 4px;
    font-size: 0.8rem;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    position: relative;
    width: calc(100% - 10px); /* 調整寬度，配合容器內邊距 */
    box-sizing: border-box;
    min-height: 60px; /* 保證足夠高度以容納垂直排列的元素 */
}

/* 選中的存檔項目樣式 - 淡藍色背景 */
.file-item.selected-file {
    background: linear-gradient(135deg, #e3f2fd 0%, #f0f8ff 100%) !important;
    border: 2px solid #42a5f5 !important;
    box-shadow: 0 3px 10px rgba(66, 165, 245, 0.3) !important;
    transform: translateX(3px);
}

.file-item.selected-file:hover {
    background: linear-gradient(135deg, #d1e7dd 0%, #e8f4fd 100%) !important;
    transform: translateX(5px);
}

/* 載入中禁用的檔案項目樣式 */
.file-item.loading-disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* 刪除按鈕樣式，統一與紀錄區塊 */
.file-delete-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 18px;
    height: 18px;
    background-color: #b6d9fa; /* 淺藍色背景 */
    color: #6495ED; /* 藍色文字 */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
    opacity: 0; /* 預設隱藏 */
    border: 1px solid #e1f0ff;
}

/* 滑鼠移到檔案項目時顯示按鈕 */
.file-item:hover .file-delete-btn {
    opacity: 0.7;
}

.file-delete-btn:hover {
    opacity: 1 !important;
    transform: scale(1.1);
    background-color: #90c3f9;
    color: white;
}

.file-item:hover {
    transform: translateX(5px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    background-color: #f0f7ff; /* 鼠標懸停時的淺藍色背景，與紀錄區塊相同 */
    border-left-color: #1976d2; /* 懸停時使用深藍色 */
}

/* 檔案資訊佈局 */
.file-info {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding-right: 20px; /* 防止與刪除按鈕重疊 */
}

/* 檔案名稱與斷行效果 */
.file-name {
    font-weight: 500;
    color: #333;
    margin-bottom: 8px;
    position: relative;
    width: 100%;
    max-width: 100%;
    padding-right: 15px; /* 增加右側間距，避免與刪除按鈕重疊 */
    /* 修改為在3/4寬度處換行 */
    white-space: normal;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
}

/* 檔案名稱內部容器 */
.file-name-inner {
    display: inline;
    position: relative;
    transition: transform 0.5s ease;
}

/* 檔案項目底部信息行 */
.file-item-footer {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    margin-top: 4px;
}

.file-date {
    color: #666;
    font-size: 0.7rem;
    margin-bottom: 4px;
}

/* 檔案狀態樣式，統一與紀錄區塊 */
.file-status {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 3px;
    display: inline-block;
    white-space: nowrap;
    align-self: flex-start;
}

.status-0 {
    background-color: #fff3cd;
    color: #856404;
}

.status-1 {
    background-color: #cce5ff;
    color: #004085;
}

.status-2 {
    background-color: #d4edda;
    color: #155724;
}

.status-3 {
    background-color: #f8d7da;
    color: #721c24;
}

/* 管理員檔案編號標記 */
.file-id-badge,
.record-id-badge {
    font-size: 0.65rem;
    padding: 1px 5px;
    border-radius: 3px;
    background-color: #e9ecef;
    color: #6c757d;
    white-space: nowrap;
    margin-left: 4px;
    display: inline;
}

/* 管理員時間查詢區塊 */
.admin-lookup-section {
    margin-top: 12px;
    padding: 10px;
    border: 1px dashed #dee2e6;
    border-radius: 6px;
    background: #f8f9fa;
}
.admin-lookup-title {
    font-size: 0.7rem;
    color: #6c757d;
    margin-bottom: 6px;
}
.admin-lookup-row {
    display: flex;
    gap: 6px;
}
.admin-datetime-input {
    width: 100%;
    padding: 5px 8px;
    font-size: 0.65rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-family: monospace;
    box-sizing: border-box;
}
.admin-lookup-result {
    margin-top: 6px;
}
.admin-lookup-item {
    padding: 6px 8px;
    margin-top: 4px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
}
.admin-lookup-item:hover {
    background: #e3f2fd;
    border-color: #90caf9;
}
.admin-lookup-meta {
    font-size: 0.65rem;
    color: #6c757d;
    margin-top: 2px;
}
.admin-lookup-error {
    font-size: 0.7rem;
    color: #dc3545;
    margin-top: 4px;
}
.admin-lookup-loading {
    font-size: 0.7rem;
    color: #6c757d;
    margin-top: 4px;
}

/* 標題行樣式 - 用於存檔和紀錄標題 */
.sidebar-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    gap: 5px;
    padding-right: 5px;
}

.sidebar-title {
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 5px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* 展開/收起按鈕樣式 - 同時用於存檔和紀錄 */
.expand-btn {
    font-size: 0.75rem;
    color: #2196F3;
    background: none;
    border: none;
    cursor: pointer;
    margin-left: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 28px;
    min-height: 28px;
}

.expand-btn:hover {
    background-color: rgba(33, 150, 243, 0.1); /* 藍色背景 */
    color: #1565C0; /* 深藍色 */
}

.expand-btn i {
    margin-right: 0;
    font-size: 0.75rem;
}

/* 空存檔提示 */
.no-files-message {
    font-size: 0.8rem;
    color: #666;
    text-align: center;
    padding: 15px 0;
    font-style: italic;
}

/* 載入中訊息 */
.loading-message {
    font-size: 0.8rem;
    color: #2196F3; /* 藍色文字 */
    text-align: center;
    padding: 15px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.loading-message i {
    font-size: 1rem;
    color: #2196F3; /* 藍色圖標 */
}

/* 會員等級限制樣式 */
.save-section-disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
    position: relative;
}

/* 以 DOM 元素呈現可國際化的覆蓋層（替代 ::before 固定中文） */
.save-section-disabled .save-section-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(240, 240, 240, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: #666;
    z-index: 10;
    pointer-events: none;
    font-weight: 500;
    padding: 10px;
    text-align: center;
    border-radius: 5px;
}

/* 錯誤訊息 */
.error-message {
    color: #d32f2f;
    background-color: #fbe9e7;
    border-radius: 4px;
    padding: 10px;
    margin: 10px 0;
}

.error-message small {
    display: block;
    margin-top: 5px;
    color: #666;
}

/* 側邊欄整體樣式調整 */
.sidebar {
    max-height: 100vh; /* 修改：從calc(100vh - 60px)改為100vh，使其延伸至整個視窗高度 */
    overflow-y: auto;
}

/* 側邊欄滾動條樣式 */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(136, 176, 222, 0.7);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-track {
    background-color: rgba(0, 0, 0, 0.05);
}

/* 紀錄項目樣式統一 - 移除左邊藍色條 */
.record-item {
    border-left: none !important; /* 確保沒有左邊框 */
    padding: 10px 12px !important;
    width: calc(100% - 10px) !important;
    box-sizing: border-box !important;
    min-height: 40px !important; /* 縮小最小高度，因為不顯示名稱 */
}

/* 紀錄項目懸停效果 */
.record-item:hover {
    border-left: none !important;
    transform: translateX(5px) !important;
}

/* 紀錄資訊佈局 */
.record-info {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    padding-right: 20px !important;
}

/* 紀錄底部資訊行 */
.record-item-footer {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    width: 100% !important;
    margin-top: 0 !important; /* 移除頂部間距，因為沒有名稱 */
}

/* 隱藏紀錄名稱樣式 */
.record-name {
    display: none !important; /* 隱藏紀錄名稱 */
}

/* 紀錄日期樣式 */
.record-date {
    color: #666 !important;
    font-size: 0.7rem !important;
    margin-bottom: 4px !important;
}

/* 記錄列表加載和錯誤信息樣式 */
.loading-records {
    text-align: center;
    padding: 20px 10px;
    color: #666;
    font-size: 0.8rem;
    background-color: #f8f9fa;
    border-radius: 4px;
    margin-bottom: 8px;
}

.records-error {
    text-align: center;
    padding: 20px 10px;
    color: #721c24;
    font-size: 0.8rem;
    background-color: #f8d7da;
    border-radius: 4px;
    margin-bottom: 8px;
}

.no-records {
    text-align: center;
    padding: 20px 10px;
    color: #666;
    font-size: 0.8rem;
    background-color: #f8f9fa;
    border-radius: 4px;
    margin-bottom: 8px;
}

/* 測試記錄樣式 */
.test-record {
    border-left-color: #9c27b0;
    background-color: #f3e5f5;
    position: relative;
}

.test-record::after {
    content: "測試數據";
    position: absolute;
    top: -8px;
    right: 10px;
    font-size: 10px;
    padding: 2px 6px;
    background-color: #9c27b0;
    color: white;
    border-radius: 3px;
    z-index: 2;
}

/* Loading/Deleting Animations */
.loading-item, .deleting-item {
    position: relative;
    pointer-events: none;
    transition: all 0.3s ease;
}

.loading-item {
    background-color: rgba(240, 247, 255, 0.9) !important;
    border-color: #c0d7f1 !important;
}

.deleting-item {
    background-color: rgba(255, 240, 240, 0.9) !important;
    border-color: #f1c0c0 !important;
}

.loading-animation, .deleting-animation {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 15px;
    text-align: center;
}

.loading-animation i, .deleting-animation i {
    font-size: 24px;
    margin-bottom: 8px;
    color: #3498db;
    animation: spin 1s linear infinite;
}

.deleting-animation i {
    color: #e74c3c;
}

.loading-animation span, .deleting-animation span {
    font-size: 14px;
    color: #555;
}

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

/* 針對文件項和記錄項的特殊樣式 */
.file-item.loading-item,
.record-item.loading-item {
    background-color: rgba(52, 152, 219, 0.1);
    border: 1px solid rgba(52, 152, 219, 0.3);
}

.file-item.deleting-item,
.record-item.deleting-item {
    background-color: rgba(231, 76, 60, 0.1);
    border: 1px solid rgba(231, 76, 60, 0.3);
}

/* 側邊欄標題區域樣式 */
.sidebar-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    position: relative;
    padding-right: 32px;
    /* 預留展開按鈕空間 */
}

.sidebar-header-buttons {
    display: flex;
    gap: 3px;
    align-items: center;
    flex-shrink: 0;
}

/* 展開按鈕固定在右側 */
.sidebar-section-header .expand-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

/* 重新整理按鈕樣式 */
.refresh-btn {
    background: linear-gradient(135deg, #90caf9, #81c784);
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    font-size: 12px;
    padding: 4px 6px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    opacity: 0;
    transform: scale(0.8);
    visibility: hidden;
}

.refresh-btn:hover {
    background: linear-gradient(135deg, #81c784, #66bb6a);
    transform: translateY(-1px) scale(0.8);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* 規劃畫布快捷按鈕樣式 */
.refresh-btn.visual-canvas-btn {
    background: linear-gradient(135deg, #9bb6ff, #7aa7ff);
}

.refresh-btn.visual-canvas-btn:hover {
    background: linear-gradient(135deg, #7aa7ff, #5f8ff0);
}

.refresh-btn:active {
    transform: translateY(0) scale(0.8);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* 展開時顯示重新整理按鈕 */
.sidebar-section.expanded .refresh-btn {
    opacity: 1;
    transform: scale(1);
    visibility: visible;
}

/* 篩選按鈕樣式（與其他按鈕相同行為，展開時才顯示） */
.refresh-btn.filter-btn {
    background: linear-gradient(135deg, #b39ddb, #9575cd);
}

.refresh-btn.filter-btn:hover {
    background: linear-gradient(135deg, #9575cd, #7e57c2);
}

.refresh-btn.filter-btn.active {
    background: linear-gradient(135deg, #7e57c2, #673ab7);
    box-shadow: 0 0 0 2px rgba(103, 58, 183, 0.3);
}

/* 重新整理按鈕載入狀態 */
.refresh-btn.loading {
    background: linear-gradient(135deg, #bdbdbd, #9e9e9e);
    cursor: not-allowed;
    pointer-events: none;
}

.refresh-btn.loading i {
    animation: refresh-spin 1s linear infinite;
}

/* 旋轉動畫 */
@keyframes refresh-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* 重新整理按鈕禁用狀態 */
.refresh-btn:disabled {
    background: linear-gradient(135deg, #e0e0e0, #bdbdbd);
    cursor: not-allowed;
    opacity: 0.6;
}



/* ========================================
 * 檔案共享功能樣式
 * ======================================== */

/* 共享檔案分隔線 */
.shared-files-divider {
    display: flex;
    align-items: center;
    margin: 16px 0 12px 0;
    padding: 0 5px;
}

.shared-files-divider span {
    font-size: 0.75rem;
    font-weight: 600;
    color: #667eea;
    background: linear-gradient(90deg, transparent, #f8f9fa 10%, #f8f9fa 90%, transparent);
    padding: 4px 12px;
    border-radius: 10px;
    white-space: nowrap;
}

.shared-files-divider::before,
.shared-files-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, #ddd);
}

.shared-files-divider::after {
    background: linear-gradient(90deg, #ddd, transparent);
}

/* 共享檔案項目樣式 */
.file-item-shared {
    background: #e8e4f7 !important;
    border-radius: 6px !important;
}

.file-item-shared:hover {
    background: #ddd6f3 !important;
}

/* 共享標記徽章 */
.shared-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 0.6rem;
    padding: 2px 5px;
    border-radius: 3px;
    margin-right: 6px;
    vertical-align: middle;
}

.shared-badge i {
    font-size: 0.55rem;
}

/* 分享中徽章（我的檔案已分享給他人） */
.sharing-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 3px;
    margin-right: 6px;
    vertical-align: middle;
}

.sharing-badge i {
    font-size: 0.55rem;
}

/* 檔案來源顯示 */
.file-owner {
    font-size: 0.65rem;
    color: #888;
    margin-top: 2px;
    margin-bottom: 4px;
    font-style: italic;
}

/* 分享按鈕樣式 */
.file-action-btn {
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
    opacity: 0; /* 預設隱藏 */
    border: 1px solid;
}

/* 滑鼠移到檔案項目時顯示按鈕 */
.file-item:hover .file-action-btn {
    opacity: 0.7;
}

.file-action-btn:hover {
    opacity: 1 !important;
    transform: scale(1.1);
}

.file-share-btn {
    top: 26px;
    right: 5px;
    background-color: #e8f5e9;
    color: #4caf50;
    border-color: #c8e6c9;
}

.file-share-btn:hover {
    background-color: #c8e6c9;
    color: #388e3c;
}

/* 停止接收分享按鈕 */
.file-unshare-btn {
    top: 5px;
    right: 5px;
    background-color: #fff3e0;
    color: #ff9800;
    border-color: #ffe0b2;
}

.file-unshare-btn:hover {
    background-color: #ffe0b2;
    color: #f57c00;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .sidebar-header-buttons {
        gap: 4px;
    }

    .refresh-btn {
        min-width: 20px;
        height: 20px;
        font-size: 10px;
        padding: 3px 4px;
    }

    .file-action-btn {
        width: 16px;
        height: 16px;
        font-size: 9px;
    }

    .file-share-btn {
        right: 24px;
    }

    .shared-badge,
    .sharing-badge {
        font-size: 0.55rem;
        padding: 1px 4px;
    }
} 
/* 資產查詢功能樣式 */
:root {
    --query-btn-color: #4285f4;
    --query-btn-hover-color: #2a75f3;
    --light-bg: #f8fafc;
    --border-color: #e0e4e8;
    --text-color: #333;
    --secondary-text: #666;
    --box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --border-radius: 6px;
}

/* 輸入框與按鈕組合容器 */
.input-with-button {
    display: flex;
    align-items: center;
    position: relative;
    width: 100%;
    gap: 8px; /* 輸入框和按鈕之間的間距 */
}

/* 交由通用輸入寬度管理，避免與主頁表單衝突 */
.input-with-button .standard-input {
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: border-color 0.2s;
}

.input-with-button .standard-input:focus {
    border-color: var(--query-btn-color);
    outline: none;
    box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.1);
}

.input-with-button .query-btn {
    position: static;
    transform: none;
    width: 36px;
    height: 36px;
    border: none;
    background-color: var(--query-btn-color);
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
    flex-shrink: 0; /* 防止按鈕被擠壓 */
}

.input-with-button .query-btn:hover {
    background-color: var(--query-btn-hover-color);
}

.input-with-button .query-btn i {
    pointer-events: none;
}

/* 資產查詢面板樣式 */
.asset-query-panel {
    position: absolute;
    right: 0;
    top: 100%;
    width: 380px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    margin-top: 8px;
    display: none;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.asset-query-panel.active {
    display: block;
}

.asset-query-header {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    background-color: #f7f9fc;
}

.asset-query-header h4 {
    margin: 0;
    color: var(--text-color);
    font-size: 16px;
}

.asset-query-container {
    padding: 15px;
}

.asset-type-section {
    margin-bottom: 15px;
}

.section-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-color);
}

.asset-type-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.asset-type-btn {
    padding: 6px 12px;
    background-color: var(--light-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    color: var(--text-color);
}

.asset-type-btn:hover {
    background-color: #edf1f7;
}

.asset-type-btn.active {
    background-color: var(--query-btn-color);
    color: white;
    border-color: var(--query-btn-color);
}

.search-section {
    display: none;
    margin-top: 15px;
}

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

.search-bar {
    display: flex;
    margin-bottom: 15px;
}

.search-input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius) 0 0 var(--border-radius);
    font-size: 14px;
}

.search-btn {
    padding: 10px 15px;
    background-color: var(--query-btn-color);
    color: white;
    border: none;
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.search-btn:hover {
    background-color: var(--query-btn-hover-color);
}

/* 新增下拉選單相關樣式 */
.dropdown-section {
    margin-top: 15px;
    margin-bottom: 15px;
}

.dropdown-label {
    font-size: 14px;
    color: var(--text-color);
    margin-bottom: 5px;
    display: block;
}

.etf-dropdown {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: white;
    font-size: 14px;
    color: var(--text-color);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%2716%27 height=%2716%27 viewBox=%270 0 24 24%27 fill=%27none%27 stroke=%27%23666%27 stroke-width=%272%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27%3E%3Cpolyline points=%276 9 12 15 18 9%27%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
}

.etf-dropdown:focus {
    outline: none;
    border-color: var(--query-btn-color);
    box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.1);
}

.etf-dropdown option {
    padding: 5px;
}

.etf-dropdown optgroup {
    font-weight: 600;
    color: var(--text-color);
}

.period-tags {
    display: flex;
    gap: 8px;
    margin-top: 5px;
}

.period-tag {
    padding: 2px 8px;
    font-size: 12px;
    border-radius: 12px;
    background-color: #E3F2FD;
    color: #1565C0;
    font-weight: 500;
}

.period-tag.years-5 {
    background-color: #E3F2FD;
    color: #1565C0;
}

.period-tag.years-10 {
    background-color: #E8F5E9;
    color: #2E7D32;
}

.period-tag.years-15 {
    background-color: #FFF8E1;
    color: #F57F17;
}

.results-container {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: white;
}

.result-item {
    padding: 10px 15px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.result-item:last-child {
    border-bottom: none;
}

.result-item:hover {
    background-color: #f5f8ff;
}

.result-symbol {
    font-weight: 600;
    margin-right: 10px;
}

.result-return {
    color: var(--secondary-text);
    font-size: 13px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 4px;
}

.result-return span {
    font-weight: 500;
}

.no-results {
    padding: 15px;
    text-align: center;
    color: var(--secondary-text);
}

.asset-selection-info {
    background-color: #f7f9fc;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 12px;
    margin-top: 15px;
    margin-bottom: 15px;
    display: none;
}

.asset-selection-info.active {
    display: block;
}

.selected-asset-name {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.selected-asset-details {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 14px;
}

.selected-asset-detail {
    flex: 1;
    min-width: 120px;
}

.detail-label {
    color: var(--secondary-text);
    margin-bottom: 2px;
}

.detail-value {
    font-weight: 500;
}

.import-button-container {
    text-align: right;
    margin-top: 15px;
}

.import-button {
    background-color: var(--query-btn-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.import-button:hover {
    background-color: var(--query-btn-hover-color);
}

.close-panel {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

.close-panel:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.close-panel i {
    font-size: 14px;
    color: #666;
}

/* 響應式設計 */
@media screen and (max-width: 768px) {
    .asset-query-panel {
        width: 320px;
    }
    
    .input-with-button .query-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .asset-type-buttons {
        gap: 6px;
    }
    
    .asset-type-btn {
        padding: 5px 10px;
        font-size: 13px;
    }
    
    .search-input, .search-btn {
        padding: 8px 12px;
    }
}

@media screen and (max-width: 480px) {
    .asset-query-panel {
        width: 280px;
        right: -70px;
    }
    
    .asset-type-buttons {
        gap: 5px;
    }
    
    .asset-type-btn {
        padding: 4px 8px;
        font-size: 12px;
    }
} 
/* Account Popup Styling */
.account-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.account-popup {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    padding: 20px;
    width: 90%;
    max-width: 400px;
    position: relative;
}

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

.account-popup-header h3 {
    margin: 0;
    color: #333;
}

.account-popup-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #999;
}

.account-popup-close:hover {
    color: #333;
}

.account-popup-content {
    margin-bottom: 20px;
}

.account-info-item {
    margin-bottom: 15px;
}

.account-info-label {
    font-weight: bold;
    display: block;
    margin-bottom: 5px;
    color: #666;
}

.account-info-value {
    font-size: 16px;
    color: #333;
}

/* Special colors for different membership levels */
.membership-level-0 {
    color: #b83939; /* Red for frozen/deactivated level */
}

.membership-level-1 {
    color: #5c8a36; /* Green for free level */
}

.membership-level-2 {
    color: #c27a0e; /* Gold for premium level */
}

.account-popup-footer {
    text-align: right;
}

.account-popup-button {
    background-color: #4285f4;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.account-popup-button:hover {
    background-color: #3367d6;
}

/* New styles for upgrade button */
.account-upgrade-section {
    text-align: center;
    margin-top: 25px;
    padding-top: 15px;
    border-top: 1px dashed #e0e0e0;
}

.account-upgrade-button {
    display: inline-block;
    background: linear-gradient(to right, #f6d365, #fda085);
    color: #333;
    font-weight: bold;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 25px;
    box-shadow: 0 3px 6px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.account-upgrade-button:hover {
    background: linear-gradient(to right, #fda085, #f6d365);
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(0,0,0,0.15);
}

/* Business management button */
.business-management-section {
    text-align: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed #e0e0e0;
}

.btn-manage-business {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 500;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    box-shadow: 0 3px 6px rgba(102, 126, 234, 0.3);
}

.btn-manage-business:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 12px rgba(102, 126, 234, 0.4);
}

/* Partner management button */
.partner-management-section {
    text-align: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed #e0e0e0;
}

.btn-manage-partners {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
    font-weight: 500;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    box-shadow: 0 3px 6px rgba(76, 175, 80, 0.3);
}

.btn-manage-partners:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 12px rgba(76, 175, 80, 0.4);
} 
/* 進階投資模組樣式 */

/* 主要容器樣式 */
.advanced-investment-container {
    margin-bottom: 20px;
}

/* 行項目樣式 */
.portfolio-item {
    display: flex;
    margin-bottom: 10px;
    align-items: center;
    gap: 10px;
    width: 100%;
}

/* 欄位標題樣式 */
.portfolio-headers {
    display: flex;
    margin-bottom: 8px;
    align-items: center;
    gap: 10px;
    width: 100%;
    font-weight: bold;
    padding: 0 5px;
}

.item-number-header,
.category-header,
.code-header,
.ratio-header,
.search-header {
    text-align: center;
    white-space: nowrap;
}

.item-number-header {
    width: 55px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.category-header {
    flex: 1;
    width: 50%;
    /* Adjusted to 50% as requested */
    max-width: 50%;
}

.code-header {
    flex: 1;
    width: 25%;
    max-width: 25%;
}

.ratio-header {
    flex: 1;
    width: 15%;
    max-width: 100px;
}

.data-range-header {
    flex: 1;
    width: 18%;
    max-width: 160px;
    text-align: center;
    white-space: nowrap;
}

.search-header {
    width: 36px;
}

/* 項目編號樣式 */
.item-number {
    width: 55px;
    text-align: center;
    font-weight: bold;
    background-color: #f0f0f0;
    border-radius: 5px;
    padding: 8px 0;
}

/* 下拉式選單樣式 */
.category-select {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 8px 10px;
    background-color: #fff;
    width: 50%;
    /* Adjusted to 50% as requested */
    max-width: 50%;
}

/* 輸入欄位樣式 */
.code-input,
.ratio-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 8px 10px;
    text-align: center;
}

/* 代號欄位樣式 */
.code-input {
    width: 25%;
    max-width: 25%;
}

/* 比例欄位樣式 */
.ratio-input {
    width: 15%;
    max-width: 100px;
    font-weight: bold;
    /* Make the ratio text bold for better visibility */
}

/* 資料區間顯示樣式 */
.data-range-display {
    width: 18%;
    max-width: 160px;
    font-size: 0.85rem;
    color: #94a3b8;
    text-align: center;
    padding: 8px 4px;
    white-space: nowrap;
}

.data-range-display.shortest {
    color: #e11d48;
    font-weight: 600;
}

/* 確保比例數值顏色樣式能被正確應用 */
.ratio-input[style*="color"] {
    color: inherit !important;
    /* Use the inline style color */
}

/* 使用特殊類別標記有顏色的比例欄位 */
.colored-ratio {
    color: attr(data-ratio-color) !important;
}

/* 針對不同比例值的特定顏色設置 */
.ratio-input[value="0"] {
    color: rgb(0, 0, 0) !important;
}

.ratio-input[value="10"] {
    color: rgb(0, 0, 17) !important;
}

.ratio-input[value="20"] {
    color: rgb(0, 0, 34) !important;
}

.ratio-input[value="30"] {
    color: rgb(0, 0, 51) !important;
}

.ratio-input[value="40"] {
    color: rgb(0, 0, 68) !important;
}

.ratio-input[value="50"] {
    color: rgb(0, 0, 85) !important;
}

.ratio-input[value="60"] {
    color: rgb(0, 0, 102) !important;
}

.ratio-input[value="70"] {
    color: rgb(0, 0, 119) !important;
}

.ratio-input[value="80"] {
    color: rgb(0, 0, 136) !important;
}

.ratio-input[value="90"] {
    color: rgb(0, 0, 153) !important;
}

.ratio-input[value="100"] {
    color: rgb(0, 0, 170) !important;
}

/* 搜尋按鈕樣式 */
.search-btn {
    background-color: var(--gradient-start);
    color: white;
    border: none;
    border-radius: 5px;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.search-btn:hover {
    background-color: var(--gradient-end);
}

/* 刪除按鈕樣式 */
.remove-item-btn {
    background-color: #f44336;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.remove-item-btn:hover {
    background-color: #d32f2f;
}

/* 添加按鈕和操作按鈕樣式 */
.portfolio-actions {
    display: flex;
    justify-content: flex-start;
    margin-top: 15px;
    gap: 10px;
}

.add-item-btn {
    background-color: var(--gradient-start);
    color: white;
    border: none;
    border-radius: 5px;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.add-item-btn:hover {
    background-color: var(--gradient-end);
}

/* 總計百分比樣式 */
.total-percentage {
    margin-top: 15px;
    margin-bottom: 15px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
}

.percentage-value {
    color: var(--gradient-start);
}

.percentage-warning {
    color: #f44336;
    display: none;
}

.percentage-warning.show {
    display: inline;
}

/* 切換投資模式按鈕組 */
.investment-toggle-group {
    display: flex;
    margin-bottom: 20px;
    border: 1px solid #ddd;
    border-radius: 5px;
    overflow: hidden;
}

.investment-toggle-btn {
    flex: 1;
    background-color: #f5f5f5;
    border: none;
    padding: 10px 15px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-weight: normal;
}

.investment-toggle-btn.active {
    background-color: var(--gradient-start);
    color: white;
    font-weight: bold;
}

/* 投資模式容器 */
.investment-mode-container {
    display: none;
}

.investment-mode-container.active {
    display: block;
}

/* 圆饼图样式 */
.portfolio-pie-chart-section {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.portfolio-pie-chart-section h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.pie-chart-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    /* 确保不超过父容器 */
    min-height: 400px;
    max-height: 400px;
    /* 桌面版限制最大高度 */
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: 8px;
    gap: 20px;
    overflow: hidden;
    /* 桌面版防止内容溢出 */
}

.individual-chart-section,
.category-chart-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 50%;
    max-height: 100%;
    /* 限制最大高度 */
}

.individual-chart-section h5,
.category-chart-section h5 {
    margin: 0 0 15px 0;
    color: #555;
    font-size: 0.9rem;
    text-align: center;
    font-weight: 500;
}

#advanced-portfolio-pie-chart,
#advanced-category-pie-chart {
    max-width: 100%;
    max-height: 320px;
    /* 限制图表最大高度 */
    width: auto;
    height: auto;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
    transition: transform 0.3s ease;
    border-radius: 50%;
}

#advanced-portfolio-pie-chart:hover,
#advanced-category-pie-chart:hover {
    transform: scale(1.02);
}

/* 圆饼图空状态样式 */
.pie-chart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 1.1rem;
    height: 350px;
}

.pie-chart-empty i {
    font-size: 3rem;
    margin-bottom: 15px;
    color: #ddd;
}

/* 響應式設計 - 增加更多斷點以更好處理不同屏幕尺寸 */

/* 大桌面屏幕 (1200px+) - 保持默認佈局 */
@media (min-width: 1200px) {
    .pie-chart-container {
        padding: 25px;
        gap: 25px;
    }

    #advanced-portfolio-pie-chart,
    #advanced-category-pie-chart {
        max-height: 350px;
    }
}

/* 中等桌面屏幕 (992px - 1199px) */
@media (max-width: 1199px) and (min-width: 992px) {
    .pie-chart-container {
        padding: 20px;
        gap: 18px;
        min-height: 380px;
        max-height: 380px;
    }

    #advanced-portfolio-pie-chart,
    #advanced-category-pie-chart {
        max-height: 300px;
    }

    .individual-chart-section h5,
    .category-chart-section h5 {
        font-size: 0.85rem;
    }
}

/* 平板橫向 (768px - 991px) */
@media (max-width: 991px) and (min-width: 768px) {
    .pie-chart-container {
        padding: 18px;
        gap: 15px;
        min-height: 360px;
        max-height: 360px;
    }

    #advanced-portfolio-pie-chart,
    #advanced-category-pie-chart {
        max-height: 280px;
    }
}

/* 平板直向和大手機 (576px - 767px) */
@media (max-width: 767px) and (min-width: 576px) {
    .pie-chart-container {
        flex-direction: column;
        align-items: center;
        min-height: auto;
        max-height: none;
        /* 移除高度限制 */
        gap: 25px;
        padding: 20px;
        overflow: visible;
        /* 允許內容顯示 */
    }

    .individual-chart-section,
    .category-chart-section {
        max-width: 100%;
        width: 100%;
        max-height: none;
        /* 移除高度限制 */
    }

    #advanced-portfolio-pie-chart,
    #advanced-category-pie-chart {
        width: 300px;
        height: 300px;
        max-height: none;
    }

    .individual-chart-section h5,
    .category-chart-section h5 {
        font-size: 1rem;
        margin-bottom: 20px;
    }
}

/* 小手機 (最大 575px) */
@media (max-width: 575px) {
    .pie-chart-container {
        flex-direction: column;
        align-items: center;
        min-height: auto;
        max-height: none;
        /* 移除高度限制 */
        gap: 20px;
        padding: 15px;
        overflow: visible;
        /* 允許內容顯示 */
    }

    .individual-chart-section,
    .category-chart-section {
        max-width: 100%;
        width: 100%;
        max-height: none;
        /* 移除高度限制 */
    }

    #advanced-portfolio-pie-chart,
    #advanced-category-pie-chart {
        width: 260px;
        height: 260px;
        max-height: none;
    }

    .individual-chart-section h5,
    .category-chart-section h5 {
        font-size: 0.9rem;
        margin-bottom: 15px;
    }

    .portfolio-pie-chart-section h4 {
        font-size: 1rem;
        text-align: center;
    }
}

/* 超小手機 (最大 400px) */
@media (max-width: 400px) {
    .pie-chart-container {
        padding: 10px;
        gap: 15px;
        max-height: none;
        /* 移除高度限制 */
        overflow: visible;
        /* 允許內容顯示 */
    }

    .individual-chart-section,
    .category-chart-section {
        max-height: none;
        /* 移除高度限制 */
    }

    #advanced-portfolio-pie-chart,
    #advanced-category-pie-chart {
        width: 220px;
        height: 220px;
    }

    .individual-chart-section h5,
    .category-chart-section h5 {
        font-size: 0.85rem;
        margin-bottom: 12px;
    }
}

/* 验证错误信息美化样式 */
.validation-error-container {
    background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
    border: 1px solid #f44336;
    border-radius: 6px;
    padding: 12px;
    margin-top: 8px;
    font-size: 0.9rem;
    box-shadow: 0 2px 4px rgba(244, 67, 54, 0.1);
}

.validation-error-container .error-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #c62828;
    margin-bottom: 8px;
}

.validation-error-container .error-header i {
    font-size: 1rem;
    color: #f44336;
}

.validation-error-container .error-list {
    margin: 0;
    padding-left: 20px;
    list-style: none;
}

.validation-error-container .error-list li {
    position: relative;
    margin-bottom: 4px;
    padding-left: 16px;
    line-height: 1.4;
    color: #d32f2f;
}

.validation-error-container .error-list li:before {
    content: "•";
    position: absolute;
    left: 0;
    color: #f44336;
    font-weight: bold;
}

.validation-error-container .error-item {
    font-weight: 600;
    color: #b71c1c;
}

.validation-error-container .error-message {
    color: #d32f2f;
}

.validation-error-container .error-list li:last-child {
    margin-bottom: 0;
}

/* 移动设备响应式样式 */
@media (max-width: 480px) {
    .validation-error-container {
        padding: 10px;
        font-size: 0.85rem;
    }

    .validation-error-container .error-list {
        padding-left: 16px;
    }

    .validation-error-container .error-list li {
        padding-left: 12px;
    }
}

/* 投资组合回测结果美化样式 */
.backtest-results {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: 1px solid #e3f2fd !important;
    border-radius: 12px !important;
    padding: 24px !important;
    margin-top: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: hidden;
}

.backtest-results::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #1976d2, #42a5f5, #64b5f6);
    border-radius: 12px 12px 0 0;
}

.backtest-results h4 {
    margin-top: 0 !important;
    margin-bottom: 20px !important;
    padding-bottom: 12px !important;
    border-bottom: 2px solid #e3f2fd !important;
    color: #1976d2;
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.backtest-results h4::before {
    content: '';
}

.backtest-metrics {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important;
    gap: 16px !important;
    margin-bottom: 20px !important;
}

.metric-card {
    background: #ffffff;
    border: 1px solid #e8f4fd;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    border-color: #1976d2;
}

.metric-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 8px;
    font-weight: 500;
}

.metric-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: #1976d2;
    margin-bottom: 4px;
}

.metric-value.positive {
    color: #2e7d32;
}

.metric-value.negative {
    color: #d32f2f;
}

.metric-period {
    font-size: 0.8rem;
    color: #999;
    font-style: italic;
}

.backtest-disclaimer {
    font-size: 0.8em;
    color: #666;
    margin-top: 10px;
}

.backtest-disclaimer-text {
    /* 保持简单的文字样式 */
}

/* 移动设备响应式样式 */
@media (max-width: 768px) {
    .backtest-results {
        padding: 20px !important;
        margin-top: 16px;
    }

    .backtest-metrics {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .metric-card {
        padding: 12px;
    }

    .metric-value {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .backtest-results {
        padding: 16px !important;
        border-radius: 8px !important;
    }

    .backtest-results h4 {
        font-size: 1.1rem;
    }

    .metric-value {
        font-size: 1.1rem;
    }

    .metric-label {
        font-size: 0.85rem;
    }

    .backtest-disclaimer {
        padding: 10px 12px;
        font-size: 0.8rem;
    }
}

/* 投资组合净值走势图样式 - 与回测结果容器保持一致 */
.chart-container-wrapper {
    margin-top: 20px;
    display: none;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 15px;
    padding-right: 20px;
    /* 增加右側 padding 防止圖表被切掉 */
    overflow-x: auto;
    /* 允許水平滾動 */
    overflow-y: visible;
    box-sizing: border-box;
}

.chart-container-wrapper h4 {
    margin-top: 0;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.backtest-chart-section {
    width: 100%;
    min-width: 100%;
    box-sizing: border-box;
}

.backtest-chart-container {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    position: relative;
}

/* 圖表畫布容器 */
.chart-canvas-container {
    width: 100%;
    position: relative;
    box-sizing: border-box;
}

/* 確保 Canvas 正確顯示 */
#backtest-price-chart {
    display: block;
    width: 100% !important;
    max-width: 100%;
    box-sizing: border-box;
}

/* 響應式圖表容器 */
@media (max-width: 768px) {
    .chart-container-wrapper {
        padding: 10px;
        padding-right: 15px;
    }
}

@media (max-width: 480px) {
    .chart-container-wrapper {
        padding: 8px;
        padding-right: 12px;
    }
}

/* ====== 自定義代號搜尋下拉組件樣式 ====== */

/* 下拉組件容器 */
.code-dropdown-container {
    position: relative;
    flex: 1;
    width: 25%;
    max-width: 25%;
}

/* 輸入框包裝器 */
.code-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

/* 代號輸入框 */
.code-dropdown-container .code-input {
    width: 100%;
    max-width: 100%;
    padding-right: 30px;
    /* 為下拉箭頭預留空間 */
    cursor: text;
}

/* 下拉箭頭按鈕 */
.code-dropdown-toggle {
    position: absolute;
    right: 1px;
    top: 1px;
    bottom: 1px;
    width: 28px;
    background: linear-gradient(to bottom, #f8f8f8 0%, #e8e8e8 100%);
    border: none;
    border-left: 1px solid #ddd;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    padding: 0;
}

.code-dropdown-toggle:hover {
    background: linear-gradient(to bottom, #f0f0f0 0%, #e0e0e0 100%);
}

.code-dropdown-toggle:focus {
    outline: none;
}

/* 下拉箭頭圖標 */
.code-dropdown-toggle::after {
    content: '';
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #666;
    transition: transform 0.2s;
}

.code-dropdown-toggle.open::after {
    transform: rotate(180deg);
}

/* 下拉選單 */
.code-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 250px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 5px 5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: none;
}

.code-dropdown-menu.show {
    display: block;
}

/* 下拉選項 */
.code-dropdown-item {
    padding: 10px 12px;
    cursor: pointer;
    transition: background-color 0.15s;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.code-dropdown-item:last-child {
    border-bottom: none;
}

.code-dropdown-item:hover,
.code-dropdown-item.highlighted {
    background-color: #e3f2fd;
}

.code-dropdown-item.selected {
    background-color: #bbdefb;
    font-weight: 500;
}

/* 選項中的代號 */
.code-dropdown-item .item-symbol {
    font-weight: 600;
    color: #1976d2;
    font-size: 0.95rem;
}

/* 選項中的名稱 */
.code-dropdown-item .item-name {
    font-size: 0.8rem;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 找不到結果提示 */
.code-dropdown-no-result {
    padding: 15px 12px;
    text-align: center;
    color: #999;
    font-size: 0.9rem;
    font-style: italic;
}

.code-dropdown-no-result i {
    display: block;
    font-size: 1.5rem;
    margin-bottom: 8px;
    color: #ddd;
}

/* 加載中提示 */
.code-dropdown-loading {
    padding: 15px 12px;
    text-align: center;
    color: #666;
    font-size: 0.9rem;
}

/* 請先選擇分類提示 */
.code-dropdown-hint {
    padding: 15px 12px;
    text-align: center;
    color: #ff9800;
    font-size: 0.85rem;
    background-color: #fff8e1;
}

/* 現金類別特殊樣式 */
.code-dropdown-container.is-cash .code-input {
    background-color: #f0f0f0;
    cursor: not-allowed;
}

.code-dropdown-container.is-cash .code-dropdown-toggle {
    display: none;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .code-dropdown-menu {
        max-height: 200px;
    }

    .code-dropdown-item {
        padding: 8px 10px;
    }

    .code-dropdown-item .item-symbol {
        font-size: 0.9rem;
    }

    .code-dropdown-item .item-name {
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .code-dropdown-container {
        width: 30%;
        max-width: 30%;
    }

    .code-dropdown-menu {
        max-height: 180px;
    }

    .code-dropdown-toggle {
        width: 24px;
    }

    .code-dropdown-item {
        padding: 8px;
    }
}

/* ========== 緊急備用金設定樣式 ========== */
.cash-reserve-setting input[type="checkbox"] {
    accent-color: #0369a1;
}

.cash-reserve-amount {
    transition: border-color 0.2s ease;
}

.cash-reserve-amount:focus {
    outline: none;
    border-color: #0369a1;
    box-shadow: 0 0 0 2px rgba(3, 105, 161, 0.1);
}

.cash-reserve-amount:disabled {
    background-color: #f8fafc;
    cursor: not-allowed;
}

.settings-divider {
    display: block;
}

/* 響應式設計 - 設定列 */
@media (max-width: 600px) {
    .settings-row {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
    }

    .settings-divider {
        display: none;
    }

    .cash-reserve-setting {
        flex-wrap: wrap;
    }
}

/* ====== 動態投資組合（生命週期策略）樣式 ====== */

.dynamic-allocation-container {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    margin-top: 15px;
}

.dynamic-allocation-container h5 {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #334155;
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 15px 0;
}

.dynamic-allocation-container h5 i {
    color: #3b82f6;
}

/* 時間軸圖表容器 */
.timeline-chart-container {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 15px;
}

.allocation-timeline-canvas {
    display: block;
}

/* 里程碑分頁標籤 */
.milestone-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 15px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.milestone-tab {
    flex-shrink: 0;
    padding: 10px 20px;
    border: none;
    background: transparent;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 400;
    color: #64748b;
    transition: all 0.2s ease;
    white-space: nowrap;
    border-radius: 0;
}

.milestone-tab:hover:not(.active) {
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.08);
}

.milestone-tab.active {
    background: #3b82f6 !important;
    border-bottom-color: #3b82f6;
    border-radius: 6px 6px 0 0;
    font-weight: 600;
    color: #fff !important;
    box-shadow: 0 -2px 8px rgba(59, 130, 246, 0.25);
}

.milestone-year-input {
    width: 50px;
    padding: 2px 6px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 12px;
    text-align: center;
    background: #fff;
}

.milestone-year-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* 里程碑控制按鈕 */
.milestone-controls {
    display: flex;
    gap: 4px;
}

.milestone-controls .add-item-btn,
.milestone-controls .remove-item-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    border-radius: 6px;
}

/* 上一步 / 快轉按鈕 */
.timeline-step-btn:hover {
    background: #f1f5f9 !important;
    color: #3b82f6 !important;
    border-color: #3b82f6 !important;
    transform: scale(1.08);
}

.timeline-step-btn:active {
    transform: scale(0.93);
}

/* 自訂資產參數輸入 */
.custom-asset-params {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-right: 8px;
}

.custom-param-group {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
}

.custom-param-group label {
    color: #64748b;
    white-space: nowrap;
}

.custom-param-group input {
    width: 55px;
    padding: 4px 6px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 12px;
    text-align: right;
}

.custom-param-group input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.custom-param-group span {
    color: #64748b;
    font-size: 11px;
}

/* 自訂分類下拉容器樣式 */
.code-dropdown-container.is-custom .code-dropdown-toggle {
    display: none;
}

/* 自訂標的警告標籤 */
.custom-asset-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 500;
    color: #b45309;
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: 4px;
    padding: 1px 8px;
    margin-left: 10px;
    vertical-align: middle;
    line-height: 1.6;
}

/* 響應式設計 - 動態投資組合 */
@media (max-width: 768px) {
    .dynamic-allocation-container {
        padding: 15px;
    }

    .milestone-tabs {
        padding-bottom: 5px;
    }

    .milestone-tab {
        padding: 8px 12px;
        font-size: 12px;
    }

    .timeline-chart-container {
        height: 60px;
    }
}

/* ====== 動態投資組合參數變化圖表樣式 ====== */
.dynamic-allocation-chart-container {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: 1px solid #e3f2fd !important;
    border-radius: 12px !important;
    padding: 24px !important;
    margin-top: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: hidden;
}

.dynamic-allocation-chart-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #10b981, #34d399, #6ee7b7);
    border-radius: 12px 12px 0 0;
}

.dynamic-allocation-chart-container h4 {
    margin-top: 0 !important;
    margin-bottom: 20px !important;
    padding-bottom: 12px !important;
    border-bottom: 2px solid #e3f2fd !important;
    color: #059669;
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dynamic-allocation-chart-container h4 i {
    color: #10b981;
}

.chart-wrapper {
    height: 300px;
    width: 100%;
    position: relative;
}

/* 響應式調整 */
@media (max-width: 768px) {
    .dynamic-allocation-chart-container {
        padding: 20px !important;
        margin-top: 16px;
    }
}

@media (max-width: 480px) {
    .dynamic-allocation-chart-container {
        padding: 16px !important;
        border-radius: 8px !important;
    }

    .dynamic-allocation-chart-container h4 {
        font-size: 1.1rem;
    }
}
/* 收入事件模組專用樣式 */
.income-events-container {
    max-height: 500px;
    overflow-y: auto;
    padding: 8px 0;
}

.income-events-controls {
    display: flex;
    justify-content: flex-start;
    gap: 5px;
    margin-bottom: 10px;
}

/* 參照custom-income.css的按鈕樣式 */
.add-point-btn, .remove-point-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.add-point-btn {
    background-color: #3498db;
    color: white;
}

.remove-point-btn {
    background-color: #e74c3c;
    color: white;
}

.add-point-btn:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.remove-point-btn:hover {
    background-color: #c0392b;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* 移除虛線，減少間距 */
.income-event-row {
    margin-bottom: 6px;
    padding-bottom: 6px;
}

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

.income-event {
    display: flex;
    gap: 15px;
}

.income-event .form-group {
    flex: 1;
}

/* 數字輸入框樣式覆蓋 */
.income-event-year,
.income-event-amount {
    width: 100%;
} 
/* 支出事件模組專用樣式 */
.expense-events-container {
    max-height: 500px;
    overflow-y: auto;
    padding: 8px 0;
}

.expense-event-row {
    margin-bottom: 6px;
    padding-bottom: 6px;
}

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

.expense-events-controls {
    display: flex;
    justify-content: flex-start;
    gap: 5px;
    margin-bottom: 10px;
}

/* 參照custom-expense.css的按鈕樣式 */
.add-point-btn, .remove-point-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.add-point-btn {
    background-color: #3498db;
    color: white;
}

.remove-point-btn {
    background-color: #e74c3c;
    color: white;
}

.add-point-btn:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.remove-point-btn:hover {
    background-color: #c0392b;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.expense-event {
    display: flex;
    gap: 15px;
}

.expense-event .form-group {
    flex: 1;
}

/* 數字輸入框樣式覆蓋 */
.expense-event-year,
.expense-event-amount {
    width: 100%;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .expense-event {
        flex-direction: column;
        gap: 10px;
    }
} 
.curve-editor-container {
    width: 100%;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    background-color: #f9f9f9;
    margin-bottom: 15px;
}

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

.curve-editor-header h4 {
    margin: 0;
    color: #333;
    font-size: 16px;
    font-weight: 600;
}

.point-controls {
    display: flex;
    gap: 5px;
}

.add-point-btn, .remove-point-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.add-point-btn {
    background-color: #3498db;
    color: white;
}

.remove-point-btn {
    background-color: #e74c3c;
    color: white;
}

.add-point-btn:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.remove-point-btn:hover {
    background-color: #c0392b;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.curve-editor-canvas-container {
    width: 100%;
    height: 300px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background-color: white;
    margin-bottom: 15px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

#income-curve-editor {
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.curve-editor-points-container {
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 6px;
    background-color: white;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

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

.points-table th,
.points-table td {
    padding: 10px;
    text-align: center;
    border-bottom: 1px solid #e0e0e0;
}

.points-table th {
    background-color: #f5f7fa;
    font-weight: bold;
    color: #555;
    font-size: 14px;
}

.point-row:hover {
    background-color: #f5f5f5;
}

.point-year, .point-income {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
    transition: border-color 0.3s ease;
    font-size: 14px;
}

.point-year:focus, .point-income:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.25);
}

/* 響應式設計 */
@media (max-width: 768px) {
    .curve-editor-container {
        padding: 10px;
    }
    
    .curve-editor-canvas-container {
        height: 250px;
    }
    
    .points-table th,
    .points-table td {
        padding: 8px;
    }
    
    .point-year, .point-income {
        padding: 6px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .curve-editor-header h4 {
        font-size: 14px;
    }
    
    .add-point-btn, .remove-point-btn {
        width: 26px;
        height: 26px;
        font-size: 16px;
    }
    
    .curve-editor-canvas-container {
        height: 200px;
    }
    
    .points-table th,
    .points-table td {
        padding: 6px;
    }
    
    .point-year, .point-income {
        padding: 4px;
        font-size: 12px;
    }
} 
.expense-curve-editor-container {
    width: 100%;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    background-color: #f9f9f9;
    margin-bottom: 15px;
}

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

.curve-editor-header h4 {
    margin: 0;
    color: #333;
    font-size: 16px;
    font-weight: 600;
}

.point-controls {
    display: flex;
    gap: 5px;
}

.curve-control-btn {
    padding: 6px 12px;
    border-radius: 4px;
    border: none;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-left: 5px;
    color: white;
    font-weight: 500;
}

.add-point-btn {
    background-color: #3498db;
}

.add-point-btn:hover {
    background-color: #2980b9;
}

.remove-point-btn {
    background-color: #e74c3c;
}

.remove-point-btn:hover {
    background-color: #c0392b;
}

.expense-curve-layout {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    margin-top: 15px;
    padding: 0 5px;
    box-sizing: border-box;
}

.chart-canvas-container {
    width: 100%;
    height: 300px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background-color: white;
    margin-bottom: 15px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

#expense-curve-editor {
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.curve-points-editor {
    width: 100%;
}

.curve-editor-points-container {
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 6px;
    background-color: white;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

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

.points-table th,
.points-table td {
    padding: 10px;
    text-align: center;
    border-bottom: 1px solid #e0e0e0;
}

.points-table th {
    background-color: #f5f7fa;
    font-weight: bold;
    color: #555;
    font-size: 14px;
}

.point-row:hover {
    background-color: #f5f5f5;
}

.point-year, .point-expense {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
    transition: border-color 0.3s ease;
    font-size: 14px;
}

.point-year:focus, .point-expense:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.25);
}

/* 響應式設計 */
@media (min-width: 992px) {
    .expense-curve-layout {
        flex-direction: row;
    }
    
    .chart-canvas-container {
        flex: 7;
        min-height: 350px;
    }
    
    .curve-points-editor {
        flex: 3;
    }
}

@media (max-width: 768px) {
    .expense-curve-editor-container {
        padding: 10px;
    }
    
    .chart-canvas-container {
        height: 250px;
    }
    
    .points-table th,
    .points-table td {
        padding: 8px;
    }
    
    .point-year, .point-expense {
        padding: 6px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .curve-editor-header h4 {
        font-size: 14px;
    }
    
    .curve-control-btn {
        padding: 4px 8px;
        font-size: 12px;
    }
    
    .chart-canvas-container {
        height: 200px;
    }
    
    .points-table th,
    .points-table td {
        padding: 6px;
    }
    
    .point-year, .point-expense {
        padding: 4px;
        font-size: 12px;
    }
} 
/**
 * 導引設定樣式 - Guided Setup Styles
 * 文件名: guided-setup.css
 * 功能: 提供導引設定界面的樣式設計
 */

/* 導引設定按鈕 */
.guided-setup-trigger-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 15px 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    width: 100%;
    justify-content: center;
}

.guided-setup-trigger-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.guided-setup-trigger-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.3);
}

.guided-setup-trigger-btn i {
    font-size: 18px;
}

/* 導引設定系統樣式 */

/* 模態框樣式 */
.guided-setup-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.guided-setup-modal.show {
    display: block;
    opacity: 1;
}

.guided-setup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.guided-setup-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    width: 95%;
    max-width: 1200px;
    max-height: 95vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* 標題區域 */
.guided-setup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #e0e0e0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.guided-setup-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

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

.guided-setup-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 進度顯示 */
.guided-setup-progress {
    padding: 20px 25px;
    border-bottom: 1px solid #f0f0f0;
}

.progress-text-large {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 12px;
    border: 1px solid #dee2e6;
}

#progressPercentage {
    font-size: 24px;
    font-weight: bold;
    color: #4CAF50;
}

#progressStage {
    font-size: 16px;
    color: #666;
    font-weight: 500;
}

/* 內容區域 */
.guided-setup-content {
    flex: 1;
    padding: 25px;
    overflow-y: auto;
    max-height: 70vh;
    min-height: 400px;
}

.question-container {
    width: 100%;
}

.question-header h3 {
    font-size: 1.3rem;
    margin: 0 0 10px 0;
    color: #333;
    font-weight: 600;
}

.question-subtitle {
    font-size: 1rem;
    color: #666;
    margin: 0 0 15px 0;
    line-height: 1.4;
}

.question-explanation {
    background: #f8f9fa;
    padding: 12px 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    border-left: 4px solid #667eea;
    font-size: 0.9rem;
    color: #555;
}

/* 選項卡片 */
.option-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.option-card {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
    position: relative;
    overflow: hidden;
}

.option-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    transform: translateY(-2px);
}

.option-card.selected {
    border-color: #667eea;
    background: linear-gradient(135deg, #667eea10, #764ba210);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
}

.option-icon {
    font-size: 2rem;
    color: #667eea;
    margin-bottom: 15px;
}

.option-content h4 {
    margin: 0 0 8px 0;
    font-size: 1.1rem;
    color: #333;
    font-weight: 600;
}

.option-content p {
    margin: 0;
    font-size: 0.9rem;
    color: #666;
    line-height: 1.4;
}

.option-check {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 24px;
    height: 24px;
    background: #667eea;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.8rem;
}

.option-card.selected .option-check {
    display: flex;
}

/* 輸入框樣式 */
.number-input-container,
.amount-input-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
    justify-content: center;
}

.guided-number-input,
.guided-amount-input {
    width: 200px;
    max-width: 300px;
    padding: 14px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 500;
    transition: border-color 0.2s ease;
    text-align: center;
}

/* 針對特定類型的寬度調整 */
.guided-number-input {
    width: 160px;
    max-width: 200px;
}

.guided-amount-input {
    width: 220px;
    max-width: 300px;
}

.guided-number-input:focus,
.guided-amount-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.input-unit {
    font-size: 1.1rem;
    color: #666;
    font-weight: 600;
    min-width: 30px;
}

/* 輸入反饋樣式 */
.input-feedback-text {
    margin-top: 12px;
    color: #667eea;
    font-size: 0.95rem;
    font-weight: 500;
    text-align: center;
    min-height: 20px;
    transition: all 0.3s ease;
}

.input-feedback-text:empty {
    display: none;
}

/* 歡迎頁面樣式 */
.welcome-container {
    text-align: center;
    padding: 40px 20px;
}

.welcome-icon {
    font-size: 4rem;
    color: #667eea;
    margin-bottom: 30px;
}

.welcome-actions {
    margin-top: 30px;
}

.welcome-start-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.welcome-start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

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

.welcome-auto-next {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #667eea;
    font-size: 1.1rem;
    opacity: 0.8;
    animation: pulse 2s infinite;
}

.welcome-auto-next i {
    font-size: 1.2rem;
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateX(0); }
    40% { transform: translateX(-5px); }
    60% { transform: translateX(5px); }
}

/* 投資設定樣式 */
.investment-setup-container {
    width: 100%;
}

.investment-instruction {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    border-left: 4px solid #28a745;
}

.investment-instruction p {
    margin: 5px 0;
    color: #555;
    font-size: 0.9rem;
}

.investment-help-info {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 15px;
    margin-top: 15px;
}

.investment-help-info h5 {
    margin: 0 0 10px 0;
    color: #495057;
    font-size: 1rem;
}

.investment-help-info ul {
    margin: 0;
    padding-left: 20px;
}

.investment-help-info li {
    margin-bottom: 8px;
    font-size: 0.85rem;
    line-height: 1.4;
}

.investment-help-info li strong {
    color: #495057;
}

.investment-item {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 10px;
    background: #fafafa;
}

.investment-row {
    display: grid;
    grid-template-columns: 1fr 1fr 150px 120px;
    gap: 15px;
    align-items: center;
}

.investment-field {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.investment-field label {
    font-size: 0.9rem;
    color: #555;
    font-weight: 500;
    min-width: 50px;
    text-align: left;
}

.investment-category,
.investment-code,
.investment-name,
.investment-ratio {
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    text-align: center;
    flex: 1;
}

.investment-ratio-field {
    justify-content: flex-start;
}

.investment-ratio-field .ratio-input-container {
    display: flex;
    align-items: center;
    position: relative;
    flex: 1;
    max-width: 100px;
}

.investment-ratio-field .investment-ratio {
    flex: 1;
    padding-right: 25px;
    text-align: center;
}

.investment-ratio-field .ratio-unit {
    position: absolute;
    right: 8px;
    font-size: 0.9rem;
    color: #666;
    pointer-events: none;
}

.investment-actions {
    display: flex;
    gap: 10px;
    margin: 20px 0;
    align-items: center;
}

.add-investment-btn,
.remove-investment-btn {
    padding: 8px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background-color 0.2s ease;
}

.add-investment-btn {
    background: #28a745;
    color: white;
}

.add-investment-btn:hover {
    background: #218838;
}

.remove-investment-btn {
    background: #dc3545;
    color: white;
}

.remove-investment-btn:hover:not(:disabled) {
    background: #c82333;
}

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

.investment-summary {
    border-top: 1px solid #e0e0e0;
    padding-top: 20px;
    margin-top: 20px;
}

.total-allocation {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.1rem;
}

.pie-chart-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
}

#portfolio-pie-chart {
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* 完成步驟樣式 */
.completion-container {
    text-align: center;
    padding: 20px;
}

.completion-icon {
    font-size: 4rem;
    color: #28a745;
    margin-bottom: 20px;
}

.completion-container h3 {
    color: #28a745;
    margin-bottom: 15px;
}

.completion-summary {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
    text-align: left;
}

.completion-summary h4 {
    margin-top: 0;
    color: #333;
}

.completion-summary ul {
    list-style: none;
    padding: 0;
}

.completion-summary li {
    padding: 5px 0;
    border-bottom: 1px solid #e0e0e0;
}

.completion-summary li:last-child {
    border-bottom: none;
}

/* 按鈕樣式 */
.guided-setup-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-top: 1px solid #e0e0e0;
    background: #fafafa;
    gap: 15px;
}

.guided-setup-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.guided-setup-btn.secondary {
    background: #6c757d;
    color: white;
}

.guided-setup-btn.secondary:hover:not(:disabled) {
    background: #5a6268;
}

.guided-setup-btn.primary {
    background: #667eea;
    color: white;
}

.guided-setup-btn.primary:hover:not(:disabled) {
    background: #5a6fd8;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.guided-setup-btn.primary.enabled {
    background: #10b981;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    animation: pulse 2s infinite;
}

.guided-setup-btn.primary.enabled:hover {
    background: #059669;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.guided-setup-btn.success {
    background: #28a745;
    color: white;
}

.guided-setup-btn.success:hover {
    background: #218838;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

/* 響應式設計 */
@media (max-width: 1200px) {
    .investment-row {
        grid-template-columns: 1fr 1fr 80px;
    }
    
    .pie-chart-container {
        min-height: 250px;
    }
    
    #portfolio-pie-chart {
        width: 250px;
        height: 250px;
    }
}

@media (max-width: 768px) {
    .guided-setup-container {
        width: 98%;
        max-height: 98vh;
    }
    
    .guided-setup-content {
        max-height: 60vh;
        min-height: 300px;
    }
    
    .option-cards {
        grid-template-columns: 1fr;
    }
    
    .investment-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .guided-setup-actions {
        flex-direction: column;
        gap: 10px;
        justify-content: center;
    }
    
    .guided-setup-btn {
        width: 100%;
        justify-content: center;
    }
    
    .pie-chart-container {
        min-height: 200px;
    }
    
    #portfolio-pie-chart {
        width: 200px;
        height: 200px;
    }
    
    /* 手機版輸入欄位寬度調整 */
    .guided-number-input {
        width: 140px;
        max-width: 160px;
        font-size: 1rem;
        padding: 12px 14px;
    }
    
    .guided-amount-input {
        width: 180px;
        max-width: 220px;
        font-size: 1rem;
        padding: 12px 14px;
    }
    
    .number-input-container,
    .amount-input-container {
        gap: 10px;
    }
    
    .input-unit {
        font-size: 1rem;
        min-width: 25px;
    }
}

/* 動畫效果 */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.question-container {
    animation: slideIn 0.3s ease;
}

/* 滾動條樣式 */
.guided-setup-content::-webkit-scrollbar {
    width: 8px;
}

.guided-setup-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.guided-setup-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.guided-setup-content::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 輔助類別 */
.guided-setup-hidden {
    display: none !important;
}

.guided-setup-loading {
    position: relative;
    pointer-events: none;
}

.guided-setup-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    transform: translate(-50%, -50%);
}

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

@keyframes pulse {
    0% {
        box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3), 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3), 0 0 0 8px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3), 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

/* 錯誤狀態 */
.guided-setup-error {
    border-color: #dc3545 !important;
    background: #fff5f5 !important;
}

.guided-setup-error-message {
    color: #dc3545;
    font-size: 14px;
    margin-top: 8px;
    padding: 8px 12px;
    background: #fff5f5;
    border: 1px solid #fecaca;
    border-radius: 6px;
}

/* 成功狀態 */
.guided-setup-success {
    border-color: #28a745 !important;
    background: #f8fff8 !important;
}

.guided-setup-success-message {
    color: #28a745;
    font-size: 14px;
    margin-top: 8px;
    padding: 8px 12px;
    background: #f8fff8;
    border: 1px solid #c3e6cb;
    border-radius: 6px;
}

/* 模擬進度和結果相關樣式 */
.completion-actions {
    margin-top: 20px;
    text-align: center;
}

.guided-setup-btn.large {
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: 600;
}

.simulation-progress {
    margin-top: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    text-align: center;
}

.progress-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #666;
    font-size: 1rem;
}

.progress-info i {
    font-size: 1.2rem;
    color: #667eea;
}

.simulation-results {
    margin-top: 20px;
    animation: slideIn 0.5s ease;
}

.results-header {
    text-align: center;
    margin-bottom: 25px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
}

.results-header h3 {
    margin: 0 0 10px 0;
    font-size: 1.3rem;
    font-weight: 600;
}

.results-header p {
    margin: 0;
    font-size: 1rem;
    opacity: 0.9;
    line-height: 1.4;
}

.results-header i {
    margin-right: 8px;
    font-size: 1.2rem;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.result-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.result-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.result-card.primary {
    border-color: #667eea;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.result-card.primary:hover {
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3);
}

.result-icon {
    font-size: 2rem;
    margin-bottom: 15px;
}

.result-card.primary .result-icon {
    color: rgba(255, 255, 255, 0.9);
}

.result-card .result-icon {
    color: #667eea;
}

.result-content h4 {
    margin: 0 0 10px 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.result-value {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 10px 0;
    color: inherit;
}

.result-card.primary .result-value {
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.result-content p {
    margin: 10px 0 0 0;
    font-size: 0.9rem;
    line-height: 1.4;
    opacity: 0.8;
}

.result-range {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.range-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 4px;
}

.range-label {
    font-size: 0.9rem;
    color: #666;
}

.range-value {
    font-weight: 600;
    color: #333;
}

.results-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.welcome-ready {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #28a745;
    font-size: 1.1rem;
    font-weight: 600;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.welcome-ready i {
    font-size: 1.3rem;
    color: #28a745;
}

/* 響應式設計 - 模擬結果 */
@media (max-width: 768px) {
    .results-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .results-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .guided-setup-btn.large {
        width: 100%;
    }
    
    .result-card {
        padding: 15px;
    }
    
    .result-value {
        font-size: 1.5rem;
    }
    
    .range-item {
        flex-direction: column;
        gap: 5px;
        text-align: center;
    }
}

/* 機率條樣式 */
.probability-bars {
    margin-top: 15px;
}

.prob-bar {
    margin-bottom: 10px;
}

.prob-bar span {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.bar-container {
    position: relative;
    width: 100%;
    height: 20px;
    background: #f5f5f5;
    border-radius: 10px;
    overflow: hidden;
}

.bar {
    height: 100%;
    border-radius: 10px;
    position: relative;
    transition: width 0.3s ease;
}

.bar.success {
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
}

.bar.failure {
    background: linear-gradient(90deg, #F44336, #FF9800);
}

.percentage {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    font-size: 12px;
    font-weight: 600;
}

/* 風險指標樣式 */
.risk-indicators {
    margin-top: 10px;
}

.risk-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding: 8px 12px;
    background: #f9f9f9;
    border-radius: 6px;
}

.risk-label {
    font-weight: 500;
    color: #666;
}

.risk-value {
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    color: white;
}

.risk-value.low {
    background: #4CAF50;
}

.risk-value.medium {
    background: #FF9800;
}

.risk-value.high {
    background: #F44336;
}

/* 圖表區域樣式 */
.results-chart-section {
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.results-chart-section h4 {
    margin-bottom: 10px;
    color: #495057;
    font-size: 1.1em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.results-chart-section p {
    margin-bottom: 15px;
    color: #6c757d;
    font-size: 0.9em;
    line-height: 1.4;
}

.chart-container-small {
    position: relative;
    height: 300px;
    background: white;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-container-small canvas {
    max-width: 100%;
    max-height: 100%;
}

#guidedSetupAreaChart {
    width: 100% !important;
    height: 100% !important;
}

/* 響應式設計擴展 */
@media (max-width: 768px) {
    .chart-container-small {
        height: 250px;
    }
    
    .risk-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .risk-value {
        align-self: flex-end;
    }
    
    .probability-bars {
        margin-top: 10px;
    }
    
    .bar-container {
        height: 18px;
    }
    
    .percentage {
        font-size: 11px;
    }
}

/* 全螢幕圖表樣式已移至 main_simulation.css 以避免重複定義和樣式衝突 */

/* 會員升級相關樣式 */
.option-card.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.option-card.membership-required {
    border: 2px solid #f39c12;
    background: linear-gradient(135deg, #fff9e6, #ffeaa7);
}

.membership-notice {
    margin-top: 10px;
    padding: 10px;
    background: rgba(243, 156, 18, 0.1);
    border-radius: 6px;
    border: 1px solid #f39c12;
    text-align: center;
}

.membership-notice i {
    color: #f39c12;
    margin-right: 5px;
}

.membership-notice span {
    font-size: 14px;
    color: #d68910;
    font-weight: 500;
}

.upgrade-btn {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    margin-top: 8px;
    transition: all 0.2s ease;
}

.upgrade-btn:hover {
    background: linear-gradient(135deg, #e67e22, #d35400);
    transform: translateY(-1px);
}

.option-check.disabled {
    background: #bdc3c7;
    border-color: #bdc3c7;
}

.option-check.disabled i {
    color: #7f8c8d;
}

/* 升級會員模態框 */
.upgrade-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 15000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.upgrade-modal-overlay.show {
    opacity: 1;
}

.upgrade-modal {
    background: white;
    border-radius: 12px;
    max-width: 450px;
    width: 90%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.upgrade-modal-overlay.show .upgrade-modal {
    transform: scale(1);
}

.upgrade-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #e0e0e0;
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
    border-radius: 12px 12px 0 0;
}

.upgrade-modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
}

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

.upgrade-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.upgrade-modal-content {
    padding: 25px;
}

.upgrade-modal-content p {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 16px;
    line-height: 1.5;
}

.upgrade-modal-content ul {
    margin: 15px 0;
    padding-left: 20px;
}

.upgrade-modal-content li {
    margin-bottom: 8px;
    color: #555;
    font-size: 14px;
}

.upgrade-modal-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    padding: 20px 25px;
    border-top: 1px solid #e0e0e0;
}

.upgrade-btn-primary {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.upgrade-btn-primary:hover {
    background: linear-gradient(135deg, #e67e22, #d35400);
    transform: translateY(-1px);
}

.upgrade-btn-secondary {
    background: transparent;
    color: #666;
    border: 2px solid #ddd;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

/* 群組輸入容器樣式 */
.group-inputs-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    overflow: visible; /* 確保下拉選單可見 */
}

.group-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.group-field label {
    font-weight: 600;
    color: #495057;
    font-size: 1rem;
    margin-bottom: 5px;
}

.group-field-explanation {
    font-size: 0.85rem;
    color: #6c757d;
    line-height: 1.4;
    margin-bottom: 10px;
    padding: 8px 12px;
    background: #ffffff;
    border-radius: 4px;
    border-left: 3px solid #667eea;
}

.group-field-input {
    display: flex;
    align-items: center;
    gap: 10px;
}

.group-field-input input,
.group-field-input select,
.group-field-input .guided-amount-input,
.group-field-input .guided-number-input,
.group-field-input .guided-select-input,
.group-field-input .guided-text-input {
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s ease;
    background: white;
    flex: 1;
    min-width: 0; /* 確保在flex容器中可以縮小 */
}

/* 投資組合報酬率和風險設定 - 特定寬度控制 */
.group-field-input .guided-number-input[id*="portfolio-return"],
.group-field-input .guided-number-input[id*="return-std"],
.group-field-input .guided-number-input[id*="non-investment-return"],
.group-field-input .guided-number-input[id*="non-investment-std"] {
    max-width: 120px;
    min-width: 100px;
    flex: none; /* 不要自動伸縮 */
    text-align: center; /* 數字置中顯示 */
}

/* ETF 選擇器寬度控制 */
.group-field-input .guided-select-input[id*="etf-selector"] {
    min-width: 250px;
    max-width: 400px;
    flex: 1; /* 允許適度伸縮 */
    position: relative;
    z-index: 100; /* 確保選單在最上層 */
}

/* 投資參數組合排版優化 */
.group-field:has(.guided-number-input[id*="portfolio-return"]),
.group-field:has(.guided-number-input[id*="return-std"]),
.group-field:has(.guided-number-input[id*="non-investment-return"]),
.group-field:has(.guided-number-input[id*="non-investment-std"]) {
    flex: 0 0 auto; /* 不要自動伸縮，保持固定寬度 */
}

.group-field-input input:focus,
.group-field-input select:focus,
.group-field-input .guided-amount-input:focus,
.group-field-input .guided-number-input:focus,
.group-field-input .guided-select-input:focus,
.group-field-input .guided-text-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.group-field-unit,
.input-unit {
    font-size: 1rem;
    color: #6c757d;
    font-weight: 500;
    min-width: 30px;
    white-space: nowrap; /* 防止單位換行 */
}

.group-field-select,
.guided-select-input {
    min-width: 200px;
    padding: 8px 12px;
    min-height: 40px;
    position: relative;
    z-index: 10;
}

.group-field-select option,
.guided-select-input option {
    padding: 12px 8px;
    min-height: 40px;
    line-height: 1.5;
}

/* ETF 選擇器特殊樣式 */
.etf-selector-field {
    border-top: 1px solid #e9ecef;
    padding-top: 15px;
    margin-top: 15px;
    margin-bottom: 20px; /* 增加底部邊距防止被切到 */
    position: relative;
    z-index: 50;
}

.etf-selector-field label {
    color: #28a745;
    font-weight: 600;
}

.etf-selector-field .group-field-explanation {
    border-left-color: #28a745;
    background: #f8fff8;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .group-field-input {
        flex-direction: column;
        align-items: stretch;
    }
    
    .group-field-input input,
    .group-field-input select,
    .group-field-input .guided-amount-input,
    .group-field-input .guided-number-input,
    .group-field-input .guided-select-input,
    .group-field-input .guided-text-input {
        width: 100%;
    }
    
    /* 平板上投資參數輸入框保持固定寬度 */
    .group-field-input .guided-number-input[id*="portfolio-return"],
    .group-field-input .guided-number-input[id*="return-std"],
    .group-field-input .guided-number-input[id*="non-investment-return"],
    .group-field-input .guided-number-input[id*="non-investment-std"] {
        width: auto;
        max-width: 150px;
        align-self: center; /* 置中顯示 */
    }
    
    .group-field-unit,
    .input-unit {
        text-align: center;
        margin-top: 5px;
    }
    
    .group-field-select,
    .guided-select-input {
        min-width: auto;
    }
    
    /* ETF 選擇器在平板上保持合適寬度 */
    .group-field-input .guided-select-input[id*="etf-selector"] {
        min-width: 200px;
        max-width: 300px;
    }
}

@media (max-width: 480px) {
    .group-inputs-container {
        padding: 15px;
        gap: 15px;
    }
    
    .group-field-input input,
    .group-field-input select,
    .group-field-input .guided-amount-input,
    .group-field-input .guided-number-input,
    .group-field-input .guided-select-input,
    .group-field-input .guided-text-input {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
    
    /* 手機上投資參數輸入框的特殊處理 */
    .group-field-input .guided-number-input[id*="portfolio-return"],
    .group-field-input .guided-number-input[id*="return-std"],
    .group-field-input .guided-number-input[id*="non-investment-return"],
    .group-field-input .guided-number-input[id*="non-investment-std"] {
        width: auto;
        max-width: 120px;
        min-width: 80px;
        align-self: center;
        padding: 8px 10px;
    }
    
    /* ETF 選擇器在手機上的寬度 */
    .group-field-input .guided-select-input[id*="etf-selector"] {
        min-width: auto;
        max-width: 100%;
    }
    
    .group-field-explanation {
        font-size: 0.8rem;
        padding: 6px 10px;
    }
}

/* 投資組合驗證樣式 */
.investment-validation {
    margin-top: 8px;
    min-height: 20px;
}

.validation-message {
    font-size: 0.85rem;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    max-width: 100%;
}

.validation-message.valid {
    color: #28a745;
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
}

.validation-message.invalid {
    color: #dc3545;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
}

.validation-message.warning {
    color: #856404;
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
}

/* 投資項目樣式增強 */
.investment-code {
    position: relative;
}

.investment-code[readonly] {
    background-color: #f8f9fa;
    cursor: not-allowed;
}

/* 總配置比例樣式 */
.total-allocation {
    text-align: center;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.total-allocation span {
    font-weight: bold;
    transition: color 0.3s ease;
}

/* 投資項目行增強 */
.investment-item {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    background-color: #fafafa;
    transition: box-shadow 0.2s ease;
}

.investment-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.investment-field {
    flex: 1;
    margin-right: 10px;
}

.investment-field:last-child {
    margin-right: 0;
}

.investment-field label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
}

.investment-category,
.investment-code,
.investment-ratio {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: border-color 0.2s ease;
}

.investment-category:focus,
.investment-code:focus,
.investment-ratio:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

/* 響應式調整 */
@media (max-width: 768px) {
    .investment-row {
        flex-direction: column;
    }
    
    .investment-field {
        margin-right: 0;
        margin-bottom: 10px;
    }
    
    .investment-validation {
        margin-top: 5px;
    }
}

/* 全螢幕圖表功能現在使用 main_simulation.css 中的共用樣式 */

/* 四群組結果卡片樣式 */
.goal1-groups-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin: 25px 0;
    padding: 0;
}

.group-card {
    background: linear-gradient(145deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border: 1px solid transparent;
    position: relative;
    overflow: hidden;
}

.group-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.group-card.top10 {
    background: linear-gradient(145deg, #e8f5e8 0%, #f0f9f0 100%);
    border-left: 5px solid #4CAF50;
}

.group-card.top10:hover {
    background: linear-gradient(145deg, #d4f2d4 0%, #e8f5e8 100%);
    border-left-color: #2E7D32;
}

.group-card.middle50 {
    background: linear-gradient(145deg, #e3f2fd 0%, #f0f8ff 100%);
    border-left: 5px solid #2196F3;
}

.group-card.middle50:hover {
    background: linear-gradient(145deg, #bbdefb 0%, #e3f2fd 100%);
    border-left-color: #1565C0;
}

.group-card.worst10 {
    background: linear-gradient(145deg, #fff3e0 0%, #fff8f0 100%);
    border-left: 5px solid #FF9800;
}

.group-card.worst10:hover {
    background: linear-gradient(145deg, #ffe0b2 0%, #fff3e0 100%);
    border-left-color: #E65100;
}

.group-card.worst1 {
    background: linear-gradient(145deg, #ffebee 0%, #fff5f5 100%);
    border-left: 5px solid #F44336;
}

.group-card.worst1:hover {
    background: linear-gradient(145deg, #ffcdd2 0%, #ffebee 100%);
    border-left-color: #C62828;
}

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

.group-header i {
    font-size: 1.4rem;
    width: 24px;
    text-align: center;
}

.group-card.top10 .group-header i {
    color: #4CAF50;
}

.group-card.middle50 .group-header i {
    color: #2196F3;
}

.group-card.worst10 .group-header i {
    color: #FF9800;
}

.group-card.worst1 .group-header i {
    color: #F44336;
}

.group-title {
    font-weight: 600;
    font-size: 1.1rem;
    color: #333;
}

.group-amount {
    font-size: 1.6rem;
    font-weight: bold;
    margin: 10px 0;
    color: #2c3e50;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.group-description {
    font-size: 0.9rem;
    color: #666;
    line-height: 1.4;
    margin-top: 8px;
}

/* 圖表放大按鈕現在使用 main_simulation.css 中的 .chart-expand-btn 樣式 */

/* 響應式設計 - 四群組卡片 */
@media (max-width: 768px) {
    .goal1-groups-container {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 15px;
        margin: 20px 0;
    }
    
    .group-card {
        padding: 15px;
    }
    
    .group-amount {
        font-size: 1.3rem;
    }
    
    .group-title {
        font-size: 1rem;
    }
    
    .group-header i {
        font-size: 1.2rem;
    }
    
    /* 圖表放大按鈕響應式樣式在 main_simulation.css 中處理 */
}

@media (max-width: 480px) {
    .goal1-groups-container {
        grid-template-columns: 1fr;
        gap: 12px;
        margin: 15px 0;
    }
    
    .group-card {
        padding: 12px;
    }
    
    .group-amount {
        font-size: 1.2rem;
    }
    
    .group-title {
        font-size: 0.95rem;
    }
    
    .group-description {
        font-size: 0.85rem;
    }
    
    /* 圖表放大按鈕響應式樣式在 main_simulation.css 中處理 */
}

/* 結果說明文字樣式 */
.results-notes {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.results-notes p {
    margin: 5px 0;
    color: #666;
    font-size: 0.9rem;
}

.results-help-text {
    margin: 20px 0;
    text-align: center;
}

.results-help-text p {
    margin: 0;
    padding: 10px;
    background: #f0f7ff;
    border-radius: 6px;
    border: 1px solid #e3f2fd;
}


/* ========================================
   main_simulation.html 頁面專用樣式
   從 HTML inline <style> 移出，由 webpack 打包
   ======================================== */

/* --- 按鈕定位修正 --- */
.container {
    margin-top: 70px !important;
    padding-top: 0px !important;
}
#resetButton, #guideButton, #guidedSetupButton, #open-visual-canvas-btn {
    top: 0px !important;
}
.finance-sections {
    margin-top: 70px !important;
    padding-top: 0px !important;
}

/* --- 頁面載入遮罩 --- */
#page-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease-out;
}
#page-loading-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}
.page-loading-content {
    text-align: center;
    color: white;
}
.page-loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: page-spin 1s linear infinite;
    margin: 0 auto;
}
.page-loading-content p {
    font-size: 16px;
    font-weight: 500;
    margin: 0;
    letter-spacing: 2px;
}
@keyframes page-spin {
    to { transform: rotate(360deg); }
}

