/* 简账 H5 样式 */
:root {
	--bg: #f4f6fb;
	--card: #ffffff;
	--ink: #1e293b;
	--ink-2: #64748b;
	--ink-3: #94a3b8;
	--line: #e8edf5;
	--primary: #3b82f6;
	--primary-2: #8b5cf6;
	--danger: #ef4444;
	--success: #10b981;
	--warn: #f59e0b;
	--shadow: 0 4px 16px rgba(30, 41, 59, 0.08);
	--radius: 16px;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
	font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
	background: var(--bg);
	color: var(--ink);
	font-size: 15px;
	line-height: 1.5;
}
button { font-family: inherit; border: none; cursor: pointer; background: none; }
input, select, textarea { font-family: inherit; font-size: 15px; }

/* ---------- 布局 ---------- */
.shell { min-height: 100%; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
.page { padding: 14px 14px 24px; max-width: 560px; margin: 0 auto; }

.topbar {
	position: sticky; top: 0; z-index: 20;
	background: linear-gradient(135deg, #3b82f6, #8b5cf6);
	color: #fff;
	padding: 16px 16px 18px calc(16px + env(safe-area-inset-left));
	padding-top: calc(16px + env(safe-area-inset-top));
	border-radius: 0 0 24px 24px;
}
.topbar .tb-title { font-size: 19px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.topbar .tb-sub { font-size: 12px; opacity: .85; margin-top: 2px; }
.tb-add {
	width: 34px; height: 34px; border-radius: 50%;
	background: rgba(255,255,255,.22); color: #fff;
	font-size: 22px; line-height: 34px; text-align: center;
}

.bottomnav {
	position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
	display: flex; background: rgba(255,255,255,.94);
	backdrop-filter: blur(12px);
	border-top: 1px solid var(--line);
	padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav button {
	flex: 1; padding: 10px 0 8px; font-size: 12px; color: var(--ink-3);
	display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.bottomnav button svg { width: 22px; height: 22px; }
.bottomnav button.active { color: var(--primary); font-weight: 600; }

/* ---------- 卡片 ---------- */
.card {
	background: var(--card); border-radius: var(--radius);
	box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px;
}
.card-title { font-size: 14px; font-weight: 600; color: var(--ink-2); margin-bottom: 12px; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.stat {
	background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
	padding: 14px 16px;
}
.stat .s-label { font-size: 12px; color: var(--ink-3); }
.stat .s-value { font-size: 21px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat.danger .s-value { color: var(--danger); }
.stat.success .s-value { color: var(--success); }

/* ---------- 仪表盘 ---------- */
.gauge-wrap { display: flex; align-items: center; gap: 18px; }
.gauge-info { flex: 1; }
.gauge-ratio { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.gauge-level {
	display: inline-block; padding: 2px 12px; border-radius: 999px;
	font-size: 12px; font-weight: 600; color: #fff; margin: 6px 0;
}
.gauge-desc { font-size: 12px; color: var(--ink-2); }
.gauge-meta { font-size: 12px; color: var(--ink-3); margin-top: 8px; }

.donut-wrap { display: flex; align-items: center; gap: 16px; }
.donut-legend { flex: 1; font-size: 12px; }
.donut-legend .dl-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.dl-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.dl-name { color: var(--ink-2); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-val { font-variant-numeric: tabular-nums; color: var(--ink); }

.trend { display: flex; align-items: flex-end; gap: 10px; height: 130px; padding-top: 8px; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.trend-bars { display: flex; align-items: flex-end; gap: 3px; height: 100%; width: 100%; justify-content: center; }
.tbar { width: 9px; border-radius: 4px 4px 0 0; min-height: 2px; }
.tbar.exp { background: #f87171; }
.tbar.inc { background: #34d399; }
.trend-label { font-size: 11px; color: var(--ink-3); }
.trend-legend { display: flex; gap: 16px; justify-content: center; margin-top: 10px; font-size: 12px; color: var(--ink-2); }
.trend-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

.recent-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.recent-row:last-child { border-bottom: none; }
.recent-main { flex: 1; min-width: 0; }
.recent-name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-sub { font-size: 11px; color: var(--ink-3); }
.recent-amt { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- 列表/条目 ---------- */
.item-card {
	background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
	padding: 14px 16px; margin-bottom: 12px;
}
.item-head { display: flex; justify-content: space-between; align-items: baseline; }
.item-name { font-size: 15px; font-weight: 600; }
.item-badge {
	font-size: 10px; padding: 1px 8px; border-radius: 999px; margin-left: 6px;
	background: #eff6ff; color: var(--primary); vertical-align: 2px;
}
.item-badge.credit { background: #fef3c7; color: #b45309; }
.item-big { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--danger); }
.item-big.green { color: var(--success); }
.item-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink-2); margin-top: 6px; }
.item-actions { display: flex; gap: 8px; margin-top: 10px; }

.progress { height: 6px; background: var(--line); border-radius: 3px; margin-top: 10px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-2)); border-radius: 3px; }

.btn {
	padding: 7px 14px; border-radius: 10px; font-size: 13px;
	background: #f1f5f9; color: var(--ink-2);
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.danger { background: #fee2e2; color: var(--danger); }
.btn.full { width: 100%; padding: 12px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 按钮加载中：转圈图标 + 阻止交互 */
.btn.is-loading { pointer-events: none; opacity: .75; }
.btn.is-loading::before {
	content: ''; display: inline-block; width: 12px; height: 12px;
	margin-right: 6px; border-radius: 50%; vertical-align: -2px;
	border: 2px solid currentColor; border-top-color: transparent;
	animation: btn-spin .7s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; }
.chip {
	flex-shrink: 0; padding: 5px 12px; border-radius: 999px; font-size: 12px;
	background: var(--card); box-shadow: var(--shadow); color: var(--ink-2);
}
.chip b { color: var(--ink); font-variant-numeric: tabular-nums; }

.seg { display: flex; background: var(--card); border-radius: 12px; padding: 4px; box-shadow: var(--shadow); margin-bottom: 14px; }
.seg button { flex: 1; padding: 8px; border-radius: 9px; font-size: 14px; color: var(--ink-2); }
.seg button.active { background: var(--primary); color: #fff; font-weight: 600; }

.month-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.month-row input[type="month"] {
	border: none; background: var(--card); box-shadow: var(--shadow);
	border-radius: 10px; padding: 8px 12px; color: var(--ink); font-size: 14px;
}
.month-sum { font-size: 13px; color: var(--ink-2); }
.month-sum b { color: var(--danger); font-variant-numeric: tabular-nums; }

.date-group { font-size: 12px; color: var(--ink-3); margin: 14px 4px 8px; }

.empty { text-align: center; color: var(--ink-3); padding: 40px 0; font-size: 13px; }

/* ---------- 认证页 ---------- */
.auth-page {
	min-height: 100vh; display: flex; flex-direction: column; justify-content: center;
	padding: 24px; max-width: 420px; margin: 0 auto;
}
.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-logo .logo-icon {
	width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 12px;
	background: linear-gradient(135deg, #3b82f6, #8b5cf6);
	display: flex; align-items: center; justify-content: center;
}
.auth-logo h1 { font-size: 22px; }
.auth-logo p { font-size: 13px; color: var(--ink-2); margin-top: 4px; }
.auth-tip { font-size: 12px; color: var(--ink-2); background: #eff6ff; border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; }
.key-box {
	background: #0f172a; color: #a5f3fc; font-family: ui-monospace, monospace;
	font-size: 13px; word-break: break-all; border-radius: 12px;
	padding: 14px; margin: 12px 0; user-select: all;
}
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); margin: 10px 0 14px; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 5px; }
.field input, .field select, .field textarea {
	width: 100%; border: 1px solid var(--line); border-radius: 10px;
	padding: 10px 12px; background: #f8fafc; color: var(--ink); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); background: #fff; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- 弹层 ---------- */
.mask {
	position: fixed; inset: 0; z-index: 50; background: rgba(15, 23, 42, .45);
	display: flex; align-items: flex-end; justify-content: center;
}
.modal {
	background: #fff; width: 100%; max-width: 560px; max-height: 88vh;
	border-radius: 20px 20px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
	overflow-y: auto;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h3 { font-size: 16px; }
.modal-close { font-size: 18px; color: var(--ink-3); padding: 4px 8px; }

.toast {
	position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom));
	transform: translateX(-50%); z-index: 60;
	background: rgba(15, 23, 42, .9); color: #fff; font-size: 13px;
	padding: 9px 18px; border-radius: 999px; animation: fadein .2s;
}
@keyframes fadein { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------- 设置页 ---------- */
.setting-row {
	display: flex; justify-content: space-between; align-items: center;
	padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px;
}
.setting-row:last-child { border-bottom: none; }
.setting-row .sr-val { color: var(--ink-3); font-size: 12px; }
.sec-list { font-size: 12px; color: var(--ink-2); }
.sec-list li { margin: 4px 0 4px 18px; }

/* ---------- 选项配置页 ---------- */
.cfg-toolbar {
	display: flex; justify-content: space-between; align-items: center;
	padding-bottom: 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px;
}
.cfg-row {
	display: flex; align-items: center; gap: 12px;
	padding: 10px 0; border-bottom: 1px solid var(--line);
}
.cfg-row:last-of-type { border-bottom: none; }
.cfg-row.is-hidden { opacity: .5; }
.cfg-check { width: 17px; height: 17px; accent-color: var(--primary); flex: none; }
.cfg-name {
	flex: 1; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.cfg-act { display: flex; gap: 8px; flex: none; }
.cfg-act .btn { padding: 5px 12px; font-size: 12px; }

@media (min-width: 640px) {
	.mask { align-items: center; }
	.modal { border-radius: 20px; }
	/* 宽屏导航居中：显式宽度 + left:50% 平移，与 .page 内容区对齐 */
	.bottomnav { right: auto; left: 50%; transform: translateX(-50%); width: 560px; border-radius: 20px 20px 0 0; box-shadow: 0 -2px 16px rgba(0,0,0,.08); border: 1px solid var(--line); border-bottom: none; }
}

/* ---------- 首页可点击指标卡 ---------- */
.stat-link { text-align: left; cursor: pointer; transition: transform .15s, box-shadow .15s; }
.stat-link:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,.1); }
.stat-link:active { transform: translateY(0); }
.stat-link .s-hint {
	display: block; margin-top: 4px; font-size: 11px; color: var(--ink-3); font-weight: 400;
}
