/* ===========================================================
   共用 CSS — TodoList + 收支查询系统
   =========================================================== */

/* ---------- CSS 变量 ---------- */
:root {
    --primary: #4f46e5;
    --primary-light: #818cf8;
    --primary-bg: #eef2ff;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --sidebar-width: 240px;
    --header-height: 56px;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-lg: 0 4px 12px rgba(0,0,0,.1);
}

/* ---------- 全局重置 ---------- */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    font-size: 14px;
    line-height: 1.6;
}

/* ---------- 侧边栏布局 ---------- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, #1e1b4b 0%, #312e81 100%);
    color: #fff;
    z-index: 1000;
    transition: transform .3s;
}
.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -.02em;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-brand i {
    font-size: 1.4rem;
    margin-right: .6rem;
}
.sidebar-nav {
    padding: .75rem 0;
}
.sidebar-nav .nav-item {
    padding: .6rem 1.25rem;
    display: flex;
    align-items: center;
    color: rgba(255,255,255,.7);
    text-decoration: none;
    transition: all .15s;
    font-size: .9rem;
    border-left: 3px solid transparent;
}
.sidebar-nav .nav-item:hover,
.sidebar-nav .nav-item.active {
    color: #fff;
    background: rgba(255,255,255,.1);
}
.sidebar-nav .nav-item.active {
    border-left-color: var(--primary-light);
}
.sidebar-nav .nav-item i {
    width: 22px;
    margin-right: .7rem;
    font-size: 1.1rem;
}

/* ---------- 主内容区 ---------- */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}
.main-header {
    height: var(--header-height);
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 999;
    box-shadow: var(--shadow);
}
.main-header h5 {
    margin: 0;
    font-weight: 600;
}
.page-content {
    padding: 1.25rem 1.5rem 2rem;
}

/* ---------- 卡片 ---------- */
.card {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--gray-200);
    padding: .9rem 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ---------- 统计卡片 ---------- */
.stat-card {
    border-radius: var(--radius-lg);
    padding: 1.2rem 1.25rem;
    color: #fff;
    position: relative;
    overflow: hidden;
}
.stat-card .stat-icon {
    position: absolute;
    right: 1rem;
    bottom: 1rem;
    font-size: 3rem;
    opacity: .2;
}
.stat-card .stat-label {
    font-size: .85rem;
    opacity: .85;
    margin-bottom: .3rem;
}
.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
}
.stat-card.bg-primary { background: linear-gradient(135deg, #4f46e5, #6366f1); }
.stat-card.bg-success { background: linear-gradient(135deg, #059669, #10b981); }
.stat-card.bg-warning { background: linear-gradient(135deg, #d97706, #f59e0b); }
.stat-card.bg-info { background: linear-gradient(135deg, #2563eb, #3b82f6); }
.stat-card.bg-danger { background: linear-gradient(135deg, #dc2626, #ef4444); }

/* ---------- 表格 ---------- */
.table th {
    font-weight: 600;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--gray-500);
    border-top: none;
    white-space: nowrap;
}
.table td {
    vertical-align: middle;
}

/* ---------- 标签 ---------- */
.badge-priority {
    font-weight: 500;
    font-size: .75rem;
    padding: .2em .6em;
}
.badge-high { background: #fee2e2; color: #b91c1c; }
.badge-medium { background: #fef3c7; color: #92400e; }
.badge-low { background: #dbeafe; color: #1e40af; }

.badge-income {
    background: #d1fae5;
    color: #065f46;
}
.badge-expense {
    background: #fee2e2;
    color: #991b1b;
}

/* ---------- 金额 ---------- */
.amount-income { color: var(--success); font-weight: 600; }
.amount-expense { color: var(--danger); font-weight: 600; }

/* ---------- 空状态 ---------- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray-400);
}
.empty-state i {
    font-size: 3rem;
    margin-bottom: .8rem;
    display: block;
}

/* ---------- Toast 通知 ---------- */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
}

/* ---------- 快捷按钮行 ---------- */
.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: 1rem;
}
.filter-bar {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}
.filter-bar .form-select,
.filter-bar .form-control {
    width: auto;
    min-width: 120px;
}

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .page-content {
        padding: .8rem;
    }
    .filter-bar .form-select,
    .filter-bar .form-control {
        min-width: 100px;
        font-size: .8rem;
    }
}

/* ---------- 模态框调整 ---------- */
.modal-header {
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

/* ---------- 加载动画 ---------- */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}
.spinner-custom {
    width: 2.5rem;
    height: 2.5rem;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
