/* --- 基礎設定與拖曳效果 --- */
body { margin: 0; padding: 0; display: flex; height: 100dvh !important; height: 100vh; background-color: #f1f5f9; overflow: hidden; -webkit-overflow-scrolling: touch; }
.sortable-drag { opacity: 0.5 !important; background: white !important; box-shadow: none !important; cursor: grabbing; touch-action: none !important; -webkit-user-select: none !important; user-select: none !important; }
.sortable-ghost { opacity: 0.2; background-color: #e2e8f0; border: 2px dashed #94a3b8; touch-action: none !important; -webkit-user-select: none !important; user-select: none !important; }
.is-choosing { transform: scale(1.05) !important; border: 2px solid #3b82f6 !important; box-shadow: 0 10px 20px rgba(59, 130, 246, 0.2) !important; transition: transform 0.5s linear, border 0.5s ease-in, box-shadow 1s linear !important; z-index: 9998; touch-action: none !important; -webkit-user-select: none !important; user-select: none !important; }
#mandatory-zone .metrics-grid > div { touch-action: pan-y !important; -webkit-user-select: none !important; -webkit-touch-callout: none !important; }

/* --- Sidebar 左側選單 --- */
.sidebar { width: 280px; background-color: #1e293b; color: white; display: flex; flex-direction: column; flex-shrink: 0; transition: width 0.3s ease; z-index: 999; white-space: nowrap; overflow: hidden; height: 100vh; }
.sidebar.collapsed { width: 70px; }
.sidebar-header { height: 60px; display: flex; align-items: center; padding: 0 20px; border-bottom: 1px solid #334155; justify-content: space-between; position: relative; z-index: 10; }
.logo-text { font-weight: bold; font-size: 24px; color: #60a5fa; transition: opacity 0.2s; overflow: hidden; cursor:pointer; }
.sidebar.collapsed .logo-text { opacity: 0; width: 0; }
.toggle-btn { background: none; border: none; color: white; font-size: 20px; cursor: pointer; padding: 5px 10px; transition: background 0.2s; flex-shrink: 0; }
.toggle-btn:hover { background-color: rgba(255, 255, 255, 0.1); border-radius: 4px; }
.menu-container { padding: 10px; overflow-y: auto; flex: 1; }
.menu-group-title { font-size: 12px; color: #64748b; margin: 15px 0 5px 10px; font-weight: bold; text-transform: uppercase; }
.sidebar.collapsed .menu-group-title { display: none; }
.menu-level-1 { display: flex; align-items: center; justify-content: space-between; padding: 12px 15px; cursor: pointer; color: #cbd5e1; border-radius: 8px; margin-bottom: 2px; transition: background 0.2s; font-weight: bold; font-size: 16px; padding-left: 30px; }
.menu-level-1:hover { background-color: #334155; color: white; }
.menu-level-1 .arrow { transition: transform 0.2s; font-size: 12px; }
.menu-level-1.expanded .arrow { transform: rotate(90deg); }
.sidebar.collapsed .menu-level-1 .arrow { display: none; }
.menu-level-2-container { margin-left: 15px; border-left: 2px solid #475569; padding-left: 10px; display: none; }
.menu-level-2-container.show { display: block; }
.sidebar.collapsed .menu-level-2-container { display: none; }
.menu-level-2 { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; cursor: pointer; color: #94a3b8; border-radius: 6px; margin-bottom: 2px; transition: background 0.2s; font-size: 16px; }
.menu-level-2:hover { background-color: rgba(255, 255, 255, 0.05); color: white; }
.menu-level-2 .arrow { transition: transform 0.2s; font-size: 10px; }
.menu-level-2.expanded .arrow { transform: rotate(90deg); }
.menu-level-3-container { margin-left: 10px; padding-left: 8px; border-left: 1px solid #475569; display: none; }
.menu-level-3-container.show { display: block; }
.menu-item { display: flex; align-items: center; padding: 12px 15px; cursor: pointer; color: #cbd5e1; border-radius: 8px; margin-bottom: 2px; transition: background 0.2s; }
.menu-item:hover { background-color: #334155; color: white; }
.menu-icon { font-size: 18px; min-width: 30px; text-align: center; }
.menu-text { margin-left: 10px; transition: opacity 0.2s; }
.sidebar.collapsed .menu-text { opacity: 0; display: none; }
.submenu { margin-left: 10px; border-left: 1px solid #475569; padding-left: 5px; }
.sidebar.collapsed .submenu { display: none; }
.draggable-container { margin-bottom: 2px; }
.draggable-source {
    width: 100%;
    white-space: normal;
    font-size: 16px;
    padding: 8px 12px;
    cursor: grab;
    color: #94a3b8;
    display: flex;
    align-items: center;
    border-radius: 4px;
    margin-bottom: 2px;
    user-select: none;
    position: relative;
}
.draggable-source:hover { color: white; background: rgba(255, 255, 255, 0.05); }
    .draggable-source::before {
        content: "⠿";
        margin-right: 8px;
        color: #475569;
        font-size: 10px;
    }

/* --- Top Bar & User Dropdown --- */
.top-bar { height: 60px; background: white; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; justify-content: space-between; padding: 0 30px; flex-shrink: 0; }
.user-profile-wrapper { display: flex; align-items: center; gap: 12px; position: relative; }
.user-info { display: flex; align-items: center; gap: 15px; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; cursor:pointer; background-color: var(--bg-color, #9370DB); display: flex; align-items: center; justify-content: center; color: white; font-weight: bold; }
.avatar-container { position: relative; display: inline-block; }
.user-dropdown { display: none; position: absolute; top: 50px; right: 0; background: white; border: 1px solid #e2e8f0; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); z-index: 1000; min-width: 100px; padding: 5px 0; }
.user-dropdown.show { display: block; }
.user-dropdown::before { content: ""; position: absolute; top: -11px; right: 12px; width: 0; height: 0; border-width: 0 10px 11px 10px; border-style: solid; border-color: transparent transparent #e2e8f0 transparent; }
.user-dropdown::after { content: ""; position: absolute; top: -10px; right: 13px; width: 0; height: 0; border-width: 0 9px 10px 9px; border-style: solid; border-color: transparent transparent #ffffff transparent; }
.dropdown-item {
    width: 100%;
    border: none;
    background: none;
    padding: 5px 20px;
    color: #3e3e3e;
    cursor: pointer;
    font-weight: 600;
    font-size: 17px;
    text-align: center;
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
}
.dropdown-item:hover { background-color: #95a824; color:#fff; }
.user-name { font-weight: 500; color: #334155; text-align: right; padding: 0 10px; }
.user-role { font-size: 13px; color: #64748b; }

/* --- Main Content & Grid --- */
.tasks-badge {
    position: relative;
    display: flex;
    align-items: center;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s;
    justify-content: flex-end;
    gap: 5px;
}
.tasks-badge:hover { background: #f1f5f9; }
.tasks-count { background: #ef4444; color: white; padding: 2px 6px; border-radius: 20px; font-size: 11px; min-width: 18px; text-align: center; }
.main-content { flex: 1; display: flex; flex-direction: column; height: 100%; position: relative; background-color: #f1f5f9; transition: margin-left 0.3s; }
.content-scroll-area { padding: 20px; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.section-title { font-size: 18px; font-weight: bold; color: #334155; margin-bottom: 15px; display: flex; align-items: center; margin-top: 20px; justify-content: space-between; }
.section-hint { font-size: 13px; font-weight: normal; color: #64748b; margin-left: 10px; background: #e2e8f0; padding: 4px 8px; border-radius: 12px; }
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; min-height: 120px; padding: 5px; }
.empty-placeholder { border: 2px dashed #cbd5e1; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: #94a3b8; font-size: 14px; height: 100%; width: 100%; grid-column: 1 / -1; padding: 20px; background: rgba(255, 255, 255, 0.5); }
.card { background: white; border-radius: 12px; padding: 20px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05); cursor: move; border-top: 5px solid #e2e8f0; position: relative; display: flex; flex-direction: column; justify-content: space-between; user-select: none; height: 150px; }
.card:hover { transform: translateY(-3px); box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1); }
.card.alert { border-top-color: #ef4444; }
.card.warning { border-top-color: #f59e0b; }
.card.safe { border-top-color: #10b981; }
.card.info { border-top-color: #3b82f6; }
.card-icon { font-size: 24px; margin-bottom: 10px; }
.card-number { font-size: 36px; font-weight: bold; color: #334155; line-height: 1; margin-bottom: 5px; }
.card.alert .card-number { color: #ef4444; }
.card-title { color: #64748b; font-size: 15px; font-weight: 500; text-wrap-mode: nowrap; }
.delete-btn { position: absolute; top: 10px; right: 10px; color: #cbd5e1; cursor: pointer; display: block; width: 20px; height: 20px; text-align: center; line-height: 20px; border-radius: 50%; }
.delete-btn:hover { background: #fee2e2; color: #ef4444; }
.card.locked .delete-btn { display: none !important; }
.card.locked::after { content: "🔒"; position: absolute; top: 10px; right: 10px; font-size: 14px; opacity: 0.5; }

/* --- Side Drawer --- */
.side-drawer { position: fixed; top: 0; right: -700px; width: 600px; height: 100vh; background: white; box-shadow: -5px 0 25px rgba(0, 0, 0, 0.15); transition: right 0.3s; z-index: 1000; display: flex; flex-direction: column; }
.side-drawer.open { right: 0; }
.drawer-header { padding: 20px; border-bottom: 1px solid #e2e8f0; display: flex; justify-content: space-between; align-items: center; }
.drawer-title { margin: 0; font-size: 20px; color: #334155; }
.drawer-close { border: none; background: none; font-size: 24px; cursor: pointer; color: #64748b; }
.drawer-content { padding: 20px; overflow-y: auto; flex: 1; }
.task-group { margin-bottom: 30px; }
.task-group-title { font-size: 16px; font-weight: bold; color: #334155; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 2px solid #e2e8f0; }
.task-item { padding: 12px 15px; margin-bottom: 8px; background: #f8fafc; border-radius: 8px; border-left: 3px solid var(--bl-color, #3b82f6); cursor: pointer; transition: all 0.2s; }
.task-item:hover { background: #e0f2fe; transform: translateX(5px); }
.task-item-title { font-size: 14px; color: #334155; margin-bottom: 4px; }
.task-item-date { font-size: 12px; color: #64748b; }

/* --- Metrics Grid Waterfall --- */
.metrics-grid {
    column-width: 350px;
    column-gap: 20px;
    width: 100% 1262px;
    padding: 10px 0;
    display: grid;
    align-items: start;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
}
.metric-card { break-inside: avoid; display: block; width: 100%; min-height:350px;margin-bottom: 20px; background: #ffffff; border-radius: 12px; padding: 20px; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05); border: 1px solid #e2e8f0; }
.metric-card-content { background: #ffffff; border-radius: 12px; padding: 20px; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05); border: 1px solid #e2e8f0; }
.metric-card {
    display: flex;
    flex-direction: column;
    grid-row: span 2;
}
.metric-card.is-long { grid-row: span 3; }
.metric-card.is-short { grid-row: span 1; }
.metric-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.metric-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.metric-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; transition: var(--transition); }
.revenue-card .metric-icon { background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, rgba(139, 92, 246, 0.2) 100%); color: var(--revenue-color); }
.trend-badge { display: flex; align-items: center; gap: 4px; padding: 6px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.trend-badge.positive { background: rgba(16, 185, 129, 0.1); color: var(--positive-color); }
.trend-badge.negative { background: rgba(239, 68, 68, 0.1); color: var(--negative-color); }
.metric-content { margin-bottom: 16px; }
.metric-value { font-size: 32px; font-weight: 800; color: var(--text-primary); margin-bottom: 4px; letter-spacing: -1px; }
.metric-label { font-size: clamp(10px, 4cqw, 16px); color: var(--text-tertiary); font-weight: 500; }
.progress-bar { height: 8px; background: var(--bg-tertiary); border-radius: 10px; overflow: hidden; margin-bottom: 12px; }
.progress-fill { height: 100%; border-radius: 10px; transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1); width: 0; }
.revenue-progress { background: var(--gradient-purple); }
.users-progress { background: var(--gradient-blue); }
.conversion-progress { background: var(--gradient-orange); }
.orders-progress { background: var(--gradient-green); }
.metric-footer { font-size: 12px; color: var(--text-tertiary); font-weight: 500; }
.tag-container { width: 60%; }

/* --- Root Variables & Custom Grid --- */
:root { --bg-primary: #f0f4f8; --bg-secondary: #ffffff; --bg-tertiary: #f8fafc; --text-primary: #0f172a; --text-secondary: #475569; --text-tertiary: #94a3b8; --border-color: #e2e8f0; --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05); --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08); --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.1); --revenue-color: #8b5cf6; --users-color: #3b82f6; --conversion-color: #f59e0b; --orders-color: #10b981; --positive-color: #10b981; --negative-color: #ef4444; --gradient-purple: linear-gradient(135deg, #667eea 0%, #764ba2 100%); --gradient-blue: linear-gradient(135deg, #667eea 0%, #3b82f6 100%); --gradient-orange: linear-gradient(135deg, #f59e0b 0%, #f97316 100%); --gradient-green: linear-gradient(135deg, #10b981 0%, #059669 100%); --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.item-list { height :35px; padding:0; }
.dashboard-custom-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; padding: 20px; width: 100%; box-sizing: border-box; align-self: flex-start; transition: all 0.3s ease; border: 1px solid #e1e1e1; border-radius: 5px; }
.tag-container { width: 280px; background: #fff; padding: 15px; display: flex; height: 80px; align-items: center; justify-content: space-around; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); border-radius: 5px; }
.tag-container:hover { transform: translateY(-4px); cursor: pointer; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1); }
.tag-icon { width: 50px; height: 50px; display: flex; justify-content: center; align-items: center; border-radius: 5px; margin-right: 10px; background-color: var(--tag-bg-color, #ff00e81c); color: var(--tag-text-color, #ff82f4); }
.path-name { width: 250px; }
.controls { position: relative; top: 0; right: 0; display: flex; padding: 10px 10px; gap: 0px; z-index: 10; }
.controls button { background: none; border: none; cursor: pointer; color: #64748b; transition: transform 0.2s; }
.controls button:hover { color: #3b82f6; transform: scale(1.1); }

/* --- List Mode (35px) --- */
.dashboard-custom-grid.is-list { display: grid !important; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px !important; padding: 10px !important; max-width: 100%; }
.dashboard-custom-grid.is-list .tag-container { width: 100% !important; height: 35px !important; min-height: 35px !important; padding: 0px !important; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05) !important; display: flex; align-items: center; overflow: hidden; }
.dashboard-custom-grid.is-list .tag-icon { width: 40px !important; height: 100% !important; margin-right: 8px !important; font-size: 16px !important; flex-shrink: 0; }
.dashboard-custom-grid.is-list .path-name { width: auto !important; flex: 1; font-size: 14px; line-height: 35px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dashboard-btn { font-size: 15px; width: 100px; text-align: center; background: #fff; border-radius: 5px; margin: 0 5px; padding: 0 5px; }

/* --- Modal Layout & Hover Details --- */
.modal-backdrop { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.4); display: flex; align-items: center; justify-content: center; z-index: 9999; }
.modal-container { background: #fff; width: 90%; max-width: 1000px; height: 80%; border-radius: 12px; padding: 24px; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1); display: flex; flex-direction: column; position: relative; box-sizing: border-box; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-shrink: 0; }
.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e293b;
    align-items: center;
    gap:10px;
    display:flex;
}
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #94a3b8; }
.modal-alert { background: #fff9db; border: 1px solid #ffe066; padding: 12px 16px; border-radius: 8px; display: flex; gap: 12px; margin-bottom: 16px; flex-shrink: 0; }
.alert-text { font-size: 0.85rem; color: #856404; line-height: 1.5; }
.modal-hint { font-size: 0.85rem; color: #64748b; margin-bottom: 20px; flex-shrink: 0; }
.modal-selection-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)); gap: 16px; flex-grow: 1; overflow-y: auto; overflow-x: visible; padding: 10px 10px 250px 10px; margin: 0 -10px; scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }
.selection-item { position: relative; width: 100%; z-index: 1; }
.selection-item:hover { z-index: 50; }
.selection-content {
    display: flex;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    background: #fff;
    transition: all 0.2s ease;
    height: 100%;
    box-sizing: border-box;
    position: relative;
    flex-direction: column;
}
.card-checkbox { position: absolute; top: 14px; right: 14px; width: 18px; height: 18px; z-index: 10; }
.card-checkbox:checked + .selection-content { border-color: #3b82f6; background-color: #eff6ff; }
.hover-details { position: absolute; top: -2px; left: -2px; width: calc(100% + 4px); height: auto; min-height: calc(100% + 4px); background: #ffffff !important; border-radius: 12px; padding: 24px; box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2); border: 2px solid #3b82f6; visibility: hidden; opacity: 0; pointer-events: none; transition: opacity 0.2s ease; box-sizing: border-box; z-index: 100; }
.selection-item:hover .hover-details { visibility: visible; opacity: 1; pointer-events: auto; }
.selection-item.locked {
    background-color: #f1f5f9;
    pointer-events: none;
    cursor: not-allowed;
    /* 通常還會搭配 pointer-events，讓它完全無法點擊 */
    pointer-events: none;
    opacity: 0.6; /* 讓視覺看起來更像被禁用 */
}
.selection-item.locked .selection-content { background-color: #f8fafc; border-color: #cbd5e1; pointer-events: none; }
.lock-tag { position: absolute; top: 12px; right: 12px; font-size: 0.7rem; color: white; padding: 2px 6px; border-radius: 4px; }
.card-badge { display: inline-block; background: #ecfdf5; color: #10b981; padding: 4px 8px; border-radius: 4px; font-size: 0.7rem; margin-left: 24px; }
.card-main-val { font-size: 1.5rem; font-weight: 700; color: #1e293b; margin: 12px 0 4px; }
.card-sub-label { font-size: 0.85rem; color: #64748b; margin-bottom: 12px; }
.card-footer-info {
    font-size: 0.75rem;
    border-top: 1px solid #f1f5f9;
    padding-top: 8px;
    color: #475569;
    margin-top: 10px;
    border-top: 1px solid #eee;
    position: relative;
    cursor:pointer;
}
.details-header {
    font-weight: 600;
    color: #4A4A4A;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 30px;
}
.details-header-bk {
    display: flex;
    align-items: center;
    width: 100%;
    margin: 0px;
    padding: 0px;
    background: linear-gradient(to right, #adbdc252, #99a6363b);
    position: absolute;
    top: 0px;
    left: 0;
    font-weight: 600;
    border-radius: 10px 10px 0 0;
}
.purple-icon {
    font-size: 20px;
    background: #f3e8ff;
    color: #7e22ce;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-weight: bold;
    margin-right: 10px;
}
.reload-btn:hover svg { stroke: #3b82f6; transform: rotate(180deg); }
.reload-btn:active { transform: scale(0.9); }
.details-body {
    flex-grow: 1; /* 讓內容區塊自動延伸，也是一種置底方式 */
    padding: 0px 10px;
    border-top: 1px solid #eee;
    padding-top: 8px;
}
.detail-group { display: flex; justify-content: space-between; align-items: center; width: 100%; overflow: hidden; }
.detail-val {
    font-family: Helvetica;
    font-weight: 600;
    font-size: 1.4rem;
    color: #555555; /* 舒適黑 */
    white-space: nowrap;
}
.detail-lab {
    color: #555555; /* 降低標籤標題亮度，突出數值 */
    font-size: 1.4rem;
}
.dept_ui {
    font-size: 23px;
    font-weight: 600;
}
.red-text { color: #ef4444 !important; }
.setting-item {
    display: flex;
    justify-content: flex-start;
    border-bottom: 1px solid #ececec;
    padding: 15px 0;
}
.setting-label {
    width: 200px;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    flex-direction: column;
}
.setting-val-block {
    display: flex;
    flex-direction: column;
}
.setting-no-allowed {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}
.time-detail {
    display: flex;
    flex-direction: column;
}
/* --- Footer & Buttons --- */
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid #f1f5f9;
    background: #fff;
    flex-shrink: 0;
    z-index: 1000;
}
.btn-secondary { padding: 8px 16px; border: 1px solid #e2e8f0; background: white; border-radius: 6px; cursor: pointer; }
.btn-primary { padding: 8px 16px; background: #3b82f6; color: white; border: none; border-radius: 6px; cursor: pointer; }



.swal2-container {
    z-index: 99999 !important;
}

#custom-zone.loading {
    position: relative;
    pointer-events: none; /* 禁止操作 */
    opacity: 0.6; /* 可選：變淡 */
}

    /* loading 覆蓋層 */
    #custom-zone.loading::before {
        content: "";
        position: absolute;
        inset: 0;
        background: rgba(255, 255, 255, 0.4);
        z-index: 10;
    }

    /* spinner */
    #custom-zone.loading::after {
        content: "";
        position: absolute;
        top: 50%;
        left: 50%;
        width: 28px;
        height: 28px;
        transform: translate(-50%, -50%);
        border: 3px solid #ccc;
        border-top-color: #3b82f6;
        border-radius: 50%;
        animation: spin 0.8s linear infinite;
        z-index: 11;
    }

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}


/* =========================
   backdrop（遮罩層）
========================= */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px; /* ⭐關鍵：避免貼邊被切 */
    box-sizing: border-box;
    overflow: hidden;
}

.modal-container {
    width: 100%;
    max-width: 900px; /* 桌機最大寬度 */
    max-height: 90vh;
    height: 80vh;
    background: #fff;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box; /* ⭐避免 padding 撐爆 */
}

/* =========================
   header（固定）
========================= */
.modal-header {
    flex: 0 0 auto;
    padding: 16px 20px;
    border-bottom: 1px solid #ececec;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* =========================
   body（可滾動區）
========================= */
.modal-body {
    flex: 1; /* ⭐關鍵：撐滿中間 */
    overflow-y: auto; /* ⭐只有這裡滾動 */

    padding: 20px;
}

/* =========================
   footer（固定）
========================= */
.modal-footer {
    flex: 0 0 auto;
    padding: 12px 20px;
    border-top: 1px solid #ececec;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* =========================
   小螢幕優化
========================= */
/* 小螢幕 */
@media (max-width: 768px) {
    .modal-container {
        width: 100%; /* ⭐不要用 95vw（容易造成微溢出） */
        height: 90vh;
        border-radius: 10px;
    }

    .modal-backdrop {
        padding: 8px; /* 小螢幕更保守 */
    }
}
