/* ==========================================================
   个人工作台 · 财务模块样式
   与 macos-theme.css / responsive.css 配套，沿用同一套设计变量
   结构：概览卡 → 账户条 → 记账按钮 → 流水列表 → 分类占比 → 趋势 → 预算
   ========================================================== */

/* ---------- 概览：三张并排的数字卡 ---------- */
.fin-overview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.fin-kpi {
  background: var(--card);
  border: .5px solid var(--mac-sep);
  border-radius: 11px;
  padding: 12px 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.fin-kpi .k-label {
  font-size: 11.5px; color: var(--text2); font-weight: 500;
  display: flex; align-items: center; gap: 5px;
}
.fin-kpi .k-value {
  font-size: 21px; font-weight: 600; letter-spacing: -0.03em;
  margin-top: 3px; font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.fin-kpi .k-value .cur { font-size: 12px; font-weight: 500; color: var(--text3); margin-right: 2px; }
.fin-kpi .k-sub { font-size: 11px; color: var(--text3); margin-top: 2px; }
.fin-kpi.income .k-value { color: #1e7a2e; }
.fin-kpi.expense .k-value { color: #c0392b; }
.fin-kpi.net .k-value { color: var(--text); }
.fin-kpi.net.neg .k-value { color: #c0392b; }

/* ---------- 账户横向条 ---------- */
.fin-accounts { margin-bottom: 14px; }
.fin-acc-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 7px;
}
.fin-acc-head .t { font-size: 11.5px; font-weight: 600; color: var(--text2); }
.fin-acc-scroll {
  display: flex; gap: 8px;
  overflow-x: auto; overflow-y: hidden;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.fin-acc {
  flex: 0 0 auto;
  min-width: 118px;
  padding: 9px 11px;
  border-radius: 9px;
  border: .5px solid var(--line);
  background: #fff;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s, transform .08s;
}
.fin-acc:hover { border-color: rgba(0,122,255,.45); box-shadow: 0 3px 10px rgba(0,122,255,.12); }
.fin-acc:active { transform: scale(.985); }
.fin-acc .a-name {
  font-size: 11.5px; color: var(--text2);
  display: flex; align-items: center; gap: 4px;
  white-space: nowrap;
}
.fin-acc .a-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.fin-acc .a-bal {
  font-size: 15px; font-weight: 600; margin-top: 3px;
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}
.fin-acc .a-bal.neg { color: #c0392b; }
.fin-acc .a-sub { font-size: 10px; color: var(--text3); margin-top: 1px; }
.fin-acc.total {
  background: linear-gradient(160deg, rgba(0,122,255,.08), rgba(0,122,255,.03));
  border-color: rgba(0,122,255,.25);
}
.fin-acc.total .a-bal { color: var(--primary); }

/* ---------- 操作行 ---------- */
.fin-actions {
  display: flex; gap: 8px; align-items: center;
  margin-bottom: 13px; flex-wrap: wrap;
}
.fin-actions .spacer { flex: 1; }
.fin-month-nav {
  display: flex; align-items: center; gap: 4px;
  background: rgba(118,118,128,.1); border-radius: 8px; padding: 2px;
}
.fin-month-nav button {
  width: 26px; height: 24px; border: none; background: transparent;
  border-radius: 6px; cursor: pointer; color: var(--text2);
  font-size: 13px; line-height: 1;
}
.fin-month-nav button:hover { background: rgba(255,255,255,.8); color: var(--text); }
.fin-month-nav .mk { font-size: 12px; font-weight: 600; padding: 0 6px; min-width: 62px; text-align: center; }

/* ---------- 流水列表 ---------- */
.fin-txns { margin-bottom: 16px; }
.fin-day-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 9px 2px 5px;
  font-size: 11px; color: var(--text3);
  border-bottom: .5px solid var(--line-soft);
  margin-bottom: 1px;
}
.fin-day-head .d-sum { font-variant-numeric: tabular-nums; }
.fin-txn {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 2px;
  border-bottom: .5px solid var(--line-soft);
  transition: background .1s;
}
.fin-txn:hover { background: rgba(0,122,255,.035); }
.fin-txn .t-icon {
  width: 32px; height: 32px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex: none;
  background: rgba(118,118,128,.1);
}
.fin-txn .t-main { flex: 1; min-width: 0; }
.fin-txn .t-title {
  font-size: 13px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fin-txn .t-meta {
  font-size: 11px; color: var(--text3); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fin-txn .t-amt {
  font-size: 14px; font-weight: 600; flex: none;
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}
.fin-txn .t-amt.expense { color: #c0392b; }
.fin-txn .t-amt.income { color: #1e7a2e; }
.fin-txn .t-amt.transfer { color: var(--text2); font-weight: 500; }
.fin-txn .t-ops { flex: none; display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.fin-txn:hover .t-ops { opacity: 1; }
.fin-txn .t-ops .btn { height: 22px; padding: 0 6px; font-size: 11px; }

.fin-empty {
  text-align: center; padding: 34px 16px;
  color: var(--text3); font-size: 12.5px;
}
.fin-empty .ico { font-size: 30px; opacity: .5; margin-bottom: 8px; }

/* ---------- 分类占比 ---------- */
.fin-cats { margin-bottom: 16px; }
.fin-cat-row {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 0;
}
.fin-cat-row .c-ico { width: 20px; text-align: center; font-size: 13px; flex: none; }
.fin-cat-row .c-name { font-size: 12.5px; width: 58px; flex: none; }
.fin-cat-row .c-bar {
  flex: 1; height: 7px; border-radius: 4px;
  background: rgba(118,118,128,.13); overflow: hidden; min-width: 40px;
}
.fin-cat-row .c-bar > i {
  display: block; height: 100%; border-radius: 4px;
  transition: width .35s cubic-bezier(.2,.85,.25,1);
}
.fin-cat-row .c-amt {
  font-size: 12px; width: 74px; text-align: right; flex: none;
  font-variant-numeric: tabular-nums; font-weight: 500;
}
.fin-cat-row .c-pct {
  font-size: 10.5px; width: 34px; text-align: right; flex: none;
  color: var(--text3); font-variant-numeric: tabular-nums;
}

/* ---------- 趋势柱状 ---------- */
.fin-trend { margin-bottom: 16px; }
.fin-chart {
  display: flex; align-items: flex-end; gap: 10px;
  height: 110px; padding: 6px 2px 0;
  border-bottom: .5px solid var(--line);
}
.fin-chart .col {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end;
  gap: 2px; height: 100%; position: relative;
}
.fin-chart .bars {
  display: flex; align-items: flex-end; gap: 3px;
  height: 100%; width: 100%; justify-content: center;
}
.fin-chart .bar {
  width: 42%; max-width: 16px; border-radius: 3px 3px 0 0;
  min-height: 2px; transition: height .4s cubic-bezier(.2,.85,.25,1);
}
.fin-chart .bar.inc { background: linear-gradient(180deg,#52c41a,#3fa314); }
.fin-chart .bar.exp { background: linear-gradient(180deg,#ff7875,#e04b4b); }
.fin-chart .col.now .bar.inc { background: linear-gradient(180deg,#73d13d,#52c41a); }
.fin-chart .lbl { font-size: 9.5px; color: var(--text3); }
.fin-legend {
  display: flex; gap: 14px; justify-content: center;
  font-size: 10.5px; color: var(--text2); margin-top: 6px;
}
.fin-legend i {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 2px; margin-right: 4px; vertical-align: 1px;
}

/* ---------- 预算 ---------- */
.fin-budgets .bud-row { padding: 8px 0; }
.fin-budgets .b-head {
  display: flex; justify-content: space-between;
  font-size: 12px; margin-bottom: 5px;
}
.fin-budgets .b-head .n { font-weight: 500; }
.fin-budgets .b-head .v { font-variant-numeric: tabular-nums; color: var(--text2); }
.fin-budgets .b-head .v b { color: var(--text); font-weight: 600; }
.fin-budgets .b-bar {
  height: 7px; border-radius: 4px; background: rgba(118,118,128,.13);
  overflow: hidden;
}
.fin-budgets .b-bar > i {
  display: block; height: 100%; border-radius: 4px;
  transition: width .35s cubic-bezier(.2,.85,.25,1);
}
.fin-budgets .b-bar > i.ok { background: linear-gradient(90deg,#52c41a,#73d13d); }
.fin-budgets .b-bar > i.warn { background: linear-gradient(90deg,#faad14,#ffc53d); }
.fin-budgets .b-bar > i.over { background: linear-gradient(90deg,#ff4d4f,#ff7875); }
.fin-budgets .b-hint { font-size: 10.5px; margin-top: 3px; }
.fin-budgets .b-hint.over { color: #c0392b; }
.fin-budgets .b-hint.warn { color: #ad6800; }
.fin-budgets .b-hint.ok { color: var(--text3); }

/* ---------- 记账弹窗里的方向切换 ---------- */
.fin-dir {
  display: flex; gap: 0; padding: 2px;
  background: rgba(118,118,128,.12); border-radius: 8px;
  margin-bottom: 13px;
}
.fin-dir button {
  flex: 1; height: 30px; border: none; background: transparent;
  border-radius: 6px; font-size: 12.5px; font-weight: 500;
  color: var(--text2); cursor: pointer; font-family: inherit;
  transition: background .14s, color .14s, box-shadow .14s;
}
.fin-dir button.on {
  background: #fff; color: var(--text); font-weight: 600;
  box-shadow: 0 .5px 2px rgba(0,0,0,.14), 0 0 0 .5px rgba(0,0,0,.05);
}
.fin-dir button.on[data-dir="expense"] { color: #c0392b; }
.fin-dir button.on[data-dir="income"] { color: #1e7a2e; }

/* 金额输入：大号数字 */
.fin-amount-wrap {
  display: flex; align-items: baseline; gap: 6px;
  border: .5px solid rgba(0,0,0,.16); border-radius: 8px;
  padding: 7px 11px; background: #fff;
  box-shadow: inset 0 .5px 1px rgba(0,0,0,.04);
  transition: border-color .14s, box-shadow .14s;
}
.fin-amount-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3.5px rgba(0,122,255,.28);
}
.fin-amount-wrap .cur { font-size: 14px; color: var(--text3); font-weight: 500; }
.fin-amount-wrap input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 22px; font-weight: 600; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; color: var(--text);
  font-family: inherit; min-width: 0; padding: 0;
}

/* 分类选择：宫格 */
.fin-cat-pick {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 6px; max-height: 168px; overflow-y: auto; padding: 2px;
}
.fin-cat-pick button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 3px; border-radius: 8px;
  border: .5px solid transparent; background: rgba(118,118,128,.07);
  cursor: pointer; font-family: inherit;
  transition: background .12s, border-color .12s;
}
.fin-cat-pick button:hover { background: rgba(118,118,128,.13); }
.fin-cat-pick button.on {
  border-color: var(--primary); background: rgba(0,122,255,.1);
}
.fin-cat-pick .ci { font-size: 15px; line-height: 1.2; }
.fin-cat-pick .cn { font-size: 10.5px; color: var(--text2); white-space: nowrap; }
.fin-cat-pick button.on .cn { color: var(--primary); font-weight: 600; }

/* ---------- 窄屏适配 ---------- */
@media (max-width: 767px) {
  .fin-overview { grid-template-columns: repeat(3, 1fr); gap: 7px; }
  .fin-kpi { padding: 9px 10px; border-radius: 9px; }
  .fin-kpi .k-value { font-size: 16px; }
  .fin-kpi .k-value .cur { font-size: 10px; }
  .fin-kpi .k-label { font-size: 10.5px; }
  .fin-kpi .k-sub { display: none; }

  .fin-acc { min-width: 104px; padding: 8px 10px; }
  .fin-acc .a-bal { font-size: 13.5px; }

  .fin-actions { gap: 6px; }
  .fin-actions .btn { flex: 1 1 auto; }

  .fin-txn .t-ops { opacity: 1; }          /* 触屏没有 hover，直接显示 */
  .fin-txn .t-icon { width: 28px; height: 28px; font-size: 13px; border-radius: 8px; }
  .fin-txn .t-title { font-size: 12.5px; }
  .fin-txn .t-amt { font-size: 13px; }

  .fin-cat-row .c-name { width: 46px; font-size: 11.5px; }
  .fin-cat-row .c-amt { width: 62px; font-size: 11.5px; }
  .fin-cat-row .c-pct { display: none; }

  .fin-chart { height: 90px; gap: 6px; }
  .fin-chart .lbl { font-size: 8.5px; }

  .fin-cat-pick { grid-template-columns: repeat(4, 1fr); max-height: 140px; }
  .fin-amount-wrap input { font-size: 20px; }
}

/* 深色模式（跟随系统） */
@media (prefers-color-scheme: dark) {
  .fin-kpi, .fin-acc { background: rgba(255,255,255,.045); border-color: rgba(255,255,255,.1); }
  .fin-txn .t-icon { background: rgba(255,255,255,.09); }
  .fin-amount-wrap { background: rgba(255,255,255,.06); }
  .fin-dir { background: rgba(255,255,255,.09); }
  .fin-dir button.on { background: rgba(255,255,255,.16); box-shadow: none; }
  .fin-cat-pick button { background: rgba(255,255,255,.07); }
  .fin-cat-pick button.on { background: rgba(0,122,255,.22); }
  .fin-month-nav { background: rgba(255,255,255,.09); }
  .fin-month-nav button:hover { background: rgba(255,255,255,.14); }
}

/* ==========================================================
   净资产构成明细
   ========================================================== */
.fin-nw {
  background: var(--bg-card);
  border: .5px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.fin-not-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 9px;
}
.fin-not-head .t { font-size: 12.5px; font-weight: 600; }

.nw-rows { display: grid; gap: 5px; }
.nw-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11.5px; color: var(--text2);
  padding: 3px 0;
}
.nw-label i {
  font-style: normal; font-size: 9.5px; color: var(--text3);
  margin-left: 5px;
}
.nw-val { font-variant-numeric: tabular-nums; font-weight: 500; }
.nw-row.plus .nw-val { color: #18a058; }
.nw-row.minus .nw-val { color: #e5484d; }

.nw-total {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 8px; padding-top: 8px;
  border-top: .5px solid var(--line);
  font-size: 11.5px; color: var(--text3);
}
.nw-total b {
  font-size: 16px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.nw-total b.neg { color: #e5484d; }

@media (prefers-color-scheme: dark) {
  .nw-row.plus .nw-val { color: #4ade80; }
  .nw-row.minus .nw-val { color: #f87171; }
  .nw-total b.neg { color: #f87171; }
}
