/* ============ 基础样式 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 16px; }

@media screen and (max-width: 375px) {
    html { font-size: calc(100vw / 375 * 16); }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
    background: #f0f2f5;
}

.app-container {
    width: 100%;
    max-width: 414px;
    margin: 0 auto;
    min-height: 100vh;
    background: #f8f9fa;
    position: relative;
    padding-bottom: 70px;
}

.page-content { padding: 15px; }

/* ============ 底部导航 ============ */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 414px;
    background: #fff;
    border-top: 1px solid #e8e8e8;
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #999;
    text-decoration: none;
    font-size: 0.7rem;
    transition: color 0.2s;
}

.nav-item i { font-size: 1.2rem; margin-bottom: 4px; }
.nav-item.active { color: #667eea; }

/* ============ 首页 ============ */
.dashboard-page section {
    margin-bottom: 20px;
    background: #fff;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.dashboard-page h3 { font-size: 1rem; font-weight: 600; margin-bottom: 12px; color: #333; }

/* 快捷操作 */
.quick-actions .action-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 10px;
    border: none;
    border-radius: 12px;
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.action-btn:active { transform: scale(0.95); }
.action-btn i { font-size: 1.5rem; margin-bottom: 6px; }
.action-btn span { font-size: 0.75rem; }

.action-btn.primary { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.action-btn.success { background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%); }
.action-btn.warning { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }
.action-btn.danger { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }

/* 统计卡片 */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    border: 1px solid #e8e8e8;
    transition: all 0.2s;
}

.stat-card:hover { border-color: #667eea; box-shadow: 0 4px 12px rgba(102,126,234,0.15); }
.stat-card.warning { background: #fffbeb; border-color: #f59e0b; }
.stat-card.info { background: #eff6ff; border-color: #3b82f6; }
.stat-card.success { background: #f0fdf4; border-color: #22c55e; }
.stat-card.danger { background: #fef2f2; border-color: #ef4444; }

.stat-value { font-size: 1.5rem; font-weight: 700; color: #333; display: block; }
.stat-label { font-size: 0.75rem; color: #666; margin-top: 4px; }

/* 待办事项 */
.todo-item-card:hover { background: #e5e7eb !important; }

/* 空状态 */
.empty-text { text-align: center; color: #999; padding: 20px; font-size: 0.875rem; }

/* ============ Tab 导航 ============ */
.tab-nav {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    border-bottom: 1px solid #e8e8e8;
    padding-bottom: 10px;
    overflow-x: auto;
}

.tab-nav a, .tab-nav button {
    padding: 8px 16px;
    border: none;
    background: transparent;
    font-size: 0.875rem;
    color: #6b7280;
    cursor: pointer;
    border-radius: 20px;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s;
}

.tab-nav a:hover, .tab-nav button:hover { color: #667eea; }
.tab-nav a.active, .tab-nav button.active { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; }

/* ============ 小区标签 ============ */
.community-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    overflow-x: auto;
    padding-bottom: 5px;
}

.community-tab {
    padding: 8px 16px;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    background: #fff;
    color: #374151;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
}

.community-tab:hover { border-color: #667eea; color: #667eea; }
.community-tab.active { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; border-color: transparent; }

.default-badge {
    font-size: 0.6rem;
    background: #10b981;
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 5px;
}

/* ============ 小区信息 ============ */
.community-info {
    background: #fff;
    border-radius: 12px;
    padding: 15px;
    margin-top: 25px;
    border: 1px solid #e8e8e8;
}

.community-info p { font-size: 0.875rem; color: #6b7280; margin-bottom: 5px; }

.community-actions { display: flex; gap: 10px; margin-top: 10px; }
.community-actions button {
    padding: 6px 12px;
    border: 1px solid #667eea;
    border-radius: 6px;
    background: #fff;
    color: #667eea;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}
.community-actions button:hover { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; }

/* ============ 房屋卡片 ============ */
.houses-section { margin-bottom: 20px; }

.houses-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

.house-card {
    background: #fff;
    border-radius: 12px;
    padding: 12px;
    border: 1px solid #e8e8e8;
    transition: all 0.2s;
}

.house-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.house-card.vacant { border-left: 4px solid #22c55e; }
.house-card.rented { border-left: 4px solid #ef4444; }

.house-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.room-number { font-size: 1rem; font-weight: 600; color: #1f2937; }

.status-badge { font-size: 0.65rem; padding: 2px 6px; border-radius: 4px; }
.status-badge.vacant { background: #d1fae5; color: #065f46; }
.status-badge.rented { background: #fee2e2; color: #991b1b; }
.status-badge.active { background: #dbeafe; color: #1e40af; }

.house-info p { font-size: 0.75rem; color: #6b7280; margin-bottom: 3px; }

.house-actions { display: flex; gap: 5px; margin-top: 10px; }
.house-actions button {
    flex: 1;
    padding: 6px;
    border: 1px solid #d1d5db;
    background: #fff;
    color: #374151;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
}
.house-actions button:hover { background: #f3f4f6; border-color: #667eea; color: #667eea; }

/* ============ 租约列表 ============ */
.lease-list { display: flex; flex-direction: column; gap: 10px; }

.lease-card {
    background: #fff;
    border-radius: 12px;
    padding: 12px 15px;
    border: 1px solid #e8e8e8;
    cursor: pointer;
    transition: all 0.2s;
}

.lease-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.lease-card.ended { opacity: 0.8; }

.lease-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.lease-row:last-child { margin-bottom: 0; }

.community-name { font-size: 0.8rem; color: #667eea; font-weight: 500; }

.tenant-name { font-size: 0.875rem; color: #374151; }
.tenant-phone { font-size: 0.8rem; color: #6b7280; }
.rent-info { font-size: 0.8rem; color: #6b7280; }
.end-date { font-size: 0.75rem; color: #9ca3af; }

/* ============ 快捷租期按钮 ============ */
.quick-periods { display: flex; gap: 10px; margin-bottom: 15px; }
.quick-periods button {
    padding: 8px 16px;
    border: 1px solid #667eea;
    background: #fff;
    color: #667eea;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}
.quick-periods button:hover { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; }

/* ============ 表格 ============ */
.rent-form, .renew-form, .checkout-form, .expense-form {
    background: #fff;
    border-radius: 12px;
    padding: 15px;
}

.tenant-info {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.tenant-info p { font-size: 0.875rem; margin-bottom: 5px; color: #374151; }

.refund-summary p { font-size: 1rem; font-weight: 600; margin-bottom: 5px; color: #92400e; }

/* ============ 收款 ============ */
.payment-cards { display: flex; flex-direction: column; gap: 10px; }

.payment-card {
    background: #fff;
    border-radius: 12px;
    padding: 15px;
    border: 1px solid #e8e8e8;
}

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

.payment-type {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
}

.payment-amount { font-size: 1.25rem; font-weight: 700; color: #22c55e; }
.payment-info p { font-size: 0.875rem; color: #6b7280; margin-bottom: 5px; }

.payment-actions { display: flex; gap: 10px; margin-top: 10px; }
.payment-actions button {
    flex: 1;
    padding: 8px;
    border: 1px solid #667eea;
    background: #fff;
    color: #667eea;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}
.payment-actions button:hover { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; }

/* ============ 支出记录 ============ */
.expense-list { margin-bottom: 15px; }

/* ============ 系统设置 ============ */
.admin-section, .logs-section, .settings-section {
    background: #fff;
    border-radius: 12px;
    padding: 15px;
}

.admin-section h3, .logs-section h3 { margin-bottom: 15px; color: #1f2937; }
.hint { color: #6b7280; font-size: 0.875rem; margin-bottom: 15px; }

.password-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 15px; }
.password-form input {
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.875rem;
}

.logs-list { display: flex; flex-direction: column; gap: 10px; }

/* ============ 弹窗 ============ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}

.modal {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.modal h3 { margin-bottom: 15px; font-size: 1.1rem; color: #1f2937; }

/* ============ 表单 ============ */
.form-group { margin-bottom: 15px; }

.form-group label {
    display: block;
    font-size: 0.875rem;
    color: #374151;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.875rem;
    background: #fff;
    color: #1f2937;
    transition: all 0.2s;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: #667eea;
    outline: none;
    box-shadow: 0 0 0 3px rgba(102,126,234,0.1);
}

.form-group.checkbox { display: flex; align-items: center; gap: 8px; }
.form-group.checkbox input { width: auto; }

.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.form-row .form-group { margin-bottom: 0; }

.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.form-actions { margin-top: 20px; }
.form-actions button, .form-actions .btn-primary, .form-actions .btn-secondary { width: 100%; padding: 12px; }

/* ============ 按钮 ============ */
.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-block;
    text-decoration: none;
}

.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-block;
    text-decoration: none;
}

.btn-secondary:hover { background: #e5e7eb; }

.btn-danger {
    background: #ef4444;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.btn-success {
    background: #22c55e;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

/* ============ 设施选择 ============ */
.facilities-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.facility-checkbox {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    cursor: pointer;
    color: #374151;
}

.facility-checkbox input { width: auto; }

/* ============ 联系方式 ============ */
.contact-input { display: flex; gap: 8px; }
.contact-input input { flex: 1; }
.contact-input button {
    padding: 10px 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.contact-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.contact-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: #ede9fe;
    border-radius: 4px;
    font-size: 0.75rem;
    color: #5b21b6;
}

/* ============ 区块标题 ============ */
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }

/* ============ 登录 ============ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-container {
    background: #fff;
    border-radius: 16px;
    padding: 30px;
    width: 100%;
    max-width: 320px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.login-container h2 { margin-bottom: 20px; color: #1f2937; }
.login-container .form-group { margin-bottom: 15px; text-align: left; }

.login-container input {
    width: 100%;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.875rem;
}

.login-container button {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    cursor: pointer;
    margin-top: 10px;
}

.error-message { color: #ef4444; font-size: 0.75rem; margin-bottom: 10px; text-align: left; }

/* ============ 租客统计 ============ */
.tenant-stats {
    background: #fff;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
}
.tenant-stats h3 { font-size: 1rem; font-weight: 600; margin-bottom: 12px; color: #333; }

/* ============ 响应式 ============ */
@media screen and (max-width: 320px) { html { font-size: 14px; } }
@media screen and (min-width: 415px) { html { font-size: 18px; } }
