/* ---------------------------------------------------------------------------
   DebtOS design system · v4
   简约大气：墨色主视觉 + 细线卡片 + 克制的红绿语义色 + 等宽数字
--------------------------------------------------------------------------- */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #17181c;
  --ink-2: #4b5160;
  --muted: #878e9c;
  --line: #e8eaee;
  --line-soft: #f0f1f4;
  --accent: #2c55e0;
  --accent-soft: #eef2fe;
  --danger: #cf3f36;
  --danger-soft: #fdf1f0;
  --success: #17805a;
  --success-soft: #edf9f3;
  --hero: #17181c;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --shadow-card: 0 1px 2px rgba(23, 24, 28, .04);
  --shadow-float: 0 18px 48px rgba(23, 24, 28, .16);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", ui-sans-serif, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.num, .hero-number, .next-amount, .entity-balance, .repayment-amount, .timeline-amount,
.metric-card strong, .summary-strip strong, .platform-card strong, .goal-gap {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

#app-shell { max-width: 720px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(92px + env(safe-area-inset-bottom)); }

/* ---- 顶栏 ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(18px + env(safe-area-inset-top)) 20px 12px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.eyebrow { color: var(--muted); font-size: 12px; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.page-heading { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.page-heading h1 { font-size: 21px; margin: 0; }
.page-back { display: grid; place-items: center; min-width: 44px; height: 44px; padding: 0; margin-left: -8px; border: 0; background: transparent; font-size: 30px; }
.asset-consumption-link { margin-top: 16px; }
.asset-consumption-link button { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 58px; padding: 12px 18px; border: 0; background: transparent; }
.asset-consumption-link button > span:first-child { display: flex; align-items: center; gap: 12px; }
.asset-consumption-link svg { width: 20px; height: 20px; }
h1 { margin: 2px 0 0; font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
h2 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-button {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  border-radius: 12px; width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color .15s ease, border-color .15s ease;
}
.icon-button svg { width: 19px; height: 19px; }
.icon-button:hover { color: var(--ink); border-color: #d5d9e0; }

main { padding: 8px 16px 16px; }
.view { display: none; }
.view.active { display: block; animation: rise .26s cubic-bezier(.22,.8,.36,1); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

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

/* ---- Hero：总负债 ---- */
.hero { border-radius: 26px; padding: 28px 24px 22px; margin-bottom: 12px; }
.debt-hero {
  background: linear-gradient(160deg, #1c1e24 0%, var(--hero) 58%, #101115 100%);
  color: #fff;
  border: 0;
  box-shadow: 0 20px 44px rgba(23, 24, 28, .18);
}
.hero-label { color: rgba(255,255,255,.56); font-size: 13px; letter-spacing: .05em; }
.hero-number {
  font-size: clamp(30px, 9.4vw, 60px);
  font-weight: 700; letter-spacing: -.035em; line-height: 1.05;
  margin: 10px 0 8px; color: #ff453a; white-space: nowrap;
}
.hero-updated { color: rgba(255,255,255,.42); font-size: 11.5px; margin-bottom: 20px; min-height: 15px; }
.debt-pressure-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid rgba(255,255,255,.12); padding-top: 18px;
}
.debt-pressure-grid > div { min-width: 0; padding-right: 10px; }
.debt-pressure-grid > div + div { padding-left: 14px; border-left: 1px solid rgba(255,255,255,.12); }
.debt-pressure-grid span { display: block; color: rgba(255,255,255,.5); font-size: 12px; margin-bottom: 7px; }
.debt-pressure-grid strong {
  display: block; color: rgba(255,255,255,.95); font-weight: 600;
  font-size: clamp(11.5px, 3.1vw, 16px);
  white-space: nowrap;
}
.debt-pressure-grid strong.gap-warn { color: #ff453a; font-weight: 750; }

/* ---- 下一还款日 ---- */
.next-card, .summary-strip { padding: 20px; margin-bottom: 12px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.section-label { color: var(--muted); font-size: 12.5px; }
.next-date { font-size: clamp(14px, 4vw, 18px); font-weight: 650; margin-top: 5px; letter-spacing: -.01em; white-space: nowrap; }
.next-amount { font-size: 22px; font-weight: 700; color: var(--danger); letter-spacing: -.02em; }
.compact-list { margin-top: 14px; display: grid; gap: 6px; }
.compact-item {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  color: var(--ink-2); font-size: 13px;
  background: var(--line-soft); padding: 10px 13px; border-radius: var(--radius-sm);
}
.compact-item strong { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- 登录 ---- */
.auth-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.auth-card {
  width: min(92vw, 360px); background: var(--surface);
  border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow-float);
  padding: 32px 26px; text-align: center;
}
.auth-logo { width: 64px; height: 64px; border-radius: 16px; margin-bottom: 14px; }
.auth-card h2 { margin: 0 0 6px; font-size: 21px; letter-spacing: -.01em; }
.auth-sub { margin: 0 0 20px; color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.auth-card input {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; margin-bottom: 10px; background: var(--surface); outline: none; font-size: 15px;
}
.auth-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent); }
.auth-error { color: var(--danger); font-size: 12.5px; min-height: 18px; margin-bottom: 4px; }

/* ---- 趋势入口与弹窗 ---- */
.trend-button {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  border-radius: 10px; width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color .15s ease, border-color .15s ease;
}
.trend-button svg { width: 15px; height: 15px; }
.trend-button:hover { color: var(--accent); border-color: var(--accent); }
.hero-trend {
  position: absolute; top: 20px; right: 20px;
  background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.18); color: rgba(255,255,255,.75);
}
.hero-trend:hover { color: #fff; border-color: rgba(255,255,255,.4); }
.debt-hero { position: relative; }
.metric-card { position: relative; }
.metric-card .trend-button { position: absolute; top: 12px; right: 12px; }
.inline-trend { width: 24px; height: 24px; border-radius: 8px; vertical-align: -7px; margin-left: 2px; }
.inline-trend svg { width: 13px; height: 13px; }
.seg-control.trend-seg { margin-bottom: 14px; grid-template-columns: 1fr 1fr 1fr 1fr; }
@media (max-width: 420px) { .seg-control.trend-seg button { font-size: 12px; padding: 8px 2px; } }
/* 汇总条上的趋势小图标：紧跟标签，克制不抢眼 */
.strip-trend {
  width: 22px; height: 22px; margin-left: 6px; vertical-align: -6px;
  border-radius: 7px; color: #b3771b; border-color: color-mix(in srgb, #b3771b 32%, var(--line));
  background: color-mix(in srgb, #b3771b 6%, var(--surface));
}
.strip-trend svg { width: 13px; height: 13px; }
.strip-trend:hover { color: #854f0b; border-color: #b3771b; background: color-mix(in srgb, #b3771b 12%, var(--surface)); }
.trend-chart { min-height: 140px; }
.trend-empty { color: var(--muted); font-size: 13px; line-height: 1.7; text-align: center; padding: 40px 16px; background: var(--line-soft); border-radius: var(--radius-md); }
.trend-stats { margin-top: 12px; display: grid; gap: 5px; }
.trend-now { font-size: 24px; font-weight: 700; letter-spacing: -.02em; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.trend-delta { font-size: 13px; font-weight: 600; }

/* ---- 待确认还款 ---- */
.attention-inner { padding: 20px; margin-bottom: 12px; border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); }
.attention-total { font-size: 22px; font-weight: 700; color: var(--danger); letter-spacing: -.02em; margin-top: 6px; }
.attention-count { color: var(--muted); font-size: 12px; }
.attention-list { margin-top: 10px; }
.attention-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 13px 0; border-top: 1px solid var(--line-soft); }
.attention-item:last-child { padding-bottom: 2px; }
.attention-name { font-weight: 600; font-size: 14px; }
.attention-meta { margin-top: 6px; }
.badge-overdue, .badge-today { border-radius: 999px; padding: 3px 9px; font-size: 11px; font-weight: 600; }
.badge-overdue { background: var(--danger-soft); color: var(--danger); }
.badge-today { background: var(--line-soft); color: var(--ink-2); }
.attention-side { text-align: right; flex: 0 0 auto; }
.attention-amount { font-weight: 700; }
.attention-side .paid-button { margin-top: 7px; }

.attention-clear {
  display: flex; align-items: center; gap: 9px;
  padding: 14px 18px; margin-bottom: 12px;
  color: var(--success); font-size: 13px; font-weight: 550;
  border-color: color-mix(in srgb, var(--success) 24%, var(--line));
}
.clear-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex: 0 0 auto; }

/* ---- 确认还款弹窗 ---- */
.pay-summary { background: var(--line-soft); border-radius: var(--radius-sm); padding: 13px 15px; }
.pay-plan { font-weight: 600; font-size: 14px; }
.pay-due { color: var(--muted); font-size: 12.5px; margin-top: 5px; }
.pay-early-warn {
  margin-top: 10px; padding: 10px 12px; border-radius: 10px;
  background: var(--warning-soft, #fffaeb); color: var(--warning, #b54708);
  font-size: 12px; line-height: 1.55;
}
.repayment-day-head .badge-overdue { margin-left: 6px; vertical-align: 2px; }

/* ---- 还款月历 ---- */
.cal-card { padding: 16px; margin-bottom: 12px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-title { font-weight: 650; font-size: 14px; letter-spacing: .01em; }
.cal-nav {
  border: 0; background: var(--line-soft); border-radius: 10px;
  width: 30px; height: 30px; font-size: 17px; line-height: 1; color: var(--ink-2);
}
.cal-nav:hover { color: var(--ink); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow { text-align: center; font-size: 11.5px; color: var(--muted); padding: 5px 0 7px; }
.strip-right { text-align: right; }
.strip-sub { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; font-weight: 400; font-variant-numeric: tabular-nums; }
.delta-good { color: var(--success); font-weight: 600; }
.delta-bad { color: var(--danger); font-weight: 600; }
.cal-day {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 42px; border-radius: 10px; font-size: 14px; color: var(--muted);
  background: transparent; border: 0; font-variant-numeric: tabular-nums;
}
.cal-day.cal-empty { visibility: hidden; height: 42px; padding: 0; }
button.cal-day { cursor: pointer; color: var(--ink); font-weight: 650; }
button.cal-day:hover { background: var(--line-soft); }
.cal-day i { width: 4px; height: 4px; border-radius: 50%; background: var(--danger); margin-top: 3px; }
.cal-day.today { outline: 1.5px solid var(--accent); outline-offset: -1.5px; }
.repayment-day.flash { animation: rowflash 1.8s ease; }
@keyframes rowflash {
  0% { background: var(--accent-soft); border-color: var(--accent); }
  100% { background: var(--surface); }
}

/* ---- 区块标题 ---- */
.money-shortcuts { display: flex; align-items: center; gap: 10px; margin: 18px 0; }
.money-shortcuts > button { flex: 1; width: auto; margin: 0; padding: 12px 8px; }
.money-summary { padding: 24px; margin-bottom: 14px; }
.money-total { display: block; font-size: 38px; margin: 10px 0; letter-spacing: -1px; }
#money-comparison { color: var(--muted); font-size: 14px; }
#money-month { font: inherit; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface, white); }
.money-categories { padding: 20px; }
.money-category { margin-bottom: 16px; }
.money-category > div:first-child { display: flex; justify-content: space-between; margin-bottom: 8px; }
.money-bar { height: 5px; background: var(--line-soft); border-radius: 4px; overflow: hidden; }
.money-bar i { display: block; height: 100%; background: var(--ink); }
.money-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px; border-bottom: 1px solid var(--line-soft); }
.money-row > div > div { font-size: 13px; color: var(--muted); margin-top: 6px; overflow-wrap: anywhere; }
.money-row-right { text-align: right; flex-shrink: 0; max-width: 48%; }
.money-row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.money-history { padding: 18px; margin-top: 16px; font-size: 14px; }
.money-history summary { cursor: pointer; font-weight: 600; }
.money-history p { color: var(--muted); line-height: 1.7; }
.money-row-actions button { background: none; border: 0; padding: 10px 4px; min-height: 44px; min-width: 44px; font: inherit; color: var(--ink-2); }
.money-manual { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.money-shortcuts button, .money-manual button, .change-actions button, .repayment-item button { min-height: 44px; touch-action: manipulation; }
#money-dialog input, #money-dialog select { min-height: 44px; font-size: 16px; }
#money-dialog .check-row input { min-height: 22px; }
#money-submit { position: sticky; bottom: 0; min-height: 48px; }
.money-void { opacity: .55; }
.money-options { margin: 20px 0 10px; }
.money-options summary { cursor: pointer; }
#money-subtitle { color: var(--ink-2); line-height: 1.6; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 26px 4px 12px; }
.wealth-section-head { margin-top: 28px; }
.text-button { border: 0; background: transparent; color: var(--accent); padding: 4px 2px; font-size: 13px; font-weight: 600; }

/* ---- 指标 / 目标 ---- */
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.metric-card { padding: 18px; min-height: 96px; display: flex; flex-direction: column; justify-content: space-between; }
.metric-card span { color: var(--muted); font-size: 12.5px; }
.metric-card strong { font-size: clamp(15px, 4.6vw, 21px); font-weight: 700; letter-spacing: -.02em; white-space: nowrap; }
.goal-card { padding: 20px; margin-bottom: 12px; }
.goal-gap { font-weight: 700; font-size: 26px; letter-spacing: -.02em; margin-top: 6px; }
.progress { background: var(--line-soft); border-radius: 999px; height: 6px; overflow: hidden; margin: 18px 0 10px; }
.progress > div { height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .45s cubic-bezier(.22,.8,.36,1); }
.split-row { display: flex; justify-content: space-between; gap: 12px; }
.muted { color: var(--muted); font-size: 12px; }
.goal-secondary { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-soft); }

/* ---- 时间线 / 还款 ---- */
.timeline { display: grid; gap: 10px; }
.timeline-day, .repayment-day {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-md); padding: 16px; box-shadow: var(--shadow-card);
}
.timeline-day-head, .repayment-day-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.timeline-date { font-weight: 650; font-size: 14px; }
.timeline-amount { font-weight: 700; color: var(--danger); }
.timeline-items { margin-top: 12px; border-top: 1px solid var(--line-soft); padding-top: 10px; display: grid; gap: 7px; }
.timeline-item { display: flex; justify-content: space-between; gap: 12px; color: var(--ink-2); font-size: 13px; }
.timeline-item span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }

.seg-control {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: var(--line-soft); border-radius: 14px; padding: 4px; margin-bottom: 12px;
}
.seg-control button {
  border: 0; background: transparent; color: var(--muted);
  border-radius: 11px; padding: 9px; font-size: 13.5px; font-weight: 600;
  transition: background .15s ease, color .15s ease;
}
.seg-control button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-card); }
.paid-card { padding: 6px 18px; }
.paid-amount { color: var(--success); }

.summary-strip { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.summary-strip span { display: block; color: var(--muted); font-size: 12.5px; }
.summary-strip strong { display: block; margin-top: 5px; font-size: 23px; font-weight: 700; letter-spacing: -.02em; }
.date-range { color: var(--muted); font-size: 12px; text-align: right; }
.repayment-list { display: grid; gap: 10px; }
.repayment-item { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.repayment-item:last-child { border-bottom: 0; padding-bottom: 2px; }
.repayment-name { font-weight: 600; font-size: 14px; }
.repayment-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.repayment-amount { font-weight: 700; text-align: right; }
.paid-button {
  border: 1px solid var(--line); color: var(--ink-2); background: var(--surface);
  border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 600; margin-top: 6px;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.paid-button:hover { border-color: var(--success); color: var(--success); background: var(--success-soft); }
/* 标记已还：纯提醒开关，不改账本 */
.remind-button {
  border: 1px solid var(--line); color: var(--ink-2); background: var(--surface);
  border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 600; margin-top: 6px;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.remind-button:hover { border-color: var(--success); color: var(--success); background: var(--success-soft); }
.attention-note { margin-top: 10px; font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.repayment-side-col { text-align: right; }
.stamp-fallback { color: #8a5a00; }
.basis-pill { background: var(--accent-soft); color: var(--accent); }
.derive-preview { background: var(--accent-soft); color: var(--ink-2); line-height: 1.7; }
.derive-preview strong { color: var(--accent); }
.unscheduled-card { padding: 16px 18px; margin-top: 12px; border-style: dashed; box-shadow: none; }
.unscheduled-item { cursor: pointer; border-radius: 10px; margin: 0 -8px; padding-left: 8px; padding-right: 8px; }
.unscheduled-item:hover { background: var(--line-soft); }
.unscheduled-card .section-label { margin-bottom: 4px; }

/* ---- 底部导航 ---- */
.bottom-nav {
  position: fixed; z-index: 50; bottom: 0; left: 50%; transform: translateX(-50%);
  width: min(720px, 100%);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--line);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
}
.bottom-nav button {
  border: 0; background: transparent; color: var(--muted);
  display: grid; gap: 3px; justify-items: center; padding: 7px 4px 5px;
  border-radius: var(--radius-sm); transition: color .15s ease;
}
.bottom-nav button svg { width: 23px; height: 23px; }
.bottom-nav button small { font-size: 10.5px; font-weight: 500; letter-spacing: .02em; }
.bottom-nav button.active { color: var(--ink); }
.bottom-nav button.active small { font-weight: 650; }
.bottom-nav .chat-nav.active, .bottom-nav .chat-nav { color: var(--accent); }
.bottom-nav .chat-nav:not(.active) { color: color-mix(in srgb, var(--accent) 68%, var(--muted)); }

/* ---- AI 导入 ---- */
.provider-strip { padding: 16px 18px; display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.provider-strip strong { display: block; font-size: 16px; font-weight: 650; margin-top: 4px; }
.provider-strip small { color: var(--muted); display: block; margin-top: 4px; line-height: 1.45; font-size: 12px; }
.chat-messages { display: grid; gap: 14px; padding-bottom: 130px; }
.import-welcome { min-height: 340px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 28px 12px; }
.import-welcome svg { width: 32px; height: 32px; color: var(--accent); margin-bottom: 20px; }
.import-welcome h2 { font-size: 22px; margin-bottom: 10px; }
.import-welcome p { margin: 0; line-height: 1.85; color: var(--ink-2); font-size: 14px; }
.message { display: flex; gap: 9px; align-items: flex-start; }
.message.user { flex-direction: row-reverse; }
.avatar {
  flex: 0 0 auto; width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: 50%; background: var(--ink); color: #fff; font-weight: 650; font-size: 10.5px;
}
.message.user .avatar { display: none; }
.bubble {
  max-width: min(86%, 580px);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 4px 16px 16px 16px; padding: 12px 15px;
  line-height: 1.65; font-size: 14px; white-space: pre-wrap;
  box-shadow: var(--shadow-card);
}
.message.user .bubble { background: var(--ink); color: #fff; border: 0; border-radius: 16px 4px 16px 16px; }
.model-stamp { margin-top: 10px; color: var(--muted); font-size: 10.5px; border-top: 1px solid var(--line-soft); padding-top: 7px; }

.composer-wrap {
  position: fixed; z-index: 40; bottom: calc(74px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%); width: min(720px, 100%);
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(246,247,249,0), rgba(246,247,249,.96) 34%);
}
.composer-model-row { position: relative; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 0 6px 7px; }
.quick-chips { display: flex; gap: 6px; overflow-x: auto; }
.quick-chips button {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  border-radius: 999px; padding: 6px 11px; font-size: 12px; white-space: nowrap; flex: 0 0 auto;
}
.quick-chips button:hover { border-color: var(--accent); color: var(--accent); }

/* 账户标签栏：点选即把账户名插入输入框 */
.account-chips { display: flex; gap: 7px; overflow-x: auto; padding: 0 2px 9px; scrollbar-width: none; }
.account-chips::-webkit-scrollbar { display: none; }
.account-chips button {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px;
  padding: 6.5px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: 12.5px; font-weight: 550;
  white-space: nowrap; transition: border-color .15s ease;
}
.account-chips button:active, .account-chips button:hover { border-color: var(--accent); color: var(--accent); }
.account-chips .dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
@media (max-width: 480px) { .account-chips button { font-size: 13px; padding: 7px 13px; } }
.thinking-bubble { color: var(--muted); }
.dots { display: inline-flex; gap: 3px; margin-right: 7px; vertical-align: 1px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: dotpulse 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes dotpulse { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }
.model-pill {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  border-radius: 999px; padding: 6px 13px; font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 7px; box-shadow: var(--shadow-card);
  flex: 0 1 auto; min-width: 0; min-height: 44px;
}
.pill-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 65vw; }
.model-pill.warn { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 32%, var(--line)); background: var(--danger-soft); }
.pill-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.pill-caret { color: var(--muted); font-size: 11px; line-height: 1; }
.model-menu {
  width: min(480px, calc(100vw - 24px)); max-height: 75dvh;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: 22px; box-shadow: var(--shadow-float); padding: 18px;
}
.model-menu[open] { display: flex; flex-direction: column; gap: 10px; }
.model-menu::backdrop { background: rgba(0,0,0,.35); }
.model-menu-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-shrink: 0; }
.model-menu-head h2 { margin: 0; font-size: 18px; }
.model-menu-head button { min-width: 44px; min-height: 44px; }
.model-menu-status { color: var(--muted); font-size: 14px; flex-shrink: 0; }
.model-options { overflow-y: auto; overscroll-behavior: contain; min-height: 0; }
@media (max-width: 600px) {
  .model-menu { margin: auto auto max(12px, env(safe-area-inset-bottom)); }
}
.model-item {
  border: 0; background: transparent; text-align: left; padding: 10px 12px;
  border-radius: 12px; font-size: 15px; min-height: 60px; width: 100%; color: var(--ink); flex-shrink: 0;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.model-item:hover { background: var(--line-soft); }
.model-item.current { background: var(--accent-soft); }
.model-item-name { display: grid; gap: 4px; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.model-item:disabled { opacity: .55; cursor: wait; }
.model-item-name small { color: var(--ink-2); font-weight: 400; font-size: 13px; }
.model-check { color: var(--accent); font-weight: 700; }
.model-menu-divider { border-top: 1px solid var(--line-soft); margin: 4px 8px; }
.models-current { font-size: 18px; line-height: 1.5; overflow-wrap: anywhere; }
.model-catalog-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 16px 0; border-bottom: 1px solid var(--line-soft); }
.model-catalog-row > div { flex: 1 1 0; min-width: 0; overflow-wrap: anywhere; }
.model-catalog-row small { display: block; color: var(--ink-2); margin-top: 6px; }
.model-catalog-row button { width: auto; flex: 0 0 auto; min-width: 60px; min-height: 44px; margin: 0; padding: 10px 12px; font-size: 15px; }
.model-catalog-row strong { display: block; font-size: 15px; line-height: 1.5; }
.model-catalog-row small { font-size: 13px; line-height: 1.5; }
.model-catalog-row small:not(.model-catalog-id) { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#model-catalog { background: var(--line-soft); border-radius: 14px; padding: 14px; margin: 4px 0 18px; }
#model-catalog-results { max-height: 380px; overflow-y: auto; overscroll-behavior: contain; }
.model-catalog-trigger { min-height: 44px; width: auto; text-align: left; margin: -8px 0 12px; }
#model-catalog .catalog-search { margin: 0; }
#model-catalog-status { margin: 10px 0 0; }
.model-connection-summary { display:flex; align-items:center; gap:12px; margin:8px 0 12px; }
.model-connection-summary .settings-status { flex:1; min-width:0; margin:0; }
.model-connection-summary button { flex:0 0 auto; min-width:44px; min-height:44px; font-size:14px; }
#provider-key-entry { margin-bottom:20px; }
#provider-key-entry > button { width:auto; min-height:44px; margin:0; }
.model-choice { display:flex; justify-content:space-between; gap:12px; width:100%; min-height:50px; margin-top:8px; padding:12px 14px; border:1px solid var(--line); border-radius:12px; background:var(--surface); color:var(--ink); font:inherit; text-align:left; }
.model-choice span:first-child { flex:1; min-width:0; overflow-wrap:anywhere; }
.model-choice span:last-child { flex:0 0 auto; }
.model-choice small { display:block; margin-top:3px; color:var(--ink-2); font-size:13px; }
.catalog-toolbar { display:flex; align-items:end; gap:10px; }
.catalog-toolbar label { flex:1; min-width:0; }
.catalog-toolbar button { flex:0 0 auto; min-width:44px; min-height:44px; font-size:14px; }
#model-catalog-results { max-height:min(300px, 36vh); }
#provider-advanced > summary, #provider-connection-details > summary { min-height:44px; display:flex; align-items:center; }
.model-confirm { padding: 24px; }
#provider-leave-confirm { padding: 24px; }
.model-confirm h3 { margin-top: 0; }
.model-confirm p { font-size: 15px; line-height: 1.6; }
.model-confirm input { font-size: 16px; }
#provider-readonly h2 { font-size: 20px; overflow-wrap: anywhere; }
#provider-readonly dl { display: grid; gap: 8px; }
#provider-readonly dt { color: var(--ink-2); font-size: 13px; }
#provider-readonly dd { margin: 0 0 12px; overflow-wrap: anywhere; }
.model-management-actions { flex-wrap: wrap; }
.model-management-actions button, .p-actions button, #provider-editor summary { min-height: 44px; }
#provider-test-history { font-size: 13px; color: var(--ink-2); }

.composer {
  display: flex; align-items: flex-end; gap: 6px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 22px; padding: 7px; box-shadow: var(--shadow-float);
}
.composer textarea {
  resize: none; border: 0; outline: 0; flex: 1;
  max-height: 128px; min-height: 40px; padding: 10px 6px;
  background: transparent; font-size: 14px;
}
.composer-button, .send-button {
  border: 0; border-radius: 50%; width: 40px; height: 40px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
}
.composer-button { background: var(--line-soft); color: var(--ink-2); }
.composer-button svg { width: 19px; height: 19px; }
.send-button { background: var(--ink); color: #fff; }
.send-button svg { width: 18px; height: 18px; }
.send-button:disabled { opacity: .45; }
.attachment-preview { display: none; gap: 8px; overflow-x: auto; padding: 0 4px 8px; }
.attachment-preview.active { display: flex; }
.attachment-chip {
  position: relative; flex: 0 0 auto; width: 68px; height: 68px;
  border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--line); background: var(--surface);
}
.attachment-chip img { width: 100%; height: 100%; object-fit: cover; }
.attachment-chip span { display: grid; place-items: center; height: 100%; font-size: 10px; padding: 4px; text-align: center; color: var(--ink-2); }
.attachment-chip button {
  position: absolute; right: 3px; top: 3px; border: 0; border-radius: 50%;
  width: 19px; height: 19px; background: rgba(23,24,28,.78); color: #fff; font-size: 12px; line-height: 1;
}

/* ---- 变更草稿卡片 ---- */
.change-card {
  margin-top: 10px; border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--line));
  background: var(--accent-soft); border-radius: var(--radius-md); padding: 14px; color: var(--ink);
}
.change-card h4 { margin: 0 0 8px; font-size: 14px; }
.change-operation { background: rgba(255,255,255,.8); border-radius: 10px; padding: 9px 11px; margin-top: 6px; font-size: 12px; line-height: 1.5; }
.change-operation small { color: var(--muted); }
/* ---- 资金流向图：确认前一眼核对 AI 的理解 ---- */
.flow-map {
  position: relative; display: flex; flex-direction: column; gap: 14px;
  margin: 6px 0 4px; padding: 26px 14px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 1px 3px rgba(23, 24, 28, .04);
}
.flow-map-label {
  position: absolute; top: 9px; left: 14px;
  font-size: 10.5px; font-weight: 650; letter-spacing: .12em; color: var(--muted);
}
.flow-row { display: flex; align-items: center; gap: 8px; }
.flow-node {
  flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 8px;
  padding: 9px 11px; border-radius: 10px;
  background: #f4f6fa; border: 1px solid #e4e9f2;
  font-size: 12.5px; font-weight: 600; line-height: 1.4; color: var(--ink);
}
.flow-node-text { min-width: 0; overflow-wrap: anywhere; }
.flow-icon { flex: 0 0 auto; width: 17px; height: 17px; color: var(--accent); display: grid; place-items: center; }
.flow-icon svg { width: 100%; height: 100%; }
.flow-node.kind-loan { background: #fdf4f3; border-color: #f2ddda; }
.flow-node.kind-loan .flow-icon { color: var(--danger); }
.flow-node.kind-external { background: transparent; border-style: dashed; border-color: #d7dbe3; color: var(--muted); font-weight: 500; }
.flow-node.kind-external .flow-icon { color: #b0b6c1; }
.flow-node i {
  font-style: normal; font-size: 10px; font-weight: 650; color: #fff;
  background: var(--accent); border-radius: 4px; padding: 1.5px 5px; margin-left: 5px;
  white-space: nowrap; vertical-align: 1px;
}
.flow-arrow { flex: 1.15 1 72px; min-width: 68px; display: flex; flex-direction: column; align-items: stretch; gap: 3px; color: var(--accent); }
.flow-track { position: relative; display: grid; place-items: center; padding: 8px 0; }
.flow-track em {
  position: relative; z-index: 1; font-style: normal; font-size: 10.5px; font-weight: 600; white-space: nowrap;
  color: inherit; background: color-mix(in srgb, currentColor 9%, var(--surface));
  border-radius: 999px; padding: 2px 9px;
}
.flow-line { position: absolute; left: 2px; right: 8px; top: 50%; height: 1.5px; background: color-mix(in srgb, currentColor 55%, var(--surface)); }
.flow-line::after {
  content: ''; position: absolute; right: -6px; top: -3.25px;
  border-left: 6px solid currentColor; border-top: 4px solid transparent; border-bottom: 4px solid transparent;
}
.flow-arrow b { font-size: 13.5px; font-weight: 700; text-align: center; white-space: nowrap; letter-spacing: -.01em; }
.flow-row.tone-out .flow-arrow, .flow-row.tone-debt .flow-arrow { color: var(--danger); }
.flow-row.tone-in .flow-arrow { color: var(--success); }
.flow-row.tone-borrow .flow-arrow { color: #b3771b; }
.flow-balance { display: block; margin-top: 3px; font-size: 11px; font-weight: 550; color: var(--muted); letter-spacing: 0; }
.flow-node.kind-loan .flow-balance { color: color-mix(in srgb, var(--danger) 72%, var(--muted)); }
.flow-row-solo { gap: 10px; }
.flow-row-solo .flow-node { flex: 0 1 auto; }
.flow-note { color: var(--muted); font-size: 12.5px; }
/* 账户余额流水 */
.flow-history-list { display: flex; flex-direction: column; max-height: 56vh; overflow-y: auto; margin: 4px 0 10px; }
.flow-hist-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.flow-hist-row:last-child { border-bottom: none; }
.flow-hist-main { min-width: 0; }
.flow-hist-note { display: block; font-size: 13px; font-weight: 550; overflow-wrap: anywhere; }
.flow-hist-time { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.flow-hist-nums { text-align: right; flex: 0 0 auto; }
.flow-hist-delta { display: block; font-size: 12.5px; font-weight: 650; }
.flow-hist-balance { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }

/* 减债透视 */
.insight-card { padding: 18px 20px; margin-bottom: 12px; }
.insight-sub { font-size: 11px; color: var(--muted); }
.insight-title { font-size: 12px; font-weight: 650; color: var(--ink-2); margin: 14px 0 8px; }
.pressure-list { display: flex; flex-direction: column; gap: 6px; }
.pressure-row { display: grid; grid-template-columns: 58px 1fr 104px; align-items: center; gap: 10px; font-size: 12.5px; }
.pressure-month { color: var(--muted); white-space: nowrap; }
.pressure-bar { height: 8px; background: var(--line-soft); border-radius: 4px; overflow: hidden; }
.pressure-bar i { display: block; height: 100%; background: var(--ink-2); border-radius: 4px; }
.pressure-amt { text-align: right; font-weight: 600; }
.pressure-row.is-peak .pressure-bar i { background: var(--danger); }
.pressure-row.is-peak .pressure-amt, .pressure-row.is-peak .pressure-month { color: var(--danger); font-weight: 700; }
.insight-note { margin-top: 10px; font-size: 12px; color: var(--ink-2); line-height: 1.5; }
.insight-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.insight-stat { background: var(--line-soft); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; }
.insight-stat span { font-size: 11px; color: var(--muted); }
.insight-stat strong { font-size: 14px; letter-spacing: -.01em; }
.insight-stat small { font-size: 11px; color: var(--ink-2); line-height: 1.4; }
.lev-history { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 11px; color: var(--muted); }
.payoff-list { display: flex; flex-direction: column; }
.payoff-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line-soft); font-size: 12.5px; }
.payoff-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.payoff-meta { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
@media (max-width: 480px) {
  .insight-grid { grid-template-columns: 1fr; }
  .pressure-row { grid-template-columns: 54px 1fr 92px; font-size: 12px; }
  .payoff-row { flex-direction: column; align-items: flex-start; gap: 2px; }
  .payoff-meta { white-space: normal; }
}

/* 巡检提醒：久未更新的账户，更新标签渐次示警 */
.update-pill.stale-warn { background: #fdf6e7; color: #8a5a00; border-color: #f0e2bd; }
.update-pill.stale-bad { background: #fdf1f0; color: var(--danger); border-color: #f2ddda; }

/* 钉钉提醒 */
.notify-actions { display: flex; gap: 8px; }
.notify-actions .secondary-button { flex: 1; }

/* 数据体检 */
.integrity-overall { font-size: 13px; font-weight: 650; margin-bottom: 8px; }
.integrity-overall.integrity-ok { color: var(--success); }
.integrity-overall.integrity-warn { color: #a56a00; }
.integrity-overall.integrity-fail { color: var(--danger); }
.integrity-row { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 12px; line-height: 1.45; }
.integrity-row:last-child { border-bottom: none; }
.integrity-row small { color: var(--muted); }
.integrity-icon { flex: 0 0 auto; font-weight: 700; }
.integrity-ok .integrity-icon { color: var(--success); }
.integrity-warn .integrity-icon { color: #a56a00; }
.integrity-fail .integrity-icon { color: var(--danger); }

.msg-warnings {
  margin-top: 7px; padding: 7px 10px; border-radius: 8px;
  background: #fdf6e7; border: 1px solid #f0e2bd;
  color: #7a5200; font-size: 12px; line-height: 1.55;
}
.change-detail { margin-top: 9px; }
.change-detail summary { font-size: 11.5px; color: var(--muted); cursor: pointer; user-select: none; }

/* 手机端：纵向流程图——节点全宽、字号加大，杜绝看不清 */
@media (max-width: 560px) {
  .flow-map { padding: 26px 12px 13px; gap: 16px; }
  .flow-row { flex-direction: column; align-items: stretch; gap: 0; }
  .flow-node { font-size: 13.5px; padding: 11px 12px; }
  .flow-icon { width: 18px; height: 18px; }
  .flow-arrow { flex: 0 0 auto; flex-direction: row; align-items: center; gap: 9px; min-width: 0; padding: 3px 2px 3px 20px; }
  .flow-track { padding: 0; flex: 0 0 auto; display: flex; }
  .flow-line { position: relative; left: auto; right: auto; top: auto; width: 2px; height: 34px; border-radius: 1px; }
  .flow-line::after {
    left: -3px; right: auto; top: auto; bottom: -5px;
    border-top: 6px solid currentColor; border-left: 4px solid transparent; border-right: 4px solid transparent;
  }
  .flow-track em { font-size: 11.5px; }
  .flow-arrow b { font-size: 14.5px; }
  .flow-row-solo { flex-direction: row; align-items: center; }
}
.change-actions { display: flex; gap: 8px; margin-top: 12px; }
.change-actions button {
  flex: 1; border-radius: var(--radius-sm); padding: 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  background: var(--surface); font-weight: 600; font-size: 13px;
}
.change-actions .confirm { color: #fff; background: var(--accent); border-color: var(--accent); }
.success-text { color: var(--success); font-weight: 650; padding: 8px; display: block; width: 100%; text-align: center; font-size: 13px; }

/* ---- 资产 / 负债列表 ---- */
.page-note { color: var(--muted); font-size: 12px; line-height: 1.55; margin: -2px 4px 14px; }
.entity-list { display: grid; gap: 10px; }
.entity-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 16px 18px; box-shadow: var(--shadow-card); }
.entity-card.clickable { cursor: pointer; transition: border-color .15s ease; }
.entity-card.clickable:hover { border-color: #cfd5df; }
.entity-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.entity-name { font-weight: 650; font-size: 14.5px; }
.entity-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.entity-balance { text-align: right; font-weight: 700; font-size: 17px; letter-spacing: -.01em; white-space: nowrap; }
.entity-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; }
.meta-pill { border-radius: 999px; padding: 4px 9px; font-size: 11px; background: var(--line-soft); color: var(--ink-2); }
.update-pill { color: var(--muted); font-variant-numeric: tabular-nums; }
.pill-button {
  border: 1px solid var(--line); background: var(--surface); color: var(--accent);
  border-radius: 999px; padding: 4px 12px; font-size: 11px; font-weight: 600;
  margin-left: auto; flex: 0 0 auto; transition: border-color .15s ease;
}
.pill-button:hover { border-color: var(--accent); }
.entity-note { margin-top: 12px; color: var(--muted); font-size: 12px; line-height: 1.5; border-top: 1px solid var(--line-soft); padding-top: 10px; }
.debt-text { color: var(--danger); }

.platform-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; }
.platform-card { padding: 15px 16px; border-radius: var(--radius-md); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-card); }
.platform-clickable { cursor: pointer; transition: border-color .15s ease, background .15s ease; }
.platform-clickable:hover { border-color: #cfd5df; }
.platform-card.selected { border-color: var(--accent); background: var(--accent-soft); }
.platform-card.selected span { color: var(--accent); }
.platform-card span { color: var(--muted); font-size: 12px; }
.platform-card strong { display: block; font-size: 16px; font-weight: 700; margin-top: 7px; letter-spacing: -.01em; }

/* ---- 上传档案：收起时为虚线幽灵行，与数据卡片明确区分 ---- */
.archive { margin-top: 26px; border: 1px dashed #d3d8e0; border-radius: var(--radius-md); background: transparent; }
.archive[open] { border-style: solid; border-color: var(--line); background: var(--surface); }
.archive summary {
  cursor: pointer; user-select: none; list-style: none;
  color: var(--muted); font-size: 12.5px; padding: 12px 16px;
  display: flex; align-items: center; gap: 5px;
}
.archive summary::after { content: '原始截图与 PDF 的存档记录'; margin-left: auto; font-size: 11px; color: #b0b6c1; }
.archive[open] summary::after { content: ''; }
.archive summary::before { content: '▸'; font-size: 11px; transition: transform .15s ease; }
.archive[open] summary::before { transform: rotate(90deg); }
.archive summary::-webkit-details-marker { display: none; }
.archive-count { color: var(--muted); }
.archive[open] summary { border-bottom: 1px solid var(--line-soft); }
.archive-list { display: grid; padding: 6px 8px 8px; }
.archive-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 8px; border-radius: 10px; text-decoration: none; color: inherit;
}
.archive-row:hover { background: var(--line-soft); }
.archive-main { min-width: 0; display: grid; gap: 3px; }
.archive-name { font-size: 13px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.archive-meta { color: var(--muted); font-size: 11.5px; }
.archive-tag { flex: 0 0 auto; border-radius: 999px; padding: 3px 9px; font-size: 10.5px; font-weight: 600; background: var(--success-soft); color: var(--success); }
.tag-other { background: var(--line-soft); color: var(--ink-2); }
.archive-empty { color: var(--muted); font-size: 12px; line-height: 1.55; padding: 12px 10px; }

/* ---- 按钮 ---- */
.primary-small { border: 0; border-radius: var(--radius-sm); padding: 10px 14px; background: var(--ink); color: #fff; font-weight: 600; font-size: 13px; }
.primary-button { width: 100%; border: 0; border-radius: 14px; padding: 13px; background: var(--ink); color: #fff; font-weight: 650; margin-top: 8px; }
.secondary-button { width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: var(--surface); color: var(--ink); font-weight: 650; margin-top: 9px; }
.danger-button {
  width: 100%; border: 1px solid color-mix(in srgb, var(--danger) 32%, var(--line));
  border-radius: 14px; padding: 12px; background: var(--surface); color: var(--danger);
  font-weight: 650; margin-top: 9px;
}
.danger-button:hover { background: var(--danger-soft); }
.repay-expand { margin-top: 12px; }

/* ---- 弹窗 ---- */
.settings-back { min-height: 44px; padding: 4px 0 12px; font-size: 15px; }
.settings-view.active { animation: none; }
.settings-brand { display: flex; align-items: center; gap: 14px; padding: 14px 2px 28px; }
.settings-brand img { width: 52px; height: 52px; border-radius: 14px; }
.settings-brand strong { display: block; font-size: 23px; }
.settings-brand span { display: block; color: var(--muted); font-size: 14px; margin-top: 4px; }
.settings-group { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; margin-bottom: 20px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 62px; padding: 16px 20px; border: 0; background: transparent; color: var(--ink); text-align: left; font-size: 16px; }
.settings-row + .settings-row { border-top: 1px solid var(--line-soft); }
.settings-row:hover { background: var(--line-soft); }
.settings-row:disabled { opacity: .6; }
.settings-row > span:last-child { color: var(--muted); }
.settings-trailing { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.settings-card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 20px; margin-bottom: 18px; line-height: 1.7; }
.settings-card h2 { font-size: 17px; margin: 0 0 10px; }
.settings-card p { color: var(--ink-2); font-size: 15px; margin: 10px 0; }
.settings-card label { display: grid; gap: 8px; margin-top: 16px; font-size: 14px; }
.settings-card input { width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); padding: 10px 12px; font-size: 16px; }
.settings-card [role="status"] { margin-top: 14px; font-size: 14px; }
.settings-prose h2:not(:first-child) { margin-top: 26px; }
.settings-footer { text-align: center; color: var(--muted); font-size: 13px; line-height: 1.9; padding: 12px 0; }
.settings-about { text-align: center; padding: 20px 0 30px; }
.settings-about img { width: 76px; height: 76px; border-radius: 20px; }
.settings-about h2 { margin: 14px 0 6px; font-size: 27px; }
.settings-about p { color: var(--muted); margin: 8px 0; font-size: 14px; }
.settings-about strong { display: block; margin-top: 20px; font-size: 15px; }
.settings-address { overflow-wrap: anywhere; }
.settings-status { color: var(--ink-2); font-size: 14px; text-align: center; }
.modal { border: 0; border-radius: 24px; padding: 0; width: min(92vw, 500px); max-height: 88vh; box-shadow: var(--shadow-float); }
.modal::backdrop { background: rgba(23,24,28,.44); backdrop-filter: blur(4px); }
.modal form { padding: 22px; overflow-y: auto; max-height: 88vh; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal h3 { margin: 0; font-size: 19px; letter-spacing: -.01em; }
.modal label { display: grid; gap: 7px; margin: 13px 0; color: var(--ink-2); font-size: 13px; }
.modal input, .modal select, .modal textarea {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 13px; background: var(--surface); color: var(--ink); outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.modal input:focus, .modal select:focus, .modal textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}
.modal input:disabled, .modal select:disabled { background: var(--line-soft); color: var(--muted); }
.check-row { grid-template-columns: auto 1fr !important; align-items: center; }
.check-row input { width: 17px; height: 17px; accent-color: var(--ink); }
.modal-note { color: var(--ink-2); font-size: 12px; line-height: 1.55; background: var(--line-soft); border-radius: var(--radius-sm); padding: 11px 13px; }
.provider-modal hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.provider-modal .modal-note { margin-bottom: 14px; }
.preset-hint { color: var(--ink-2); font-size: 12px; line-height: 1.5; margin: -6px 2px 0; }
.fetch-models { display: block; font-size: 12px; margin: -4px 0 2px; padding: 4px 2px; text-align: left; }
.preset-hint.warn { color: var(--warning, #b54708); }
.key-note { color: var(--muted); font-size: 11.5px; line-height: 1.55; margin: -6px 2px 0; padding-left: 2px; }
.advanced { margin: 14px 0 4px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 13px; }
.advanced summary { cursor: pointer; color: var(--ink-2); font-size: 13px; padding: 11px 0; user-select: none; }
.advanced[open] summary { border-bottom: 1px solid var(--line-soft); }
.test-result { display: grid; gap: 6px; }
.test-result:not(:empty) { margin-top: 12px; }
.test-line { font-size: 13px; line-height: 1.5; border-radius: var(--radius-sm); padding: 10px 13px; }
.test-line.ok { background: var(--success-soft); color: var(--success); }
.test-line.fail { background: var(--danger-soft); color: var(--danger); }
.test-line.muted-line { background: var(--line-soft); color: var(--ink-2); }
.test-line small { opacity: .8; }
.provider-list { display: grid; gap: 8px; margin-bottom: 12px; }
.model-management-actions { display: flex; gap: 12px; flex-wrap: wrap; margin: 20px 0; }
.model-management-actions button { flex: 1; min-height: 46px; }
[data-settings-panel="models"] .model-management-actions .primary-button { flex: 1 1 160px; margin: 0; }
[data-settings-panel="models"] .model-management-actions .text-button { flex: 0 0 auto; width: auto; }
[data-settings-panel="models"] .provider-list { gap: 16px; }
[data-settings-panel="models"] .provider-row { display: flex; align-items: center; padding: 16px; border-radius: 16px; gap: 12px; }
[data-settings-panel="models"] .p-main { min-width: 0; flex: 1; }
[data-settings-panel="models"] .p-name { overflow-wrap: anywhere; }
[data-settings-panel="models"] .p-actions { margin-top: 0; flex-direction: column; justify-content: center; gap: 4px; }
[data-settings-panel="models"] .p-actions button { min-width: 44px; min-height: 44px; }
[data-settings-panel="models"] .p-model { overflow-wrap: anywhere; white-space: normal; }
[data-settings-panel="models"] .p-model, [data-settings-panel="models"] .p-test-status { color: var(--ink-2); font-size: 13px; }
.p-test-status { color: var(--muted); font-size: 13px; margin-top: 10px; line-height: 1.6; }
.model-editor select { width: 100%; min-height: 46px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; color: var(--ink); font-size: 16px; }
.model-editor input:disabled, .model-editor select:disabled { opacity: 1; color: var(--ink-2); -webkit-text-fill-color: var(--ink-2); }
.model-editor input[type="checkbox"] { width: 20px; min-height: 20px; }
.model-editor .check-row { display: flex; align-items: center; min-height: 44px; width: 100%; cursor: pointer; }
.model-editor .primary-button { margin-top: 20px; }
.model-editor input:not([type="checkbox"]) { width: 100%; min-height: 48px; font-size: 16px; box-sizing: border-box; }
.model-editor label { font-size: 14px; }
.model-editor #provider-connection-status:empty, .model-editor #provider-save-status:empty { display: none; }
.model-editor #provider-connection-status { margin: 0; }
.model-editor .settings-status { text-align: left; }
.model-editor #provider-enabled-note:empty { display: none; }
.model-editor .advanced { margin-top: 16px; }
.model-editor .advanced[open] label { margin-top: 16px; }
.model-editor .advanced[open] { padding-bottom: 12px; }
#provider-save-status { overflow-wrap: anywhere; }
#provider-test-card .settings-status { margin-bottom: 0; }
#provider-test-confirm { padding: 24px; }
#provider-test-confirm p { line-height: 1.7; }
#provider-test-result { margin: 12px 0 18px; line-height: 1.7; }
.provider-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px;
}
.provider-row.current { border-color: color-mix(in srgb, var(--success) 36%, var(--line)); background: color-mix(in srgb, var(--success-soft) 46%, var(--surface)); }
.p-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.p-model { color: var(--muted); font-size: 12px; margin-top: 3px; }
.p-badge { border-radius: 999px; padding: 2px 8px; font-size: 10.5px; font-weight: 600; }
.p-badge.use { background: var(--success-soft); color: var(--success); }
.p-badge.dim { background: var(--line-soft); color: var(--ink-2); }
.p-badge.analysis { background: var(--accent-soft); color: var(--accent); }
.p-badge.warn { background: var(--warning-soft, #fffaeb); color: var(--warning, #b54708); }
.p-actions { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.usage-head { color: var(--muted); font-size: 12.5px; margin-bottom: 10px; }
.usage-stats { display: grid; gap: 7px; }
.usage-summary { font-size: 13px; font-weight: 600; background: var(--line-soft); border-radius: var(--radius-sm); padding: 10px 13px; font-variant-numeric: tabular-nums; }
.usage-row { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; padding: 2px 2px; }
.usage-model { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usage-nums { color: var(--muted); white-space: nowrap; }
.usage-note, .usage-empty { color: var(--muted); font-size: 11.5px; line-height: 1.5; margin-top: 4px; }

/* ---- 反馈 ---- */
.toast {
  position: fixed; z-index: 100; left: 50%; bottom: 104px;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; border-radius: 999px;
  padding: 11px 18px; font-size: 13px; transition: .22s cubic-bezier(.22,.8,.36,1);
  max-width: 88vw; text-align: center; box-shadow: var(--shadow-float);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.loading { opacity: .55; pointer-events: none; }
.empty {
  color: var(--muted); text-align: center; padding: 44px 18px;
  background: var(--surface); border-radius: var(--radius-md); border: 1px dashed #d9dde4; font-size: 13px;
}

@media (min-width: 680px) {
  main { padding: 10px 24px 24px; }
  .topbar { padding-left: 28px; padding-right: 28px; }
  .platform-list { grid-template-columns: repeat(3, 1fr); }
  .hero { padding: 34px 30px 26px; }
}
@media (max-width: 430px) {
  .provider-strip { align-items: flex-start; }
  .provider-strip .primary-small { flex: 0 0 auto; }
  .capability-grid { grid-template-columns: 1fr; }
}

/* 移动端：汇总条允许换行，操作按钮独占一行不再被挤出屏幕 */
@media (max-width: 480px) {
  .summary-strip { flex-wrap: wrap; row-gap: 10px; }
  .summary-strip .strip-right { margin-left: auto; }
  .summary-strip .primary-small { flex: 1 0 100%; text-align: center; padding: 11px; }
  .summary-strip strong { font-size: clamp(17px, 5.6vw, 23px); }
}
/* Import review stays readable on narrow phones and preserves pending work. */
.import-review-dialog { width:min(620px,calc(100vw - 28px)); max-height:85dvh; overflow:auto; border:0; border-radius:20px; padding:20px; }
.import-review-dialog label { display:block; margin:12px 0; }
.import-review-dialog select,.import-review-dialog input:not([type=checkbox]) { width:100%; min-width:0; box-sizing:border-box; padding:12px; font-size:16px; }
.import-review-dialog { padding:0; width:min(560px,calc(100vw - 24px)); max-height:90dvh; background:var(--bg,#f5f6f8); color:var(--ink,#202124); }
.import-review-dialog form { padding:0 16px; }
.review-header,.review-footer { position:sticky; background:var(--bg,#f5f6f8); z-index:1; padding:16px 0; }
.review-header { top:0; display:flex; align-items:center; justify-content:space-between; }
.review-header h2 { font-size:19px; margin:0; }
.review-header button { width:44px; height:44px; border:0; background:transparent; font-size:24px; }
.review-footer { bottom:0; padding-bottom:max(16px,env(safe-area-inset-bottom)); }
.review-footer button { width:100%; min-height:48px; }
.review-intro,.review-hint { font-size:13px; line-height:1.6; color:var(--ink-2,#626975); }
.import-review-dialog .review-item { background:var(--surface,#fff); border:1px solid var(--line,#e4e6ec); border-radius:16px; padding:16px; margin:12px 0; }
.review-item-heading { display:flex; align-items:baseline; justify-content:space-between; gap:12px; font-size:16px; }
.review-item-heading strong { font-size:20px; overflow-wrap:anywhere; }
.import-review-dialog label { font-size:13px; line-height:1.5; color:var(--ink-2,#626975); }
.import-review-dialog input:not([type=checkbox]),.import-review-dialog select { border:1px solid var(--line,#e4e6ec); border-radius:12px; background:var(--surface,#fff); min-height:48px; color:var(--ink,#202124); margin-top:6px; }
.import-review-dialog select[hidden],#money-dialog select[hidden] { display:none !important; }
.review-edit { margin-top:14px; font-size:14px; }
.review-edit summary { padding:8px 0; cursor:pointer; }
.import-review-dialog .check-row { display:flex; align-items:flex-start; gap:8px; }
.check-row input[type=checkbox] { flex:none; width:20px; height:20px; margin:0; }
.account-picker-trigger { display:block; width:100%; padding:12px 14px; margin-top:6px; min-height:48px; border:1px solid var(--line,#e4e6ec); border-radius:12px; background:var(--surface,#fff); color:var(--ink,#202124); text-align:left; font-size:15px; line-height:1.5; overflow-wrap:anywhere; }
.account-picker-sheet { width:min(480px,calc(100vw - 24px)); max-height:80dvh; padding:18px; border:0; border-radius:20px; background:var(--surface,#fff); color:var(--ink,#202124); }
.account-picker-sheet header { display:flex; align-items:center; justify-content:space-between; }
.account-picker-sheet header button { width:44px; height:44px; border:0; background:transparent; font-size:24px; }
.account-picker-sheet h3 { font-size:18px; margin:0; }
.account-picker-sheet input { width:100%; box-sizing:border-box; padding:12px; border:1px solid var(--line,#e4e6ec); border-radius:12px; font-size:16px; margin:12px 0; }
.account-picker-options { max-height:55dvh; overflow:auto; }
.account-picker-option { display:flex; flex-direction:column; align-items:flex-start; gap:5px; width:100%; min-height:64px; padding:12px; border:0; border-bottom:1px solid var(--line,#e4e6ec); background:transparent; text-align:left; }
.account-picker-option strong { font-size:15px; font-weight:500; line-height:1.5; }
.account-picker-option small { font-size:12px; color:var(--ink-2,#626975); }
.account-picker-option[aria-pressed=true] { background:var(--accent-soft,#eef2ff); border-radius:12px; }
.review-item { border-top:1px solid #ddd; padding:16px 0; overflow-wrap:anywhere; }
.review-item h3 {font-size:16px;}
.review-error { color:#b42318; overflow-wrap:anywhere; }
.account-change-preview { background:var(--surface,#fff); border:1px solid var(--line,#e4e6ec); border-radius:14px; padding:14px; margin:14px 0; font-size:14px; line-height:1.6; overflow-wrap:anywhere; }
.account-change-preview > div { border-top:1px solid var(--line,#e4e6ec); padding-top:10px; margin-top:10px; }
#import-reply { padding:8px 12px; font-size:13px; color:var(--ink-2,#626975); }
#import-reply[hidden],.import-review-dialog .check-row[hidden] { display:none; }
/* Inline recognition: the identified values, one question, then exact effects. */
.bubble:has(.import-review-card) { width:min(86%,580px); }
.import-review-card { font-family:inherit; min-width:0; white-space:normal; }
.import-review-card .review-card-heading { display:flex; gap:12px; align-items:flex-start; }
.import-review-card .review-card-heading h4 { flex:1; min-width:0; margin:0; font-size:16px; line-height:1.5; }
.import-review-card .review-state { flex:none; color:var(--ink-2); font-size:13px; padding-top:3px; }
.import-review-card .review-material { margin-top:10px; padding:0; }
.import-review-card .review-material + .review-material { border-top:1px solid var(--line); padding-top:12px; }
.import-review-card h5 { margin:14px 0 8px; font-size:14px; line-height:1.5; }
.import-review-card .review-item { border:0; padding:14px 0 4px; }
.import-review-card .review-item + .review-item { border-top:1px solid var(--line-soft); margin-top:8px; }
.import-review-card .review-item-heading { align-items:baseline; flex-wrap:wrap; gap:4px 12px; font-size:14px; }
.import-review-card .review-item-heading strong { font-size:19px; line-height:1.5; font-weight:650; }
.import-review-card .review-item-heading .review-balance-change { display:flex; flex-wrap:wrap; align-items:baseline; gap:3px 5px; width:100%; font-size:17px; }
.import-review-card .review-balance-change .review-before { color:var(--ink-2); font-size:14px; font-weight:400; }
.import-review-card .review-matched-account { color:var(--ink); margin:4px 0 0; font-size:14px; line-height:1.5; }
.import-review-card .review-item-note,.import-review-card .review-effect-outcome { color:var(--ink-2); font-size:13px; line-height:1.6; margin:5px 0 0; }
.import-review-card .review-edit { margin-top:4px; }
.import-review-card .review-edit > summary { display:flex; align-items:center; min-height:44px; font-size:14px; color:var(--ink-2); padding:0; }
.import-review-card label { display:block; font-size:14px; line-height:1.5; margin:12px 0; }
.import-review-card input:not([type=checkbox]),.import-review-card select { font:inherit; font-size:16px; min-height:48px; width:100%; min-width:0; box-sizing:border-box; border:1px solid var(--line); border-radius:12px; padding:10px 12px; background:var(--surface); color:var(--ink); margin-top:6px; }
.import-review-card select[hidden] { display:none!important; }
.import-review-card .check-row { display:flex; align-items:center; gap:8px; min-height:44px; }
.import-review-card .check-row input { flex:none; width:20px; height:20px; }
.import-review-card .review-question { border:0; min-width:0; padding:0; margin:14px 0 0; }
.import-review-card .review-question legend { padding:0; font-size:15px; line-height:1.55; font-weight:500; }
.import-review-card .review-answer-buttons { display:grid; grid-template-columns:repeat(auto-fit,minmax(100px,1fr)); gap:8px; margin-top:12px; }
.import-review-card .review-answer-buttons button { min-height:44px; min-width:44px; padding:10px 8px; font:inherit; font-size:14px; line-height:1.4; background:var(--surface); border:1px solid var(--line); border-radius:10px; color:var(--ink); }
.import-review-card .review-answer-buttons button[aria-pressed=true] { border-color:var(--accent,#5055f3); background:var(--accent-soft,#eef0ff); color:var(--ink); }
.import-review-card .review-answer-note,.import-review-card .review-inline-status { font-size:13px; line-height:1.6; color:var(--ink-2); }
.import-review-card .review-inline-preview { border:1px solid var(--line); border-radius:14px; margin-top:14px; padding:0 14px 12px; background:var(--surface); }
.import-review-card .review-account-change { border-top:1px solid var(--line-soft); padding:10px 0; font-size:14px; line-height:1.6; overflow-wrap:anywhere; }
.import-review-card .review-account-change p { margin:3px 0 0; }
.import-review-card .review-account-change small { color:var(--ink-2); font-size:13px; }
.import-review-card .review-inline-actions { display:grid; gap:8px; margin-top:14px; }
.import-review-card .review-inline-actions button { min-height:48px; min-width:44px; font-family:inherit; font-size:15px; }
.import-review-card .review-inline-actions .primary-button { width:100%; margin:0; }
.import-review-card .review-inline-actions button:disabled { opacity:.45; cursor:default; }
.import-review-card .review-error { font-size:14px; line-height:1.6; }
.import-review-card .review-inline-status:empty,.import-review-card .review-error:empty { display:none; }
.import-review-card [hidden] { display:none!important; }
.message-footer { display:flex; align-items:center; gap:14px; margin-top:12px; font-size:12px; color:var(--muted,#737780); flex-wrap:wrap; }
.message-footer button { border:0; background:none; color:inherit; font:inherit; padding:8px 4px; min-height:36px; cursor:pointer; }
.message.user .message-footer { color:inherit; opacity:.85; }
#import-reply { display:flex; align-items:center; gap:12px; }
#import-reply span { flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
#import-reply button { border:0; background:none; color:inherit; font-size:22px; min-width:40px; min-height:40px; }
.old-import-drafts { margin:16px 0; font-size:14px; }
.old-import-drafts > summary { padding:12px; cursor:pointer; }
/* Credit totals and statement dues are separate, readable on narrow phones. */
.credit-total-label{display:block;font-size:12px;font-weight:400;color:var(--muted,#747b89);margin-bottom:5px}
.credit-bill-row{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:16px;padding:16px 0;border-top:1px solid var(--border,#e5e7eb);margin-top:14px}
.credit-bill-row span{display:block;font-size:13px;color:var(--muted,#747b89);margin-bottom:6px}
.credit-bill-row strong{display:block;font-size:18px;font-variant-numeric:tabular-nums;overflow-wrap:anywhere}
.credit-bill-note{font-size:13px;line-height:1.6;padding:0 8px;color:var(--muted,#747b89)}
.credit-due-summary { display:flex; flex-wrap:wrap; gap:8px 16px; align-items:center; padding:16px 0; font-size:14px; }
.credit-due-summary strong { margin-left:auto; font-size:20px; font-variant-numeric:tabular-nums; }
.credit-due-summary small { width:100%; color:var(--muted); }
.credit-due-summary[hidden] { display:none; }
