/* ========== Reset ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }

/* ========== 背景图叠加 ========== */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: #f0f2f5; color: #333; line-height: 1.6; min-height: 100vh;
    position: relative;
}
body.has-bg::before {
    content: '';
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-image: var(--bg-url);
    background-size: cover; background-position: center; background-repeat: no-repeat;
    z-index: -1;
}
body.has-bg::after {
    content: '';
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,var(--bg-opacity, 0.3));
    z-index: -1;
}
body.has-bg { background: transparent; }
a { color: #1677ff; text-decoration: none; }
img { max-width: 100%; }

/* ========== Auth Pages ========== */
.auth-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 20px;
    background: transparent;
}
.auth-box {
    background: rgba(255,255,255,0.95); border-radius: 20px; padding: 40px 36px;
    width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.auth-header { text-align: center; margin-bottom: 24px; }
.auth-logo { font-size: 48px; margin-bottom: 8px; }
.auth-logo-img { max-width: 200px; max-height: 80px; margin-bottom: 12px; object-fit: contain; }
.auth-header h1 { font-size: 1.4rem; color: #1a1a2e; }

.auth-tabs { display: flex; margin-bottom: 24px; border-radius: 10px; overflow: hidden; border: 1px solid #e8e8e8; }
.tab-btn { flex: 1; padding: 10px; border: none; background: #fafafa; cursor: pointer; font-size: .95rem; color: #666; transition: all .2s; }
.tab-btn.active { background: #1677ff; color: #fff; font-weight: 600; }
.tab-btn:not(.active):hover { background: #f0f0f0; }

.zhiwo-divider { display: flex; align-items: center; margin: 20px 0 16px; color: #ccc; font-size: .85rem; }
.zhiwo-divider::before, .zhiwo-divider::after { content: ''; flex: 1; height: 1px; background: #eee; }
.zhiwo-divider span { padding: 0 12px; }
.btn-zhiwo { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; padding: 12px; background: #07c160; color: #fff; border: none; border-radius: 10px; font-size: 1rem; font-weight: 600; cursor: pointer; text-decoration: none; transition: all .2s; }
.btn-zhiwo:hover { background: #06ad56; transform: translateY(-1px); }

/* ========== Form ========== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; color: #555; margin-bottom: 6px; }
.form-group input, .form-group select {
    width: 100%; padding: 10px 14px; border: 2px solid #e8e8e8; border-radius: 10px;
    font-size: .95rem; outline: none; transition: border-color .2s; background: #fff;
}
.form-group input:focus, .form-group select:focus { border-color: #1677ff; }
.form-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.btn { display: inline-block; padding: 10px 24px; border: none; border-radius: 10px; font-size: .95rem; font-weight: 600; cursor: pointer; transition: all .2s; text-align: center; }
.btn-primary { background: #1677ff; color: #fff; }
.btn-primary:hover { background: #0958d9; transform: translateY(-1px); }
.btn-full { width: 100%; padding: 12px; font-size: 1rem; }
.btn-sm { padding: 6px 14px; font-size: .85rem; }
.btn-outline { background: transparent; border: 1px solid rgba(255,255,255,0.5); color: #fff; }
.btn-outline:hover { background: rgba(255,255,255,0.15); }

/* ========== Alert ========== */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: .9rem; }
.alert-error { background: #fff2f0; border: 1px solid #ffccc7; color: #cf1322; }
.alert-success { background: #f6ffed; border: 1px solid #b7eb8f; color: #389e0d; }

/* ========== Topbar ========== */
.topbar {
    background: rgba(245,239,224,0.85);
    color: #333; padding: 0 20px; position: sticky; top: 0; z-index: 100;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(0,0,0,0.06);
}
.topbar-inner {
    max-width: 800px; margin: 0 auto; display: flex;
    align-items: center; justify-content: space-between; height: 56px;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-title { font-size: 1.1rem; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.topbar-logo { height: 28px; width: auto; display: block; }
.topbar-user { font-size: .85rem; opacity: .8; }
.topbar a { color: #333; }
.topbar .btn-outline { border-color: rgba(0,0,0,0.2); color: #333; }
.topbar .btn-outline:hover { background: rgba(0,0,0,0.06); }

/* ========== Container ========== */
.container { max-width: 800px; margin: 0 auto; padding: 20px; }

/* ========== Card ========== */
.card {
    background: rgba(255,255,255,0.92); border-radius: 16px; padding: 24px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06); margin-bottom: 20px;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.card-header h2 { font-size: 1.1rem; color: #1a1a2e; }

/* ========== Add Form ========== */
.add-form .form-row { margin-bottom: 12px; }

/* ========== Month Nav ========== */
.month-form { display: flex; gap: 8px; }
.month-form select {
    padding: 6px 10px; border: 1px solid #d9d9d9; border-radius: 8px;
    font-size: .85rem; outline: none; background: #fff; cursor: pointer;
}

/* ========== Stats ========== */
.stats-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.stat-card {
    background: rgba(248,250,252,0.9); border-radius: 12px; padding: 16px; text-align: center;
    border: 1px solid #e8e8e8;
}
.stat-label { font-size: .8rem; color: #888; margin-bottom: 4px; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: #1a1a2e; }

/* ========== Category Stats ========== */
.cat-stats { margin-top: 16px; }
.cat-stats h3 { font-size: .9rem; color: #555; margin-bottom: 12px; }
.cat-bar-row {
    display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
    font-size: .85rem;
}
.cat-label { width: 48px; color: #555; flex-shrink: 0; }
.cat-bar-bg { flex: 1; height: 20px; background: #f0f0f0; border-radius: 10px; overflow: hidden; }
.cat-bar-fill { height: 100%; background: linear-gradient(90deg, #1677ff, #69b1ff); border-radius: 10px; transition: width .3s; }
.cat-amount { width: 80px; text-align: right; font-weight: 600; color: #1a1a2e; flex-shrink: 0; }
.cat-count { width: 40px; text-align: right; color: #999; flex-shrink: 0; }

/* ========== Report List ========== */
.report-list { margin-top: 8px; }
.report-item {
    display: flex; align-items: flex-start; justify-content: space-between;
    padding: 12px; border-radius: 10px; transition: background .15s; gap: 12px;
    border-bottom: 1px solid #f5f5f5;
}
.report-item:hover { background: #f8fafc; }
.report-main { flex: 1; min-width: 0; }
.report-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; font-size: .9rem; }
.report-label { color: #999; font-size: .8rem; width: 68px; flex-shrink: 0; }
.report-value { color: #333; }
.report-tag { display: inline-block; padding: 1px 8px; background: #e6f4ff; color: #1677ff; border-radius: 6px; font-size: .8rem; }
.report-time { color: #999; font-size: .8rem; margin-left: auto; }
.report-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.report-amount { font-size: 1.1rem; font-weight: 700; color: #cf1322; }
.report-del { color: #ccc; font-size: .85rem; padding: 2px 6px; border-radius: 4px; cursor: pointer; text-decoration: none; }
.report-del:hover { color: #cf1322; background: #fff2f0; }

.expense-list { margin-top: 8px; }
.date-divider {
    font-size: .8rem; color: #999; padding: 8px 0 4px;
    border-bottom: 1px solid #f0f0f0; margin-bottom: 4px;
}
.expense-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px; border-radius: 10px; transition: background .15s;
}
.expense-item:hover { background: #f8fafc; }
.expense-left { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.expense-cat { font-size: .8rem; color: #1677ff; background: #e6f4ff; padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.expense-desc { font-size: .9rem; color: #555; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.expense-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.expense-amount { font-size: .95rem; font-weight: 700; color: #cf1322; }
.expense-del { color: #ccc; font-size: .85rem; padding: 2px 6px; border-radius: 4px; cursor: pointer; text-decoration: none; }
.expense-del:hover { color: #cf1322; background: #fff2f0; }

/* ========== Empty State ========== */
.empty-state { text-align: center; padding: 40px 20px; }
.empty-icon { font-size: 48px; margin-bottom: 8px; }
.empty-state p { color: #999; }

/* ========== Responsive ========== */
@media (max-width: 600px) {
    .form-row { grid-template-columns: 1fr; }
    .stats-row { grid-template-columns: 1fr; }
    .month-form { flex-wrap: wrap; }
    .month-form select { flex: 1; }
    .auth-box { padding: 28px 20px; }
    .stat-value { font-size: 1.2rem; }
    .cat-amount { width: 60px; font-size: .8rem; }
}
