/* 外壳、每日页、记一笔面板。颜色只用 base.css 的变量。
   按 1280×720 设计：页面本身不滚动，明细多了只在明细区里滚。 */
body { overflow: hidden; }
.shell {
  height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: 44px minmax(0, 1fr);
  gap: 0 14px; padding: 0 16px 14px;
}
.shell.with-panel { grid-template-columns: minmax(0, 1fr) 288px; }

/* ---------- 顶栏 ---------- */
.top { grid-column: 1 / -1; display: flex; align-items: center; gap: 18px; position: relative; min-width: 0; }
.top > h1, .top > nav, .top > .tools, .top > .who { flex: none; }
.top h1 { font-size: 15px; font-weight: 600; white-space: nowrap; }
.top nav { display: flex; gap: 16px; }
.top nav a { color: var(--muted); white-space: nowrap; }
.top nav a:hover { color: var(--ink); text-decoration: none; }
.top nav a.on { color: var(--ink); font-weight: 600; }
.top nav kbd, .per kbd, .vw kbd { font-size: 11px; opacity: .55; margin-left: 4px; font-weight: 400; }
.ghint {
  position: absolute; top: 38px; left: 120px; z-index: 30; background: var(--ink); color: var(--sheet);
  padding: 4px 10px; font-size: 12px; white-space: nowrap;
}
.ghint kbd { font-weight: 600; }
.tools { margin-left: auto; display: flex; align-items: center; gap: 10px; position: relative; }
.per, .vw { display: flex; gap: 2px; }
.per button, .vw button { background: none; border: 0; padding: 3px 9px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.per button:hover, .vw button:hover { color: var(--ink); }
.per button.on, .vw button.on { background: var(--ink); color: var(--sheet); }
.range { color: var(--muted); font-family: var(--num); font-size: 14px; min-width: 92px; }
.vw { margin-right: 6px; }
.vw button.on kbd { display: none; }   /* S 切到另一张：只在没选中的那个上标 */

/* 顶栏提示（T-11，F-071、F-073）：平时没有；琥珀色 = 提醒，红色 = 出问题了；点了跳到对应页面。
   顶栏只放最要紧的一条，其余收进「另 N 条」（点开是下拉的小浮层，每条完整显示、可换行）。 */
.notes { display: flex; gap: 6px; min-width: 0; flex: 0 1 auto; margin-left: -6px; position: relative; }
.notes[hidden] { display: none; }
.notes a { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 48px; flex: 0 1 auto; padding: 3px 8px; font-size: 13px; border-left: 3px solid; color: var(--ink); }
.notes a.warn { background: var(--wait-bg); border-color: var(--wait); }
.notes a.error { background: var(--loss); border-color: var(--loss); color: #fff; font-weight: 600; }
.notes .more { flex: none; white-space: nowrap; padding: 3px 8px; font-size: 13px; background: none; border: 1px solid var(--line); color: var(--ink); cursor: pointer; }
.notes .more.error { border-color: var(--loss); color: var(--loss); font-weight: 600; }
.notes .more[aria-expanded="true"] { background: var(--ink); border-color: var(--ink); color: var(--sheet); }
.notepop {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 30; width: 300px; background: var(--sheet);
  border: 1px solid var(--ink); padding: 8px; display: grid; gap: 6px;
}
.notepop[hidden] { display: none; }
.notepop a { white-space: normal; overflow: visible; min-width: 0; }
.top.has-notes { gap: 12px; }
.top.has-notes nav { gap: 12px; }
.top.has-notes #help .lbl { display: none; }
.top.has-notes #help kbd { margin-left: 0; }
.who { display: flex; align-items: center; gap: 10px; color: var(--muted); white-space: nowrap; }
.who .sec { padding: 3px 9px; }

/* 自选周期浮层 */
.pop {
  position: absolute; top: 34px; right: 0; z-index: 20; width: 260px; background: var(--sheet);
  border: 1px solid var(--ink); padding: 12px; display: grid; gap: 8px;
}
.pop .err { min-height: 0; font-size: 12px; }
.pop .err:empty { display: none; }
.btns { display: grid; grid-template-columns: 1fr auto; gap: 6px; }

/* ---------- 内容区 ---------- */
main { min-height: 0; min-width: 0; display: grid; }
.board { background: var(--sheet); display: grid; grid-template-rows: auto 218px minmax(0, 1fr); min-height: 0; min-width: 0; }
.board.stub { display: block; padding: 22px 24px; }
.board.stub h2 { font-size: 15px; font-weight: 600; }
.board.stub p { color: var(--muted); margin-top: 8px; }

/* 汇总一行 */
.sum { display: flex; gap: 30px; padding: 12px 18px 6px; align-items: flex-end; min-width: 0; }
.sum .k { display: flex; flex-direction: column; white-space: nowrap; }
.sum .l { font-size: 12px; color: var(--muted); }
.sum .n { font-family: var(--num); font-size: 30px; font-weight: 500; line-height: 1.1; }
.sum .n small { font-size: 19px; }
.sum .sub { font-size: 12px; color: var(--muted); }
.sum .sep { width: 1px; align-self: stretch; background: var(--line); }
.gain { color: var(--gain); }
.loss { color: var(--loss); }
.legend {
  margin-left: auto; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px 12px;
  font-size: 12px; color: var(--muted); max-width: 300px; padding-bottom: 2px;
}
.legend span { white-space: nowrap; }
.legend i { display: inline-block; width: 9px; height: 9px; margin-right: 4px; vertical-align: -1px; }
.legend i.ln { width: 12px; height: 2px; background: var(--ink); vertical-align: 3px; }

/* 收支图 */
.chart { padding: 0 18px 0 6px; min-height: 0; }
.chart svg { width: 100%; height: 100%; display: block; font-family: var(--num); }
.chart .hit { cursor: pointer; }
.chart .hit:hover { fill: rgba(22, 33, 44, .045); }

/* 成本结构（T-11，F-038）：替换收支图那一块，高度不变，行多了在这块里滚 */
.struct { height: 100%; overflow-y: auto; padding: 0 0 0 12px; }
.struct[hidden] { display: none; }
table.st { width: 100%; border-collapse: collapse; table-layout: fixed; }
.st col.c-per { width: 92px; } .st col.c-bar { width: 18%; } .st col.c-tot { width: 108px; }
.st thead th {
  position: sticky; top: 0; z-index: 1; background: var(--sheet); font-size: 12px; color: var(--muted); font-weight: 400;
  text-align: left; padding: 6px 6px 3px; border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.st thead th i { display: inline-block; width: 9px; height: 9px; margin-right: 4px; vertical-align: -1px; }
.st .r { text-align: right; }
.st tbody th, .st td { padding: 2px 5px; border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st tbody th { text-align: left; font-weight: 400; font-family: var(--num); font-size: 14px; line-height: 17px; }
.st tbody th small { display: block; font: 12px/15px var(--text); color: var(--muted); }
.st tr.cur th { font-weight: 600; box-shadow: inset 3px 0 var(--act); }
.st td b { font-family: var(--num); font-size: 14px; font-weight: 500; line-height: 17px; }
.st td[data-cat] b { font-size: 13px; }
.st td em { font-style: normal; font-family: var(--num); font-size: 11px; color: var(--muted); }
.st td small { display: block; font-family: var(--num); font-size: 12px; line-height: 15px; min-height: 15px; }
.st .up { color: var(--loss); }
.st .down { color: var(--gain); }
.st .m { color: var(--muted); }
.sbar { display: flex; height: 18px; overflow: hidden; background: var(--hover); }
.sbar span { flex: none; height: 100%; font: 11px/18px var(--num); text-align: center; overflow: hidden; white-space: nowrap; }
.sbar em { font-style: normal; font-size: 12px; color: var(--muted); line-height: 18px; padding-left: 6px; }

/* 当天明细 */
.day { border-top: 1px solid var(--line); display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; }
.day h3 { font-size: 13px; padding: 8px 18px 6px; display: flex; gap: 12px; align-items: baseline; white-space: nowrap; }
.day h3 span { color: var(--muted); font-weight: 400; }
.day h3 .tot { margin-left: auto; }
.day h3 .tot b { font-family: var(--num); font-size: 14px; color: var(--ink); font-weight: 600; }
.day h3 .tot b.gain { color: var(--gain); }
.day h3 .tot b.loss { color: var(--loss); }
.scroll { overflow-y: auto; min-height: 0; }
.waitc { color: var(--wait); font-weight: 600; }
.spr { color: var(--muted); font-weight: 600; }
table.detail { width: 100%; border-collapse: collapse; table-layout: fixed; }
.detail .c-sw { width: 40px; } .detail .c-cat { width: 74px; } .detail .c-name { width: 24%; }
.detail .c-orig { width: 130px; } .detail .c-amt { width: 112px; } .detail .c-who { width: 66px; }
.detail tr { border-bottom: 1px solid var(--line); }
.detail td { padding: 4px 8px; height: 28px; line-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detail td:first-child { text-overflow: clip; }
.detail td:first-child { padding-left: 18px; }
.detail td.r { text-align: right; font-family: var(--num); font-size: 14px; }
.detail td.m { color: var(--muted); }
.detail td.who { text-align: right; padding-right: 18px; }
.detail .sw { display: inline-block; width: 9px; height: 9px; }
.detail tr.wait td { background: var(--wait-bg); }
.detail tr.wait td:first-child { box-shadow: inset 3px 0 var(--wait); }
.detail tr.wait td.amt { color: var(--muted); }
.empty { padding: 26px 18px; color: var(--muted); font-size: 14px; }
/* 明细一行：点一下 / ↑ ↓ 选中后 Enter 修改（T-09） */
.detail tr[data-id] { cursor: pointer; }
.detail tr[data-id]:hover td { background: var(--hover); }
.detail tr.sel td, .detail tr.editing td { background: var(--hover); }
.detail tr.sel td:first-child, .detail tr.editing td:first-child { box-shadow: inset 3px 0 var(--act); }
.detail tr.editing td { color: var(--ink); }

/* ---------- 记一笔面板 ---------- */
.panel { background: var(--sheet); padding: 14px 16px; display: flex; flex-direction: column; gap: 9px; min-height: 0; overflow: hidden; }
.panel[hidden] { display: none !important; }
.panel h2 { font-size: 14px; display: flex; justify-content: space-between; }
.panel h2 kbd { font: 12px var(--num); color: var(--muted); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--ink); }
.seg button { background: none; border: 0; padding: 5px; cursor: pointer; }
.seg button.on { background: var(--ink); color: var(--sheet); }
.seg.sm button { padding: 4px 5px; }
.pbody { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 0; flex: 0 1 auto; margin: 0 -4px; padding: 2px 4px; }
.fld { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.lab { font-size: 12px; color: var(--muted); }
.picks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.picks button {
  border: 1px solid var(--line); background: var(--sheet); padding: 4px 6px; display: flex; align-items: center;
  gap: 5px; cursor: pointer; text-align: left; min-width: 0;
}
.picks button:hover { border-color: var(--muted); }
.picks button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picks button i { flex: none; width: 9px; height: 9px; }
.picks.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.picks button small { font-size: 11px; color: var(--muted); white-space: nowrap; }
.picks button kbd { margin-left: auto; font: 12px var(--num); color: var(--muted); }
.picks button.on { background: var(--ink); border-color: var(--ink); color: var(--sheet); }
.picks button.on kbd, .picks button.on small { color: var(--sheet); opacity: .7; }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; align-items: end; }
.row2.dn { grid-template-columns: 136px minmax(0, 1fr); }
input[data-k="amount"], input[data-k="points"], input[data-k="rate"], input[data-k="mult"], input[data-k="days"] { font-family: var(--num); font-size: 15px; }
.calc { font-family: var(--num); font-size: 14px; color: var(--muted); min-height: 20px; line-height: 1.4; }
.calc b { color: var(--ink); font-weight: 600; }
.row2 .calc { padding-bottom: 5px; }
.pverr { color: var(--loss); font: 12px var(--text); }
.fe { color: var(--loss); font-size: 12px; margin-top: -4px; }
.fe:empty { display: none; }
.need { font-size: 12px; background: var(--wait-bg); border-left: 3px solid var(--wait); padding: 5px 8px; }
.lt-wrap { overflow: auto; max-height: 232px; }
table.lt { width: 100%; border-collapse: collapse; }
.lt th, .lt td { padding: 3px 4px; border-bottom: 1px solid var(--line); text-align: left; font-weight: 400; }
.lt thead th { font-size: 12px; color: var(--muted); vertical-align: bottom; }
.lt thead th small { display: block; font: 12px var(--num); }
.lt tbody th { white-space: nowrap; max-width: 70px; overflow: hidden; text-overflow: ellipsis; }
.lt td input { padding: 3px 5px; font-family: var(--num); font-size: 14px; text-align: right; }
.lt .r { text-align: right; font-family: var(--num); font-size: 14px; white-space: nowrap; }
.lt tfoot th, .lt tfoot td { font-weight: 600; border-bottom: 0; }
.lnk { background: none; border: 0; color: var(--act); cursor: pointer; text-align: left; padding: 0; font-size: 12px; align-self: flex-start; }
.amts { display: flex; flex-direction: column; gap: 4px; }
label.inl { flex-direction: row; align-items: center; gap: 6px; color: var(--ink); font-size: 13px; }
label.inl span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
label.inl input { width: 100px; text-align: right; font-family: var(--num); }
.foot { display: flex; flex-direction: column; gap: 6px; margin-top: auto; padding-top: 4px; }
.foot .err { min-height: 0; font-size: 12px; }
.foot .err:empty { display: none; }
.ask { background: var(--wait-bg); border-left: 3px solid var(--wait); padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.okmsg { font-size: 12px; color: var(--gain); min-height: 17px; }

/* 修改状态（T-09）：顶上一道钴蓝线，标题写「修改 10-14 代理费」 */
.panel.editing { box-shadow: inset 0 3px var(--act); }
.emeta { font-size: 12px; color: var(--muted); margin-top: -6px; }
.ebtns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.ebtns .sec { padding: 4px 6px; justify-content: space-between; white-space: nowrap; }
.ebtns .sec kbd { font: 12px var(--num); }
.ebtns .del { color: var(--loss); }
.ebtns .sec:disabled { color: var(--muted); cursor: default; }
.clash { border-left-color: var(--loss); }
.clash .btns { grid-template-columns: minmax(0, 1fr); }
.clash .btns .sec { justify-content: space-between; padding: 6px 12px; }
.clash ul { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.clash li { font-family: var(--num); font-size: 14px; }
.clash li span { font: 12px var(--text); color: var(--muted); margin-right: 4px; }

/* 删除后页面底部的撤销条，8 秒后消失 */
.undo {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 35;
  background: var(--ink); color: var(--sheet); padding: 7px 8px 7px 14px;
  display: flex; align-items: center; gap: 16px; white-space: nowrap;
}
.undo button {
  background: none; color: var(--sheet); border: 1px solid var(--muted); padding: 3px 9px; cursor: pointer;
  display: inline-flex; gap: 8px; align-items: baseline;
}
.undo button kbd { opacity: .7; }
.undo .uerr { color: var(--wait-bg); }

/* 修改记录（history.js）：浮层和嵌在页面里共用 */
.hsheet { width: 860px; max-width: calc(100vw - 40px); height: min(560px, calc(100vh - 110px)); display: flex; flex-direction: column; }
.hsheet .hbody { min-height: 0; flex: 1; display: flex; flex-direction: column; }
.histv { min-height: 0; display: flex; flex-direction: column; }
.hscroll { overflow-y: auto; min-height: 0; flex: 1; }
table.hist { width: 100%; border-collapse: collapse; table-layout: fixed; }
.hist th { position: sticky; top: 0; background: var(--sheet); text-align: left; font-weight: 400; font-size: 12px; color: var(--muted); padding: 4px 8px; border-bottom: 1px solid var(--line); }
.hist td { padding: 5px 8px; border-bottom: 1px solid var(--line); vertical-align: top; overflow: hidden; text-overflow: ellipsis; }
.hist .c-at { width: 92px; font-family: var(--num); font-size: 14px; white-space: nowrap; }
.hist .c-who { width: 64px; white-space: nowrap; }
.hist .c-act { width: 92px; white-space: nowrap; }
.hist .c-obj { width: 150px; white-space: nowrap; }
.hist td.ch div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--num); font-size: 14px; }
.hist td.ch p { font-family: var(--num); font-size: 14px; line-height: 1.5; }
.hist td.ch p .hl { margin-left: 2px; }
.hist td.ch .hl { font: 12px var(--text); color: var(--muted); }
.hist .none { color: var(--muted); }
.hist tr.a-delete td.c-act { color: var(--loss); }
.hist tr.a-restore td.c-act, .hist tr.a-create td.c-act { color: var(--gain); }
.hist tbody tr { cursor: default; }
.hist tbody tr.sel td { background: var(--hover); }
.hist tbody tr.sel td:first-child { box-shadow: inset 3px 0 var(--act); }
.hfoot { padding: 8px; color: var(--muted); font-size: 12px; }

/* ---------- 快捷键表 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 40; background: rgba(22, 33, 44, .28);
  display: grid; justify-items: center; align-items: start; padding-top: 72px;
}
.sheet { background: var(--sheet); border: 1px solid var(--line); padding: 14px 18px 16px; min-width: 480px; }
.sheet h2 { font-size: 14px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.help table { border-collapse: collapse; }
.help th { text-align: left; font-weight: 600; white-space: nowrap; padding: 3px 18px 3px 0; font-family: var(--num); font-size: 14px; }
.help td { padding: 3px 0; }
.help td.grp { color: var(--muted); font-size: 12px; padding-top: 10px; }

/* ---------- 窄窗口：记一笔收成按 N 弹出的浮层 ---------- */
@media (max-width: 1099px) {
  .shell.with-panel { grid-template-columns: minmax(0, 1fr); }
  .panel {
    display: none; position: fixed; top: 44px; right: 16px; bottom: 14px; width: 300px; z-index: 25;
    box-shadow: 0 0 0 1px var(--line), -10px 0 28px rgba(22, 33, 44, .12);
  }
  body.panel-open .panel { display: flex; }
  .legend { display: none; }
  /* 顶栏挤不下：去掉按钮上的键位提示（? 快捷键表里都有），间距收紧 */
  .top { gap: 12px; }
  .top nav kbd, .per kbd, .vw kbd { display: none; }
}

/* 待确认（T-14，F-061）：标题旁「N 笔待确认 · 全部确认 ⇧Y」；待确认行下面一行写来源钥匙和接口提醒；全部确认前在明细上面问一次 */
.day { position: relative; }
.day h3 .cfall {
  background: var(--wait-bg); border: 0; border-left: 3px solid var(--wait); color: var(--wait); font-weight: 600;
  padding: 1px 8px; cursor: pointer; display: inline-flex; gap: 6px; align-items: baseline;
}
.day h3 .cfall:hover { color: var(--ink); }
.day h3 .cfall kbd { font: 12px var(--num); color: var(--muted); }
.detail tr.wnote { border-bottom: 1px solid var(--line); }
.detail tr.wnote td { background: var(--wait-bg); height: 22px; line-height: 16px; padding-top: 0; padding-bottom: 4px; font-size: 12px; color: var(--muted); }
.detail tr.wnote td:first-child { box-shadow: inset 3px 0 var(--wait); }
.detail tr.wait { border-bottom: 0; }
.detail tr.wnote .ww { color: var(--wait); font-weight: 600; margin-right: 14px; }
.detail tr.wnote .src { margin-right: 14px; }
.detail tr.wnote .kh { display: none; margin-right: 14px; color: var(--ink); }
.detail tr.wait.sel + tr.wnote .kh { display: inline; }   /* 选中待确认的那笔时才写键位 */
.cfask {
  position: absolute; top: 32px; left: 18px; right: 18px; z-index: 20; background: var(--sheet);
  border: 1px solid var(--ink); border-left: 3px solid var(--wait); padding: 10px 12px;
  display: grid; grid-template-columns: minmax(0, 1fr) 160px auto; gap: 10px; align-items: center;
}
.cfask p { font-size: 14px; }
.cfask p b { font-family: var(--num); }
.cfask .go { padding: 6px 12px; }
.cfask .sec { padding: 5px 12px; }
