/* ── 设计系统 ─────────────────────────────────────── */
:root {
    --sidebar-w: 260px;
    --sidebar-bg: #0b0f19;
    --sidebar-hover: rgba(255, 255, 255, 0.06);
    --sidebar-active: rgba(99, 102, 241, 0.18);
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.35);
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --bg: #eef1f6;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 4px 6px rgba(15, 23, 42, 0.04), 0 20px 48px rgba(15, 23, 42, 0.1);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }

body.app-body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── 侧边栏 ───────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform var(--transition);
    border-right: 1px solid rgba(255,255,255,0.05);
}

.sidebar-brand {
    padding: 1.5rem 1.25rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.02em;
}

.sidebar-brand .brand-icon {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--accent), #a855f7);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
}

.sidebar-nav .nav-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.35);
    padding: 0.5rem 0.75rem 0.35rem;
    margin-top: 0.5rem;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    margin-bottom: 2px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
}

.sidebar-nav .nav-link i {
    font-size: 1.15rem;
    width: 1.25rem;
    text-align: center;
    opacity: 0.8;
}

.sidebar-nav .nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background: var(--sidebar-active);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--accent-light);
}

.sidebar-nav .nav-link.active i { opacity: 1; color: var(--accent-light); }

.sidebar-footer {
    padding: 1rem 0.75rem;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.04);
}

.user-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #a855f7);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.user-chip .user-name {
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-logout {
    background: none;
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.6);
    border-radius: 8px;
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
    color: #fca5a5;
}

/* ── 主内容区 ─────────────────────────────────────── */
.main-wrapper {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1030;
}

.btn-sidebar-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.4rem 0.6rem;
    font-size: 1.2rem;
    color: var(--text);
    cursor: pointer;
}

.main-content {
    flex: 1;
    padding: 2rem 2.25rem 3rem;
    max-width: 1400px;
}

/* ── 页面标题 ─────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin: 0 0 0.25rem;
    color: var(--text);
}

.page-header .page-subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin: 0;
}

.page-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

/* ── 统计卡片 ─────────────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.25rem 1.35rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: transform var(--transition), box-shadow var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    border-radius: var(--radius) var(--radius) 0 0;
}

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

.stat-card.stat-indigo::before { background: linear-gradient(90deg, #6366f1, #818cf8); }
.stat-card.stat-emerald::before { background: linear-gradient(90deg, #10b981, #34d399); }
.stat-card.stat-sky::before { background: linear-gradient(90deg, #0ea5e9, #38bdf8); }
.stat-card.stat-amber::before { background: linear-gradient(90deg, #f59e0b, #fbbf24); }

.stat-icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.stat-indigo .stat-icon { background: rgba(99,102,241,0.12); color: #6366f1; }
.stat-emerald .stat-icon { background: rgba(16,185,129,0.12); color: #10b981; }
.stat-sky .stat-icon { background: rgba(14,165,233,0.12); color: #0ea5e9; }
.stat-amber .stat-icon { background: rgba(245,158,11,0.12); color: #f59e0b; }

.stat-body .stat-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.2rem;
}

.stat-body .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
    color: var(--text);
}

.stat-body .stat-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

/* ── 面板卡片 ─────────────────────────────────────── */
.panel-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
    height: 100%;
}

.panel-card .panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.35rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}

.panel-card .panel-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-card .panel-header h3 i {
    color: var(--accent);
    font-size: 1rem;
}

.panel-card .panel-body {
    padding: 1.25rem 1.35rem;
}

.panel-card .panel-body-flush {
    padding: 0;
}

/* ── 按钮 ─────────────────────────────────────────── */
.btn-accent {
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    border: none;
    color: #fff;
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.5rem 1.1rem;
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 8px var(--accent-glow);
    transition: all var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-accent:hover {
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-ghost {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-ghost:hover {
    background: var(--surface-2);
    color: var(--text);
    border-color: #cbd5e1;
}

.btn-sm-link {
    font-size: 0.8rem;
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.btn-sm-link:hover { color: #4f46e5; }

/* ── 进度条 ───────────────────────────────────────── */
.progress-modern {
    height: 8px;
    background: #e2e8f0;
    border-radius: 99px;
    overflow: hidden;
    margin-top: 0.6rem;
}

.progress-modern .progress-fill {
    height: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg, var(--accent), #a855f7);
    transition: width 0.6s ease;
    min-width: 0;
}

.progress-modern .progress-fill.complete {
    background: linear-gradient(90deg, #10b981, #34d399);
}

.goal-row {
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border);
}
.goal-row:last-child { border-bottom: none; padding-bottom: 0; }
.goal-row:first-child { padding-top: 0; }

.goal-row-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.1rem;
}

.goal-row-header strong {
    font-size: 0.9rem;
    font-weight: 600;
}

.goal-row-header span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ── 列表项 ───────────────────────────────────────── */
.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.35rem;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
    gap: 1rem;
}

.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--surface-2); }

.list-item .item-main {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
}

.list-item .item-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.list-item .item-amount {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

/* ── 任务卡片 ─────────────────────────────────────── */
.task-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    transition: all var(--transition);
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.task-card:hover {
    box-shadow: var(--shadow-lg);
    border-color: #cbd5e1;
}

.task-card.completed { opacity: 0.65; }

.task-check {
    width: 20px; height: 20px;
    accent-color: var(--accent);
    cursor: pointer;
    margin-top: 2px;
    flex-shrink: 0;
}

.task-content { flex: 1; min-width: 0; }

.task-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
}

.task-title.done { text-decoration: line-through; color: var(--text-muted); }

.task-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 0.25rem 0;
}

.task-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.task-actions {
    display: flex;
    gap: 0.35rem;
    flex-shrink: 0;
}

/* ── 徽章 ─────────────────────────────────────────── */
.badge-priority {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: 99px;
    letter-spacing: 0.02em;
}

.badge-high { background: rgba(239,68,68,0.12); color: #dc2626; }
.badge-mid { background: rgba(245,158,11,0.12); color: #d97706; }
.badge-low { background: rgba(100,116,139,0.12); color: #64748b; }

/* ── 表单 ─────────────────────────────────────────── */
.form-panel {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 1.75rem 2rem;
    max-width: 640px;
}

.form-panel .form-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.35rem;
}

.form-panel .form-control,
.form-panel .form-select,
.main-content .form-control,
.main-content .form-select {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.85rem;
    font-size: 0.9rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    background: var(--surface);
}

.form-panel .form-control:focus,
.form-panel .form-select:focus,
.main-content .form-control:focus,
.main-content .form-select:focus {
    border-color: var(--accent-light);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ── 表格 ─────────────────────────────────────────── */
.table-modern {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.875rem;
}

.table-modern thead th {
    background: var(--surface-2);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table-modern thead th:first-child { border-radius: var(--radius-sm) 0 0 0; }
.table-modern thead th:last-child { border-radius: 0 var(--radius-sm) 0 0; }

.table-modern tbody td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table-modern tbody tr:last-child td { border-bottom: none; }
.table-modern tbody tr:hover td { background: var(--surface-2); }

.table-wrap {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table-wrap .table-responsive { margin: 0; }

/* ── 空状态 / 提示 ─────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 2.5rem;
    opacity: 0.3;
    display: block;
    margin-bottom: 0.75rem;
}

.alert-modern {
    border-radius: var(--radius-sm);
    border: none;
    font-size: 0.875rem;
    padding: 0.85rem 1.1rem;
}

/* ── 登录页 ───────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sidebar-bg);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(99,102,241,0.25) 0%, transparent 70%);
    top: -200px; right: -100px;
    pointer-events: none;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 500px; height: 500px;
    background: radial-gradient(circle, rgba(168,85,247,0.2) 0%, transparent 70%);
    bottom: -150px; left: -100px;
    pointer-events: none;
}

.login-card {
    background: rgba(255,255,255,0.04);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px;
    padding: 2.5rem 2.25rem;
    width: 100%;
    max-width: 400px;
    position: relative;
    z-index: 1;
    box-shadow: 0 25px 60px rgba(0,0,0,0.4);
}

.login-card .login-logo {
    width: 48px; height: 48px;
    background: linear-gradient(135deg, var(--accent), #a855f7);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: #fff;
    margin: 0 auto 1.25rem;
    box-shadow: 0 8px 24px var(--accent-glow);
}

.login-card h2 {
    color: #fff;
    text-align: center;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 0.35rem;
}

.login-card .login-sub {
    text-align: center;
    color: rgba(255,255,255,0.45);
    font-size: 0.85rem;
    margin-bottom: 1.75rem;
}

.login-card .form-label { color: rgba(255,255,255,0.7); font-size: 0.82rem; font-weight: 500; }

.login-card .form-control {
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.12);
    color: #fff;
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.9rem;
}

.login-card .form-control:focus {
    background: rgba(255,255,255,0.1);
    border-color: var(--accent-light);
    box-shadow: 0 0 0 3px var(--accent-glow);
    color: #fff;
}

.login-card .form-control::placeholder { color: rgba(255,255,255,0.3); }

.btn-login {
    width: 100%;
    padding: 0.7rem;
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    margin-top: 0.5rem;
    box-shadow: 0 4px 16px var(--accent-glow);
    transition: all var(--transition);
}

.btn-login:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px var(--accent-glow);
}

/* ── 快捷表单 ─────────────────────────────────────── */
.quick-form-panel {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.quick-form-panel .panel-header {
    background: linear-gradient(135deg, rgba(99,102,241,0.08), rgba(168,85,247,0.06));
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.35rem;
}

.quick-form-panel .panel-body { padding: 1.25rem 1.35rem; }

/* ── Bootstrap 覆盖 ───────────────────────────────── */
.main-content .card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.main-content .btn-primary {
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    border: none;
    font-weight: 600;
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 8px var(--accent-glow);
}

.main-content .btn-primary:hover {
    background: linear-gradient(135deg, #4f46e5, #6d28d9);
    box-shadow: 0 4px 16px var(--accent-glow);
}

.main-content .btn-outline-primary {
    border-color: var(--accent);
    color: var(--accent);
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.main-content .btn-outline-primary:hover {
    background: var(--accent);
    border-color: var(--accent);
}

.main-content .btn-outline-secondary,
.main-content .btn-outline-danger,
.main-content .btn-outline-success,
.main-content .btn-outline-info {
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.82rem;
}

.main-content .progress {
    border-radius: 99px;
    background: #e2e8f0;
}

.main-content .progress-bar {
    background: linear-gradient(90deg, var(--accent), #a855f7);
    border-radius: 99px;
}

.main-content .list-group-item {
    border-color: var(--border);
    padding: 0.85rem 1.25rem;
}

.main-content .alert-info {
    background: rgba(99,102,241,0.08);
    color: #4338ca;
    border: 1px solid rgba(99,102,241,0.2);
    border-radius: var(--radius-sm);
}

/* ── 笔记 / Markdown ──────────────────────────────── */
.note-content h1, .note-content h2, .note-content h3 { margin-top: 1.25rem; font-weight: 700; }
.note-content pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: 0.85rem;
}
.note-content code {
    background: rgba(99,102,241,0.1);
    color: #4338ca;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
}
.note-content blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1rem;
    color: var(--text-muted);
    margin: 1rem 0;
}

.note-list-item {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.35rem;
    margin-bottom: 0.65rem;
    text-decoration: none;
    color: inherit;
    transition: all var(--transition);
    box-shadow: var(--shadow);
}

.note-list-item:hover {
    border-color: var(--accent-light);
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
    color: inherit;
}

.note-list-item h6 {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.3rem;
    color: var(--text);
}

.note-list-item p {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.category-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1.25rem;
}

.category-pills a {
    padding: 0.35rem 0.85rem;
    border-radius: 99px;
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    background: var(--surface);
    transition: all var(--transition);
}

.category-pills a:hover,
.category-pills a.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ── 盈亏颜色 ─────────────────────────────────────── */
.text-profit { color: #10b981; font-weight: 600; }
.text-loss { color: #ef4444; font-weight: 600; }

/* ── 响应式 ───────────────────────────────────────── */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1035;
    }
    .sidebar-overlay.show { display: block; }
    .main-wrapper { margin-left: 0; }
    .topbar { display: flex; }
    .main-content { padding: 1.25rem 1rem 2rem; }
}

@media (max-width: 576px) {
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .stat-body .stat-value { font-size: 1.4rem; }
    .page-header { flex-direction: column; }
    .task-actions { flex-direction: column; }
}

/* ── 页面切换加载条 ───────────────────────────────── */
.page-loader {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 3px;
    z-index: 9999;
    background: linear-gradient(90deg, var(--accent), #a855f7);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
    pointer-events: none;
}

.htmx-request#page-loader,
.htmx-request.page-loader {
    transform: scaleX(0.7);
    transition: transform 0.8s ease;
}

body.htmx-request .main-content {
    opacity: 0.85;
    transition: opacity 0.15s;
}

/* ── 暗色模式 ─────────────────────────────────────── */
[data-theme="dark"] {
    --sidebar-bg: #070a12;
    --surface: #111827;
    --surface-2: #1a2234;
    --bg: #0b0f19;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #1e293b;
    --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.25);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.2), 0 20px 48px rgba(0,0,0,0.35);
}

[data-theme="dark"] .panel-card .panel-header,
[data-theme="dark"] .table-modern thead th {
    background: #151d32;
}

[data-theme="dark"] .form-panel .form-control,
[data-theme="dark"] .main-content .form-control,
[data-theme="dark"] .main-content .form-select {
    background: #1a2234;
    color: #f1f5f9;
    border-color: #334155;
}

[data-theme="dark"] .topbar {
    background: var(--surface);
    border-color: var(--border);
}

.theme-toggle {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.7);
    border-radius: 8px;
    padding: 0.35rem 0.55rem;
    cursor: pointer;
    margin-left: 0.5rem;
    transition: all var(--transition);
}

.theme-toggle:hover { background: rgba(255,255,255,0.12); color: #fff; }

/* ── 问候横幅 ───────────────────────────────────── */
.greeting-banner {
    background: linear-gradient(135deg, rgba(99,102,241,0.12), rgba(168,85,247,0.08));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.greeting-banner h2 {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0 0 0.25rem;
    letter-spacing: -0.02em;
}

.greeting-banner p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.prediction-badge {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 99px;
    font-weight: 600;
}

.pred-on_track, .pred-active, .pred-completed { background: rgba(16,185,129,0.15); color: #10b981; }
.pred-behind, .pred-overdue { background: rgba(239,68,68,0.15); color: #ef4444; }
.pred-stalled { background: rgba(100,116,139,0.15); color: #64748b; }

/* ── 移动端底部导航 ─────────────────────────────── */
.mobile-tabbar {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 0.35rem 0 calc(0.35rem + env(safe-area-inset-bottom));
    z-index: 1050;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
    justify-content: space-around;
}

.mobile-tabbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 500;
    padding: 0.35rem 0.5rem;
    border-radius: 8px;
    min-width: 56px;
}

.mobile-tabbar a i { font-size: 1.2rem; }
.mobile-tabbar a.active { color: var(--accent); }

@media (max-width: 991px) {
    .mobile-tabbar { display: flex; }
    .main-content { padding-bottom: 5rem !important; }
    .sidebar-footer .theme-toggle { display: none; }
}

.holdings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.holding-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    box-shadow: var(--shadow);
}

.holding-card .symbol {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.report-stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* ── 手机快捷记录 ─────────────────────────────────── */
.mobile-shortcuts {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.65rem;
}

.shortcut-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 1rem 0.5rem;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    font-size: 0.75rem;
    font-weight: 600;
    transition: transform var(--transition);
}

.shortcut-btn i { font-size: 1.5rem; }
.shortcut-btn:active { transform: scale(0.96); }
.shortcut-diet i { color: #f59e0b; }
.shortcut-fitness i { color: #10b981; }
.shortcut-task i { color: #6366f1; }
.shortcut-check i { color: #0ea5e9; }

.mobile-fab {
    display: none;
    position: fixed;
    right: 1.25rem;
    bottom: 5.5rem;
    width: 56px; height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    color: #fff;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 20px var(--accent-glow);
    z-index: 1045;
    text-decoration: none;
    transition: transform var(--transition);
}

.mobile-fab:active { transform: scale(0.92); }

.mobile-tabbar .tab-record i {
    font-size: 1.6rem;
    color: var(--accent);
}

@media (max-width: 991px) {
    .mobile-fab { display: flex; }
    .main-content input,
    .main-content select,
    .main-content textarea,
    .main-content .form-control {
        font-size: 16px !important; /* 防止 iOS 缩放 */
    }
}

@media (max-width: 400px) {
    .mobile-shortcuts { grid-template-columns: repeat(2, 1fr); }
}
