:root {
  --bg: #f5f6f4;
  --surface: #ffffff;
  --surface-2: #f0f2ef;
  --text: #1f2923;
  --text-muted: #6b7670;
  --border: #e4e7e4;
  --primary: #2f5d46;
  --primary-soft: #e7f0eb;
  --sage: #8a9a7b;
  --terracotta: #b08a6e;
  --red: #c94a4a;
  --red-bg: #fdecec;
  --amber: #c07a24;
  --amber-bg: #fef5e7;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(20, 30, 24, 0.04);
}

[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #334155;
  --primary: #4b8b6b;
  --primary-soft: rgba(75, 139, 107, 0.18);
  --red-bg: rgba(201, 74, 74, 0.18);
  --amber-bg: rgba(192, 122, 36, 0.18);
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 90px;
}

.app-shell { max-width: 1240px; margin: 0 auto; padding: 14px 16px; }
.hidden { display: none !important; }

/* 顶部栏 */
.top-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.brand h1 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.top-actions { display: flex; gap: 8px; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn-sm { background: none; border: none; color: var(--text-muted); font-size: 18px; cursor: pointer; }

/* 横幅 */
.banner {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 12px;
}
.banner-cream { background: var(--amber-bg); color: var(--amber); }
.banner-warn { background: var(--red-bg); color: var(--red); }
.btn-link { background: none; border: none; color: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }

/* 卡片基础 */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}

/* 置顶卡 */
.sticky-card { padding: 12px 14px; margin-bottom: 14px; }
.sticky-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.seg-tabs { display: inline-flex; background: var(--surface-2); padding: 3px; border-radius: 10px; gap: 4px; }
.seg-btn {
  border: none; background: transparent; color: var(--text-muted); font-size: 13px; font-weight: 500;
  padding: 5px 12px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
}
.seg-btn.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.badge {
  background: var(--primary); color: #fff; font-size: 10px; font-weight: 600;
  padding: 1px 6px; border-radius: 99px; line-height: 1.4;
}

.market-wrap {
  flex: 1; min-width: 180px; overflow-x: auto; scrollbar-width: none;
  mask-image: linear-gradient(to right, #000 88%, transparent 100%);
  -webkit-mask-image: linear-gradient(to right, #000 88%, transparent 100%);
}
.market-wrap::-webkit-scrollbar { display: none; }
.market-ticker { display: flex; gap: 14px; white-space: nowrap; font-size: 12px; color: var(--text-muted); padding-right: 20px; }
.mk-item strong { color: var(--text); font-weight: 600; margin: 0 3px; }
.mk-up { color: #c94a4a; }
.mk-down { color: #2f7d57; }

.sticky-body { display: flex; flex-direction: column; gap: 8px; }
.due-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px; background: var(--surface-2); font-size: 13px;
}
.due-left { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.due-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.due-sub { font-size: 12px; color: var(--text-muted); }
.due-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.sticky-expand {
  width: 100%; margin-top: 8px; padding: 6px; border: none; background: transparent;
  color: var(--primary); font-size: 12px; font-weight: 500; cursor: pointer;
}

/* 倒计时颜色 */
.cd-red { color: var(--red); font-weight: 600; }
.cd-amber { color: var(--amber); font-weight: 600; }
.cd-gray { color: var(--text-muted); }

/* 分类栏 */
.cat-tabs, .sub-tabs {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin-bottom: 12px; padding-bottom: 2px;
}
.cat-tabs::-webkit-scrollbar, .sub-tabs::-webkit-scrollbar { display: none; }
.cat-pill {
  flex-shrink: 0; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
  padding: 6px 14px; border-radius: 99px; font-size: 13px; cursor: pointer; transition: 0.15s;
}
.cat-pill.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 工具栏 */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.search-box { flex: 1; min-width: 160px; }
.search-box input {
  width: 100%; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 13px; outline: none;
}
.select-sm, .btn-outline {
  padding: 7px 11px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 13px; cursor: pointer;
}
.chk-inline { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--text-muted); cursor: pointer; }

/* 概览与 30 天时间线 */
.overview-section { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; margin-bottom: 16px; }
.ov-card { padding: 14px; }
.ov-title { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.ov-big { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.bar-track { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; display: flex; margin: 10px 0 8px; }
.bar-seg-sage { background: var(--sage); }
.bar-seg-terra { background: var(--terracotta); }
.bar-seg-gray { background: #cbd5e1; }
.ov-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); }

.tl-chart { display: flex; align-items: flex-end; gap: 3px; height: 72px; margin-top: 10px; }
.tl-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; height: 100%; cursor: pointer; }
.tl-block { height: 12px; border-radius: 3px; width: 100%; }
.tl-day-detail { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--border); font-size: 12px; }

/* 卡片网格（手机1列，平板2列，桌面3列） */
.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 960px) { .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .card-grid { grid-template-columns: 1fr; } }

/* 常规卡片 */
.item-card {
  position: relative; padding: 14px; display: flex; flex-direction: column; justify-content: space-between;
  min-height: 148px; cursor: pointer; transition: transform 0.15s;
}
.item-card:hover { transform: translateY(-2px); }
.item-card.inactive { opacity: 0.58; }
.item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.item-name { font-size: 15px; font-weight: 600; line-height: 1.3; }
.item-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.pill {
  font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--surface-2);
  color: var(--text-muted); flex-shrink: 0;
}
.pill-red { background: var(--red-bg); color: var(--red); }
.item-meta { margin-top: 12px; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.item-benefit {
  margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-muted); display: flex; justify-content: space-between;
}

/* 保险双段卡 */
.ins-card { padding: 0; overflow: hidden; }
.ins-top { padding: 14px; color: #fff; }
.ins-blue { background: linear-gradient(135deg, #2b5876, #4e4376); }
.ins-orange { background: linear-gradient(135deg, #c26a2e, #d98c4a); }
.ins-red { background: linear-gradient(135deg, #8b2635, #a93b4b); }
.ins-bottom { padding: 11px 14px; background: var(--surface); font-size: 12px; }
.ins-tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.ins-tag { background: rgba(255,255,255,0.2); padding: 2px 8px; border-radius: 6px; font-size: 11px; }

/* 银行卡 1.586:1 比例 */
.bank-card {
  position: relative; aspect-ratio: 1.586 / 1; border-radius: 16px; overflow: hidden;
  padding: 16px; color: #fff; display: flex; flex-direction: column; justify-content: space-between;
  cursor: pointer; background: linear-gradient(135deg, #334155, #1e293b);
}
.bank-card.has-img { padding: 0; background: #e8eef5; }
.bank-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bank-img-overlay {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 14px;
  background: linear-gradient(transparent, rgba(0,0,0,0.58));
  display: flex; justify-content: space-between; align-items: center; font-size: 13px; letter-spacing: 1px;
}
.bank-num { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 1.2px; }

/* 浅色线稿 SVG 占位 + 斜扫微光 */
.card-placeholder {
  width: 100%; height: 100%; position: relative; overflow: hidden;
  background: linear-gradient(135deg, #eef2f6, #e2e8f0);
}
.card-placeholder::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,0.55) 50%, transparent 70%);
  animation: shimmer 1.8s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* 批量勾选框与底栏 */
.batch-chk { position: absolute; top: 10px; right: 10px; width: 20px; height: 20px; z-index: 5; accent-color: var(--primary); }
.batch-bar {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 99px;
  display: flex; align-items: center; gap: 14px; box-shadow: 0 8px 24px rgba(0,0,0,0.22); z-index: 40;
}
.batch-actions { display: flex; gap: 8px; }
.btn-sm { padding: 5px 10px; border-radius: 8px; border: none; background: rgba(255,255,255,0.16); color: inherit; font-size: 12px; cursor: pointer; }
.btn-danger { background: var(--red); color: #fff; }
.btn-primary { padding: 8px 16px; border-radius: 10px; border: none; background: var(--primary); color: #fff; font-size: 13px; font-weight: 500; cursor: pointer; }

/* 悬浮按钮 */
.fab {
  position: fixed; right: 20px; bottom: 24px; width: 52px; height: 52px; border-radius: 50%;
  border: none; background: var(--primary); color: #fff; box-shadow: 0 6px 18px rgba(47,93,70,0.35);
  display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 30;
}

/* 弹窗 */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); z-index: 50;
  display: flex; justify-content: center; align-items: flex-start; overflow-y: auto; padding: 24px 12px;
}
.modal-panel {
  width: 100%; max-width: 680px; background: var(--surface); border-radius: 16px;
  padding: 20px; box-shadow: 0 16px 40px rgba(0,0,0,0.2);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-muted); }
.field input, .field select, .field textarea {
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 13px;
}
.field.full { grid-column: 1 / -1; }

.load-more-wrap { text-align: center; margin-top: 18px; }
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 10px;
  font-size: 13px; display: flex; align-items: center; gap: 12px; z-index: 60;
}