* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* 侧边栏 */
.sidebar {
    width: 250px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.logo {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 30px;
    padding: 10px;
    text-align: center;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nav-item {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    text-align: left;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateX(4px);
}

.nav-item.active {
    background: rgba(255, 255, 255, 0.3);
    font-weight: bold;
}

/* 主内容区 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.view {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 30px;
}

.view.active {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* 表格管理视图单独控制滚动 */
#main-view.active {
    overflow: hidden;
}

.header-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-shrink: 0;
}

.filter-section {
    flex-shrink: 0;
    margin-bottom: 16px;
}

.header-section h1 {
    font-size: 28px;
    color: var(--text-primary);
}

.action-buttons {
    display: flex;
    gap: 10px;
}

/* 按钮 */
.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--border-color);
}

/* 筛选区 */
.filter-section {
    background: var(--bg-primary);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.filter-group label {
    font-weight: 500;
    color: var(--text-secondary);
}

.filter-group select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}

.filter-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-options select,
.filter-options input {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
}

/* 表格 */
.table-wrapper {
    flex: 1;
    background: var(--bg-primary);
    border-radius: 8px;
    overflow-y: auto;
    overflow-x: auto;
    box-shadow: var(--shadow-md);
    min-height: 0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    cursor: grab;
    user-select: none;
    white-space: nowrap;
}

.data-table th:active {
    cursor: grabbing;
}

.data-table tbody {
}

.data-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.data-table tbody tr {
    transition: background-color 0.2s ease;
}

.data-table tbody tr:hover {
    background-color: var(--bg-secondary);
}

.data-table tbody tr.warning {
    background-color: #fef3c7;
}

.data-table tbody tr.warning td {
    border-bottom-color: #fcd34d;
}

.row-actions {
    display: flex;
    gap: 8px;
}

.row-actions button {
    padding: 6px 10px;
    font-size: 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.edit-btn {
    background-color: var(--primary-color);
    color: white;
}

.edit-btn:hover {
    background-color: var(--primary-dark);
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

.modal-content .modal-body {
    overflow-y: auto;
    flex: 1;
}

.modal-content .modal-footer {
    flex-shrink: 0;
    border-top: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.modal-content .modal-header {
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-color);
}

.modal-content.modal-large {
    max-width: 800px;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 20px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s ease;
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

/* 表单 */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* 导入视图 */
.import-section {
    max-width: 900px;
}

.import-section h2 {
    margin-bottom: 30px;
    font-size: 24px;
}

.import-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.option-card {
    background: var(--bg-primary);
    padding: 20px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    transition: all 0.3s ease;
}

.option-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.option-card h3 {
    margin-bottom: 10px;
    color: var(--text-primary);
}

.option-card p {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 15px;
}

.option-card input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 10px;
    font-size: 14px;
}

.option-card button {
    width: 100%;
}

.import-status {
    padding: 15px;
    border-radius: 6px;
    margin-top: 20px;
    display: none;
}

.import-status.success {
    background-color: #d1fae5;
    color: #065f46;
    display: block;
}

.import-status.error {
    background-color: #fee2e2;
    color: #991b1b;
    display: block;
}

/* 设置视图 */
.settings-section {
    max-width: 600px;
}

.settings-section h2 {
    margin-bottom: 30px;
    font-size: 24px;
}

.setting-item {
    background: var(--bg-primary);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
}

.setting-item label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 500;
}

.setting-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.setting-item input[type="number"] {
    width: 100px;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-left: 10px;
}

.setting-desc {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 8px;
}

/* 备份视图 */
.backup-section {
    max-width: 800px;
}

.backup-section h2 {
    margin-bottom: 20px;
    font-size: 24px;
}

.backup-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.backup-item {
    background: var(--bg-primary);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.backup-info {
    flex: 1;
}

.backup-time {
    font-weight: 500;
    color: var(--text-primary);
}

.backup-size {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 4px;
}

.backup-actions {
    display: flex;
    gap: 10px;
}

.backup-actions button {
    padding: 8px 12px;
    font-size: 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.restore-btn {
    background-color: var(--success-color);
    color: white;
}

.restore-btn:hover {
    opacity: 0.9;
}

.delete-backup-btn {
    background-color: var(--danger-color);
    color: white;
}

.delete-backup-btn:hover {
    opacity: 0.9;
}

/* 表头列表 */
.header-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.header-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    cursor: grab;
    user-select: none;
    transition: all 0.2s ease;
}

.header-item:active {
    cursor: grabbing;
    opacity: 0.7;
}

.header-item.dragging {
    opacity: 0.5;
}

.header-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.header-item span {
    flex: 1;
    font-weight: 500;
}

.drag-handle {
    color: var(--text-secondary);
    font-size: 18px;
}

/* 复选框组 */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.checkbox-item:hover {
    background-color: var(--bg-secondary);
}

.checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* 提示框 */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 6px;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    display: none;
    animation: slideIn 0.3s ease;
}

.toast.active {
    display: block;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.warning {
    background-color: #fef3c7;
    color: #92400e;
    border-left: 4px solid var(--warning-color);
}

.toast.success {
    background-color: #d1fae5;
    color: #065f46;
    border-left: 4px solid var(--success-color);
}

.toast.error {
    background-color: #fee2e2;
    color: #991b1b;
    border-left: 4px solid var(--danger-color);
}

/* 营收统计 */
.revenue-section { max-width: 900px; }
.revenue-header { display:flex; justify-content:space-between; align-items:center; margin-bottom:24px; }
.revenue-header h2 { font-size:24px; }
.revenue-month-nav { display:flex; align-items:center; gap:12px; font-size:16px; font-weight:600; }
.revenue-summary { display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:16px; margin-bottom:24px; }
.summary-card { background:var(--bg-primary); padding:20px; border-radius:10px; border:1px solid var(--border-color); box-shadow:var(--shadow-sm); }
.summary-label { font-size:13px; color:var(--text-secondary); margin-bottom:8px; }
.summary-value { font-size:22px; font-weight:700; color:var(--primary-color); }
.progress-bar { height:6px; background:var(--bg-tertiary); border-radius:3px; margin-top:8px; overflow:hidden; }
.progress-fill { height:100%; background:linear-gradient(90deg,#667eea,#764ba2); border-radius:3px; transition:width 0.4s ease; }
.calendar-container { background:var(--bg-primary); border-radius:10px; border:1px solid var(--border-color); padding:16px; margin-bottom:24px; }
.cal-grid { display:grid; grid-template-columns:repeat(7,1fr); gap:4px; }
.cal-header-cell { text-align:center; font-size:12px; font-weight:600; color:var(--text-secondary); padding:6px 0; }
.cal-cell { min-height:64px; padding:6px; border-radius:6px; background:var(--bg-secondary); cursor:pointer; transition:background 0.2s; display:flex; flex-direction:column; align-items:flex-start; }
.cal-cell.empty { background:transparent; cursor:default; }
.cal-cell:not(.empty):hover { background:var(--bg-tertiary); }
.cal-cell.today { border:2px solid var(--primary-color); }
.cal-cell.has-revenue { background:#ede9fe; }
.cal-day { font-size:13px; font-weight:600; color:var(--text-primary); }
.cal-rev { font-size:11px; color:#7c3aed; margin-top:2px; word-break:break-all; }
.extra-income-section { background:var(--bg-primary); border-radius:10px; border:1px solid var(--border-color); padding:20px; margin-bottom:24px; }
.extra-income-section h3 { margin-bottom:12px; font-size:16px; }
.extra-income-form { display:flex; gap:8px; flex-wrap:wrap; align-items:center; margin-bottom:12px; }
.extra-income-form input { padding:8px 10px; border:1px solid var(--border-color); border-radius:6px; font-size:14px; }
.extra-income-list { display:flex; flex-direction:column; gap:8px; }
.extra-income-item { display:flex; align-items:center; gap:12px; padding:10px; background:var(--bg-secondary); border-radius:6px; font-size:14px; }
.extra-date { color:var(--text-secondary); min-width:90px; }
.extra-amount { font-weight:600; color:var(--success-color); min-width:80px; }
.extra-note { flex:1; color:var(--text-primary); }
.day-detail { position:fixed; bottom:20px; left:50%; transform:translateX(-50%); background:var(--bg-primary); border-radius:10px; border:1px solid var(--border-color); box-shadow:var(--shadow-lg); padding:20px; min-width:320px; max-width:500px; z-index:500; }
.day-detail-header { display:flex; justify-content:space-between; align-items:center; margin-bottom:12px; }
.day-detail-header h3 { font-size:16px; }
.day-detail-row { display:flex; justify-content:space-between; padding:6px 0; border-bottom:1px solid var(--border-color); font-size:14px; }
.import-tips { background:var(--bg-secondary); border-radius:8px; padding:16px; margin-bottom:20px; border-left:4px solid var(--primary-color); }
.import-tips h3 { margin-bottom:8px; font-size:15px; }
.import-tips ul { padding-left:18px; color:var(--text-secondary); font-size:13px; line-height:2; }
.import-mode { margin:10px 0; display:flex; gap:16px; font-size:13px; }
.import-preview { margin-top:16px; background:var(--bg-secondary); border-radius:8px; padding:16px; }

/* 项目生成 */
.project-generate-section { max-width: 860px; }
.project-generator-panel {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 22px;
    box-shadow: var(--shadow-sm);
}
.segmented-control {
    display: inline-flex;
    gap: 6px;
    padding: 4px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}
.segmented-control label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
}
.segmented-control label:has(input:checked) {
    background: var(--bg-primary);
    box-shadow: var(--shadow-sm);
}
.project-generator-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}
.project-generate-status {
    color: var(--text-secondary);
    font-size: 13px;
    min-height: 22px;
    margin: 10px 0 4px;
}
.row-new-highlight {
    animation: rowFlash 2.6s ease;
}
@keyframes rowFlash {
    0%, 70% { background: #dcfce7; }
    100% { background: transparent; }
}


/* View mode */
.form-group.view-mode { margin-bottom:16px; }
.form-group.view-mode label { font-weight:600; color:#64748b; font-size:12px; text-transform:uppercase; letter-spacing:0.5px; margin-bottom:4px; display:block; }
.view-value { font-size:15px; color:#1e293b; padding:8px 0; border-bottom:1px solid #e2e8f0; white-space:pre-wrap; word-break:break-word; margin:0; }

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        padding: 15px;
    }

    .nav-menu {
        flex-direction: row;
        gap: 5px;
    }

    .nav-item {
        flex: 1;
        padding: 8px 12px;
        font-size: 12px;
    }

    .main-content {
        flex: 1;
    }

    .view {
        padding: 15px;
    }

    .header-section {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .action-buttons {
        width: 100%;
        flex-wrap: wrap;
    }

    .action-buttons button {
        flex: 1;
        min-width: 120px;
    }

    .import-options {
        grid-template-columns: 1fr;
    }

    .modal-content {
        max-width: 95%;
    }
}
