:root {
    /* 高級莫蘭迪森林綠與奢華金配色系統 */
    --primary-color: #2D5B45;       /* 森林綠 */
    --primary-light: #4A8265;       /* 亮綠 */
    --primary-dark: #1E3F30;        /* 深綠 */
    --accent-color: #D4A359;        /* 莫蘭迪金 */
    --accent-orange: #C25E3A;       /* 珊瑚橘 */
    --bg-base: #F8F6F0;             /* 質感燕麥奶油底色 */
    --bg-card: rgba(255, 255, 255, 0.85); /* 玻光感卡片背景 */
    --text-primary: #1C2B24;        /* 深墨綠文字 */
    --text-secondary: #5C6E65;      /* 灰綠副文字 */
    --border-color: rgba(45, 91, 69, 0.12); /* 細邊框 */
    
    --success: #3E8E41;
    --danger: #D9534F;
    --line-color: #06C755;          /* LINE 品牌綠 */
    
    --border-radius-lg: 16px;
    --border-radius-md: 12px;
    --border-radius-sm: 8px;
    
    --shadow-soft: 0 8px 30px rgba(28, 43, 36, 0.04);
    --shadow-medium: 0 12px 40px rgba(28, 43, 36, 0.08);
    --shadow-glass: 0 8px 32px 0 rgba(45, 91, 69, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Outfit', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-base);
    background-image: 
        radial-gradient(at 0% 0%, rgba(212, 163, 89, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(45, 91, 69, 0.05) 0px, transparent 50%);
    color: var(--text-primary);
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

a:hover {
    color: var(--primary-light);
}

/* ==================== 頁首 Header ==================== */
.app-header {
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0.8rem 0;
}

.header-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 1.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
    font-size: 1.4rem;
    color: var(--primary-color);
}

.logo-icon {
    font-size: 1.5rem;
    color: var(--accent-color);
}

.logo-text {
    letter-spacing: -0.5px;
}

.user-profile-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: rgba(45, 91, 69, 0.06);
    padding: 0.3rem 0.6rem;
    border-radius: 50px;
    border: 1px solid rgba(45, 91, 69, 0.05);
}

.avatar-img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid var(--primary-color);
}

.user-name-text {
    font-size: 0.85rem;
    font-weight: 600;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.btn-logout-icon {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.2rem;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
}

.btn-logout-icon:hover {
    opacity: 0.7;
}

/* ==================== 內容區 Main Content ==================== */
.content {
    flex: 1;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 1.5rem 1.2rem 3rem 1.2rem;
}

/* ==================== 頁尾 Footer ==================== */
.app-footer {
    background-color: transparent;
    color: var(--text-secondary);
    text-align: center;
    padding: 1.5rem 0;
    font-size: 0.8rem;
    border-top: 1px solid rgba(45, 91, 69, 0.05);
}

/* ==================== 卡片樣式 Card ==================== */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.45);
    box-shadow: var(--shadow-glass);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary-color);
    opacity: 0;
    transition: opacity 0.3s;
}

.card:hover {
    box-shadow: var(--shadow-medium);
}

/* ==================== 按鈕樣式 Buttons ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.7rem 1.4rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--border-radius-md);
    border: none;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

.btn-icon-left {
    margin-right: 0.5rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: #fff;
    box-shadow: 0 4px 12px rgba(45, 91, 69, 0.2);
}

.btn-primary:hover {
    background-color: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(45, 91, 69, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-outline {
    background-color: transparent;
    border: 1.5px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover {
    background-color: rgba(45, 91, 69, 0.05);
}

.btn-line {
    background-color: var(--line-color);
    color: #fff;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(6, 199, 85, 0.25);
}

.btn-line:hover {
    background-color: #05b04b;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(6, 199, 85, 0.35);
}

.btn-full {
    display: flex;
    width: 100%;
}

.btn-large {
    padding: 0.9rem 1.8rem;
    font-size: 1.1rem;
    border-radius: var(--border-radius-lg);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    border-radius: var(--border-radius-sm);
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

/* ==================== 首頁 UI - 未登入 Hero 介紹 ==================== */
.brand-hero {
    margin-bottom: 2.5rem;
}

.hero-icon {
    font-size: 3.5rem;
    color: var(--accent-color);
    margin-bottom: 1.2rem;
    display: inline-block;
}

.hero-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary-dark);
    margin-bottom: 0.8rem;
    letter-spacing: -0.5px;
}

.hero-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.features-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.8rem;
    margin-bottom: 3rem;
}

.feature-item {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(45, 91, 69, 0.05);
    border-radius: var(--border-radius-md);
    padding: 1rem 0.5rem;
}

.feature-icon {
    font-size: 1.4rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.feature-item h4 {
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
    color: var(--text-primary);
}

.feature-item p {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ==================== 首頁 UI - 已登入列表 ==================== */
.welcome-banner {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: #fff;
    border: none;
}

.welcome-banner::before {
    display: none;
}

.welcome-info h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
    color: #fff;
}

.welcome-info p {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
}

.highlight-text {
    color: var(--accent-color);
}

.section-header {
    margin: 2rem 0 1rem 0;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.title-icon {
    font-size: 1.2rem;
    color: var(--accent-color);
}

/* 專案卡片網格 */
.project-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.project-card {
    background: var(--bg-card);
    cursor: pointer;
    border-left: 4px solid var(--primary-color);
    padding: 1.2rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.project-card::before {
    display: none;
}

.project-card:hover {
    transform: translateX(4px);
    border-left-color: var(--accent-color);
}

.project-info h4 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.project-code-tag {
    font-size: 0.75rem;
    background: rgba(212, 163, 89, 0.12);
    color: #9d7031;
    font-family: monospace;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
}

.project-action-arrow {
    color: var(--primary-color);
    font-size: 1.1rem;
    opacity: 0.6;
    transition: transform 0.2s;
}

.project-card:hover .project-action-arrow {
    transform: translateX(3px);
    opacity: 1;
}

.no-data-hint {
    text-align: center;
    padding: 2.5rem 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.no-data-icon {
    font-size: 2.5rem;
    color: rgba(45, 91, 69, 0.15);
    margin-bottom: 0.8rem;
    display: block;
}

/* ==================== 專案詳情頁 UI ==================== */
.project-header-card {
    border-left: 4px solid var(--primary-color);
}

.project-header-card::before {
    display: none;
}

.project-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.2rem;
}

.project-name {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-dark);
}

.invite-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(212, 163, 89, 0.08);
    padding: 0.6rem 1rem;
    border-radius: var(--border-radius-md);
    margin-bottom: 1.2rem;
    border: 1px dashed rgba(212, 163, 89, 0.3);
}

.invite-label {
    font-size: 0.85rem;
    color: var(--text-primary);
}

.invite-code {
    font-family: monospace;
    font-size: 1.05rem;
    color: var(--primary-color);
    letter-spacing: 0.5px;
}

.section-sub {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 0.4rem;
}

/* 頭像堆疊 Avatar Stack */
.avatar-stack {
    display: flex;
    align-items: center;
    padding-left: 6px;
}

.avatar-stack-item {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #fff;
    margin-left: -6px;
    object-fit: cover;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: transform 0.2s;
    background: #fff;
}

.avatar-stack-item:hover {
    transform: translateY(-4px) scale(1.1);
    z-index: 10;
}

/* ==================== 智能結算卡片與 Tab ==================== */
.settlement-card {
    padding: 0;
}

.tabs-header {
    display: flex;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 0.9rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.25s;
    border-bottom: 3.5px solid transparent;
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: rgba(45, 91, 69, 0.02);
}

.tab-content {
    display: none;
    padding: 1.2rem;
}

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

/* 最少轉帳列表 */
.settlement-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.settlement-item {
    display: flex;
    align-items: center;
    background: rgba(45, 91, 69, 0.03);
    border-radius: var(--border-radius-md);
    padding: 0.8rem 1rem;
    border: 1px solid rgba(45, 91, 69, 0.04);
}

.party-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 32%;
}

.party-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid var(--primary-light);
    margin-bottom: 0.2rem;
    background: #fff;
}

.party-name {
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.arrow-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.transact-amount {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--accent-orange);
    font-family: 'Outfit', sans-serif;
    margin-bottom: 0.15rem;
}

.arrow-line {
    width: 80%;
    height: 1.5px;
    background: var(--text-secondary);
    position: relative;
    opacity: 0.4;
}

.arrow-line::after {
    content: '';
    position: absolute;
    right: 0;
    top: -3.5px;
    width: 0;
    height: 0;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-left: 6px solid var(--text-secondary);
}

/* 成員收支淨額列表 */
.balances-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.balance-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.2rem;
    border-bottom: 1px solid rgba(45, 91, 69, 0.04);
}

.balance-item:last-child {
    border-bottom: none;
}

.balance-user-info {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.balance-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.balance-name {
    font-size: 0.9rem;
    font-weight: 600;
}

.balance-value-box {
    text-align: right;
}

.balance-label-hint {
    font-size: 0.7rem;
    color: var(--text-secondary);
    display: block;
}

.balance-num {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 1rem;
}

.balance-num.plus {
    color: var(--success);
}

.balance-num.minus {
    color: var(--danger);
}

.balance-num.zero {
    color: var(--text-secondary);
}

/* ==================== 費用明細紀錄 ==================== */
.cost-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cost-item {
    display: flex;
    gap: 0.8rem;
    position: relative;
    padding: 1.2rem;
}

.cost-category-icon-box {
    width: 42px;
    height: 42px;
    background: rgba(45, 91, 69, 0.08);
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-size: 1.2rem;
    flex-shrink: 0;
}

.cost-info-body {
    flex: 1;
    display: flex;
    justify-content: space-between;
}

.cost-detail {
    display: flex;
    flex-direction: column;
}

.cost-main-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.15rem;
}

.cost-meta-info {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.cost-split-preview {
    font-size: 0.75rem;
    background: rgba(45, 91, 69, 0.04);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--primary-dark);
}

.cost-financial {
    text-align: right;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
}

.cost-total-amount {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text-primary);
}

/* 已集中於下方重新定義 .btn-delete-cost */

/* ==================== 現代輸入表單 Modern Form ==================== */
.modern-form {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0; /* 防止子元素（如原生時間控制項）在 Grid / Flex 中強行撐開容器 */
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
}

.input-with-icon {
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

.input-icon {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    opacity: 0.6;
    font-size: 0.95rem;
}

.modern-form input[type="text"],
.modern-form input[type="number"],
.modern-form input[type="datetime-local"],
.modern-form select,
.modern-form textarea {
    width: 100%;
    padding: 0.7rem 0.9rem 0.7rem 2.2rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-md);
    background-color: rgba(255, 255, 255, 0.8);
    font-size: 0.95rem;
    outline: none;
    color: var(--text-primary);
    font-family: inherit;
    transition: all 0.25s;
}

/* 原生 datetime-local 優化：保持高度一致、自適應點擊、美化行動端圖標 */
.modern-form input[type="datetime-local"] {
    display: block;
    width: 100%;
    min-height: 2.38rem; /* 確保 iOS Safari 與普通 input 高度完美一致 */
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    -webkit-appearance: none; /* 重置 iOS Safari 特有的預設外觀限制 */
    appearance: none;
}

/* 解決 iOS/Safari 原生 datetime-local 內部 shadow DOM 計算寬度過大而溢出的問題 */
.modern-form input[type="datetime-local"]::-webkit-datetime-edit {
    display: inline-block;
    padding: 0;
}

.modern-form input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.65;
    transition: opacity 0.2s;
}

.modern-form input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

.modern-form textarea {
    padding: 0.7rem 0.9rem;
    resize: none;
}

.modern-form input:focus,
.modern-form select:focus,
.modern-form textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(45, 91, 69, 0.1);
    background-color: #fff;
}

.form-row-2 {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.8rem;
}

.form-row-3 {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.8rem;
}

.input-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ==================== 彈窗樣式 Modal ==================== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    background-color: rgba(28, 43, 36, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.modal-content {
    background-color: #fff;
    margin: 2rem auto;
    max-width: 520px;
    width: 90%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-medium);
    padding: 0;
    border-radius: var(--border-radius-lg);
    animation: modal-fade-in 0.24s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    color: var(--primary-color);
}

.close-modal {
    color: var(--text-secondary);
    font-size: 1.8rem;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
}

.close-modal:hover {
    color: var(--danger);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.8rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* ==================== 費用分配區 (Allocation) ==================== */
.allocation-section {
    background: rgba(45, 91, 69, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 1.1rem;
    margin-top: 0.5rem;
}

.allocation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.9rem;
}

.allocation-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
}

.allocation-mode-selector {
    display: flex;
    background: rgba(45, 91, 69, 0.06);
    padding: 0.2rem;
    border-radius: var(--border-radius-sm);
}

.mode-btn {
    background: none;
    border: none;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 0.35rem 0.7rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn.active {
    background: #fff;
    color: var(--primary-color);
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.allocation-alert {
    background: rgba(194, 94, 58, 0.1);
    border: 1px solid rgba(194, 94, 58, 0.2);
    color: var(--accent-orange);
    padding: 0.5rem 0.8rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--border-radius-sm);
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.allocation-members-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-height: 200px;
    overflow-y: auto;
}

.alloc-member-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.2rem;
}

.alloc-member-left {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.alloc-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.alloc-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.alloc-name {
    font-size: 0.85rem;
    font-weight: 600;
}

.alloc-input-box {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.alloc-amount-input {
    width: 75px !important;
    text-align: right;
    padding: 0.3rem 0.5rem !important;
    border-radius: 6px !important;
    font-size: 0.85rem !important;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
}

.alloc-input-unit {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* 照片選擇與預覽 UI */
.receipt-photos-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-top: 0.6rem;
    align-items: center;
}

.receipt-photos-preview-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.photo-preview-item {
    position: relative;
    width: 68px;
    height: 68px;
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border: 1px solid rgba(45, 91, 69, 0.1);
}

.photo-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-preview-item .btn-remove-photo {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(217, 83, 79, 0.9);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    font-size: 0.65rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    line-height: 1;
}

.photo-preview-item .btn-remove-photo:hover {
    background: rgba(217, 83, 79, 1);
}

.photo-picker-item {
    width: 68px;
    height: 68px;
    border: 1.5px dashed var(--primary-color);
    border-radius: var(--border-radius-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    cursor: pointer;
    background: rgba(45, 91, 69, 0.02);
    transition: all 0.2s;
}

.photo-picker-item:hover {
    background: rgba(45, 91, 69, 0.06);
    border-color: var(--primary-light);
    color: var(--primary-light);
}

/* 費用歷史卡片中的編輯與刪除按鈕排版 */
.cost-action-row {
    display: flex;
    gap: 0.6rem;
    margin-top: 0.4rem;
}

/* ==================== 費用歷史卡片中的編輯與刪除按鈕美化 ==================== */
.btn-edit-cost {
    background: none;
    border: none;
    color: #4a7c59; /* 溫潤莫蘭迪綠 */
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0.25rem 0.4rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    border-radius: 4px;
    white-space: nowrap; /* 防止折行 */
    flex-shrink: 0;
}

.btn-edit-cost:hover {
    color: #2d5b45;
    background-color: rgba(74, 124, 89, 0.08);
    text-decoration: underline;
    transform: scale(1.05);
}

.btn-delete-cost {
    background: none;
    border: none;
    color: #e27c65; /* 高雅珊瑚橘 */
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0.25rem 0.4rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    border-radius: 4px;
    white-space: nowrap; /* 防止折行 */
    flex-shrink: 0;
}

.btn-delete-cost:hover {
    color: #c75a43;
    background-color: rgba(226, 124, 101, 0.08);
    text-decoration: underline;
    transform: scale(1.05);
}

/* ==================== 智能分帳幣別切換 Tab 樣式 ==================== */
.currency-tabs-list {
    display: flex;
    gap: 0.5rem;
    padding: 0.6rem 0.8rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    margin-bottom: 0.6rem;
    overflow-x: auto;
    scrollbar-width: none; /* Firefox */
}
.currency-tabs-list::-webkit-scrollbar {
    display: none; /* Safari & Chrome */
}

.currency-tab-btn {
    background: none;
    border: none;
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px 6px 0 0;
    border-bottom: 3px solid transparent;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.currency-tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: rgba(45, 91, 69, 0.04);
}

/* ==================== 費用歷史篩選排序控制面板 ==================== */
.filter-card {
    padding: 1rem;
    margin-bottom: 1.2rem;
    border: 1px solid rgba(0, 0, 0, 0.05);
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.2rem;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.date-filter-group {
    flex: 2;
    min-width: 280px;
}

.sort-filter-group {
    flex: 1;
    min-width: 180px;
}

.currency-filter-group {
    flex: 1;
    min-width: 150px;
}

.filter-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.date-inputs {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    padding: 0.2rem 0.5rem;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

.filter-input {
    border: none;
    background: none;
    font-size: 0.85rem;
    font-family: inherit;
    color: var(--text-primary);
    padding: 0.35rem 0.2rem;
    outline: none;
    width: 100%;
}

.filter-select {
    cursor: pointer;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    padding: 0.55rem 0.6rem 0.55rem 2.2rem !important; /* 配合 icon */
    font-weight: 500;
}

.date-sep {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.btn-clear-date {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.2rem 0.4rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-clear-date:hover {
    color: var(--danger);
    background-color: rgba(226, 124, 101, 0.08);
}

/* ==================== 收據 Lightbox 照片牆與按鈕 ==================== */
.btn-view-cost-details {
    background: rgba(74, 124, 89, 0.08);
    border: 1px solid rgba(74, 124, 89, 0.15);
    color: #4a7c59;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: 0.4rem;
}

.btn-view-cost-details:hover {
    background: rgba(74, 124, 89, 0.15);
    color: #2d5b45;
    transform: translateY(-1px);
}

.receipt-lightbox-gallery {
    display: flex;
    gap: 0.8rem;
    overflow-x: auto;
    padding: 0.5rem 0;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.receipt-lightbox-item {
    flex: 0 0 100%;
    max-width: 100%;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 8px;
    padding: 0.4rem;
}

.receipt-lightbox-img {
    max-width: 100%;
    max-height: 380px;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.3s;
}

.receipt-lightbox-img:hover {
    transform: scale(1.02);
}

.receipt-lightbox-indicator {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.6rem;
    font-weight: 600;
}

/* 歷史費用縮圖展示 */
.cost-receipts-preview {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.6rem;
    flex-wrap: wrap;
}

.cost-receipt-thumb {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid rgba(0,0,0,0.08);
    cursor: pointer;
    transition: transform 0.2s;
}

.cost-receipt-thumb:hover {
    transform: scale(1.15);
    z-index: 1;
}

/* ==================== 邀請確認頁面 join.php ==================== */
.join-icon {
    font-size: 4rem;
    color: var(--accent-color);
    margin-bottom: 1.5rem;
    display: inline-block;
}

.join-title {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
}

.join-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.join-project-box {
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    background: var(--primary-color);
    color: #fff;
    padding: 0.9rem 1.8rem;
    border-radius: var(--border-radius-lg);
    font-size: 1.2rem;
    font-weight: 700;
    margin: 1.5rem 0;
    box-shadow: 0 4px 15px rgba(45, 91, 69, 0.2);
}

.join-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ==================== 動畫與輔助類別 Animations ==================== */
.fade-in {
    animation: page-fade 0.4s ease-out forwards;
}

.loading-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-base);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.spinner-container {
    text-align: center;
}

.loading-logo {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    display: inline-block;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(45, 91, 69, 0.1);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    margin: 0 auto 1rem auto;
    animation: spin 1s linear infinite;
}

.loading-container {
    position: fixed;
    z-index: 10000;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(28, 43, 36, 0.45);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white !important;
}

.loading-container p {
    font-weight: 600;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.9);
    margin-top: 0.5rem;
}

.loading-spinner {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 0.8rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes page-fade {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes modal-fade-in {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.animated-bounce {
    animation: bounce 2s infinite;
}

.animated-pulse {
    animation: pulse 1.5s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-4px); }
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.85; }
    100% { transform: scale(1); opacity: 1; }
}

/* 行動版 RWD 優化 */
@media (max-width: 480px) {
    .content {
        padding: 1rem 0.8rem 2.5rem 0.8rem;
    }
    
    .card {
        padding: 1.2rem 1rem;
        margin-bottom: 1.2rem;
    }
    
    .form-row-2, .form-row-3 {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.8rem;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
        gap: 0.6rem;
    }
    
    .project-title-row {
        flex-direction: column;
        gap: 0.8rem;
        align-items: flex-start;
    }
    
    .project-title-row button {
        width: 100%;
    }

    /* 手機版費用彈窗與表單空間極致優化 */
    .modal-content {
        margin: 0.8rem auto;
        width: 94%;
        border-radius: 12px;
    }
    
    .modal-header {
        padding: 0.8rem 1rem;
    }
    
    .modal-body {
        padding: 0.8rem 1rem;
    }
    
    .modal-footer {
        margin-top: 1rem;
        padding-top: 0.6rem;
    }
    
    .modern-form .form-group {
        margin-bottom: 0.8rem;
    }
    
    .allocation-section {
        margin-top: 1rem;
        padding-top: 0.8rem;
    }

    .modern-form label {
        margin-bottom: 0.25rem;
        font-size: 0.78rem;
    }

    .input-with-icon input, 
    .input-with-icon select {
        padding: 0.5rem 0.6rem 0.5rem 2.1rem;
        font-size: 0.85rem;
    }

    .input-with-icon .input-icon {
        font-size: 0.85rem;
        left: 0.8rem;
    }

    /* 手機版分攤模式切換按鈕防止跑版與折行 */
    .allocation-mode-selector {
        display: flex;
        gap: 0.3rem !important;
        width: 100%;
    }
    
    .allocation-mode-selector .mode-btn {
        flex: 1;
        padding: 0.4rem 0.2rem !important;
        font-size: 0.72rem !important;
        white-space: nowrap !important;
        text-align: center;
    }
}

/* ==================== 原生全螢幕 Lightbox 樣式 ==================== */
.fullscreen-lightbox {
    position: fixed;
    z-index: 20000;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: lightbox-fade-in 0.25s ease-out forwards;
}

.fullscreen-lightbox img {
    max-width: 92%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.8);
}

.lightbox-close {
    position: absolute;
    top: 1.2rem;
    right: 1.5rem;
    color: rgba(255, 255, 255, 0.7);
    font-size: 2.8rem;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s, transform 0.2s;
    line-height: 1;
}

.lightbox-close:hover {
    color: white;
    transform: scale(1.1);
}

@keyframes lightbox-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 右下角懸浮新增費用按鈕 (FAB) */
.btn-floating-fab {
    position: fixed;
    right: 2rem;
    bottom: 2rem;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    border: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 99;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-floating-fab:hover {
    background-color: var(--primary-dark);
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.25);
}

.btn-floating-fab:active {
    transform: translateY(-1px) scale(0.98);
}