/* ========================================= */
/* 📱 響應式字體設定 (依螢幕寬度自動縮放)       */
/* ========================================= */

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent; 
}

@media (max-width: 380px) {
    html { font-size: 14px; }
}

@media (max-width: 340px) {
    html { font-size: 13px; }
}

@media (min-width: 600px) {
    html { font-size: 18px; }
}

/* ========================================= */

:root {
    --bg-main: #121212;
    --card-bg: #1e1e1e;
    --input-bg: #2d2d2d;
    --text-main: #ffffff;
    --text-sub: #b0b0b0;
    --primary: #2196f3;
    --primary-dark: #1976d2;
    --success: #4caf50;
    --danger: #f44336;
    --warning: #ff9800;
    --border: #444;
    --cal-active: #1b3a2b;
    --shadow: 0 4px 15px rgba(0,0,0,0.3);
    --navbar-height: 70px;
    --marquee-height: 36px;
}

body.light-mode {
    --bg-main: #f5f5f5;
    --card-bg: #ffffff;
    --input-bg: #f0f0f0;
    --text-main: #333333;
    --text-sub: #666666;
    --border: #ddd;
    --cal-active: #e8f5e9;
    --shadow: 0 4px 15px rgba(0,0,0,0.1);
}

body { 
    font-family: -apple-system, "Noto Sans TC", sans-serif; 
    background: var(--bg-main);
    color: var(--text-main);
    margin: 0;
    box-sizing: border-box;
    padding-top: env(safe-area-inset-top); 
    padding-bottom: calc(var(--navbar-height) + var(--marquee-height) + env(safe-area-inset-bottom) + 20px); 
    min-height: 100vh;
    overscroll-behavior-y: none;
    -webkit-tap-highlight-color: transparent;
}

button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    outline: none;
    touch-action: manipulation; 
}

/* 平台抽成欄位 - 鮮明紅色 */
#editFee, #addFee {
    background-color: transparent !important;
    color: #ff0000 !important;
    font-weight: bold;
    border: 1px solid #ffcccc !important;
    opacity: 1 !important; 
    -webkit-text-fill-color: #ff0000 !important;
}
body.light-mode #editFee, body.light-mode #addFee {
    background-color: #ffecec !important;
}

#addNet, #editNet {
    background: var(--input-bg);
    border: 1px solid var(--success);
    color: var(--success);
    text-align: center;
    transition: all 0.2s;
}
#addNet:focus, #editNet:focus {
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.3);
}

input[type="color"] {
    padding: 0; border: none; background: none; height: 40px; cursor: pointer;
}

.dynamic-input-group {
    display: flex; align-items: center; gap: 5px; width: 100%;
}
.unit-symbol {
    color: var(--text-sub); font-weight: bold; font-size: 1.1rem; flex-shrink: 0;
}

.card { 
    background: var(--card-bg); 
    border-radius: 20px; 
    padding: 20px; 
    margin-bottom: 15px; 
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}

h2, h3 { margin-top: 0; font-weight: 600; }
.hidden { display: none !important; }

input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

input, select { 
    width: 100%; padding: 14px; 
    background: var(--input-bg); 
    border: 1px solid var(--border); 
    border-radius: 12px; 
    color: var(--text-main); 
    font-size: 1rem; 
    margin: 8px 0;
    box-sizing: border-box;
    outline: none;
    transition: border 0.2s;
}
input:focus, select:focus { border-color: var(--primary); }

input[type="date"] { position: relative; padding-right: 10px; }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); cursor: pointer; }
body.light-mode input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0); }

input[type="tel"].date-input-tw { letter-spacing: 1px; }

.btn { 
    width: 100%; padding: 16px; 
    border: none; border-radius: 12px; 
    font-size: 1.1rem; font-weight: bold; 
    cursor: pointer; transition: 0.2s;
    margin-top: 5px;
    display: flex; justify-content: center; align-items: center;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-sub); margin-top: 10px; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; width: auto; margin: 0; }
.btn-share { box-shadow: 0 4px 6px rgba(0,0,0,0.2); font-size: 1.5rem; }

.tag-group { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 15px; padding-bottom: 5px;}
.tag-btn { 
    background: var(--input-bg); color: var(--text-sub); 
    padding: 8px 15px; border-radius: 20px; font-size: 0.9rem; 
    white-space: nowrap; cursor: pointer; border: 1px solid transparent;
}
.tag-btn.active { background: var(--input-bg); color: var(--primary); border-color: var(--primary); }

.progress-group { margin-top: 15px; }
.progress-label { display: flex; justify-content: space-between; font-size: 0.85rem; margin-bottom: 5px; color: var(--text-sub); }
.progress-track { background: var(--input-bg); height: 10px; border-radius: 5px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 5px; transition: width 0.5s ease; }

.timer-container { position: relative; display: flex; justify-content: center; align-items: center; margin: 15px 0; }
.timer { font-size: 3.2rem; font-weight: 700; text-align: center; color: var(--primary); font-variant-numeric: tabular-nums; }

.inline-edit-btn {
    cursor: pointer; color: var(--text-sub); font-size: 1.1rem;
    padding: 5px; border-radius: 5px; transition: background 0.2s;
}
.inline-edit-btn:active { background: rgba(255,255,255,0.1); }

.time-edit-wrapper { display: flex; align-items: center; justify-content: center; gap: 10px; }
.time-input-group { display: flex; flex-direction: column; align-items: center; width: 80px; }
.time-input-group input { text-align: center; font-size: 1.5rem; padding: 10px; }
.time-input-group span { font-size: 0.8rem; color: var(--text-sub); margin-top: 2px; }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 15px 0; }
.stat-box { background: var(--input-bg); padding: 15px; border-radius: 15px; text-align: center; }
.stat-label { font-size: 0.8rem; color: var(--text-sub); margin-bottom: 5px; }
.stat-value { font-size: 1.3rem; font-weight: bold; }

/* 🔥 新增：可點擊的統計方塊 (如總單量) */
.stat-box[onclick] {
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
}
.stat-box[onclick]:active {
    transform: scale(0.96);
    background-color: var(--border);
}

.marquee-container {
    position: fixed; bottom: var(--navbar-height); left: 0; width: 100%; height: var(--marquee-height);
    background: #000; color: #fff; overflow: hidden; white-space: nowrap; z-index: 998;
    display: flex; align-items: center; border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -2px 5px rgba(0,0,0,0.2);
}
body.light-mode .marquee-container { background: #e0e0e0; color: #000; }
.marquee-content { display: inline-block; padding-left: 100%; animation: scroll-left 15s linear infinite; font-size: 0.9rem; font-weight: bold; }
@keyframes scroll-left { 0% { transform: translateX(0); } 100% { transform: translateX(-100%); } }

.navbar { 
    position: fixed; bottom: 0; left: 0; width: 100%; height: var(--navbar-height);
    background: var(--card-bg); display: flex; 
    border-top: 1px solid var(--border); z-index: 1000; 
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}
.nav-item { 
    flex: 1; text-align: center; padding: 10px 0; 
    font-size: 0.75rem; color: var(--text-sub); cursor: pointer; max-width: 20%;
}
.nav-item i { display: block; font-size: 1.3rem; margin-bottom: 4px; font-style: normal; }
.nav-item.active { color: var(--primary); }

.list-group-header {
    background: var(--input-bg); padding: 8px 12px; border-radius: 8px;
    margin-top: 15px; margin-bottom: 5px; display: flex;
    justify-content: space-between; align-items: center;
    font-size: 0.9rem; color: var(--text-sub);
}
.list-item { 
    display: flex; justify-content: space-between; align-items: center; 
    padding: 12px 5px; border-bottom: 1px solid var(--border); 
}
.list-item:last-child { border-bottom: none; }

/* --- 平台管理列表專用樣式 --- */
.plat-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 0; border-bottom: 1px solid var(--border);
}
.plat-info { flex: 1; margin-left: 10px; }
.plat-controls { display: flex; align-items: center; gap: 8px; }
.btn-sort {
    background: var(--input-bg); border: 1px solid var(--border);
    color: var(--text-sub); width: 28px; height: 28px;
    border-radius: 5px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 0.8rem;
}
.btn-sort:active { background: var(--border); }

.cal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-top: 5px; }
.cal-head-day { text-align: center; font-size: 0.8rem; color: var(--text-sub); margin-bottom: 5px;}
.cal-empty { min-height: 45px; pointer-events: none; }
.cal-day { 
    background: var(--input-bg); padding: 6px 2px; text-align: center; 
    border-radius: 8px; font-size: 0.9rem; cursor: pointer; min-height: 45px;
    display: flex; flex-direction: column; justify-content: center;
}
.cal-day.active { background: var(--cal-active); border: 1px solid var(--success); }
.cal-day.selected { border: 2px solid var(--primary); }
.cal-amt { color: var(--success); font-size: 0.65rem; display: block; margin-top: 2px; }

/* 🔥 Modal 樣式修正 (修復疊加問題 + 滑動優化) */
.modal-overlay { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(0,0,0,0.8); z-index: 2000; 
    display: none; align-items: center; justify-content: center; 
    backdrop-filter: blur(5px); 
}
/* 確保編輯平台跳窗在最上層 */
#editPlatModal { z-index: 3000 !important; }
#addIncomeModal { z-index: 2000 !important; }

/* 🔥 更新：Modal 加入滑動優化屬性 */
.modal { 
    background: var(--card-bg); width: 85%; max-width: 350px; padding: 25px; 
    border-radius: 20px; text-align: center; 
    max-height: 85vh; /* 增加高度限制 */
    overflow-y: auto; overflow-x: hidden; /* X軸禁止滑動 */
    box-shadow: 0 10px 30px rgba(0,0,0,0.5); 
    -webkit-overflow-scrolling: touch; /* iOS 慣性滑動優化 */
    overscroll-behavior: contain;      /* 防止滑動傳遞給背景 */
}

#toast { position: fixed; bottom: 150px; left: 50%; transform: translateX(-50%); background: #fff; color: #000; padding: 10px 20px; border-radius: 20px; opacity: 0; transition: 0.3s; pointer-events: none; z-index: 10001; font-weight: bold; box-shadow: 0 5px 15px rgba(0,0,0,0.3); }
#toast.show { opacity: 1; }

.switch { position: relative; display: inline-block; width: 40px; height: 20px; }
.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; border-radius: 20px; }
.slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 2px; bottom: 2px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--success); }
input:checked + .slider:before { transform: translateX(20px); }

#settleDrawer { 
    position: fixed; bottom: 0; left: 0; width: 100%; 
    background: var(--card-bg); border-radius: 25px 25px 0 0; 
    padding: 30px 20px; box-sizing: border-box; z-index: 2001; 
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); transform: translateY(100%); 
    box-shadow: 0 -5px 20px rgba(0,0,0,0.3);
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
}
#settleDrawer.show { transform: translateY(0); }

#offlineIndicator {
    position: fixed; top: env(safe-area-inset-top); right: 10px; 
    background: var(--warning); color: #000; font-size: 0.7rem; 
    padding: 2px 8px; border-radius: 10px; z-index: 9999; 
    display: none; font-weight: bold; margin-top: 5px;
}
#offlineIndicator.show { display: block; }

.changelog-item { margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.changelog-item:last-child { border-bottom: none; }
.changelog-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.version-tag { background: var(--primary); color: white; padding: 2px 8px; border-radius: 5px; font-size: 0.8rem; font-weight: bold; }
.version-date { font-size: 0.8rem; color: var(--text-sub); }
.changelog-item ul { padding-left: 20px; margin: 0; color: var(--text-sub); font-size: 0.9rem; }
.changelog-item li { margin-bottom: 4px; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.install-guide { margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--border); text-align: center; }
.guide-item {
    background: var(--input-bg); border-radius: 12px; padding: 12px;
    margin-bottom: 10px; font-size: 0.9rem; color: var(--text-sub);
    text-align: left; display: flex; flex-direction: column;
}
.guide-title { font-weight: bold; color: var(--text-main); margin-bottom: 5px; font-size: 1rem; }
.guide-content { line-height: 1.5; }
.icon-symbol { display: inline-block; background: #444; color: #fff; padding: 0 6px; border-radius: 4px; font-size: 1.1rem; margin: 0 2px; }

.feedback-item { background: var(--input-bg); border-radius: 12px; padding: 10px; margin-bottom: 10px; }
.feedback-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.feedback-msg { font-size: 0.9rem; line-height: 1.4; word-break: break-all; }
.feedback-msg.user { color: var(--text-main); }
.feedback-reply-container { margin-top: 8px; padding-left: 10px; border-left: 2px solid var(--primary); }
.feedback-msg.admin { background: #2c3e50; color: #fff; padding: 8px; border-radius: 8px; font-size: 0.9rem; }
.status-badge { font-size: 0.7rem; padding: 2px 6px; border-radius: 4px; font-weight: bold; color: white; }
.status-pending { background: var(--text-sub); }
.status-replied { background: var(--success); }
.status-closed { background: var(--danger); }

.date-display-text { font-size: 1rem; font-weight: bold; color: var(--text-main); padding: 5px 10px; }

.backup-link-container { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.backup-btn {
    display: block; width: 100%; padding: 10px; box-sizing: border-box;
    background: var(--input-bg); color: var(--primary); border: 1px solid var(--primary);
    border-radius: 10px; text-decoration: none; font-weight: bold; text-align: center;
    transition: 0.2s; font-size: 0.9rem;
}
.backup-btn:hover { background: var(--primary); color: white; }

/* ========================================================= */
/* 🔥 Chat Room Style                                        */
/* ========================================================= */

#chatFab {
    position: fixed;
    bottom: calc(var(--navbar-height) + var(--marquee-height) + env(safe-area-inset-bottom) + 20px);
    right: 20px;
    width: 60px; height: 60px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    font-size: 1.8rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    z-index: 2000;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.3s;
}
#chatFab:active { transform: scale(0.9); }
#chatFab.hidden { display: none; }

@keyframes popIn {
  0% { transform: scale(0); opacity: 0; }
  80% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

#chatBadge {
    position: absolute; top: -5px; right: -5px;
    background: var(--danger); color: white;
    min-width: 20px; height: 20px; padding: 2px;
    border-radius: 10px;
    font-size: 0.75rem;
    display: flex; justify-content: center; align-items: center;
    font-weight: bold;
    border: 2px solid var(--bg-main);
    z-index: 2001;
}

#chatWindow {
    position: fixed;
    bottom: calc(var(--navbar-height) + var(--marquee-height) + env(safe-area-inset-bottom) + 85px);
    right: 20px;
    width: 320px; height: 450px;
    background: var(--card-bg);
    border-radius: 15px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.5);
    z-index: 9999;
    display: flex; flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border);
    animation: slideInUp 0.3s;
}

@media (max-width: 480px) {
    #chatWindow {
        right: 0; left: 0; bottom: 0; top: 0;
        width: 100%; height: 100%;
        border-radius: 0;
        border: none;
    }
}
#chatWindow.hidden { display: none; }

.chat-header {
    background: var(--primary); color: white; font-weight: bold;
    display: flex; justify-content: space-between; align-items: center;
    padding-top: calc(15px + env(safe-area-inset-top)); 
    padding-bottom: 15px; padding-left: 20px; padding-right: 20px;
}

#chatContent {
    flex: 1; padding: 15px; overflow-y: auto;
    display: flex; flex-direction: column; gap: 10px;
    background: var(--bg-main); padding-bottom: 30px;
}

.msg-bubble {
    max-width: 75%; padding: 10px 14px; border-radius: 15px;
    font-size: 0.95rem; line-height: 1.4; position: relative; word-wrap: break-word;
}
.msg-bubble.me { align-self: flex-end; background: var(--primary); color: white; border-bottom-right-radius: 2px; }
.msg-bubble.admin { align-self: flex-start; background: var(--input-bg); color: var(--text-main); border: 1px solid var(--border); border-bottom-left-radius: 2px; }
.msg-time { font-size: 0.65rem; color: rgba(255,255,255,0.7); text-align: right; margin-top: 4px; }
.msg-bubble.admin .msg-time { color: var(--text-sub); }

.chat-input-area {
    padding: 10px; background: var(--card-bg); border-top: 1px solid var(--border);
    display: flex; gap: 10px; padding-bottom: calc(10px + env(safe-area-inset-bottom));
}
.chat-input-area input { margin: 0; }
.chat-input-area button { width: auto; margin: 0; padding: 0 20px; border-radius: 10px; }

@keyframes slideInUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ========================================= */
/* 🔥 卡片式平台按鈕 (首頁/Onboarding通用)    */
/* ========================================= */

.platform-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
    padding: 4px; 
}

.platform-card {
    position: relative;
    cursor: pointer;
    user-select: none;
    margin: 0;
    touch-action: manipulation; 
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s;
}

.platform-card:active { transform: scale(0.96); }
.platform-card input[type="checkbox"] { position: absolute; opacity: 0; cursor: pointer; height: 0; width: 0; }

.plat-card-content {
    background: var(--input-bg);
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 15px 5px;
    text-align: center;
    transition: background 0.5s ease, border 0.2s; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    height: 100%;
    min-height: 90px;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    box-sizing: border-box;
    position: relative;
    z-index: 1;
    overflow: hidden;
    background-size: 100% 100%; 
    background-repeat: no-repeat;
}

.plat-name { font-size: 0.95rem; font-weight: bold; color: var(--text-main); margin-bottom: 6px; line-height: 1.3; text-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.plat-fee { 
    font-size: 0.9rem; 
    font-weight: 800; 
    color: #ffffff; 
    background: rgba(255,255,255,0.1); 
    padding: 4px 10px; 
    border-radius: 10px; 
    margin-top: 4px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.platform-card input:checked + .plat-card-content {
    border-color: var(--primary);
    background-color: rgba(33, 150, 243, 0.1);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.25);
}
.platform-card input:checked + .plat-card-content .plat-name { color: var(--primary); }

.check-icon {
    position: absolute; top: 6px; right: 6px; color: var(--primary);
    font-size: 1.1rem; opacity: 0; transform: scale(0); transition: 0.2s;
}
.platform-card input:checked + .plat-card-content .check-icon { opacity: 1; transform: scale(1); }

.color-dot {
    width: 10px; height: 10px; border-radius: 50%;
    margin-bottom: 8px; background: #888; transition: 0.2s;
    box-shadow: 0 0 3px rgba(0,0,0,0.3);
}

/* ========================================= */
/* 🔢 內建數字鍵盤樣式 (FastTouch優化)        */
/* ========================================= */

.numpad-container { margin-top: 15px; padding-top: 15px; border-top: 1px solid var(--border); }
.numpad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.num-btn {
    background: var(--input-bg); color: var(--text-main);
    font-size: 1.5rem; font-weight: bold; padding: 15px 0;
    border-radius: 12px; text-align: center; cursor: pointer;
    user-select: none; -webkit-user-select: none; touch-action: manipulation;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: transform 0.05s, background-color 0.1s; 
}
.num-btn:active { background-color: var(--border); transform: scale(0.92); }

.num-btn.action {
    background: rgba(244, 67, 54, 0.1); color: var(--danger);
    font-size: 1.2rem; display: flex; align-items: center; justify-content: center;
}
.num-btn.cancel { background: var(--danger); color: white; font-size: 1.1rem; }
.num-btn.submit { background: var(--primary); color: white; font-size: 1.1rem; }

.input-active {
    border: 2px solid var(--primary) !important;
    background-color: rgba(33, 150, 243, 0.1) !important;
    box-shadow: 0 0 10px rgba(33, 150, 243, 0.4);
    transition: all 0.2s;
}

/* ========================================= */
/* 📊 熱力圖 (Treemap) & Loading             */
/* ========================================= */

#treemapContainer {
    width: 100%; height: 250px; position: relative; 
    border-radius: 12px; overflow: hidden; margin-top: 10px;
}
.treemap-item {
    position: absolute; display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    color: #fff; font-weight: bold;
    border: 1px solid rgba(0,0,0,0.2); box-sizing: border-box;
    transition: all 0.3s ease; overflow: hidden; text-align: center; padding: 2px;
}
.tm-label {
    font-size: 0.9rem; text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; z-index: 2;
}
.tm-value {
    font-size: 0.75rem; opacity: 0.9; text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    margin-top: 2px; z-index: 2;
}
.treemap-item.small .tm-value { display: none; }
.treemap-item.tiny .tm-label { font-size: 0.7rem; }
.hidden-chart { display: none !important; }

#loadingOverlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(0,0,0,0.85); z-index: 99999; 
    display: flex; flex-direction: column; align-items: center; justify-content: center; 
    color: var(--text-main); font-size: 1.2rem; backdrop-filter: blur(5px);
}
#loadingText { margin-top: 20px; font-weight: bold; letter-spacing: 1px; animation: pulse 1.5s infinite; }
@keyframes pulse { 0% { opacity: 0.6; } 50% { opacity: 1; } 100% { opacity: 0.6; } }

/* ========================================= */
/* 🔥 新增樣式：動態規則列與模式按鈕           */
/* ========================================= */

/* 規則列外框 */
.rule-row {
    transition: transform 0.2s, opacity 0.2s;
    animation: fadeIn 0.3s ease;
}

/* 讓手機上的輸入框不會太小 */
.rule-row input[type="text"], 
.rule-row input[type="number"] {
    font-size: 1rem; padding: 8px;
}
.rule-row select {
    padding: 8px; font-size: 0.9rem; height: 40px;
}

/* 混合模式輸入框置中 */
.mix-fix, .mix-pct { text-align: center; }

/* 記帳跳窗中的「模式選擇按鈕」 */
#modeSelectorArea .tag-btn {
    padding: 8px 16px;
    font-size: 0.95rem;
    transition: all 0.2s;
}

/* ========================================= */
/* 🔒 強制背景鎖定 (配合 JS)                 */
/* ========================================= */

body.body-locked {
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
    left: 0;
}

/* 確保 Modal 內部依然可以順暢滑動 */
.modal {
    max-height: 80vh;        
    overflow-y: auto;        
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch; 
    overscroll-behavior: contain;      
}