/* 记账本样式：手机端优先自适应 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg: #f5f6f8;
    --card: #ffffff;
    --text: #1f2329;
    --text-sub: #8a9099;
    --line: #eceef1;
    --primary: #2f6fed;
    --income: #1a9e5c;
    --expense: #e64545;
    --radius: 12px;
}

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

/* 顶栏 */
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--line);
}

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

.topbar-logout {
    font-size: 14px;
    color: var(--text-sub);
    text-decoration: none;
}

/* 容器：给底部导航留空间 */
.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px 16px 96px;
}

/* 提示条 */
.flash {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 14px;
    font-size: 14px;
}

.flash-success { background: #e8f6ee; color: var(--income); }
.flash-error   { background: #fdecec; color: var(--expense); }

/* 卡片网格 */
.cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 18px;
}

.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 14px;
}

.card-balance {
    grid-column: span 2;
    background: linear-gradient(135deg, #2f6fed, #5b8ff9);
    color: #fff;
}

.card-label {
    font-size: 13px;
    color: var(--text-sub);
    margin-bottom: 6px;
}

.card-balance .card-label { color: rgba(255, 255, 255, 0.85); }

.card-value {
    font-size: 20px;
    font-weight: 600;
    word-break: break-all;
}

.card-value.income  { color: var(--income); }
.card-value.expense { color: var(--expense); }
.card-value.neg     { color: var(--expense); }

/* 区块 */
.section { margin-bottom: 18px; }

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.section-title {
    font-size: 15px;
    font-weight: 600;
}

.section-more {
    font-size: 13px;
    color: var(--primary);
    text-decoration: none;
}

.empty {
    background: var(--card);
    border-radius: var(--radius);
    padding: 28px 16px;
    text-align: center;
    color: var(--text-sub);
    font-size: 14px;
}

/* 流水列表 */
.txn-list {
    list-style: none;
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
}

.txn-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
}

.txn-item:last-child { border-bottom: none; }

.txn-category { font-weight: 600; }

.txn-meta {
    font-size: 12px;
    color: var(--text-sub);
    margin-top: 2px;
}

.txn-amount {
    font-weight: 600;
    font-size: 16px;
    white-space: nowrap;
}

.txn-amount.income  { color: var(--income); }
.txn-amount.expense { color: var(--expense); }

.txn-actions {
    margin-top: 6px;
    display: flex;
    gap: 14px;
}

.link {
    background: none;
    border: none;
    padding: 0;
    font-size: 13px;
    color: var(--primary);
    text-decoration: none;
    cursor: pointer;
}

.link-danger { color: var(--expense); }

.inline-form { display: inline; }

/* 表单 */
.form { margin-bottom: 18px; }

.form-label {
    display: block;
    font-size: 13px;
    color: var(--text-sub);
    margin: 14px 0 6px;
}

.form-input {
    width: 100%;
    padding: 12px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--card);
    font-size: 15px;
    color: var(--text);
    outline: none;
}

.form-input:focus { border-color: var(--primary); }

.form-amount { font-size: 22px; font-weight: 600; }

textarea.form-input { resize: vertical; }

/* 按钮 */
.btn {
    display: inline-block;
    border: none;
    border-radius: var(--radius);
    padding: 11px 18px;
    font-size: 15px;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-default { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.btn-block { display: block; width: 100%; margin-top: 20px; }

/* 收支切换 */
.segmented {
    display: flex;
    background: var(--card);
    border-radius: var(--radius);
    padding: 4px;
    margin: 6px 0;
}

.segmented-item {
    flex: 1;
    text-align: center;
}

.segmented-item input { display: none; }

.segmented-item span {
    display: block;
    padding: 10px 0;
    border-radius: 10px;
    font-size: 15px;
    color: var(--text-sub);
}

.segmented-item input:checked + span {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}

/* 筛选区 */
.filter-form { margin-bottom: 16px; }

.filter-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.filter-row .form-input { flex: 1; }

.filter-sep { color: var(--text-sub); font-size: 13px; }

/* 分类列表 */
.cat-list {
    list-style: none;
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
}

.cat-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
}

.cat-item:last-child { border-bottom: none; }

/* 分页 */
.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 18px;
}

.pager-info { font-size: 13px; color: var(--text-sub); }

/* 登录页 */
.login-box {
    max-width: 360px;
    margin: 12vh auto 0;
    padding: 0 20px;
}

.login-logo {
    text-align: center;
    font-size: 26px;
    margin-bottom: 24px;
}

/* 底部导航 */
.bottomnav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    display: flex;
    background: var(--card);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
}

.bottomnav-item {
    flex: 1;
    text-align: center;
    padding: 8px 0 10px;
    font-size: 12px;
    color: var(--text-sub);
    text-decoration: none;
}

.bottomnav-icon {
    display: block;
    font-size: 20px;
    margin-bottom: 2px;
}

.bottomnav-item.active { color: var(--primary); font-weight: 600; }

/* 宽屏微调 */
@media (min-width: 600px) {
    .cards { grid-template-columns: repeat(3, 1fr); }
    .card-balance { grid-column: span 3; }
}
