/* 全局样式 */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    background-color: #f4f7f9;
    color: #333;
    margin: 0;
    padding: 20px;
}

h1, h2, h3 {
    color: #2c3e50;
}

/* 布局 */
header, main {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.billing-section {
    display: flex;
    gap: 20px;
}

.left-panel {
    flex: 2;
}

.right-panel {
    flex: 1;
    background-color: #ffffff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    align-self: flex-start; /* 让右侧面板高度自适应 */
}

/* 组件样式 */
input, select, button {
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #ccc;
    font-size: 1em;
    margin-right: 5px;
}

button {
    cursor: pointer;
    background-color: #3498db;
    color: white;
    border: none;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #2980b9;
}

button.danger {
    background-color: #e74c3c;
}
button.danger:hover {
    background-color: #c0392b;
}

form {
    background-color: #fff;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* 设置区域 */
.settings-section {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.settings-section summary {
    font-size: 1.2em;
    font-weight: bold;
    cursor: pointer;
}

.family-card {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-top: 15px;
    padding: 15px;
}

.family-header, .member-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.family-name { margin: 0; }
.family-ratio, .member-ratio {
    font-style: italic;
    color: #555;
    background: #ecf0f1;
    padding: 2px 8px;
    border-radius: 10px;
}

.member-list {
    padding-left: 20px;
    border-left: 2px solid #f0f0f0;
}
.add-member-form {
    padding: 10px 0 0 20px;
    box-shadow: none;
}

/* 账单和结算 */
#bill-list, #summary-list, #settlement-plan {
    margin-top: 10px;
}
.bill-item, .summary-item {
    background-color: #fff;
    padding: 10px 15px;
    border-radius: 5px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.bill-details > span { margin-right: 15px; }
.bill-amt { font-weight: bold; }
.bill-payer-name { font-style: italic; color: #555;}

.summary-details {
    display: flex;
    gap: 15px;
    font-size: 0.9em;
}

.summary-balance.positive { color: #27ae60; }
.summary-balance.negative { color: #c0392b; }

#settlement-plan p {
    background: #e8f6fd;
    padding: 12px;
    border-left: 4px solid #3498db;
    border-radius: 4px;
}

/* 响应式设计 - 移动端适配 */
@media (max-width: 768px) {
    body {
        padding: 10px; /* 减小页面边距 */
    }

    header {
        flex-direction: column; /* 头部元素垂直排列 */
        align-items: flex-start; /* 左对齐 */
        gap: 10px;
    }

    .header-actions {
        display: flex;
        flex-wrap: wrap; /* 允许按钮换行 */
        gap: 8px;
    }

    .billing-section {
        flex-direction: column; /* 左右面板垂直堆叠 */
    }

    .family-header, .member-item, .bill-item {
        flex-direction: column; /* 卡片内元素垂直排列 */
        align-items: flex-start; /* 左对齐 */
        gap: 8px;
    }

    .family-actions, .member-actions, .bill-actions {
        margin-top: 5px;
        align-self: flex-end; /* 让操作按钮靠右 */
    }

    .bill-details {
        display: flex;
        flex-direction: column;
        gap: 5px;
    }
    
    .bill-details > span { margin-right: 0; }

    form {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    form input, form select, form button {
        margin-right: 0; /* 移除右边距 */
    }
}