/* ==================== CSS 變數定義 - 主題系統 ==================== */
:root {
    /* 主色調 */
    --color-primary: #667eea;
    --color-primary-light: #5dade2;
    --color-primary-dark: #5568d3;
    --color-secondary: #25D366; /* WhatsApp綠色 */
    --color-accent: #ff9800;
    
    /* 背景色 */
    --color-body-bg: linear-gradient(135deg, #a8d8ea 0%, #d4f1f4 100%);
    --color-container-bg: #ffffff;
    --color-section-bg: #f9f9f9;
    --color-header-bg: linear-gradient(135deg, #5dade2 0%, #25D366 100%);
    --color-footer-bg: #f5f5f5;
    
    /* 文字顏色 */
    --color-text-primary: #333333;
    --color-text-secondary: #555555;
    --color-text-muted: #888888;
    --color-text-light: #ffffff;
    
    /* 邊框顏色 */
    --color-border-light: #ddd;
    --color-border-medium: #ccc;
    
    /* 區域顏色 */
    --color-region-hk: #667eea;
    --color-region-mo: #e91e63;
    
    /* 類別顏色 */
    --color-category-a: #4caf50;
    --color-category-b: #2196f3;
    --color-category-c: #ff9800;
    --color-category-d: #f44336;
    
    /* 狀態顏色 */
    --color-success: #4caf50;
    --color-warning: #ff9800;
    --color-danger: #f44336;
    --color-info: #2196f3;
    --color-highlight: #ffeb3b;
    
    /* 表格顏色 */
    --color-table-header-bg: #667eea;
    --color-table-header-text: #ffffff;
    --color-table-row-even: #f9f9f9;
    --color-table-row-hover: #f0f4ff;
    --color-table-total-bg: #e8f5e9;
    --color-table-carry-bg: #fff3e0;
    
    /* 按鈕顏色 */
    --color-btn-primary-bg: #667eea;
    --color-btn-primary-hover: #5568d3;
    --color-btn-secondary-bg: #e0e0e0;
    --color-btn-success-bg: #4caf50;
    --color-btn-warning-bg: #ff9800;
    --color-btn-danger-bg: #f44336;
    --color-btn-info-bg: #2196f3;
    --color-btn-apply-bg: #25D366; /* WhatsApp綠色套用按鈕 */
    --color-btn-apply-hover: #1da851; /* WhatsApp綠色套用按鈕懸停效果 */
    
    /* 滾動條 */
    --color-scrollbar-track: #f1f1f1;
    --color-scrollbar-thumb: #c1c1c1;
    --color-scrollbar-thumb-hover: #a8a8a8;
    
    /* 陰影 */
    --shadow-container: 0 20px 60px rgba(0, 0, 0, 0.3);
    --shadow-card: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-button: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* ==================== 全局樣式 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--color-body-bg);
    color: var(--color-text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
    transition: background 0.3s ease, color 0.3s ease;
}

/* ==================== 容器和佈局 ==================== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--color-container-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-container);
    overflow: hidden;
    transition: background 0.3s ease;
}

header {
    background: var(--color-header-bg);
    color: var(--color-text-light);
    padding: 30px;
    text-align: center;
    transition: background 0.3s ease;
}

header h1 {
    font-size: 2.2em;
    margin-bottom: 8px;
    font-weight: bold;
}

.mode-switcher {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    margin: 0 30px 15px 30px;
    background: linear-gradient(135deg, #f0f7ff 0%, #e9f4ff 100%);
    border: 1px solid var(--color-border-light);
    border-radius: 10px;
    box-shadow: var(--shadow-card);
}

.mode-title {
    font-weight: 700;
    color: var(--color-text-primary);
    white-space: nowrap;
}

.mode-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    flex: 1;
}

.mode-btn {
    border: 1px solid var(--color-border-medium);
    background: #ffffff;
    color: var(--color-text-primary);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    transform: translateY(-1px);
}

.mode-btn.active {
    background: var(--color-primary);
    color: var(--color-text-light);
    border-color: var(--color-primary);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.25);
}

.mode-hint {
    color: var(--color-text-muted);
    font-size: 0.85em;
    white-space: nowrap;
}

@media (max-width: 900px) {
    .mode-switcher {
        flex-direction: column;
        align-items: flex-start;
        margin: 0 15px 15px 15px;
    }

    .mode-hint {
        white-space: normal;
    }
}

.subtitle {
    font-size: 1em;
    opacity: 0.9;
}

main {
    padding: 30px;
}

footer {
    background: var(--color-footer-bg);
    color: var(--color-text-secondary);
    text-align: center;
    padding: 15px;
    font-size: 0.85em;
    border-top: 1px solid var(--color-border-light);
    transition: background 0.3s ease, color 0.3s ease;
}

/* ==================== 區域樣式 ==================== */
.section {
    margin-bottom: 30px;
    padding: 20px;
    background: var(--color-section-bg);
    border-radius: 8px;
    border-left: 5px solid var(--color-primary);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.section h2 {
    font-size: 1.4em;
    margin-bottom: 15px;
    color: var(--color-text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.3s ease;
}

.section h3 {
    font-size: 1.1em;
    margin: 20px 0 10px 0;
    color: var(--color-text-secondary);
    transition: color 0.3s ease;
}

.hint {
    color: var(--color-text-muted);
    font-size: 0.9em;
    margin: 5px 0 15px 0;
    transition: color 0.3s ease;
}

/* ==================== 按鈕樣式 ==================== */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
}

.btn-large {
    padding: 12px 24px;
    font-size: 1em;
}

.btn-primary {
    background: var(--color-btn-primary-bg);
    color: var(--color-text-light);
}

.btn-primary:hover {
    background: var(--color-btn-primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-button);
}

.btn-secondary {
    background: var(--color-btn-secondary-bg);
    color: var(--color-text-primary);
}

.btn-secondary:hover {
    background: var(--color-border-medium);
}

.btn-success {
    background: var(--color-btn-success-bg);
    color: var(--color-text-light);
}

.btn-success:hover {
    background: var(--color-success);
    filter: brightness(0.9);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.4);
}

.btn-info {
    background: var(--color-btn-info-bg);
    color: var(--color-text-light);
}

.btn-info:hover {
    background: var(--color-info);
    filter: brightness(0.9);
}

.btn-apply {
    background: var(--color-btn-apply-bg);
    color: var(--color-text-light);
}

.btn-apply:hover {
    background: var(--color-btn-apply-hover);
    filter: brightness(0.9);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(118, 215, 196, 0.4);
}

.btn-warning {
    background: var(--color-btn-warning-bg);
    color: var(--color-text-light);
}

.btn-warning:hover {
    background: var(--color-warning);
    filter: brightness(0.9);
}

.btn-danger {
    background: var(--color-btn-danger-bg);
    color: var(--color-text-light);
}

.btn-danger:hover {
    background: var(--color-danger);
    filter: brightness(0.9);
}

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

/* 下一步提示樣式 */
.next-step-hint {
    margin-top: 10px;
    padding: 10px;
    background: rgba(37, 211, 102, 0.15);
    border-left: 4px solid var(--color-secondary);
    border-radius: 4px;
    font-size: 0.9em;
    color: var(--color-text-secondary);
}

.next-step-hint small {
    color: var(--color-text-muted);
}

/* ==================== Safety Stock Matrix 樣式 ==================== */
.matrix-section {
    border-left-color: var(--color-success);
}

/* ==================== 權重快速設定面板樣式 ==================== */
.weight-settings-panel {
    background: var(--color-container-bg);
    border-radius: 8px;
    margin-bottom: 20px;
    border: 2px solid var(--color-primary);
    overflow: hidden;
}

.weight-toggle-btn {
    width: 100%;
    padding: 12px;
    background: var(--color-primary);
    color: var(--color-text-light);
    border: none;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.weight-toggle-btn:hover {
    filter: brightness(0.9);
}

.weight-toggle-btn.active {
    background: var(--color-primary-dark);
}

.weight-content {
    padding: 20px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 2000px;
    }
}

.weight-group {
    margin-bottom: 20px;
    padding: 15px;
    background: var(--color-section-bg);
    border-radius: 6px;
}

.weight-group h4 {
    margin-bottom: 12px;
    color: var(--color-text-primary);
    font-size: 0.95em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.weight-hint {
    margin-top: 10px;
    margin-bottom: 0;
    font-size: 0.85em;
    color: var(--color-text-muted);
}

.weight-hint-small {
    font-size: 0.8em;
    color: var(--color-text-muted);
    margin-bottom: 8px;
}

.weight-inputs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 10px;
}

.weight-inputs label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.85em;
    color: var(--color-text-secondary);
    text-align: center;
}

.weight-inputs label.slider-label {
    gap: 8px;
}

.weight-label-text {
    font-weight: 600;
}

.weight-label-a .weight-label-text { color: var(--color-category-a); }
.weight-label-b .weight-label-text { color: var(--color-category-b); }
.weight-label-c .weight-label-text { color: var(--color-category-c); }
.weight-label-d .weight-label-text { color: var(--color-category-d); }

/* Type 權重標籤顏色 */
.weight-label-t .weight-label-text { color: #ff6b6b; }  /* 遊客區 - 紅色 */
.weight-label-m .weight-label-text { color: #4ecdc4; }  /* 混合型 - 綠松石 */
.weight-label-l .weight-label-text { color: #45b7d1; }  /* 本地型 - 淡藍 */

.weight-input {
    padding: 8px;
    border: 1px solid var(--color-border-light);
    border-radius: 4px;
    text-align: center;
    font-size: 1em;
    font-weight: 600;
    background: var(--color-container-bg);
    color: var(--color-text-primary);
    transition: all 0.2s ease;
}

.weight-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

/* Safety Stock Days 滑塊樣式 */
.weight-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, var(--color-danger), var(--color-warning), var(--color-success));
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    padding: 0;
    margin: 8px 0;
}

.weight-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    border: 2px solid white;
    transition: all 0.2s ease;
}

.weight-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 3px 8px rgba(102, 126, 234, 0.4);
}

.weight-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    border: 2px solid white;
    transition: all 0.2s ease;
}

.weight-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 3px 8px rgba(102, 126, 234, 0.4);
}

.days-display {
    font-weight: 700;
    color: var(--color-primary);
    font-size: 1.1em;
}

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

.template-btn {
    font-size: 0.85em;
    padding: 6px 12px;
}

.weight-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
    align-items: flex-end;
}

.apply-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.weight-preview {
    margin-top: 20px;
    padding: 15px;
    background: var(--color-container-bg);
    border-radius: 10px;
    border: 1px solid var(--color-border-light);
    box-shadow: var(--shadow-card);
}

.weight-preview h4 {
    margin-bottom: 15px;
    color: var(--color-text-primary);
    font-size: 1em;
}

.weight-preview-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.weight-preview-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.88em;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.weight-preview-table th,
.weight-preview-table td {
    border: 1px solid var(--color-border-light);
    padding: 8px 10px;
    text-align: center;
}

.weight-preview-table th {
    background: var(--color-footer-bg);
    font-weight: 700;
    color: var(--color-text-primary);
}

.weight-preview-table .region-header {
    font-weight: 700;
    color: var(--color-text-light);
    letter-spacing: 0.2px;
    border-color: transparent;
}

.weight-preview-table .region-header-hk {
    background: rgba(102, 126, 234, 0.15);
    color: var(--color-text-primary);
}

.weight-preview-table .region-header-mo {
    background: rgba(233, 30, 99, 0.15);
    color: var(--color-text-primary);
}

.weight-preview-table .size-header th {
    background: #f3f5f9;
    font-size: 0.85em;
    letter-spacing: 0.3px;
    text-transform: none;
}

.weight-preview-table .value-cell {
    font-weight: 600;
}

.weight-preview-summary {
    padding: 12px;
    background: var(--color-section-bg);
    border-radius: 4px;
    font-size: 0.9em;
    line-height: 1.8;
}

/* ==================== 算式簡介樣式 (摺疊式) ==================== */
.weight-formula-intro {
    background: linear-gradient(135deg, #f0f4ff 0%, #e8f5e9 100%);
    border-radius: 12px;
    margin-bottom: 20px;
    border: 2px solid var(--color-primary-light);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.1);
    overflow: hidden;
}

.formula-toggle-btn {
    width: 100%;
    padding: 15px 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 1.1em;
    font-weight: 600;
    color: var(--color-primary);
    transition: all 0.3s ease;
}

.formula-toggle-btn:hover {
    background: rgba(102, 126, 234, 0.05);
}

.formula-toggle-btn .toggle-icon {
    font-size: 0.8em;
    transition: transform 0.3s ease;
}

.formula-toggle-btn.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.formula-content {
    padding: 0 20px 20px 20px;
    animation: slideDown 0.3s ease;
}

.formula-content.collapsed {
    display: none;
}

.formula-box {
    background: var(--color-container-bg);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    border-left: 4px solid var(--color-primary);
}

.formula-title {
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
    font-size: 0.9em;
}

.formula-code {
    display: block;
    background: #f8f9fa;
    padding: 12px 15px;
    border-radius: 6px;
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 0.95em;
    color: var(--color-primary-dark);
    font-weight: 600;
    word-wrap: break-word;
    line-height: 1.5;
}

.formula-note {
    margin-top: 6px;
    color: var(--color-text-muted);
    font-size: 0.85em;
}

.formula-params {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.param-item {
    background: var(--color-container-bg);
    padding: 10px 12px;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.param-name {
    font-weight: 700;
    color: var(--color-text-primary);
    font-size: 0.9em;
}

.param-desc {
    font-size: 0.85em;
    color: var(--color-text-secondary);
    line-height: 1.4;
}

.formula-example {
    background: linear-gradient(135deg, #fff8e1 0%, #ffecb3 100%);
    border-radius: 8px;
    padding: 15px;
    border-left: 4px solid var(--color-warning);
}

.example-title {
    font-weight: 700;
    color: var(--color-warning);
    margin-bottom: 10px;
    font-size: 0.95em;
}

.example-content {
    font-size: 0.9em;
    color: var(--color-text-primary);
    line-height: 1.6;
}

.example-content p {
    margin: 5px 0;
}

.example-content strong {
    color: var(--color-primary);
}

.example-note {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--color-border-light);
    color: var(--color-text-muted);
    font-size: 0.85em;
}

/* 計算範例項目樣式 */
.formula-example-item {
    padding: 12px 16px;
    margin-bottom: 10px;
    border-left: 4px solid var(--color-success);
    background: var(--color-table-row-even);
    border-radius: 4px;
    transition: all 0.2s ease;
}

.formula-example-item:last-child {
    margin-bottom: 0;
}

.formula-example-item strong:first-of-type {
    color: var(--color-success);
}

/* 第二個範例（提示類型）- 改變風格 */
.formula-example-item:nth-child(2) {
    border-left-color: var(--color-warning);
    background: linear-gradient(135deg, rgba(255, 152, 0, 0.15) 0%, rgba(255, 193, 7, 0.12) 100%);
    border: 1px solid rgba(255, 152, 0, 0.4);
}

.formula-example-item:nth-child(2) strong:first-of-type {
    color: var(--color-warning);
}

.formula-example-item p {
    margin: 4px 0;
    font-size: 0.9em;
}

.formula-example-item strong {
    color: var(--color-primary);
    font-weight: 700;
}

@media (max-width: 768px) {
    .weight-inputs {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .weight-preview-content {
        grid-template-columns: 1fr;
    }
    
    .weight-actions {
        flex-direction: column;
    }
}

/* ==================== Matrix Controls ==================== */
.matrix-controls {
    margin-bottom: 15px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ==================== 對照表統計摘要 ==================== */
.matrix-summary-container {
    margin-top: 20px;
    padding: 0;
}

.matrix-summary-box {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border-radius: 12px;
    padding: 20px;
    border: 2px solid var(--color-region-hk);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.15);
}

.matrix-summary-box h4 {
    font-size: 1.1em;
    color: var(--color-text-primary);
    margin-bottom: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.summary-item {
    background: white;
    padding: 12px 14px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    border-left: 4px solid var(--color-success);
    transition: all 0.3s ease;
}

.summary-item:hover {
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.15);
    transform: translateY(-2px);
}

.summary-item.highlight {
    background: linear-gradient(135deg, #fff9c4 0%, #fff59d 100%);
    border-left-color: var(--color-warning);
}

.summary-item.highlight .summary-value {
    color: var(--color-warning);
    font-weight: 700;
    font-size: 1.1em;
}

.summary-label {
    color: var(--color-text-secondary);
    font-weight: 600;
    font-size: 0.85em;
    margin-bottom: 4px;
}

.summary-value {
    color: var(--color-success);
    font-weight: 700;
    font-size: 1em;
    text-align: left;
}

/* 響應式調整 */
@media (max-width: 1200px) {
    .summary-content {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .summary-content {
        grid-template-columns: 1fr;
    }
}

.matrix-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

.matrix-region {
    background: var(--color-container-bg);
    padding: 15px;
    border-radius: 8px;
    box-shadow: var(--shadow-card);
    transition: background 0.3s ease;
}

.region-title {
    font-size: 1.1em;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 10px;
    color: var(--color-text-light);
}

.region-title.region-hk {
    background: var(--color-region-hk);
}

.region-title.region-mo {
    background: var(--color-region-mo);
}

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

.matrix-table th,
.matrix-table td {
    border: 1px solid var(--color-border-light);
    padding: 8px 10px;
    text-align: center;
    transition: border-color 0.3s ease;
}

.matrix-table th {
    background: var(--color-footer-bg);
    font-weight: 600;
    color: var(--color-text-primary);
    transition: background 0.3s ease, color 0.3s ease;
}

.category-cell {
    font-weight: 600;
    text-align: left !important;
}

.category-cell.category-a { background: rgba(76, 175, 80, 0.15); color: var(--color-category-a); }
.category-cell.category-b { background: rgba(33, 150, 243, 0.15); color: var(--color-category-b); }
.category-cell.category-c { background: rgba(255, 152, 0, 0.15); color: var(--color-category-c); }
.category-cell.category-d { background: rgba(244, 67, 54, 0.15); color: var(--color-category-d); }

.matrix-cell {
    cursor: pointer;
    transition: background 0.2s;
}

.matrix-cell:hover {
    background: var(--color-table-row-hover);
}

.matrix-cell.editing {
    background: var(--color-highlight);
}

.matrix-cell .display-value {
    font-weight: 600;
    font-size: 1.1em;
}

.matrix-cell .edit-value {
    width: 60px;
    padding: 4px;
    border: 2px solid var(--color-primary);
    border-radius: 4px;
    text-align: center;
    font-size: 1em;
    background: var(--color-container-bg);
    color: var(--color-text-primary);
}

/* ==================== 店鋪選擇樣式 ==================== */
.stores-section {
    border-left-color: var(--color-primary);
}

/* 控制欄樣式 - 更現代的設計 */
.filter-controls {
    margin-bottom: 20px;
}

.filter-controls .button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, var(--color-section-bg) 0%, var(--color-container-bg) 100%);
    border-radius: 12px;
    border: 1px solid var(--color-border-light);
}

.store-count {
    font-size: 0.95em;
    color: var(--color-text-secondary);
    padding: 10px 16px;
    background: var(--color-container-bg);
    border-radius: 20px;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
}

/* ==================== 左右兩欄佈局 ==================== */
.stores-selector-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 20px;
    margin-bottom: 25px;
    align-items: stretch;
}

@media (max-width: 1100px) {
    .stores-selector-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

/* 左側篩選面板 */
.selector-left-panel {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 16px;
    padding: 20px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

/* 右側店鋪清單面板 - 高度與左側對齊 */
.selector-right-panel {
    background: var(--color-container-bg);
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* 篩選區域 - 卡片化設計 */
.category-filters {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* 篩選列（用於並排顯示） */
.filter-row {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 16px;
    align-items: stretch;
}

@media (max-width: 768px) {
    .filter-row {
        grid-template-columns: 1fr;
    }
}

/* 區域篩選 */
.region-filter {
    flex: 0 0 auto;
}

/* 特別店鋪篩選 */
.special-stores-filter {
    flex: 1;
}

.special-stores-filter .filter-label::before {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

/* 特別店鋪按鈕樣式 */
.special-store-buttons {
    gap: 10px;
}

.special-store-btn {
    min-width: 60px;
    padding: 10px 18px;
    font-weight: 700;
    font-size: 0.9em;
    border-radius: 10px;
    border: 2px solid #fcd34d;
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    color: #92400e;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(251, 191, 36, 0.15);
}

.special-store-btn:hover {
    border-color: #f59e0b;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(251, 191, 36, 0.3);
}

.special-store-btn.active {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border-color: transparent;
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
    transform: translateY(-2px);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px;
    background: var(--color-container-bg);
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
    border: 1px solid #f1f5f9;
    transition: all 0.3s ease;
}

.filter-group:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.06);
    border-color: #e2e8f0;
}

.filter-label {
    font-weight: 700;
    color: var(--color-text-primary);
    font-size: 0.9em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-label::before {
    content: '';
    width: 4px;
    height: 16px;
    background: var(--color-primary);
    border-radius: 2px;
}

.filter-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 8px 16px;
    border: 2px solid #e2e8f0;
    background: white;
    color: var(--color-text-secondary);
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.25s ease;
    font-size: 0.85em;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

.filter-btn:hover {
    border-color: var(--color-primary);
    background: var(--color-table-row-hover);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(102, 126, 234, 0.15);
}

.filter-btn.active {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: var(--color-text-light);
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.35);
}

/* 店鋪組別按鈕樣式 */
.store-group-buttons {
    gap: 10px;
}

.store-group-btn {
    min-width: 50px;
    padding: 10px 20px;
    font-weight: 700;
    font-size: 0.9em;
    border-radius: 10px;
}

.store-group-btn.active {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.35);
}

/* OM 群組樣式 */
.om-group {
    background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
    border: 1px solid #e9d5ff;
}

.om-group .filter-label::before {
    background: linear-gradient(135deg, #9333ea 0%, #7c3aed 100%);
}

/* 右側 OM 面板樣式 - 可捲動 */
.selector-right-panel .om-stores-panel {
    margin-top: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    border: none;
    box-shadow: none;
    border-radius: 0;
}

.selector-right-panel .om-stores-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* 空狀態提示 */
.om-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.om-empty-icon {
    font-size: 4em;
    margin-bottom: 20px;
    opacity: 0.5;
}

.om-empty-state p {
    font-size: 1.1em;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
}

.om-empty-hint {
    font-size: 0.95em;
    color: var(--color-text-muted);
}

/* 店鋪佈局 */
.stores-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 25px;
}

@media (max-width: 1000px) {
    .stores-layout {
        grid-template-columns: 1fr;
    }
}

/* 店鋪容器 */
.stores-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 12px;
    background: var(--color-container-bg);
    padding: 20px;
    border-radius: 12px;
    max-height: 550px;
    overflow-y: auto;
    transition: all 0.3s ease;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

.store-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 10px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.25s ease;
    font-size: 0.95em;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.store-item:hover {
    background: white;
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.15);
}

.store-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--color-primary);
    border-radius: 4px;
}

.store-item .store-name {
    flex: 1;
    cursor: pointer;
    font-weight: 600;
    min-width: 80px;
    color: var(--color-text-primary);
    font-size: 0.95em;
}

.store-item .store-code {
    font-size: 0.8em;
    color: var(--color-text-muted);
    font-family: 'SF Mono', monospace;
    background: #e2e8f0;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 600;
}

.store-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.75em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.store-badge.region-hk {
    background: linear-gradient(135deg, var(--color-region-hk) 0%, #5a67d8 100%);
    color: var(--color-text-light);
}

.store-badge.region-mo {
    background: linear-gradient(135deg, var(--color-region-mo) 0%, #c2185b 100%);
    color: var(--color-text-light);
}

.store-badge.category-a { background: linear-gradient(135deg, var(--color-category-a) 0%, #388e3c 100%); color: var(--color-text-light); }
.store-badge.category-b { background: linear-gradient(135deg, var(--color-category-b) 0%, #1976d2 100%); color: var(--color-text-light); }
.store-badge.category-c { background: linear-gradient(135deg, var(--color-category-c) 0%, #f57c00 100%); color: var(--color-text-light); }
.store-badge.category-d { background: linear-gradient(135deg, var(--color-category-d) 0%, #d32f2f 100%); color: var(--color-text-light); }

.store-badge.size-badge {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
    color: var(--color-text-light);
}

.store-safety-stock {
    font-weight: 700;
    color: var(--color-success);
    min-width: 30px;
    text-align: center;
    font-size: 1em;
    background: rgba(76, 175, 80, 0.1);
    padding: 4px 8px;
    border-radius: 6px;
}

/* 可編輯店鋪 Safety Stock */
.editable-store-stock {
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.editable-store-stock:hover {
    background: var(--color-highlight);
    box-shadow: 0 0 0 2px var(--color-warning);
}

.editable-store-stock.editing {
    background: var(--color-highlight);
    box-shadow: 0 0 0 2px var(--color-accent);
}

.store-stock-input {
    width: 50px;
    padding: 5px;
    border: 2px solid var(--color-primary);
    border-radius: 6px;
    text-align: center;
    font-size: 0.95em;
    font-weight: 700;
    color: var(--color-success);
    background: var(--color-container-bg);
}

.store-stock-input:focus {
    outline: none;
    border-color: var(--color-primary-dark);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

/* 店鋪預覽 */
.stores-preview {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    padding: 20px;
    border-radius: 12px;
    max-height: 550px;
    overflow-y: auto;
    transition: all 0.3s ease;
    border: 1px solid #e2e8f0;
}

.no-selection {
    text-align: center;
    color: var(--color-text-muted);
    padding: 40px 30px;
}

.no-selection p:first-child {
    font-size: 1.1em;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--color-text-secondary);
}

.preview-summary {
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 215, 196, 0.1) 100%);
    border-radius: 10px;
    margin-bottom: 18px;
    font-weight: 600;
    color: var(--color-text-primary);
    border: 1px solid rgba(102, 126, 234, 0.15);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9em;
    border-radius: 10px;
    overflow: hidden;
}

.preview-table th,
.preview-table td {
    border: none;
    border-bottom: 1px solid #e2e8f0;
    padding: 10px 12px;
    text-align: left;
    transition: all 0.2s ease;
}

.preview-table th {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    font-weight: 700;
    color: var(--color-text-primary);
    text-transform: uppercase;
    font-size: 0.8em;
    letter-spacing: 0.5px;
}

.preview-table tbody tr:hover {
    background: rgba(102, 126, 234, 0.03);
}

.preview-table tfoot .total-row {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    font-weight: 700;
}

.preview-table tfoot .total-row td {
    border-bottom: none;
    font-size: 1.05em;
}

/* ==================== 結果區域樣式 ==================== */
.results-section {
    border-left-color: var(--color-success);
}

.results-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

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

.stat-item {
    background: var(--color-container-bg);
    padding: 15px;
    border-radius: 8px;
    box-shadow: var(--shadow-card);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.3s ease;
}

.stat-item label {
    font-weight: 600;
    color: var(--color-text-secondary);
}

.stat-value {
    font-size: 1.5em;
    font-weight: bold;
    color: var(--color-text-primary);
}

.stat-highlight {
    background: var(--color-highlight);
}

.stat-highlight .stat-value {
    color: var(--color-text-primary);
}

/* 結果表格 */
.results-container,
.detail-container {
    background: var(--color-container-bg);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    overflow-x: auto;
    transition: background 0.3s ease;
}

.results-table,
.detail-table {
    width: 100%;
    border-collapse: collapse;
}

.results-table th,
.results-table td,
.detail-table th,
.detail-table td {
    border: 1px solid var(--color-border-light);
    padding: 10px;
    text-align: left;
    transition: border-color 0.3s ease;
}

.results-table th,
.detail-table th {
    background: var(--color-table-header-bg);
    color: var(--color-table-header-text);
    font-weight: 600;
}

.results-table tbody tr:nth-child(even),
.detail-table tbody tr:nth-child(even) {
    background: var(--color-table-row-even);
}

.results-table tbody tr:hover,
.detail-table tbody tr:hover {
    background: var(--color-table-row-hover);
}

.group-header td {
    background: rgba(59, 130, 246, 0.15);
    font-weight: bold;
    font-size: 1.1em;
    text-align: center;
    color: var(--color-text-primary);
}

.region-header-hk {
    background: var(--color-region-hk) !important;
    color: var(--color-text-light) !important;
}

.region-header-mo {
    background: var(--color-region-mo) !important;
    color: var(--color-text-light) !important;
}

.total-row td {
    background: var(--color-table-total-bg) !important;
    font-weight: bold;
    border-top: 2px solid var(--color-success);
}

.carry-row td {
    background: var(--color-table-carry-bg) !important;
    font-weight: bold;
}

.empty-message {
    text-align: center;
    color: var(--color-text-muted);
    padding: 30px !important;
}

/* Badge 樣式 */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 600;
}

.badge.category-a { background: rgba(76, 175, 80, 0.15); color: var(--color-category-a); }
.badge.category-b { background: rgba(33, 150, 243, 0.15); color: var(--color-category-b); }
.badge.category-c { background: rgba(255, 152, 0, 0.15); color: var(--color-category-c); }
.badge.category-d { background: rgba(244, 67, 54, 0.15); color: var(--color-category-d); }

/* Carry 狀態 */
.carry-status {
    font-weight: bold;
    text-align: center;
}

.carry-yes {
    color: var(--color-success);
}

.carry-no {
    color: var(--color-danger);
}

/* 可編輯單元格 */
.editable-cell {
    cursor: pointer;
    transition: background 0.2s;
}

.editable-cell:hover {
    background: var(--color-highlight) !important;
}

.editable-cell.editing {
    background: var(--color-highlight) !important;
}

.editable-cell .display-value {
    font-weight: 600;
}

.editable-cell .edit-value {
    width: 70px;
    padding: 4px;
    border: 2px solid var(--color-primary);
    border-radius: 4px;
    text-align: center;
    font-size: 1em;
    background: var(--color-container-bg);
    color: var(--color-text-primary);
}

/* ==================== 店鋪管理樣式 ==================== */
.stores-management-section {
    border-left-color: var(--color-warning);
}

.stores-management-section h2 {
    cursor: pointer;
    user-select: none;
}

/* 摺疊按鈕 */
.toggle-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--color-text-secondary);
    transition: transform 0.3s ease, color 0.3s ease;
    margin-left: auto;
}

.toggle-btn:hover {
    color: var(--color-primary);
}

/* 管理內容區域 */
.management-content {
    animation: fadeIn 0.3s ease;
}

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

/* 密碼保護區域 */
.password-protected {
    margin-top: 1rem;
}

.password-lock {
    text-align: center;
    padding: 2rem;
    background: var(--color-section-bg);
    border-radius: 8px;
    border: 2px dashed var(--color-border-medium);
    animation: fadeIn 0.3s ease;
}

.lock-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.password-lock p {
    font-size: 1.1em;
    color: var(--color-text-secondary);
    margin-bottom: 1rem;
}

.password-input-group {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin: 1rem 0;
}

.password-input-group input {
    padding: 0.5rem;
    border: 1px solid var(--color-border-medium);
    border-radius: 4px;
    font-size: 1rem;
    text-align: center;
    letter-spacing: 0.5rem;
    width: 120px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.password-input-group input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.password-hint {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin-top: 0.5rem;
    font-style: italic;
}

/* 解鎖後的內容 */
.unlocked-content {
    animation: fadeIn 0.3s ease;
}

.management-controls {
    margin-bottom: 15px;
    display: flex;
    gap: 10px;
}

.stores-editor {
    width: 100%;
    height: 400px;
    padding: 15px;
    border: 2px solid var(--color-border-light);
    border-radius: 6px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
    resize: vertical;
    background: var(--color-container-bg);
    color: var(--color-text-primary);
    transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.stores-format-hint {
    background: var(--color-container-bg);
    padding: 15px;
    border-radius: 6px;
    margin-top: 15px;
    transition: background 0.3s ease;
}

.stores-format-hint h4 {
    margin-bottom: 10px;
    color: var(--color-text-secondary);
}

.stores-format-hint pre {
    background: var(--color-section-bg);
    padding: 15px;
    border-radius: 4px;
    font-size: 0.85em;
    overflow-x: auto;
    color: var(--color-text-primary);
    transition: background 0.3s ease, color 0.3s ease;
}

/* ==================== 主題選擇器樣式 ==================== */
.top-right-controls {
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    z-index: 9999 !important;
    display: flex;
    gap: 10px;
    align-items: center;
}

.help-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--color-container-bg);
    border: 2px solid var(--color-primary);
    border-radius: 50%;
    font-size: 1.3em;
    text-decoration: none;
    box-shadow: var(--shadow-card);
    transition: all 0.3s ease;
}

.help-btn:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-container);
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.theme-selector {
    display: flex;
    align-items: center;
}

.theme-selector-btn {
    background: var(--color-container-bg);
    border: 2px solid var(--color-primary);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    box-shadow: var(--shadow-card);
    transition: all 0.3s ease;
}

.theme-selector-btn:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-container);
}

.theme-panel {
    position: absolute;
    top: 55px;
    right: 0;
    background: var(--color-container-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-container);
    padding: 15px;
    min-width: 280px;
    display: none;
    border: 1px solid var(--color-border-light);
}

.theme-panel.active {
    display: block;
    animation: slideIn 0.3s ease;
}

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

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

@keyframes slideDown {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
}

.theme-panel h3 {
    margin: 0 0 15px 0;
    font-size: 1em;
    color: var(--color-text-primary);
    border-bottom: 2px solid var(--color-primary);
    padding-bottom: 8px;
}

.theme-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.theme-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.theme-option:hover {
    background: var(--color-section-bg);
    border-color: var(--color-primary);
}

.theme-option.active {
    background: var(--color-table-row-hover);
    border-color: var(--color-primary);
}

.theme-preview {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1em;
}

.theme-info {
    flex: 1;
}

.theme-name {
    font-weight: 600;
    font-size: 0.95em;
    color: var(--color-text-primary);
}

.theme-desc {
    font-size: 0.8em;
    color: var(--color-text-muted);
}

.theme-sasa { background: linear-gradient(135deg, #E6007E 0%, #FF1493 100%); color: #fff; }
.theme-minimal { background: #374151; color: #fff; }
.theme-dark { background: linear-gradient(135deg, #1a1b26 0%, #2a2e3f 100%); color: #fff; }

/* ==================== 響應式設計 ==================== */
@media (max-width: 1200px) {
    .filter-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 1100px) {
    .stores-selector-layout {
        grid-template-columns: 1fr;
    }
    
    .selector-right-panel {
        position: relative;
        top: 0;
        order: -1;
    }
    
    .selector-right-panel .om-stores-panel {
        min-height: 300px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    header h1 {
        font-size: 1.5em;
    }
    
    main {
        padding: 15px;
    }
    
    .section {
        padding: 15px;
    }
    
    /* 雙欄佈局響應式 */
    .selector-left-panel {
        padding: 15px;
    }
    
    .selector-right-panel .om-stores-panel {
        min-height: 250px;
    }
    
    /* 篩選區域響應式 */
    .category-filters {
        gap: 12px;
    }
    
    .filter-group {
        padding: 12px;
    }
    
    .filter-buttons {
        gap: 6px;
    }
    
    .filter-btn {
        padding: 6px 12px;
        font-size: 0.8em;
    }
    
    /* 店鋪組別響應式 */
    .store-group-btn {
        padding: 8px 16px;
        min-width: 45px;
    }
    
    /* OM 按鈕響應式 */
    .om-filter-buttons {
        gap: 8px;
    }
    
    .om-filter-btn {
        padding: 10px 14px;
        min-width: 75px;
    }
    
    .om-filter-btn .om-name {
        font-size: 0.9em;
    }
    
    .om-filter-btn .om-count {
        font-size: 0.75em;
    }
    
    /* OM 面板響應式 */
    .om-stores-grid {
        grid-template-columns: 1fr;
    }
    
    .om-stores-summary {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    /* 店鋪列表響應式 */
    .stores-container {
        grid-template-columns: 1fr;
        padding: 15px;
    }
    
    .store-item {
        padding: 10px 12px;
    }
    
    .stores-layout {
        grid-template-columns: 1fr;
    }
    
    .matrix-container {
        grid-template-columns: 1fr;
    }
    
    .results-controls {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        text-align: center;
    }
    
    .next-step-hint {
        width: 100%;
        margin-top: 10px;
    }
    
    .theme-selector,
    .top-right-controls {
        top: 10px;
        right: 10px;
    }
    
    .top-right-controls {
        gap: 8px;
    }
    
    .help-btn,
    .theme-selector-btn {
        width: 40px;
        height: 40px;
        font-size: 1.1em;
    }
    
    .theme-panel {
        right: -10px;
        min-width: 260px;
    }
    
    /* 控制欄響應式 */
    .filter-controls .button-group {
        padding: 12px 15px;
    }
    
    .store-count {
        font-size: 0.85em;
        padding: 8px 12px;
    }
}

/* ==================== 滾動條美化 ==================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-scrollbar-track);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--color-scrollbar-thumb);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-scrollbar-thumb-hover);
}

/* ==================== 打印樣式 ==================== */
@media print {
    body {
        background: white;
        padding: 0;
    }
    
    .container {
        box-shadow: none;
    }
    
    .btn,
    .filter-controls,
    .matrix-controls,
    .management-controls,
    .stores-management-section,
    .theme-selector,
    .top-right-controls {
        display: none !important;
    }
    
    .section {
        break-inside: avoid;
    }
}

/* ==================== OM 營運經理篩選樣式 ==================== */
.om-filter-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    padding: 5px;
}

.om-filter-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 20px;
    min-width: 90px;
    border: 2px solid #e2e8f0;
    background: white;
    color: var(--color-text-primary);
    border-radius: 14px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    line-height: 1.4;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
    position: relative;
    overflow: hidden;
}

.om-filter-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.om-filter-btn:hover {
    border-color: var(--color-primary);
    background: white;
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.25);
}

.om-filter-btn:hover::before {
    opacity: 1;
}

.om-filter-btn.active {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: var(--color-text-light);
    border-color: transparent;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
    transform: translateY(-2px);
}

.om-filter-btn.active::before {
    opacity: 0;
}

.om-filter-btn .om-name {
    font-size: 1em;
    font-weight: 700;
}

.om-filter-btn .om-count {
    font-size: 0.8em;
    opacity: 0.7;
    margin-top: 4px;
    font-weight: 500;
    padding: 2px 8px;
    background: rgba(0,0,0,0.05);
    border-radius: 10px;
}

.om-filter-btn.active .om-count {
    opacity: 0.95;
    background: rgba(255,255,255,0.2);
}

/* OM 店鋪清單面板 */
.om-stores-panel {
    margin-top: 20px;
    background: var(--color-container-bg);
    border: none;
    border-radius: 16px;
    overflow: hidden;
    animation: slideDown 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 20px 40px rgba(0,0,0,0.12);
}

.om-stores-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: var(--color-text-light);
}

.om-stores-header h4 {
    margin: 0;
    font-size: 1.1em;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.close-om-panel {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: var(--color-text-light);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.3em;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close-om-panel:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1) rotate(90deg);
}

.om-stores-content {
    padding: 20px;
    max-height: 450px;
    overflow-y: auto;
}

.om-stores-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
}

.om-store-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    transition: all 0.25s ease;
}

.om-store-item:hover {
    background: white;
    border-color: var(--color-primary);
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.om-store-code {
    font-family: 'SF Mono', monospace;
    font-size: 0.8em;
    font-weight: 600;
    color: white;
    background: var(--color-text-secondary);
    padding: 4px 8px;
    border-radius: 6px;
    min-width: 50px;
    text-align: center;
}

.om-store-name {
    flex: 1;
    font-size: 0.95em;
    color: var(--color-text-primary);
    font-weight: 500;
}

.om-store-badges {
    display: flex;
    gap: 5px;
}

.om-store-badge {
    font-size: 0.7em;
    padding: 3px 6px;
    border-radius: 4px;
    font-weight: 700;
}

.om-empty-message {
    text-align: center;
    color: var(--color-text-muted);
    padding: 40px;
    font-style: italic;
    font-size: 1.05em;
}

.om-stores-summary {
    margin-top: 20px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95em;
    border: 1px solid #e2e8f0;
}

.om-stores-summary .total-count {
    font-weight: 700;
    color: var(--color-primary);
    font-size: 1.1em;
}

/* ==================== OM 彙總表格樣式 ==================== */
.om-summary-container {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid var(--color-border-medium);
}

.om-summary-container h3 {
    color: var(--color-primary);
    margin-bottom: 10px;
}

.percentage-bar {
    position: relative;
    height: 22px;
    background: var(--color-border-light);
    border-radius: 11px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.percentage-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    border-radius: 11px;
    transition: width 0.5s ease;
    box-shadow: 0 0 8px rgba(102, 126, 234, 0.4);
}

.percentage-bar span {
    position: relative;
    z-index: 1;
    font-size: 12px;
    font-weight: bold;
    color: var(--color-text-primary);
    text-shadow: 0 1px 2px rgba(255,255,255,0.8);
}

.category-detail-row {
    background: var(--color-section-bg) !important;
}

.category-detail-row:hover {
    background: var(--color-section-bg) !important;
}

.category-tags {
    padding: 10px 15px;
    text-align: center;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

.om-badge {
    display: inline-block;
    margin: 2px;
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.om-badge-a {
    background: rgba(76, 175, 80, 0.2);
    color: var(--color-category-a);
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.om-badge-b {
    background: rgba(33, 150, 243, 0.2);
    color: var(--color-category-b);
    border: 1px solid rgba(33, 150, 243, 0.3);
}

.om-badge-c {
    background: rgba(255, 152, 0, 0.2);
    color: var(--color-category-c);
    border: 1px solid rgba(255, 152, 0, 0.3);
}

.om-badge-d {
    background: rgba(244, 67, 54, 0.2);
    color: var(--color-category-d);
    border: 1px solid rgba(244, 67, 54, 0.3);
}

/* ==================== 分頁導航 ==================== */
.tab-navigation {
    display: flex;
    gap: 0;
    padding: 0 30px;
    background: var(--color-section-bg);
    border-bottom: 2px solid var(--color-border-light);
}

.tab-btn {
    padding: 14px 28px;
    border: none;
    background: transparent;
    color: var(--color-text-secondary);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.25s ease;
    position: relative;
    top: 2px;
}

.tab-btn:hover {
    color: var(--color-primary);
    background: rgba(102, 126, 234, 0.06);
}

.tab-btn.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    background: transparent;
}

.tab-panel {
    display: none;
}

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

/* ==================== 快速報表 (Quick Report) ==================== */
.qr-section {
    padding: 24px 30px;
}

.qr-section > h2 {
    margin-bottom: 4px;
}

.qr-section > .hint {
    margin-bottom: 20px;
    color: var(--color-text-muted);
}

/* 工具列 */
.qr-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 18px;
    background: var(--color-section-bg);
    border: 1px solid var(--color-border-light);
    border-radius: 10px;
    margin-bottom: 16px;
}

.qr-toolbar-left,
.qr-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.qr-divider {
    display: inline-block;
    width: 1px;
    height: 22px;
    background: var(--color-border-medium);
    margin: 0 4px;
}

.qr-filter-btn {
    padding: 6px 14px;
    border: 1px solid var(--color-border-medium);
    border-radius: 6px;
    background: var(--color-container-bg);
    color: var(--color-text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.qr-filter-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.qr-filter-btn.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.qr-select {
    padding: 6px 12px;
    border: 1px solid var(--color-border-medium);
    border-radius: 6px;
    background: var(--color-container-bg);
    color: var(--color-text-primary);
    font-size: 13px;
    cursor: pointer;
    min-width: 120px;
}

.qr-selected-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-primary);
    white-space: nowrap;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-lg {
    padding: 10px 24px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* 表格 */
.qr-table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--color-border-light);
    border-radius: 10px;
    margin-bottom: 20px;
}

.qr-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    white-space: nowrap;
}

.qr-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--color-table-header-bg);
    color: var(--color-table-header-text);
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 12.5px;
    border-bottom: 2px solid var(--color-primary-dark);
}

.qr-th-check {
    width: 40px;
    text-align: center !important;
}

.qr-th-ss {
    min-width: 100px;
}

.qr-table tbody tr {
    transition: background 0.15s ease;
}

.qr-table tbody tr:nth-child(even) {
    background: var(--color-table-row-even);
}

.qr-table tbody tr:hover {
    background: var(--color-table-row-hover);
}

.qr-table tbody tr.qr-row-hidden {
    display: none;
}

.qr-table tbody td {
    padding: 8px 14px;
    border-bottom: 1px solid var(--color-border-light);
}

.qr-table tbody td:first-child {
    text-align: center;
}

.qr-table tbody td.qr-cell-ss {
    font-weight: 700;
    color: var(--color-primary);
    text-align: center;
}

.qr-table tbody td.qr-cell-qty {
    font-weight: 600;
    text-align: center;
}

.qr-table tbody td.qr-cell-carry {
    text-align: center;
}

.qr-table tfoot td {
    padding: 10px 14px;
    font-weight: 700;
    background: var(--color-highlight);
    border-top: 2px solid var(--color-primary);
    font-size: 14px;
}

.qr-row-unchecked td {
    opacity: 0.4;
}

/* 底部統計面板 */
.qr-summary-panel {
    margin-top: 8px;
}

.qr-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.qr-stat-card {
    background: var(--color-section-bg);
    border: 1px solid var(--color-border-light);
    border-radius: 10px;
    padding: 16px 20px;
    text-align: center;
}

.qr-stat-card.qr-stat-highlight {
    background: var(--color-highlight);
    border-color: var(--color-primary);
}

.qr-stat-label {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

.qr-stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--color-text-primary);
}

.qr-stat-highlight .qr-stat-value {
    color: var(--color-primary-dark);
}

/* 彙總摺疊 */
.qr-details {
    margin-bottom: 12px;
}

.qr-details summary {
    cursor: pointer;
    padding: 10px 16px;
    background: var(--color-section-bg);
    border: 1px solid var(--color-border-light);
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    color: var(--color-text-primary);
    user-select: none;
}

.qr-details summary:hover {
    background: var(--color-table-row-hover);
}

.qr-details[open] summary {
    border-radius: 8px 8px 0 0;
    border-bottom: none;
}

.qr-sub-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    border: 1px solid var(--color-border-light);
    border-top: none;
    border-radius: 0 0 8px 8px;
    overflow: hidden;
}

.qr-sub-table thead th {
    background: var(--color-table-header-bg);
    color: var(--color-table-header-text);
    padding: 8px 12px;
    font-size: 12px;
    text-align: center;
    font-weight: 600;
}

.qr-sub-table tbody td {
    padding: 7px 12px;
    text-align: center;
    border-bottom: 1px solid var(--color-border-light);
}

.qr-sub-table tbody tr:nth-child(even) {
    background: var(--color-table-row-even);
}

.qr-sub-table tbody tr.qr-sub-total {
    background: var(--color-highlight);
    font-weight: 700;
}

/* 區域/舖類 badge (快速報表) */
.qr-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
}

.qr-badge-hk { background: var(--color-region-hk); }
.qr-badge-mo { background: var(--color-region-mo); }
.qr-badge-a  { background: var(--color-category-a); }
.qr-badge-b  { background: var(--color-category-b); }
.qr-badge-c  { background: var(--color-category-c); }
.qr-badge-d  { background: var(--color-category-d); }

/* ==================== 對照表預覽樣式 ==================== */

.matrix-preview-section {
    margin-top: 30px;
    padding: 20px;
    background: var(--color-section-bg);
    border-radius: 12px;
    border-left: 5px solid var(--color-primary);
}

.matrix-preview-section h3 {
    color: var(--color-text-primary);
    margin-bottom: 20px;
    font-size: 1.3em;
}

.matrix-tables-wrapper {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (min-width: 1400px) {
    .matrix-tables-wrapper {
        grid-template-columns: 1fr 1fr;
    }
}

.preview-table {
    background: var(--color-container-bg);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    overflow: hidden;
}

.preview-table th {
    background: var(--color-footer-bg);
    font-weight: 600;
    color: var(--color-text-primary);
}

.matrix-cell-preview {
    font-weight: 600;
    font-size: 1.05em;
    padding: 10px;
    border: 1px solid var(--color-border-light);
    background: var(--color-container-bg);
    color: var(--color-text-primary);
    transition: background 0.2s;
}

.matrix-cell-preview {
    border-color: var(--color-border-light) !important;
}

/* 區域分隔樣式 */
.matrix-region {
    background: var(--color-container-bg);
    border-radius: 8px;
    padding: 15px;
    border: 1px solid var(--color-border-light);
}

.region-title {
    margin: 0 0 15px 0;
    padding: 10px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 1.1em;
}

.region-title.region-hk {
    background: linear-gradient(135deg, rgba(233, 30, 99, 0.1), rgba(233, 30, 99, 0.05));
    color: var(--color-region-hk);
}

.region-title.region-mo {
    background: linear-gradient(135deg, rgba(0, 188, 212, 0.1), rgba(0, 188, 212, 0.05));
    color: var(--color-region-mo);
}

/* 對照表摘要樣式 */
.matrix-summary-box {
    background: var(--color-container-bg);
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid var(--color-highlight);
    margin-top: 20px;
}

.matrix-summary-box h4 {
    margin-top: 0;
    color: var(--color-text-primary);
    margin-bottom: 15px;
}

.summary-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: var(--color-section-bg);
    border-radius: 6px;
    border: 1px solid var(--color-border-light);
}

.summary-item.highlight {
    background: linear-gradient(135deg, var(--color-highlight) 0%, rgba(255, 152, 0, 0.1) 100%);
    border-color: var(--color-highlight);
    font-weight: 600;
}

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

.summary-value {
    color: var(--color-text-primary);
    font-weight: 600;
    font-size: 1.05em;
}

/* 列印時對照表預覽 */
@media print {
    .matrix-preview-section {
        break-inside: avoid;
        border: none;
        background: none;
        padding: 0;
    }
    
    .matrix-cell-preview {
        padding: 8px;
    }
}

