* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: #f5f5f5;
    color: #333;
}

.app-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    max-width: 480px;
    margin: 0 auto;
    background: white;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 16px;
    padding-top: calc(20px + env(safe-area-inset-top));
    position: sticky;
    top: 0;
    z-index: 100;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-title {
    font-size: 20px;
    font-weight: 600;
    text-align: center;
    flex: 1;
}

.header-buttons {
    display: flex;
    gap: 8px;
}

.add-button {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.add-button:hover {
    background: rgba(255,255,255,0.3);
}

.update-button {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.update-button:hover {
    background: rgba(255,255,255,0.3);
}

.update-button:disabled {
    background: rgba(255,255,255,0.1);
    cursor: not-allowed;
    opacity: 0.7;
}

.search-section {
    padding: 16px;
    background: white;
    border-bottom: 8px solid #f5f5f5;
}

.search-box {
    display: flex;
    align-items: center;
    background: #f5f5f5;
    border-radius: 20px;
    padding: 10px 16px;
}

.search-icon {
    color: #999;
    margin-right: 8px;
    font-size: 18px;
}

.search-box input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 16px;
    outline: none;
    color: #333;
}

.search-box input::placeholder {
    color: #999;
}

.search-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    margin-left: 12px;
    cursor: pointer;
}

.content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.customer-list {
    padding: 12px;
}

.customer-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: transform 0.2s, box-shadow 0.2s;
}

.customer-card:active {
    transform: scale(0.98);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
}

.card-info-top {
    flex: 1;
    min-width: 0;
    margin-right: 12px;
}

.card-status {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-end;
}

.status-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.status-normal {
    background: #e8f5e9;
    color: #388e3c;
}

.status-written-off {
    background: #e3f2fd;
    color: #1976d2;
}

.status-overdue {
    background: #ffebee;
    color: #d32f2f;
}

.status-default {
    background: #f5f5f5;
    color: #666;
}

.card-avatar {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    margin-right: 12px;
    flex-shrink: 0;
}

.avatar-male {
    background: linear-gradient(135deg, #1e88e5 0%, #2196f3 100%);
}

.avatar-female {
    background: linear-gradient(135deg, #e91e63 0%, #f44336 100%);
}

.card-info-top {
    flex: 1;
    min-width: 0;
}

.card-name {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.card-no {
    font-size: 13px;
    color: #999;
}

.card-details {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px;
}

.detail-item {
    display: flex;
    padding: 6px 0;
    font-size: 14px;
}

.detail-item:not(:last-child) {
    border-bottom: 1px solid #e9ecef;
}

.detail-label {
    color: #6c757d;
    width: 80px;
    flex-shrink: 0;
}

.detail-value {
    color: #333;
    flex: 1;
    word-break: break-all;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-text {
    font-size: 16px;
}

.safe-area-bottom {
    height: env(safe-area-inset-bottom);
    background: white;
}

.debug-info {
    position: fixed;
    bottom: 10px;
    right: 10px;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 10px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 1000;
}

.detail-page {
    height: 100%;
    display: flex;
    flex-direction: column;
    max-width: 480px;
    margin: 0 auto;
    background: white;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

.detail-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px;
    padding-top: calc(16px + env(safe-area-inset-top));
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.back-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
}

.detail-header h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.customer-info-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 24px 16px;
    text-align: center;
    color: white;
}

.card-avatar-large {
    width: 80px;
    height: 80px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    margin: 0 auto 12px;
}

.customer-name-large {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 4px;
}

.customer-no-large {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 16px;
}

.customer-basic-info {
    background: rgba(255,255,255,0.15);
    border-radius: 12px;
    padding: 16px;
    text-align: left;
}

.info-row {
    display: flex;
    padding: 8px 0;
    font-size: 14px;
}

.info-row:not(:last-child) {
    border-bottom: 1px solid rgba(255,255,255,0.2);
}

.info-label {
    width: 90px;
    opacity: 0.9;
}

.info-value {
    flex: 1;
    word-break: break-all;
}

.loading-state {
    text-align: center;
    padding: 40px;
    color: #999;
}

.detail-sections {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px;
}

.collapsible-section {
    background: white;
    border-radius: 12px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    overflow: hidden;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    cursor: pointer;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.section-arrow {
    transition: transform 0.3s;
    color: #667eea;
    font-size: 14px;
}

.section-arrow.open {
    transform: rotate(180deg);
}

.section-content {
    padding: 16px;
}

.empty-section {
    text-align: center;
    padding: 30px;
    color: #999;
    font-size: 14px;
}

.loan-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}

.loan-item:last-child {
    margin-bottom: 0;
}

.loan-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.loan-no {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.loan-status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-active {
    background: #e3f2fd;
    color: #1976d2;
}

.status-completed {
    background: #e8f5e9;
    color: #388e3c;
}

.status-overdue {
    background: #ffebee;
    color: #d32f2f;
}

.status-pending {
    background: #fff3e0;
    color: #f57c00;
}

.status-success {
    background: #e8f5e9;
    color: #388e3c;
}

.loan-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.loan-detail-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}

.loan-detail-row span:first-child {
    color: #6c757d;
}

.loan-detail-row span:last-child {
    color: #333;
    font-weight: 500;
}

.collection-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}

.collection-item:last-child {
    margin-bottom: 0;
}

.collection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.collection-date {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.collection-status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.collection-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.collection-detail-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}

.collection-detail-row span:first-child {
    color: #6c757d;
}

.collection-detail-row span:last-child {
    color: #333;
    font-weight: 500;
}

.collection-item-simple {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.collection-item-simple:hover {
    background: #e9ecef;
}

.collection-item-simple:active {
    transform: scale(0.98);
}

.collection-item-simple:last-child {
    margin-bottom: 0;
}

.collection-date-simple {
    font-size: 14px;
    color: #333;
    font-weight: 500;
    min-width: 100px;
}

.collection-status-simple {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    flex: 1;
    text-align: center;
    margin: 0 12px;
}

.collection-method-simple {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    flex: 1;
    text-align: center;
    margin: 0 12px;
}

.method-home {
    background: #e3f2fd;
    color: #1976d2;
}

.method-phone {
    background: #e8f5e9;
    color: #388e3c;
}

.method-sms {
    background: #fff3e0;
    color: #f57c00;
}

.method-letter {
    background: #fce4ec;
    color: #c2185b;
}

.method-default {
    background: #f5f5f5;
    color: #666;
}

.collection-collector-simple {
    font-size: 14px;
    color: #6c757d;
    min-width: 80px;
    text-align: right;
    word-break: break-all;
    line-height: 1.4;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 16px;
    max-width: 480px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.modal-close:hover {
    background: #f5f5f5;
}

.modal-body {
    padding: 20px;
}

.modal-section {
    margin-bottom: 24px;
}

.modal-section:last-child {
    margin-bottom: 0;
}

.modal-section h4 {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #667eea;
}

.modal-row {
    display: flex;
    padding: 10px 0;
    border-bottom: 1px solid #f5f5f5;
}

.modal-row:last-child {
    border-bottom: none;
}

.modal-label {
    color: #6c757d;
    width: 120px;
    flex-shrink: 0;
    font-size: 14px;
}

.modal-value {
    color: #333;
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    word-break: break-all;
}

.attachment-section {
    display: flex;
    justify-content: center;
    padding: 10px 0;
}

.attachment-photo {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    object-fit: contain;
}

.situation-textarea {
    width: 100%;
    min-height: 120px;
    padding: 12px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    color: #333;
    background: #f8f9fa;
    resize: vertical;
    line-height: 1.6;
    font-family: inherit;
}

.situation-textarea:focus {
    outline: none;
    border-color: #667eea;
    background: white;
}

.situation-textarea::placeholder {
    color: #999;
}

/* 新增客户模态框样式 */
.add-customer-form {
    padding: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 8px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    color: #333;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.form-group input.error,
.form-group select.error {
    border-color: #dc3545;
}

.error-message {
    font-size: 12px;
    color: #dc3545;
    margin-top: 4px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #e9ecef;
}

.cancel-button {
    padding: 10px 20px;
    border: 1px solid #e9ecef;
    background: white;
    color: #6c757d;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.cancel-button:hover {
    background: #f8f9fa;
}

.submit-button {
    padding: 10px 20px;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.submit-button:hover {
    opacity: 0.9;
}

.close-button {
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.close-button:hover {
    background: #f5f5f5;
}

/* 筛选按钮样式 */
.filter-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    margin-bottom: 16px;
}

.filter-buttons {
    display: flex;
    gap: 8px;
    flex: 1;
}

.summary-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 12px;
    transition: all 0.2s;
}

.summary-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.summary-section {
    padding: 20px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #f5f5f5;
}

.summary-row:last-child {
    border-bottom: none;
}

.summary-label {
    font-size: 16px;
    color: #6c757d;
}

.summary-value {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.filter-btn {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #e9ecef;
    background: white;
    color: #6c757d;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover {
    background: #f8f9fa;
    border-color: #667eea;
    color: #667eea;
}

.filter-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    color: white;
}

.loan-list {
    padding: 0 16px 16px;
    max-height: 500px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.loan-list::-webkit-scrollbar {
    width: 4px;
}

.loan-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 2px;
}

.loan-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
}

.loan-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 添加催收记录按钮 */
.add-collection-fab {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: all 0.3s ease;
}

.add-collection-fab:hover {
    transform: scale(1.1);
    opacity: 1;
    box-shadow: 0 6px 16px rgba(0,0,0,0.3);
}

.add-collection-fab:active {
    transform: scale(0.95);
}

.collection-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 6px;
}

.collection-action-btn {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s ease;
}

.edit-btn {
    background: #e3f2fd;
    color: #1976d2;
}

.edit-btn:hover {
    background: #bbdefb;
    transform: scale(1.1);
}

.delete-btn {
    background: #ffebee;
    color: #d32f2f;
}

.delete-btn:hover {
    background: #ffcdd2;
    transform: scale(1.1);
}

.clickable-image {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.clickable-image:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.image-preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.image-preview-container {
    background: white;
    border-radius: 16px;
    max-width: 95vw;
    max-height: 95vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.image-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e9ecef;
    background: white;
}

.image-preview-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.image-preview-close {
    background: none;
    border: none;
    font-size: 32px;
    color: #999;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.image-preview-close:hover {
    background: #f5f5f5;
    color: #333;
}

.image-preview-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: auto;
    background: #f5f5f5;
}

.image-preview-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
