/* ============================================
   极简主义财务OA 样式表
   风格：苹果风极简、灰白主调、柔和阴影
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #0071e3;
    --primary-hover: #0077ed;
    --text-main: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-light: #86868b;
    --bg-main: #f5f5f7;
    --bg-white: #ffffff;
    --border: #d2d2d7;
    --border-light: #e8e8ed;
    --success: #34c759;
    --danger: #ff3b30;
    --warning: #ff9500;
    --sidebar-width: 220px;
    --header-height: 60px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC",
                 "Helvetica Neue", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    color: var(--text-main);
    background: var(--bg-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

.login-box {
    background: var(--bg-white);
    border-radius: 16px;
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-hover);
}

.login-logo {
    text-align: center;
    font-size: 24px;
    font-weight: 600;
    letter-spacing: 2px;
    margin-bottom: 8px;
}

.login-box h2 {
    text-align: center;
    font-size: 18px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-main);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: all 0.2s;
    background: var(--bg-white);
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}

.login-error {
    color: var(--danger);
    font-size: 13px;
    margin-bottom: 16px;
    min-height: 18px;
}

/* ============ 按钮 ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    gap: 6px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--bg-main);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border-light);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #e0342b;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-block {
    width: 100%;
    padding: 12px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-text {
    background: none;
    color: var(--primary);
    padding: 4px 8px;
}

.btn-text:hover {
    background: rgba(0, 113, 227, 0.08);
}

.btn-text.danger {
    color: var(--danger);
}

/* ============ 主布局 ============ */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-white);
    border-right: 1px solid var(--border-light);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
    transition: transform 0.3s;
}

.sidebar-logo {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border-light);
}

.logo-text {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 1px;
}

.nav-menu {
    padding: 12px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
    gap: 12px;
}

.nav-item:hover {
    background: var(--bg-main);
    color: var(--text-main);
}

.nav-item.active {
    background: rgba(0, 113, 227, 0.08);
    color: var(--primary);
    font-weight: 500;
}

.nav-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.main-container {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

.top-header {
    height: var(--header-height);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
    gap: 16px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
}

.page-title {
    font-size: 18px;
    font-weight: 600;
    flex: 1;
}

.header-right {
    display: flex;
    align-items: center;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-name {
    font-weight: 500;
}

.dropdown-toggle {
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}

.dropdown-toggle:hover {
    background: var(--bg-main);
}

.user-dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-hover);
    min-width: 140px;
    display: none;
    z-index: 200;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: var(--bg-main);
}

.page-content {
    padding: 24px;
    flex: 1;
}

/* ============ 卡片 ============ */
.card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

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

.card-title {
    font-size: 16px;
    font-weight: 600;
}

/* 统计卡片 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 26px;
    font-weight: 600;
    color: var(--text-main);
}

.stat-value.income { color: var(--success); }
.stat-value.expense { color: var(--danger); }

.stat-sub {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 6px;
}

/* 图表网格 */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.chart-box {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.chart-container {
    width: 100%;
    height: 300px;
}

/* ============ 表格 ============ */
.table-wrapper {
    overflow-x: auto;
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    background: var(--bg-main);
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    border-bottom: 1px solid var(--border-light);
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}

.data-table tbody tr:hover {
    background: rgba(0, 113, 227, 0.03);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.text-right { text-align: right; }
.text-center { text-align: center; }
.data-table th.text-right,
.data-table td.text-right { text-align: right; }
.data-table th.text-center,
.data-table td.text-center { text-align: center; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-light); }

/* ============ 筛选栏 ============ */
.filter-bar {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.filter-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-item label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.filter-item input,
.filter-item select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    min-width: 130px;
}

.filter-actions {
    display: flex;
    gap: 8px;
}

/* ============ 筛选结果汇总条 ============ */
.filter-summary {
    display: flex;
    align-items: center;
    gap: 28px;
    flex-wrap: wrap;
    padding: 14px 20px;
    margin-bottom: 16px;
}
.filter-summary-label {
    color: var(--text-secondary);
    font-size: 13px;
}
.filter-summary-item {
    font-size: 13px;
    color: var(--text-secondary);
}
.filter-summary-item strong {
    font-size: 15px;
    margin-left: 6px;
    font-weight: 600;
}

/* ============ 分页 ============ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    background: var(--bg-white);
}

.pagination-info {
    color: var(--text-secondary);
    font-size: 13px;
    margin-right: auto;
}

.page-btn {
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: var(--bg-white);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    min-width: 36px;
    transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

.page-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============ 模态框 ============ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.2s;
}

.modal-box {
    background: var(--bg-white);
    border-radius: var(--radius);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-hover);
    animation: slideUp 0.25s;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 17px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-light);
    line-height: 1;
    padding: 4px;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ============ Toast 提示 ============ */
#toast-container {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    background: var(--bg-white);
    box-shadow: var(--shadow-hover);
    font-size: 14px;
    animation: slideInRight 0.3s;
    border-left: 4px solid var(--primary);
    min-width: 200px;
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

/* ============ 标签徽章 ============ */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background: rgba(52, 199, 89, 0.12);
    color: var(--success);
}

.badge-warning {
    background: rgba(255, 149, 0, 0.12);
    color: var(--warning);
}

.badge-danger {
    background: rgba(255, 59, 48, 0.12);
    color: var(--danger);
}

.badge-info {
    background: rgba(0, 113, 227, 0.12);
    color: var(--primary);
}

.badge-secondary {
    background: var(--bg-main);
    color: var(--text-secondary);
}

.badge-primary {
    background: rgba(0, 113, 227, 0.12);
    color: var(--primary);
}

/* ============ 动画 ============ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ============ 响应式 ============ */
@media (max-width: 992px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-hover);
    }
    .main-container {
        margin-left: 0;
    }
    .menu-toggle {
        display: block;
    }
    .page-content {
        padding: 16px;
    }
    .top-header {
        padding: 0 16px;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .stat-value {
        font-size: 20px;
    }
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-item input,
    .filter-item select {
        min-width: 0;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .login-box {
        padding: 32px 24px;
    }
    .user-name {
        display: none;
    }
}

/* ============================================
   项目利润仪表盘
   ============================================ */
.nowrap {
    white-space: nowrap;
}

.dash-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.dash-stat {
    background: var(--bg-main);
    border-radius: var(--radius-sm);
    padding: 16px;
}

.dash-stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.dash-stat-value {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-main);
}

.dash-chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.dash-chart-card {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 14px;
}

.dash-chart-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.dash-note {
    margin-top: 14px;
    font-size: 12px;
    color: var(--text-light);
    line-height: 1.6;
}

@media (max-width: 760px) {
    .dash-stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .dash-chart-grid {
        grid-template-columns: 1fr;
    }
}
