/* 基础重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Roboto, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

/* 头部 */
.header {
    background-color: #2c3e50;
    color: white;
    padding: 16px 0;
    margin-bottom: 24px;
}

.header h1 {
    font-size: 20px;
    font-weight: 500;
}

/* 主体 */
.main {
    background-color: white;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* 搜索栏 */
.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    align-items: center;
}

.search-bar input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

.search-bar input:focus {
    border-color: #3498db;
}

.btn {
    padding: 10px 20px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #f5f5f5;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:hover {
    background-color: #e8e8e8;
}

.btn-primary {
    background-color: #3498db;
    color: white;
    border-color: #3498db;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-success {
    background-color: #27ae60;
    color: white;
    border-color: #27ae60;
}

.btn-success:hover {
    background-color: #229954;
}

/* 统计 */
.stats {
    margin-bottom: 16px;
    font-size: 14px;
    color: #666;
}

.stats .count {
    color: #e74c3c;
    font-weight: bold;
    font-size: 18px;
    margin: 0 4px;
}

/* 表格容器 */
.table-container {
    overflow-x: auto;
}

/* 表格 */
table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
}

th {
    padding: 12px 10px;
    text-align: left;
    font-weight: 500;
    font-size: 14px;
    color: #495057;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    border-bottom: 2px solid #dee2e6;
}

th:hover {
    background-color: #e9ecef;
}

th .sort-icon {
    margin-left: 4px;
    color: #bbb;
}

th.sorted .sort-icon {
    color: #3498db;
}

td {
    padding: 12px 10px;
    border-bottom: 1px solid #dee2e6;
    font-size: 14px;
}

tbody tr:hover {
    background-color: #f8f9fa;
}

tbody tr .client-name {
    color: #3498db;
    cursor: pointer;
    text-decoration: underline;
}

tbody tr .client-name:hover {
    color: #2980b9;
}

/* 都靠左 */
/* td:nth-child(5), td:nth-child(6) { text-align: center; } */

.empty {
    text-align: center;
    color: #999;
    padding: 40px !important;
}

/* 模态框 */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.show {
    display: flex;
}

.modal-dialog {
    background-color: white;
    border-radius: 8px;
    width: 100%;
    max-width: 700px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    background-color: white;
    z-index: 1;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 500;
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
}

/* 详情字段 */
.detail-fields {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.detail-field {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 12px;
    align-items: start;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.detail-field .key {
    font-weight: 500;
    color: #666;
    padding-top: 4px;
}

.detail-field .value {
    color: #333;
    word-break: break-word;
}

/* 备注 */
.remark-section {
    border-top: 2px solid #eee;
    padding-top: 16px;
}

.remark-section label {
    display: block;
    font-weight: 500;
    color: #666;
    margin-bottom: 12px;
}

/* 备注列表 */
.remarks-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.remark-item {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
}

.remark-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #f8f9fa;
    padding: 8px 12px;
    border-bottom: 1px solid #e0e0e0;
}

.remark-date {
    font-size: 13px;
    color: #666;
    font-weight: 500;
}

.remark-delete-btn {
    background-color: #fff;
    border: 1px solid #dc3545;
    color: #dc3545;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.remark-delete-btn:hover {
    background-color: #dc3545;
    color: white;
}

.remark-content {
    padding: 12px;
    font-size: 14px;
    color: #333;
    white-space: pre-wrap;
    word-break: break-word;
    min-height: 40px;
}

.add-remark-actions {
    text-align: left;
}

/* 添加新备注弹窗 */
.new-remark-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1500;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.new-remark-modal.show {
    display: flex;
}

.new-remark-dialog {
    background-color: white;
    border-radius: 8px;
    width: 100%;
    max-width: 600px;
    max-height: 70vh;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.new-remark-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
}

.new-remark-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
}

.new-remark-body {
    padding: 16px;
}

.new-remark-body textarea {
    width: 100%;
    min-height: 150px;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    resize: vertical;
    outline: none;
    font-family: inherit;
}

.new-remark-body textarea:focus {
    border-color: #3498db;
}

.new-remark-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 12px 16px;
    border-top: 1px solid #eee;
}

.remark-item:only-child .remark-content {
    min-height: 60px;
}

/* 可编辑地址样式 */
.editable-address {
    color: #3498db;
    cursor: pointer;
    text-decoration: underline;
}

.editable-address:hover {
    color: #2980b9;
}

.empty-address {
    color: #bbb;
    font-style: italic;
}

/* 编辑地址弹窗 */
.edit-address-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1500;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.edit-address-modal.show {
    display: flex;
}

.edit-address-dialog {
    background-color: white;
    border-radius: 8px;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.edit-address-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
}

.edit-address-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
}

.edit-address-body {
    padding: 20px 16px;
}

.edit-address-body #edit-address-client-name {
    font-weight: 500;
    color: #333;
}

.edit-address-body .tips {
    font-size: 12px;
    color: #999;
    margin-top: 8px;
}

.edit-address-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 12px 16px;
    border-top: 1px solid #eee;
}

.form-group #edit-address-client-name {
    padding: 10px 0;
}

/* 编辑备注弹窗 */
.edit-remark-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1500;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.edit-remark-modal.show {
    display: flex;
}

.edit-remark-dialog {
    background-color: white;
    border-radius: 8px;
    width: 100%;
    max-width: 550px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.edit-remark-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
}

.edit-remark-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
}

.edit-remark-body {
    padding: 16px;
}

.edit-remark-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 12px 16px;
    border-top: 1px solid #eee;
}

/* 备注头部按钮 */
.remark-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.remark-header-buttons {
    display: flex;
    gap: 8px;
}

.remark-edit-btn {
    background-color: #fff;
    border: 1px solid #3498db;
    color: #3498db;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.remark-edit-btn:hover {
    background-color: #3498db;
    color: white;
}

/* 表单分组 */
.form-group {
    margin-bottom: 16px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-weight: 500;
    color: #666;
    margin-bottom: 6px;
    font-size: 14px;
}

.form-group textarea {
    width: 100%;
    min-height: 120px;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    resize: vertical;
    outline: none;
    font-family: inherit;
}

.form-group textarea:focus {
    border-color: #3498db;
}

.form-group input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    outline: none;
}

.form-group input[type="text"]:focus {
    border-color: #3498db;
}

/* 已有地址显示 */
.remark-address {
    border-top: 1px solid #f0f0f0;
    padding: 8px 12px;
    background-color: #fafafa;
}

.remark-address-label {
    font-size: 12px;
    color: #666;
    font-weight: 500;
}

.remark-address-value {
    font-size: 14px;
    color: #333;
    margin-top: 2px;
    word-break: break-word;
}

/* 加载遮罩 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255,255,255,0.8);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading {
    font-size: 16px;
    color: #666;
}

/* 消息弹窗 */
.message-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.3);
    z-index: 3000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.message-modal.show {
    display: flex;
}

.message-dialog {
    background-color: #f5f5f5;
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    padding: 28px 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.message-title {
    font-size: 22px;
    font-weight: 500;
    color: #333;
    margin-bottom: 16px;
}

.message-content {
    font-size: 18px;
    color: #444;
    margin-bottom: 24px;
    line-height: 1.6;
}

.message-actions {
    text-align: right;
}

.message-actions .btn {
    padding: 8px 28px;
    font-size: 16px;
}

/* 响应式 */
@media (max-width: 768px) {
    .main {
        padding: 16px;
    }
    .search-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .detail-field {
        grid-template-columns: 1fr;
        gap: 4px;
    }
    .detail-field .key {
        background-color: #f5f5f5;
        padding: 4px 8px;
    }
    .message-dialog {
        padding: 20px 16px;
    }
}
