/* ============================================================
   BZOA-PHP 全局样式（重建版）
   布局：左侧固定导航 + 右侧内容区，浅色专业风格
   品牌色与登录页一致：#667eea → #764ba2
   收支配色遵循中式财务惯例：收入=红，支出=绿
   ============================================================ */

/* 页面初始隐藏，footer.php 加载完成后显示，防 FOUC */
body {
    display: none;
    background: #f5f6fa;
    color: #1d2939;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 14px;
}

a { text-decoration: none; }

/* ---------------- 侧边导航 ---------------- */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 240px;
    background: #ffffff;
    border-right: 1px solid #e8ecf3;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: width .25s ease, transform .25s ease;
}

.sidebar-brand {
    height: 56px;
    min-height: 56px;
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: 0 .9rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    font-weight: 700;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-brand i { font-size: 1.25rem; }

.sidebar-toggle {
    margin-left: auto;
    background: transparent;
    border: 0;
    color: rgba(255, 255, 255, .85);
    font-size: .85rem;
    cursor: pointer;
    padding: .25rem .4rem;
    border-radius: .375rem;
    line-height: 1;
}

.sidebar-toggle:hover { background: rgba(255, 255, 255, .18); color: #ffffff; }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: .5rem .7rem 1rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem .75rem;
    border-radius: .5rem;
    color: #4a5568;
    font-size: .9rem;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    transition: background .15s ease, color .15s ease;
}

.nav-link i { font-size: 1.05rem; width: 1.3rem; text-align: center; flex-shrink: 0; }

.nav-link:hover { background: #f2eefc; color: #667eea; }

.nav-link.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(102, 126, 234, .35);
}

.nav-link.active:hover { color: #ffffff; }

.nav-link.text-danger { color: #dc3545; }
.nav-link.text-danger:hover { background: #fdecea; color: #b02a37; }

.nav-section {
    font-size: .72rem;
    color: #98a2b3;
    padding: .8rem .75rem .3rem;
    letter-spacing: .06em;
    white-space: nowrap;
    overflow: hidden;
}

/* 折叠状态（桌面端） */
body.sidebar-collapsed .sidebar { width: 64px; }
body.sidebar-collapsed .sidebar .nav-link span,
body.sidebar-collapsed .sidebar-brand span,
body.sidebar-collapsed .nav-section { display: none; }
body.sidebar-collapsed .main-content { margin-left: 64px; }

/* ---------------- 主内容区 ---------------- */
.main-content {
    margin-left: 240px;
    min-height: 100vh;
    transition: margin-left .25s ease;
}

.main-header {
    height: 56px;
    background: #ffffff;
    border-bottom: 1px solid #e8ecf3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.page-title { margin: 0; font-weight: 600; font-size: 1.05rem; color: #101828; }

.user-info {
    color: #667085;
    font-size: .875rem;
    display: flex;
    align-items: center;
    gap: .35rem;
    white-space: nowrap;
}

.page-content { padding: 1.25rem; }

/* ---------------- 移动端 ---------------- */
.mobile-topbar {
    display: none;
    position: sticky;
    top: 0;
    z-index: 1035;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    height: 52px;
    align-items: center;
    gap: .75rem;
    padding: 0 .75rem;
    font-weight: 600;
}

.mobile-topbar .btn-link { color: #ffffff; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(16, 24, 40, .45);
    z-index: 1035;
}

@media (max-width: 767.98px) {
    .mobile-topbar { display: flex; }
    .sidebar { transform: translateX(-100%); box-shadow: none; }
    body.sidebar-mobile-open .sidebar { transform: translateX(0); box-shadow: 0 8px 24px rgba(16, 24, 40, .18); }
    body.sidebar-mobile-open .sidebar-overlay { display: block; }
    .main-content { margin-left: 0; }
    .page-content { padding: .9rem; }
}

/* ---------------- 收支徽章（收入=红 / 支出=绿）---------------- */
.badge { font-weight: 500; padding: .32em .62em; border-radius: .375rem; }

.badge-income  { background: #fdecea; color: #d92d20; border: 1px solid #fecdca; }
.badge-expense { background: #e6f6ec; color: #067647; border: 1px solid #abefc6; }

/* ---------------- 数据表格 ---------------- */
.table-ledger { font-size: .875rem; margin-bottom: 0; }

.table-ledger thead th {
    background: #f8fafc;
    color: #475467;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 1px solid #e8ecf3;
    padding: .6rem .75rem;
}

.table-ledger td { vertical-align: middle; padding: .55rem .75rem; }
.table-ledger tbody tr:hover { background: #fafbff; }

/* ---------------- 统计卡片（仪表盘）---------------- */
.stat-card {
    background: #ffffff;
    border: 1px solid #e8ecf3;
    border-radius: .75rem;
    padding: 1rem 1.1rem;
    display: flex;
    gap: .9rem;
    align-items: center;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
    height: 100%;
}

.stat-icon {
    width: 46px;
    height: 46px;
    min-width: 46px;
    border-radius: .65rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
}

.stat-card-income   .stat-icon { background: #fdecea; color: #d92d20; }
.stat-card-expense  .stat-icon { background: #e6f6ec; color: #067647; }
.stat-card-projects .stat-icon { background: #eef4ff; color: #2e5aac; }
.stat-card-reminders .stat-icon { background: #fffaeb; color: #b54708; }

.stat-value { font-size: 1.25rem; font-weight: 700; color: #101828; line-height: 1.25; }
.stat-label { font-size: .8rem; color: #667085; margin-bottom: .1rem; }
.stat-footer { margin-top: .3rem; font-size: .78rem; color: #98a2b3; }

/* ---------------- 项目卡片 ---------------- */
.project-card { transition: box-shadow .15s ease, transform .15s ease; }
.project-card:hover { box-shadow: 0 4px 14px rgba(16, 24, 40, .10); }

/* ---------------- 租金提醒倒计时 ---------------- */
.countdown { font-variant-numeric: tabular-nums; font-weight: 600; }
.countdown.text-danger { color: #d92d20; }
.countdown.text-warning { color: #b54708; }

/* ---------------- 标记已付按钮 ---------------- */
.mark-paid { white-space: nowrap; }

/* ---------------- 登录页 ---------------- */
.login-wrapper { width: 100%; display: flex; justify-content: center; }
.login-card { max-width: 400px; width: 100%; }

/* ---------------- 打印 ---------------- */
@media print {
    .sidebar, .main-header, .mobile-topbar, .no-print, .toast-container { display: none !important; }
    .main-content { margin-left: 0; }
    body { display: block !important; background: #ffffff; }
}

/* ---------------- 滚动条（桌面端）---------------- */
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #d0d5dd; border-radius: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
