/* 沿用原结算网页的深色蓝灰与蓝色主操作（jiesuan-main/DESIGN.md） */
:root {
  --bg: #10161d;
  --side: #131c26;
  --panel: #161f2a;
  --panel-2: #1b2633;
  --line: #263444;
  --line-2: #31425a;
  --text: #e7edf4;
  --muted: #a0b0c2;
  --faint: #7d8fa5;        /* 次要文字：在 bg / panel / panel-2 上对比度都 ≥ 4.5 */
  --blue: #4c8dff;
  --blue-2: #3a78e8;
  --blue-weak: rgba(76, 141, 255, .14);
  --green: #3fbf7f;
  --green-weak: rgba(63, 191, 127, .14);
  --warn: #f0a742;
  --warn-weak: rgba(240, 167, 66, .14);
  --bad: #ef5f5f;
  --bad-weak: rgba(239, 95, 95, .14);
  --income: #5fc8a0;
  --cost: #f0a742;
  --fee: #f7d6a3;          /* 手续费：成本里的另一部分，与支出同色系、更浅 */
  --radius: 10px;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: .01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; color: var(--muted); font-weight: 500; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stack { display: grid; gap: 16px; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
::selection { background: rgba(76, 141, 255, .35); color: var(--text); }
::placeholder { color: var(--faint); opacity: 1; }
input, textarea { caret-color: var(--blue); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}
kbd {
  font-family: var(--mono); font-size: 11.5px; border: 1px solid var(--line-2); border-bottom-width: 2px;
  border-radius: 4px; padding: 0 5px; color: var(--text); background: var(--panel-2);
}
.link-btn {
  appearance: none; border: 0; background: none; padding: 0; font: inherit; color: var(--blue); cursor: pointer;
  text-decoration: underline; text-decoration-color: rgba(76, 141, 255, .4); text-underline-offset: 3px;
}
.link-btn:hover { text-decoration-color: currentColor; }

/* ---------- 布局 ---------- */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--side); border-right: 1px solid var(--line); padding: 18px 12px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 16px; font-weight: 600; font-size: 15px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--blue); display: grid; place-items: center;
}
.brand-mark svg { width: 18px; height: 18px; stroke: #fff; stroke-width: 2.4; fill: none; stroke-linecap: round; }
.nav-label { color: var(--faint); font-size: 12px; padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px; color: var(--muted);
  font-size: 14px; min-height: 38px;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--blue-weak); color: var(--text); }
.nav-item svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; flex: none; }
.nav-item .dot { margin-left: auto; }
.nav-item span.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot { margin-top: auto; padding-top: 16px; }
.main { padding: 26px 30px 60px; min-width: 0; max-width: 1360px; width: 100%; }
.main.wide { max-width: 1720px; }  /* 群组页：宽屏时右侧多一列冷钱包 */
.topbar { display: none; }
.page-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }

/* ---------- 组件 ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card.flush { padding: 0; }
.card.flush .card-head { padding: 16px 18px 0; }
.btn {
  appearance: none; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text);
  border-radius: 8px; padding: 0 14px; height: 38px; font: inherit; cursor: pointer; display: inline-flex;
  align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { border-color: var(--faint); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-2); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--panel-2); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }
.pill {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; background: var(--panel-2); color: var(--muted); white-space: nowrap;
}
.pill.ok { background: var(--green-weak); color: var(--green); }
.pill.warn { background: var(--warn-weak); color: var(--warn); }
.pill.bad { background: var(--bad-weak); color: var(--bad); }
.pill.blue { background: var(--blue-weak); color: var(--blue); }
.pill-btn { appearance: none; border: 0; font: inherit; font-size: 12px; cursor: pointer; }
.pill-btn.warn:hover { background: rgba(240, 167, 66, .24); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; flex: none; }
.dot.ok { background: var(--green); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line-2); border-radius: 8px;
  height: 38px; padding: 0 11px; min-width: 0;
}
textarea { height: auto; padding: 9px 11px; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: none; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--blue); padding: 0; }
.field { display: grid; gap: 6px; align-content: start; }
.field .seg { justify-self: start; }
.field > span, .field > label { color: var(--muted); font-size: 13px; }
.field .hint { color: var(--faint); font-size: 12px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; min-height: 38px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 18px; }
.notice {
  border: 1px solid var(--line-2); border-radius: var(--radius); padding: 12px 14px; display: flex; gap: 12px;
  align-items: flex-start; background: var(--panel);
}
.notice.warn { border-color: rgba(240, 167, 66, .45); background: rgba(240, 167, 66, .07); }
.notice.bad { border-color: rgba(239, 95, 95, .45); background: rgba(239, 95, 95, .07); }
.notice.blue { border-color: rgba(76, 141, 255, .45); background: rgba(76, 141, 255, .07); }
.notice b { display: block; margin-bottom: 2px; }
.empty { text-align: center; color: var(--muted); padding: 34px 16px; }
.tabs {
  display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto;
  overflow-y: hidden; scrollbar-width: none;
}
.tabs a {
  padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
  white-space: nowrap;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-selected="true"] { color: var(--text); border-bottom-color: var(--blue); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; height: 38px; }
.seg button {
  appearance: none; border: 0; background: transparent; color: var(--muted); padding: 0 14px; font: inherit;
  cursor: pointer; white-space: nowrap; flex: none;
}
.seg button[aria-pressed="true"] { background: var(--blue-weak); color: var(--text); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  appearance: none; border: 1px solid var(--line-2); background: transparent; color: var(--muted);
  border-radius: 999px; height: 30px; padding: 0 12px; font: inherit; font-size: 13px; cursor: pointer;
}
.chip[aria-pressed="true"] { border-color: var(--blue); color: var(--text); background: var(--blue-weak); }

/* ---------- 统计 ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .label { color: var(--muted); font-size: 13px; display: flex; gap: 6px; align-items: center; }
.tile .value { font-size: 22px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .foot { color: var(--faint); font-size: 12px; margin-top: 2px; }
.value.neg { color: var(--bad); }
/* 顶部三个数是一道算式：收入 − 成本 = 利润 */
.equation { display: grid; grid-template-columns: minmax(0, 1fr) 22px minmax(0, 1fr) 22px minmax(0, 1fr); align-items: center; }
.equation > .op { text-align: center; color: var(--faint); font: 500 20px/1 var(--mono); }
.equation .tile { height: 100%; }
/* 各方应得：每方一列竖式，左侧是运算符 */
.receipts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px 24px; }
.receipt { min-width: 0; }
.receipt-head { display: flex; align-items: baseline; gap: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.receipt-head b { font-size: 15px; }
.rc-line { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; column-gap: 8px; align-items: baseline; padding: 4px 0; }
.rc-line .op { color: var(--faint); font-family: var(--mono); text-align: center; }
.rc-line .lbl { display: grid; gap: 1px; min-width: 0; color: var(--muted); }
.rc-line .hint { color: var(--faint); font-size: 12px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rc-line .v { text-align: right; font-variant-numeric: tabular-nums; }
.rc-line.zero .v, .rc-line.zero .lbl > span:first-child { color: var(--faint); }
.rc-line.sub { border-top: 1px dashed var(--line-2); margin-top: 3px; padding-top: 7px; }
.rc-line.sub .lbl, .rc-line.sub .v { color: var(--text); font-weight: 600; }
.rc-line.total { border-top: 1px solid var(--line-2); margin-top: 6px; padding-top: 10px; }
.rc-line.total .lbl { color: var(--text); font-weight: 600; }
.rc-line.total .v { font-size: 20px; font-weight: 600; }
/* 计入不计入总额的渠道（如织宇恒）后的应得：同样大小，换成收入色区分 */
.rc-line.total.alt { border-top-style: dashed; }
.rc-line.total.alt .v, .rc-line.total.alt .lbl > span:first-child { color: var(--income); }
.settle-foot { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--faint); font-size: 12.5px; }
.settle-foot b { color: var(--muted); font-weight: 600; }
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(70px, auto) 1fr auto; gap: 10px; align-items: center; }
.bar { height: 8px; border-radius: 4px; background: var(--panel-2); overflow: hidden; display: flex; gap: 2px; }
.bar > i { display: block; flex: none; height: 100%; border-radius: 4px; background: var(--income); }
.bar.cost > i { background: var(--cost); }
.bar.cost > i.fee { background: var(--fee); }
.bar-row.off { opacity: .55; }
.legend { display: flex; gap: 14px; color: var(--faint); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; background: var(--cost); }
.legend .sw.fee { background: var(--fee); }

/* ---------- 总览群卡片 ---------- */
.group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.group-card { display: grid; gap: 14px; cursor: pointer; transition: border-color .15s; }
.group-card:hover { border-color: var(--line-2); }
.group-card .gstats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gstat .label { color: var(--muted); font-size: 12px; }
.gstat .value { font-weight: 600; font-variant-numeric: tabular-nums; }
.mini-payouts { display: grid; gap: 4px; border-top: 1px solid var(--line); padding-top: 10px; }
.mini-payouts div { display: flex; justify-content: space-between; }
.steps { counter-reset: s; display: grid; gap: 12px; padding: 0; margin: 0; list-style: none; }
.steps li { counter-increment: s; display: flex; gap: 12px; align-items: flex-start; }
.steps li::before {
  content: counter(s); flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--blue-weak);
  color: var(--blue); display: grid; place-items: center; font-size: 13px; font-weight: 600;
}

/* ---------- 账期 ---------- */
.ledger { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 18px; align-items: start; }
.period-list { display: grid; gap: 4px; position: sticky; top: 16px; }
.period-item {
  display: grid; gap: 2px; padding: 10px 12px; border-radius: 8px; border: 1px solid transparent; color: var(--text);
}
.period-item:hover { background: var(--panel); text-decoration: none; }
.period-item[aria-current="true"] { background: var(--panel); border-color: var(--line-2); }
.period-item .top { display: flex; align-items: center; gap: 8px; }
.period-item .top b { font-weight: 600; }
.period-item .meta { display: flex; justify-content: space-between; color: var(--faint); font-size: 12px; }
.period-body { display: grid; gap: 16px; min-width: 0; }
.head-meta { margin-top: 6px; gap: 8px; }
.insights { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.quick-add {
  display: grid; grid-template-columns: auto minmax(120px, 160px) minmax(120px, 160px) minmax(140px, 1fr) auto;
  gap: 8px; align-items: center;
}
.add-card .card-head { margin-bottom: 12px; }
/* 算式拆成的每一笔：金额对齐上面的金额框，摘要对齐上面的摘要框 */
.qa-lines { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; row-gap: 6px; padding-top: 4px; }
.qa-lines[hidden] { display: none; }
.qa-lines-head { grid-column: 3 / -1; }
.qa-line { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; align-items: center; }
.qa-no { grid-column: 1 / 3; justify-self: end; font-size: 12.5px; }
.qa-amt { grid-column: 3; padding: 0 12px; font-weight: 600; overflow-wrap: anywhere; }
.qa-line-note { grid-column: 4; height: 32px; }
.toolbar { display: flex; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; align-items: center; }
.toolbar input[type="search"] { width: 180px; height: 32px; }
.toolbar select { height: 32px; max-width: 200px; }
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; font-weight: 500; color: var(--faint); font-size: 12.5px; padding: 10px 12px;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: rgba(255, 255, 255, .015); }
.tbl .r { text-align: right; }
.tbl tr.void td { color: var(--faint); }
.tbl tr.void .amt, .tbl tr.void .note { text-decoration: line-through; }
.tbl .amt { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.tbl td.c-amt { min-width: 110px; }
.tbl tr.open > td { background: rgba(76, 141, 255, .05); }
.tbl .expr { display: block; color: var(--faint); font-size: 11.5px; font-weight: 400; font-family: var(--mono); }
.tbl td.note { min-width: 140px; }
.kind { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; white-space: nowrap; }
.kind::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: currentColor; }
.kind.income { color: var(--income); }
.kind.cost { color: var(--cost); }
.thumbs { display: flex; gap: 4px; align-items: center; }
.thumb {
  width: 34px; height: 34px; border-radius: 6px; object-fit: cover; border: 1px solid var(--line-2);
  background: var(--panel-2); cursor: zoom-in; padding: 0; display: block; overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 5px; display: block; }
.thumb-more { font-size: 12px; color: var(--muted); }
.who { white-space: nowrap; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; }
.tbl td.c-by { white-space: nowrap; }

/* 表格内直接编辑：平时像普通文字，悬停露出边框，聚焦时是输入框 */
.cell-input, .cell-select {
  height: 30px; width: 100%; padding: 0 8px; margin: -4px 0; border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: inherit; font: inherit; transition: border-color .15s, background-color .15s;
}
.cell-select {
  appearance: none; cursor: pointer; padding-right: 22px; background-repeat: no-repeat; background-position: right 7px center;
  background-size: 10px;
}
.tbl tr:hover .cell-input, .tbl tr:hover .cell-select { border-color: var(--line); }
.tbl tr:hover .cell-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23a0b0c2' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E");
}
.cell-input:hover, .cell-select:hover { border-color: var(--line-2) !important; }
.cell-input:focus, .cell-select:focus { border-color: var(--blue) !important; background-color: var(--bg); outline: none; }
.cell-input[aria-invalid="true"] { border-color: var(--bad) !important; }
.cell-select option, .cell-select optgroup { background: var(--panel); color: var(--text); }
.amt-input { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.cell-static { display: block; padding: 0 9px; }
.kind-text { font-size: 12.5px; }
.kind-text.income { color: var(--income); }
.kind-text.cost { color: var(--cost); }
.tbl.entries th.c-kind, .tbl.entries th.c-who, .tbl.entries th.c-note { padding-left: 21px; }
.tbl.entries th.c-amt { padding-right: 21px; }
.tbl td.c-amt .expr { padding-right: 9px; }
.kind-select.income { color: var(--income); }
.kind-select.cost { color: var(--cost); }
.tbl td.c-kind { min-width: 96px; }  /* 含左右 12px 内边距：下拉框要放下「支出」和右侧箭头 */
.tbl td.c-who { min-width: 100px; }
.tbl td.c-note { min-width: 150px; }
/* 中等宽度放不下整张表：先收起「记账」列（展开凭证时能看到记账人和时间） */
@media (min-width: 641px) and (max-width: 1400px) { .tbl.entries .c-by { display: none; } }

/* 凭证：缩略图 + 上传入口；展开后是一行拖放区 */
.proof-btn {
  appearance: none; width: 30px; height: 30px; display: grid; place-items: center; flex: none; border-radius: 6px;
  border: 1px dashed var(--line-2); background: transparent; color: var(--muted); cursor: pointer;
}
.proof-btn svg, .need-proof svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; }
.proof-btn:hover { border-color: var(--blue); color: var(--text); }
.proof-btn.quiet { opacity: .45; transition: opacity .15s; }
.tbl tr:hover .proof-btn.quiet, .proof-btn.quiet:focus-visible, .proof-btn.quiet[aria-expanded="true"] { opacity: 1; }
@media (hover: none) { .proof-btn.quiet { opacity: 1; } }
.proof-btn[aria-expanded="true"] { border-style: solid; border-color: var(--blue); color: var(--text); background: var(--blue-weak); }
.need-proof {
  appearance: none; border: 1px dashed rgba(240, 167, 66, .55); background: var(--warn-weak); color: var(--warn);
  height: 30px; padding: 0 10px; border-radius: 999px; font: inherit; font-size: 12.5px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
}
.need-proof:hover, .need-proof[aria-expanded="true"] { border-style: solid; background: rgba(240, 167, 66, .22); }
.tbl tr.drop-target > td { background: var(--blue-weak); }
.tbl tr.drop-target > td:first-child { box-shadow: inset 2px 0 0 var(--blue); }
.tbl tr.detail > td { padding: 0 12px 14px; background: rgba(76, 141, 255, .05); }
.tbl tbody tr.detail:hover { background: transparent; }
.proof-panel {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 320px); gap: 16px; align-items: stretch;
  padding: 14px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line);
}
.pp-main { display: grid; gap: 12px; align-content: start; min-width: 0; }
.proof-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.proof-tile { position: relative; width: 92px; height: 92px; }
.pt-open {
  appearance: none; padding: 0; width: 100%; height: 100%; border-radius: 8px; overflow: hidden; cursor: zoom-in;
  border: 1px solid var(--line-2); background: var(--panel-2); display: block;
}
.pt-open img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pt-del {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center;
  border: 0; background: rgba(5, 9, 14, .78); color: var(--text); cursor: pointer; opacity: 0; transition: opacity .15s;
}
.pt-del svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2.2; }
.proof-tile:hover .pt-del, .pt-del:focus-visible { opacity: 1; }
.pt-del:hover { background: var(--bad); }
.drop {
  display: grid; place-items: center; align-content: center; gap: 6px; text-align: center; min-height: 110px; padding: 14px;
  border: 1px dashed var(--line-2); border-radius: 8px; color: var(--muted); font-size: 13px;
  transition: border-color .15s, background-color .15s, opacity .15s;
}
.drop .drop-main { color: var(--text); font-size: 14px; }
.drop > svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.drop .link-btn { white-space: nowrap; }
.drop:hover { border-color: var(--faint); }
/* 选中（可以直接粘贴）或正拖着图片经过时高亮 */
.drop.over, .drop:focus, .drop:focus-within { border-style: solid; border-color: var(--blue); background: var(--blue-weak); color: var(--text); outline: none; }
.drop.busy { opacity: .55; pointer-events: none; }
/* 筛选结果和合计：在筛选栏正下方；筛选后加底色、数字放大 */
.tbl-sum {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 20px; padding: 10px 18px; border-bottom: 1px solid var(--line);
  color: var(--faint); font-size: 12.5px;
}
.tbl-sum b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.tbl-sum.filtered { background: rgba(76, 141, 255, .06); color: var(--muted); font-size: 13px; padding: 12px 18px; }
.tbl-sum.filtered b { font-size: 16px; }
.tbl-hint { padding: 12px 18px 14px; border-top: 1px solid var(--line); }

/* 勾选流水后出现的移动栏 */
.pick { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; white-space: nowrap; }
.pick input { width: 16px; height: 16px; }
.tbl tr.picked > td { background: rgba(76, 141, 255, .08); }
.move-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 18px;
  border-bottom: 1px solid var(--line); background: var(--blue-weak);
}
.move-bar[hidden] { display: none; }
.move-bar select { height: 32px; max-width: 280px; }

/* ---------- 群组页：冷钱包（宽屏在右侧一列，窄屏收成页头下的一条） ---------- */
.group-layout { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "wallet" "rest"; }
.g-head { grid-area: head; min-width: 0; }
.g-rest { grid-area: rest; min-width: 0; }
.wallet { grid-area: wallet; display: flex; flex-direction: column; gap: 12px; padding: 16px; min-width: 0; }
.w-title { font-size: 16px; }
.w-balance { display: flex; align-items: baseline; gap: 10px; color: var(--muted); font-size: 13px; }
.w-balance b { color: var(--text); font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.w-balance b.neg { color: var(--bad); }
.w-toggle { display: none; }
.w-body { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.w-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }  /* 列可以缩：输入框自带的最小宽度不能把卡片撑破 */
.w-form.editing { padding: 10px; border: 1px solid var(--blue); border-radius: 8px; background: var(--bg); }
.w-form input, .w-form .seg { height: 34px; }
.w-form .seg { flex: none; }
.w-form .seg button { padding: 0 12px; }
.w-row { display: flex; gap: 8px; align-items: center; }
.w-row > input { flex: 1 1 0; min-width: 0; width: 0; }
.w-list { list-style: none; margin: 0 -6px; padding: 0; display: grid; gap: 2px; overflow-y: auto; min-height: 0; }
.w-move {
  appearance: none; width: 100%; text-align: left; background: transparent; border: 1px solid transparent; border-radius: 8px;
  padding: 8px 10px; color: inherit; font: inherit; cursor: pointer;
  display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 10px; row-gap: 3px; align-items: baseline;
}
.w-move:hover { background: var(--panel-2); border-color: var(--line); }
.w-day { color: var(--faint); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.w-amt { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.w-amt.in { color: var(--income); }
.w-amt.out { color: var(--cost); }
.w-note { font-size: 13px; overflow-wrap: anywhere; }
.w-after { text-align: right; color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.w-empty { color: var(--faint); font-size: 12.5px; }
.w-balance-wrap { display: grid; gap: 4px; min-width: 0; }
.w-diff { color: var(--warn); }
.w-chain { display: grid; gap: 4px; min-width: 0; }
.w-chain .mono { font-size: 12.5px; }
.w-chain .btn.sm { height: 28px; padding: 0 8px; }
.w-link { align-self: flex-start; }
.w-tag { margin-left: 6px; font-size: 11px; color: var(--blue); border: 1px solid rgba(76, 141, 255, .45); border-radius: 4px; padding: 0 4px; }
@media (min-width: 1800px) {
  .group-layout {
    grid-template-columns: minmax(0, 1fr) 300px; grid-template-rows: auto 1fr; grid-template-areas: "head wallet" "rest wallet";
    column-gap: 20px; align-items: start;
  }
  .wallet { position: sticky; top: 16px; max-height: calc(100vh - 32px); }
}
@media (max-width: 1799px) {
  .wallet { display: grid; grid-template-columns: auto 1fr auto; align-items: center; column-gap: 16px; row-gap: 12px; margin-bottom: 18px; }
  .w-balance b { font-size: 18px; }
  .w-toggle { display: inline-flex; }
  .w-body { grid-column: 1 / -1; max-width: 640px; }
  .wallet.collapsed .w-body { display: none; }
  .w-list { max-height: 420px; }
}

/* ---------- 弹窗 ---------- */
dialog {
  border: 1px solid var(--line-2); border-radius: 12px; background: var(--panel); color: var(--text); padding: 0;
  width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
}
dialog::backdrop { background: rgba(5, 9, 14, .7); }
.dlg-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.dlg-body { padding: 18px 20px; display: grid; gap: 14px; }
.dlg-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.lightbox {
  position: fixed; inset: 0; background: rgba(5, 9, 14, .92); display: grid; grid-template-rows: auto 1fr auto;
  z-index: 50;
}
.lightbox .lb-top { display: flex; align-items: center; gap: 10px; padding: 12px 16px; }
.lightbox .lb-img { display: grid; place-items: center; min-height: 0; padding: 0 16px; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 140px); border-radius: 8px; }
.lightbox .lb-nav { display: flex; justify-content: center; gap: 8px; padding: 12px; }

#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: #22303f;
  border: 1px solid var(--line-2); color: var(--text); padding: 10px 16px; border-radius: 9px; opacity: 0;
  pointer-events: none; transition: .2s; z-index: 60; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { border-color: var(--bad); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(380px, 100%); display: grid; gap: 16px; padding: 28px; }

/* ---------- 响应式 ---------- */
@media (max-width: 1280px) {
  .insights { grid-template-columns: 1fr; }
}
@media (max-width: 1180px) {
  /* 笔记本宽度：账期列表改成顶部横排，把宽度留给流水表 */
  .ledger { grid-template-columns: 1fr; }
  .period-list { position: static; grid-auto-flow: column; grid-auto-columns: minmax(170px, 220px); overflow-x: auto; justify-content: start; }
}
@media (max-width: 760px) {
  /* 算式竖排：收入 / − / 成本 / = / 利润 */
  .equation { grid-template-columns: 1fr; }
  .equation > .op { line-height: 22px; }
  .proof-panel { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%);
    transition: transform .2s; box-shadow: 0 0 40px rgba(0, 0, 0, .5);
  }
  .shell.nav-open .side { transform: none; }
  .topbar {
    display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line);
    background: var(--side); position: sticky; top: 0; z-index: 30;
  }
  .main { padding: 18px 16px 48px; }
  .ledger { grid-template-columns: 1fr; }
  .period-list { position: static; grid-auto-flow: column; grid-auto-columns: minmax(170px, 1fr); overflow-x: auto; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-add { grid-template-columns: 1fr 1fr; }
  .quick-add .seg { grid-column: 1 / -1; justify-self: start; }
  .quick-add .qa-note { grid-column: 1 / -1; }
  .quick-add .btn { grid-column: 1 / -1; justify-content: center; order: 2; }
  .quick-add .qa-lines { order: 1; grid-template-columns: auto minmax(0, 1fr) minmax(0, 2fr); column-gap: 8px; }
  .qa-lines-head { grid-column: 1 / -1; }
  .qa-line { grid-column: 1 / -1; }
  .qa-no { grid-column: 1; }
  .qa-amt { grid-column: 2; padding: 0; }
  .qa-line-note { grid-column: 3; }
  .group-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .tbl .hide-sm { display: none; }
  /* 窄屏下每笔流水改为三行卡片：编号/类型/对象/金额，摘要/凭证，记账人/操作 */
  .tbl.entries thead { display: none; }
  .tbl.entries tr {
    display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; column-gap: 8px; row-gap: 6px;
    grid-template-areas: "seq kind who amt" "note note note proof" "by by by act";
    padding: 12px 14px; border-bottom: 1px solid var(--line); align-items: center;
  }
  .tbl.entries td { padding: 0; border: 0; min-width: 0; }
  .tbl.entries td.c-amt, .tbl.entries td.c-note, .tbl.entries td.c-kind, .tbl.entries td.c-who { min-width: 0; }
  .tbl.entries .amt-input { width: 112px; }
  .tbl.entries .kind-select { width: 64px; }
  .tbl.entries tr.detail { display: block; padding: 0 14px 12px; }
  .tbl.entries tr.detail > td { display: block; padding: 0; background: transparent; }
  .tbl.entries tr.open { border-bottom: 0; }
  /* 卡片布局里格子是分开的块：选中、展开的底色加在整行上，不加在每个格子上 */
  .tbl.entries tr.picked, .tbl.entries tr.open { background: rgba(76, 141, 255, .08); }
  .tbl.entries tr.picked > td, .tbl.entries tr.open > td { background: transparent; }
  .cell-input, .cell-select { border-color: var(--line); }  /* 触屏没有悬停，直接露出可编辑的边框 */
  .toolbar select { max-width: none; flex: 1; }
  .tbl.entries td.empty { grid-column: 1 / -1; padding: 24px 0; }
  .c-seq { grid-area: seq; } .c-kind { grid-area: kind; } .c-who { grid-area: who; } .c-amt { grid-area: amt; }
  .c-note { grid-area: note; } .c-proof { grid-area: proof; justify-self: end; } .c-by { grid-area: by; } .c-act { grid-area: act; }
  .tile .value { font-size: 19px; }
  .toolbar input[type="search"] { width: 100%; }
  h1 { font-size: 19px; }
}
