:root {
    --primary: #6c5ce7;
    --primary-light: #a29bfe;
    --primary-dark: #5a4bd1;
    --income: #00b894;
    --income-light: #e8f8f3;
    --expense: #e17055;
    --expense-light: #fdeeec;
    --bg: #f4f6fb;
    --card: #ffffff;
    --text: #2d3436;
    --text-sub: #95a5a6;
    --border: #eef0f4;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 6px 20px rgba(0, 0, 0, 0.1);
    --radius: 16px;
    --radius-sm: 10px;
    --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

body {
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ---------- 顶部导航 ---------- */
.app-header {
    background: var(--gradient);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(102, 126, 234, 0.3);
}

.header-inner {
    max-width: 1080px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 60px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 20px;
    font-weight: 700;
}

.logo-icon {
    font-size: 24px;
}

.main-nav {
    display: flex;
    gap: 4px;
}

.nav-item {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 15px;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.25s;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.15);
}

.nav-item.active {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    font-weight: 600;
}

/* ---------- 主内容区 ---------- */
.app-main {
    max-width: 1080px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

.view {
    display: none;
}

.view.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* ---------- 余额卡片 ---------- */
.balance-card {
    background: var(--gradient);
    border-radius: var(--radius);
    color: #fff;
    padding: 28px 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-hover);
    position: relative;
    overflow: hidden;
}

.balance-card::after {
    content: "";
    position: absolute;
    right: -40px;
    top: -40px;
    width: 180px;
    height: 180px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
}

.balance-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.balance-label {
    font-size: 14px;
    opacity: 0.9;
}

.balance-update {
    font-size: 12px;
    opacity: 0.7;
}

.balance-amount {
    font-size: 42px;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 20px;
}

.balance-sub {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.sub-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sub-label {
    font-size: 12px;
    opacity: 0.8;
}

.sub-value {
    font-size: 18px;
    font-weight: 600;
}

.sub-value.income { color: #b8ffdd; }
.sub-value.expense { color: #ffd6cc; }

/* ---------- 快捷操作 ---------- */
.quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
    color: #fff;
}

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

.income-btn {
    background: var(--income);
}

.expense-btn {
    background: var(--expense);
}

.action-icon {
    font-size: 20px;
}

/* ---------- 区块标题 ---------- */
.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 17px;
    font-weight: 700;
    margin: 24px 0 14px;
    color: var(--text);
}

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

.link-btn:hover {
    text-decoration: underline;
}

/* ---------- 图表卡片 ---------- */
.chart-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.chart-card.small {
    padding: 16px;
}

.chart-card canvas {
    width: 100%;
    max-height: 240px;
}

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

.chart-half {
    min-width: 0;
}

/* ---------- 资产卡片 ---------- */
.asset-summary {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.asset-mini-card {
    background: var(--card);
    border-radius: var(--radius-sm);
    padding: 16px;
    box-shadow: var(--shadow);
    transition: all 0.25s;
}

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

.asset-mini-type {
    font-size: 12px;
    color: var(--text-sub);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.asset-mini-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.asset-mini-balance {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

/* ---------- 账单列表 ---------- */
.tx-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tx-item {
    background: var(--card);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.2s;
    animation: fadeIn 0.3s ease;
}

.tx-item:hover {
    box-shadow: var(--shadow-hover);
}

.tx-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.tx-icon.income {
    background: var(--income-light);
}

.tx-icon.expense {
    background: var(--expense-light);
}

.tx-info {
    flex: 1;
    min-width: 0;
}

.tx-cat {
    font-size: 15px;
    font-weight: 600;
}

.tx-note {
    font-size: 12px;
    color: var(--text-sub);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tx-meta {
    text-align: right;
}

.tx-amount {
    font-size: 16px;
    font-weight: 700;
}

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

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

.tx-account-tag {
    font-size: 11px;
    color: var(--primary);
    background: #f0edff;
    padding: 2px 8px;
    border-radius: 10px;
    display: inline-block;
    margin-top: 4px;
}

/* ---------- 工具栏 ---------- */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.toolbar-group {
    display: flex;
    gap: 8px;
}

.filter-btn {
    padding: 8px 18px;
    border: 1px solid var(--border);
    background: var(--card);
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    color: var(--text-sub);
}

.filter-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.filter-btn.income.active {
    background: var(--income);
    border-color: var(--income);
}

.filter-btn.expense.active {
    background: var(--expense);
    border-color: var(--expense);
}

.select-input {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card);
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
    max-width: 180px;
}

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

/* ---------- 资产视图 ---------- */
.asset-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.view-title {
    font-size: 20px;
    font-weight: 700;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
}

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

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

.btn.full {
    width: 100%;
    padding: 14px;
    font-size: 16px;
}

.asset-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--card);
    border-radius: var(--radius-sm);
    padding: 20px;
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-card.highlight {
    background: var(--gradient);
    color: #fff;
}

.stat-card.highlight .stat-value.income { color: #b8ffdd; }
.stat-card.highlight .stat-value.expense { color: #ffd6cc; }

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

.stat-card.highlight .stat-label {
    color: rgba(255, 255, 255, 0.8);
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
}

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

.account-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.account-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: all 0.25s;
    border: 1px solid transparent;
}

.account-card:hover {
    box-shadow: var(--shadow-hover);
    border-color: var(--primary-light);
}

.account-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.account-name {
    font-size: 16px;
    font-weight: 700;
}

.account-type-badge {
    font-size: 11px;
    background: #f0edff;
    color: var(--primary);
    padding: 3px 10px;
    border-radius: 12px;
}

.account-balance-label {
    font-size: 12px;
    color: var(--text-sub);
    margin-bottom: 4px;
}

.account-balance {
    font-size: 26px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.account-initial {
    font-size: 12px;
    color: var(--text-sub);
}

.account-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.account-actions .btn {
    flex: 1;
    font-size: 13px;
    padding: 8px;
    background: var(--bg);
    color: var(--text);
}

.account-actions .btn.danger {
    color: var(--expense);
}

.account-actions .btn:hover {
    background: var(--border);
}

/* ---------- 统计视图 ---------- */
.stat-summary-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

/* 分类明细 */
.category-detail-list {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.category-detail-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

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

.cd-icon {
    font-size: 20px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.cd-info {
    flex: 1;
}

.cd-name {
    font-size: 14px;
    font-weight: 600;
}

.cd-count {
    font-size: 12px;
    color: var(--text-sub);
}

.cd-amount {
    font-weight: 700;
    color: var(--primary);
    font-size: 15px;
}

.cd-percent {
    width: 70px;
    text-align: right;
    font-size: 13px;
    color: var(--text-sub);
}

/* ---------- 弹窗 ---------- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--card);
    border-radius: var(--radius);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-hover);
    animation: slideUp 0.3s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--card);
    border-radius: var(--radius) var(--radius) 0 0;
    z-index: 1;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-sub);
    padding: 4px;
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 24px;
}

/* 收支切换 */
.kind-tabs {
    display: flex;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 20px;
}

.kind-tab {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    background: transparent;
    color: var(--text-sub);
    transition: all 0.25s;
}

.kind-tab.expense.active {
    background: var(--expense);
    color: #fff;
}

.kind-tab.income.active {
    background: var(--income);
    color: #fff;
}

.amount-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 8px;
}

.amount-symbol {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}

.amount-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
    background: transparent;
}

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

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-sub);
    margin-bottom: 8px;
    font-weight: 600;
}

.form-group .select-input {
    width: 100%;
    max-width: 100%;
}

/* 分类选择网格 */
.category-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.cat-select {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 4px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    background: var(--card);
    font-size: 13px;
    color: var(--text);
}

.cat-select:hover {
    border-color: var(--primary-light);
}

.cat-select.selected {
    border-color: var(--primary);
    background: #f0edff;
    color: var(--primary-dark);
    font-weight: 600;
}

.cat-select .cat-icon {
    font-size: 22px;
}

/* ---------- 空状态 ---------- */
.empty-tip {
    text-align: center;
    color: var(--text-sub);
    padding: 40px;
    font-size: 15px;
}

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 14px;
    z-index: 300;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ---------- 登录界面 ---------- */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 40px 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    text-align: center;
    animation: slideUp 0.4s ease;
}

.login-logo {
    font-size: 48px;
    margin-bottom: 12px;
}

.login-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.login-subtitle {
    font-size: 13px;
    color: var(--text-sub);
    margin-bottom: 28px;
}

.login-error {
    background: var(--expense-light);
    color: var(--expense);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    text-align: left;
}

.login-field {
    text-align: left;
    margin-bottom: 16px;
}

.login-field label {
    display: block;
    font-size: 13px;
    color: var(--text-sub);
    margin-bottom: 6px;
    font-weight: 600;
}

.login-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
    background: var(--bg);
}

.login-input:focus {
    border-color: var(--primary);
    background: #fff;
}

.login-card .btn {
    margin-top: 8px;
    padding: 14px;
    font-size: 16px;
}

/* ---------- 退出按钮 ---------- */
.logout-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    padding: 8px 14px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    margin-left: 8px;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ---------- 设置界面 ---------- */
.settings-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

.settings-section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 16px;
    letter-spacing: 1px;
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 0;
}

.settings-name {
    font-size: 15px;
    font-weight: 600;
}

.settings-desc {
    font-size: 13px;
    color: var(--text-sub);
    margin-top: 4px;
}

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
    .header-inner {
        padding: 0 16px;
    }

    .logo-text {
        font-size: 18px;
    }

    .nav-item {
        padding: 8px 10px;
        font-size: 14px;
    }

    .app-main {
        padding: 16px 14px 40px;
    }

    .chart-row {
        grid-template-columns: 1fr;
    }

    .balance-amount {
        font-size: 32px;
    }

    .stat-summary-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .category-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .account-list {
        grid-template-columns: 1fr;
    }

    .logout-btn {
        padding: 6px 10px;
        font-size: 12px;
        margin-left: 4px;
    }

    .settings-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}
