/* ===== 基础风格 ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: #2c3e50;
    background: #f5f6f8;
    overflow: hidden;
}
body { display: flex; flex-direction: column; }
button { font-family: inherit; cursor: pointer; outline: none; border: none; }
input, textarea, select { font-family: inherit; outline: none; }
textarea { resize: vertical; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #d0d4d9; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a8b0b8; }
::-webkit-scrollbar-track { background: transparent; }

/* ===== 顶部导航栏 ===== */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: #ffffff;
    border-bottom: 1px solid #e8ebef;
    box-shadow: 0 1px 0 rgba(0,0,0,0.02);
    flex-shrink: 0;
    z-index: 10;
}
.topbar-left { display: flex; align-items: baseline; gap: 12px; }
.logo {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
}
.subtitle {
    font-size: 12px;
    color: #95a5a6;
}
.topbar-right { display: flex; gap: 8px; }

/* ===== 按钮 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 7px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s ease;
    white-space: nowrap;
    border: 1px solid transparent;
}
.btn-primary {
    background: #4A90E2;
    color: white;
}
.btn-primary:hover { background: #357ABD; }
.btn-ghost {
    background: transparent;
    color: #5a6c7d;
    border-color: #e1e5ea;
}
.btn-ghost:hover {
    background: #f0f3f6;
    color: #2c3e50;
    border-color: #d0d4d9;
}
.btn-danger-ghost {
    background: transparent;
    color: #e74c3c;
    border-color: #fadbd8;
}
.btn-danger-ghost:hover {
    background: #fef5f4;
    border-color: #f5b7b1;
}
.btn-danger {
    background: #e74c3c;
    color: white;
}
.btn-danger:hover { background: #c0392b; }
.btn-block { width: 100%; display: flex; }
.btn-lg { padding: 11px 22px; font-size: 14px; }

/* ===== 主体布局 ===== */
.main-wrap {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ===== 左侧栏 ===== */
.sidebar {
    width: 320px;
    background: #ffffff;
    border-right: 1px solid #e8ebef;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.sidebar-header {
    padding: 14px;
    border-bottom: 1px solid #f0f2f5;
}
.search-box input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e1e5ea;
    border-radius: 6px;
    font-size: 13px;
    transition: border-color 0.15s;
}
.search-box input:focus { border-color: #4A90E2; }
.filter-row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}
.mini-select {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid #e1e5ea;
    border-radius: 6px;
    font-size: 12px;
    background: white;
    color: #5a6c7d;
}
.stats {
    margin-top: 10px;
    font-size: 12px;
    color: #95a5a6;
    text-align: right;
}
.stats span { color: #4A90E2; font-weight: 600; }

.customer-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
}
.empty-tip {
    padding: 40px 20px;
    text-align: center;
    color: #95a5a6;
    font-size: 13px;
}
.customer-item {
    padding: 12px 14px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background 0.12s;
    border-bottom: 1px solid #f5f6f8;
}
.customer-item:hover { background: #f8fafc; }
.customer-item.active {
    background: #eef5fc;
    border-left-color: #4A90E2;
}
.customer-name {
    font-weight: 600;
    font-size: 14px;
    color: #2c3e50;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.customer-name .badge {
    font-size: 11px;
    padding: 1px 6px;
    background: #4A90E2;
    color: white;
    border-radius: 8px;
    font-weight: 500;
}
.customer-snippet {
    font-size: 12px;
    color: #7f8c8d;
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.customer-tags {
    margin-top: 5px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.tag {
    font-size: 11px;
    padding: 1px 6px;
    background: #f0f3f6;
    color: #5a6c7d;
    border-radius: 3px;
}
.tag.tag-budget { background: #fff3e0; color: #e67e22; }
.tag.tag-job { background: #e8f5e9; color: #27ae60; }
.tag.tag-cycle { background: #f3e5f5; color: #8e44ad; }

.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid #f0f2f5;
}

/* ===== 工作区 ===== */
.workspace {
    flex: 1;
    overflow-y: auto;
    background: #f5f6f8;
}

/* ===== 欢迎页 ===== */
.welcome {
    max-width: 760px;
    margin: 40px auto;
    padding: 40px 32px;
    text-align: center;
}
.welcome-icon { font-size: 56px; margin-bottom: 16px; }
.welcome h2 {
    margin: 0 0 12px;
    font-size: 24px;
    color: #2c3e50;
    font-weight: 600;
}
.welcome-tip {
    color: #7f8c8d;
    margin-bottom: 28px;
    font-size: 14px;
}
.welcome-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 40px;
}
.feature-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    text-align: left;
}
.feature-item {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e8ebef;
}
.feature-icon { font-size: 24px; }
.feature-item strong {
    display: block;
    margin-bottom: 4px;
    color: #2c3e50;
}
.feature-item p {
    margin: 0;
    font-size: 12px;
    color: #95a5a6;
}

/* ===== 详情面板 ===== */
.detail-panel {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
}
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    background: white;
    padding: 14px 18px;
    border-radius: 8px;
    border: 1px solid #e8ebef;
}
.detail-title { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.detail-name-input {
    border: none;
    font-size: 20px;
    font-weight: 600;
    color: #2c3e50;
    padding: 4px 8px;
    border-radius: 4px;
    background: transparent;
    width: 240px;
}
.detail-name-input:focus { background: #f8fafc; }
.detail-name-input::placeholder { color: #bdc3c7; }
.detail-meta {
    font-size: 12px;
    color: #95a5a6;
}
.detail-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ===== 章节 ===== */
.raw-input-section, .archive-section {
    background: white;
    padding: 16px 18px;
    border-radius: 8px;
    border: 1px solid #e8ebef;
    margin-bottom: 16px;
}
.section-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
}
.section-label .hint {
    font-weight: 400;
    font-size: 12px;
    color: #95a5a6;
}
.raw-input-section textarea {
    width: 100%;
    min-height: 140px;
    padding: 12px;
    border: 1px solid #e1e5ea;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.6;
    color: #2c3e50;
    background: #fafbfc;
    transition: border-color 0.15s, background 0.15s;
}
.raw-input-section textarea:focus {
    border-color: #4A90E2;
    background: white;
}
.raw-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

/* ===== 档案网格 ===== */
.archive-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}
.field-group {
    background: #fafbfc;
    padding: 14px;
    border-radius: 6px;
    border: 1px solid #f0f2f5;
}
.group-title {
    margin: 0 0 12px;
    font-size: 13px;
    font-weight: 600;
    color: #4A90E2;
    padding-bottom: 8px;
    border-bottom: 1px solid #e8ebef;
}
.field { margin-bottom: 10px; }
.field:last-child { margin-bottom: 0; }
.field label {
    display: block;
    font-size: 12px;
    color: #5a6c7d;
    margin-bottom: 4px;
    font-weight: 500;
}
.field input, .field textarea {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #e1e5ea;
    border-radius: 5px;
    font-size: 13px;
    background: white;
    color: #2c3e50;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field textarea:focus {
    border-color: #4A90E2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.08);
}
.field textarea { line-height: 1.5; }

/* ===== 模态框 ===== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-mask {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    animation: fadeIn 0.15s ease;
}
.modal-content {
    position: relative;
    background: white;
    border-radius: 8px;
    width: 480px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.2s ease;
    box-shadow: 0 10px 40px rgba(0,0,0,0.18);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid #e8ebef;
}
.modal-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
}
.modal-close {
    background: transparent;
    border: none;
    font-size: 22px;
    color: #95a5a6;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}
.modal-close:hover { color: #2c3e50; }
.modal-body {
    padding: 18px;
    overflow-y: auto;
}
.modal-tip {
    margin: 0 0 16px;
    font-size: 13px;
    color: #7f8c8d;
    line-height: 1.6;
    background: #f8fafc;
    padding: 10px 12px;
    border-radius: 6px;
    border-left: 3px solid #4A90E2;
}
.form-row {
    margin-bottom: 14px;
}
.form-row label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #5a6c7d;
    margin-bottom: 6px;
}
.form-row input, .form-row select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e1e5ea;
    border-radius: 6px;
    font-size: 13px;
}
.form-row input:focus, .form-row select:focus { border-color: #4A90E2; }
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 18px;
}
.modal-confirm { width: 380px; }
.modal-confirm .modal-body p {
    margin: 8px 0 0;
    color: #5a6c7d;
    line-height: 1.6;
}

/* ===== 提示框 ===== */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    background: #2c3e50;
    color: white;
    padding: 10px 18px;
    border-radius: 6px;
    font-size: 13px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    z-index: 200;
    animation: toastIn 0.2s ease;
}
.toast.toast-success { background: #27ae60; }
.toast.toast-error { background: #e74c3c; }

/* ===== 动画 ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes toastIn {
    from { opacity: 0; transform: translate(-50%, 20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* ===== 响应式 ===== */
@media (max-width: 900px) {
    .sidebar { width: 260px; }
    .feature-list { grid-template-columns: 1fr; }
    .archive-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
    .main-wrap { flex-direction: column; }
    .sidebar { width: 100%; height: 50%; border-right: none; border-bottom: 1px solid #e8ebef; }
    .topbar-right .btn span { display: none; }
}
