/* 账本 · 价签
   一排货架：顶部整块货架黄，金额像标价（整数很大，角分缩小挂在右上），
   分类是撕掉一角的不干胶标签，每天的小计是一张黄色货架签。
   全部直角、黑色粗线，没有阴影和圆角卡片；红色只给角分和要处理的状态。 */
:root {
  --yellow: #ffdd00;
  --yellow-deep: #f2cf00;
  --yellow-wash: #fff8cc;
  --red: #e4002b;
  --red-deep: #b80023;
  --ink: #141414;
  --paper: #ffffff;
  --soft: #f5f4ef;          /* 展开区、未选中的标签底 */
  --rule: #dddcd6;
  --mute: #5e6166;          /* 白底上 6.3:1 */
  --green: #0a7d3b;
  --num: "DIN Alternate", "Bahnschrift", "DIN Condensed", "Roboto Condensed", "Arial Narrow", sans-serif;
  --hei: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  --row: 46px;
  --gutter: 20px;
  --snap: cubic-bezier(.16, 1, .3, 1);      /* 贴标签、盖章的那一下：快进、稳稳落定，不回弹 */
  --bar-h: 46px;            /* 冻结的筛选条高度，脚本写入 */
  --cat-h: 50px;            /* 冻结的分类标签行高度，脚本写入 */
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--ink) transparent; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 14px/1.4 var(--num); font-family: "DIN Alternate", "Bahnschrift", "DIN Condensed", -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif; font-variant-numeric: tabular-nums; }
::selection { background: var(--yellow); color: var(--ink); }
button, input, select { font: inherit; color: inherit; }
input, select { caret-color: var(--red); }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.masthead :focus-visible { outline-color: var(--ink); }
.ico { width: 14px; height: 14px; flex: none; }
[hidden] { display: none !important; }

/* 标价：整数大，角分小、挂在右上 */
.amt { font-family: var(--num); font-variant-numeric: tabular-nums; display: inline-flex; align-items: flex-start; letter-spacing: .01em; }
.amt .dc { font-size: .55em; margin: .1em 0 0 1px; color: var(--red); }

/* ---------- 货架黄的顶部 ---------- */
.masthead { background: var(--yellow); }
.top { display: flex; align-items: center; gap: 16px; padding: 12px var(--gutter) 0; flex-wrap: wrap; }
h1 { margin: 0; font-size: 20px; font-weight: 900; letter-spacing: .12em; }
.months { display: flex; gap: 4px; }
.months button { border: 0; background: transparent; padding: 5px 12px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 30px; }
.months button:hover { background: var(--yellow-deep); }
.months button[aria-current="true"] { background: var(--ink); color: var(--yellow); }
.count { font-family: var(--num); min-width: 20px; padding: 0 5px; background: var(--red); color: #fff; font-size: 13px; font-weight: 700; line-height: 18px; text-align: center; }
.saved { position: fixed; right: var(--gutter); bottom: 18px; z-index: 30; display: flex; align-items: center; gap: 8px; max-width: min(420px, calc(100vw - 2 * var(--gutter)));
  background: var(--ink); color: var(--yellow); font-weight: 700; padding: 9px 14px 9px 24px; clip-path: polygon(11px 0, 100% 0, 100% 100%, 11px 100%, 0 50%); }
.saved.is-bad { background: var(--red); color: #fff; }
.saved button { border: 0; background: transparent; color: inherit; cursor: pointer; padding: 4px; display: grid; place-items: center; margin-right: -6px; }
.saved button:hover { background: rgba(255, 255, 255, .25); }
.top-actions { margin-left: auto; display: flex; gap: 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border: 2px solid var(--ink); background: transparent; cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap; font-weight: 700; transition: transform .08s; }
.btn:hover { background: var(--ink); color: var(--paper); }
.masthead .btn:hover { color: var(--yellow); }
.btn:active { transform: translateY(1px); }
.btn:disabled { border-color: var(--rule); color: var(--mute); background: var(--soft); cursor: not-allowed; transform: none; }
.btn-ink { background: var(--ink); color: var(--yellow); }
.btn-ink:hover, .masthead .btn-ink:hover { background: #000; color: #fff; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }

.overview { display: grid; grid-template-columns: auto 1fr; gap: 2px 28px; align-items: end; padding: 6px var(--gutter) 16px; }
.ov-total { display: grid; }
.ov-total .k { font-weight: 800; }
.ov-price { font-size: 72px; line-height: .95; font-weight: 800; display: flex; align-items: flex-start; }
.ov-price .yen { font-family: var(--num); font-size: 28px; margin: 8px 4px 0 0; }
.ov-total .sub { font-weight: 600; margin-top: 6px; }
/* 待处理：一张红色的箭头签 */
.ov-todo { justify-self: end; border: 0; background: var(--red); color: #fff; font-weight: 700; cursor: pointer; padding: 9px 14px 9px 24px; clip-path: polygon(11px 0, 100% 0, 100% 100%, 11px 100%, 0 50%); display: inline-flex; align-items: baseline; gap: 12px; }
.ov-todo:hover { background: var(--red-deep); }
.ov-todo b { font-family: var(--num); font-size: 22px; line-height: 1; margin-right: 3px; }
.ov-todo.is-done { background: var(--ink); color: var(--yellow); cursor: default; align-items: center; }
.dist-bar { grid-column: 1 / -1; display: flex; height: 12px; margin-top: 10px; border: 2px solid var(--ink); background: var(--paper); }
.dist-bar i { display: block; background: var(--c); min-width: 2px; cursor: pointer; transition: flex-grow .35s cubic-bezier(.3, 0, .2, 1), opacity .12s; }
.dist-bar.has-pick i:not(.is-pick) { opacity: .28; }

/* ---------- 分类标签行：往下滑时冻结在顶部 ---------- */
.catwrap { position: sticky; top: 0; z-index: 12; background: var(--paper); border-bottom: 3px solid var(--ink); display: flex; }
.catbar { flex: 1; min-width: 0; display: flex; gap: 4px; overflow-x: auto; padding: 9px var(--gutter); scrollbar-width: none; }
.catbar::-webkit-scrollbar { display: none; }
.catbar button { flex: none; display: inline-flex; align-items: center; gap: 7px; height: 32px; border: 0; background: transparent; padding: 0 9px 0 5px; cursor: pointer; white-space: nowrap; font-weight: 700; }
.catbar button:hover { background: var(--soft); }
.catbar button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.catbar button.all { padding: 0 11px; }
.catbar b { font-size: 15px; font-weight: 600; color: var(--mute); }
.catbar button[aria-pressed="true"] b { color: var(--yellow); }
.cat-step { flex: none; width: 34px; border: 0; background: var(--ink); color: var(--yellow); cursor: pointer; display: grid; place-items: center; }
.cat-step:hover { background: #000; }
.cat-step[data-step="-1"] .ico { transform: rotate(180deg); }

/* ---------- 筛选和搜索 ---------- */
.toolbar { position: sticky; top: var(--cat-h); z-index: 10; background: var(--paper); padding: 0 var(--gutter); }
.tools { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 8px 0; }
.tabs { display: flex; gap: 16px; }
.tabs button { border: 0; background: transparent; padding: 5px 0; cursor: pointer; color: var(--mute); font-weight: 700; white-space: nowrap; box-shadow: inset 0 -3px 0 transparent; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); box-shadow: inset 0 -3px 0 var(--yellow); }
.tabs .n { font-family: var(--num); margin-left: 5px; font-weight: 600; }
.tabs button.has-todo .n { color: var(--red); }
.search { margin-left: auto; display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border: 2px solid var(--ink); color: var(--mute); width: min(240px, 100%); background: var(--paper); }
.search:focus-within { background: var(--yellow-wash); }
.search input { border: 0; outline: 0; background: transparent; width: 100%; color: var(--ink); font-weight: 600; }
.search input::placeholder { color: var(--mute); font-weight: 400; }
.notice { margin: 0 0 8px; padding: 7px 12px; background: var(--yellow-wash); border-left: 0; font-weight: 600; box-shadow: inset 0 0 0 2px var(--ink); }
.bulk { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding: 7px 12px; background: var(--ink); color: #fff; flex-wrap: wrap; }
.bulk strong { color: var(--yellow); margin-right: 6px; font-weight: 800; }
.bulk .btn, .bulk select { height: 28px; border: 2px solid #fff; background: transparent; color: #fff; padding: 0 10px; font-size: 13px; font-weight: 700; }
.bulk .btn:hover, .bulk select:hover { background: var(--yellow); border-color: var(--yellow); color: var(--ink); }
.bulk select { max-width: 150px; }
.bulk select option, .bulk select optgroup { color: var(--ink); background: #fff; }

/* ---------- 货架：记录 ---------- */
main { padding: 0 var(--gutter) 72px; }
.thead, .tr { display: grid; align-items: center; column-gap: 12px; grid-template-columns: 22px 46px 108px 70px minmax(140px, 1fr) 118px 82px minmax(120px, .9fr) 66px; }
.thead { position: sticky; top: calc(var(--cat-h) + var(--bar-h)); z-index: 5; background: var(--paper); color: var(--mute); font-size: 12px; font-weight: 700; height: 28px; }
.thead .c-amt { text-align: right; font-size: 12px; font-weight: 700; line-height: inherit; display: block; }
.thead input { margin: 0; }

.day { display: flex; align-items: center; gap: 10px; padding: 14px 0 8px; background: var(--paper); border-bottom: 3px solid var(--ink); position: sticky; top: calc(var(--cat-h) + var(--bar-h) + 28px); z-index: 3; }
.day b { font-weight: 900; font-size: 18px; }
.day .wk { font-weight: 700; color: var(--mute); }
/* 每天的小计：一张黄色货架签 */
.day .sum { margin-left: auto; background: var(--yellow); padding: 3px 12px 3px 22px; font-weight: 700; font-size: 12px; clip-path: polygon(10px 0, 100% 0, 100% 100%, 10px 100%, 0 50%); display: flex; align-items: center; gap: 8px; }
.day .sum .amt { font-size: 20px; font-weight: 800; }
.day .sum .amt .dc, .ov-todo .amt .dc { color: inherit; }

.tr { min-height: var(--row); border-bottom: 1px solid var(--rule); background: var(--paper); }
.tr:hover { background: #fbfaf6; }
.tr.is-todo { background: var(--yellow-wash); }
.tr.is-hold { background: #fff0f1; }
.tr.is-open { background: var(--soft); border-bottom-color: transparent; }
.tr.is-selected, .tr.is-selected:hover { background: #fff3a6; }
.tr.is-skip { color: var(--mute); }
.tr.is-skip .c-amt .amt { text-decoration: line-through; text-decoration-thickness: 2px; font-weight: 500; }
.tr.is-skip .c-amt .dc { color: inherit; }
.tr.is-skip .sticker { background: var(--mute); }
.td { min-width: 0; display: flex; align-items: center; }

.c-sel input, .thead input { appearance: none; -webkit-appearance: none; width: 16px; height: 16px; border: 2px solid var(--ink); background: var(--paper); cursor: pointer; display: grid; place-items: center; margin: 0; }
.c-sel input:checked, .thead input:checked { background: var(--ink); }
.c-sel input:checked::after, .thead input:checked::after { content: ""; width: 8px; height: 4px; border: solid var(--yellow); border-width: 0 0 2px 2px; transform: translateY(-1px) rotate(-45deg); }
.thead input:indeterminate::after { content: ""; width: 8px; height: 2px; background: var(--ink); }
.c-sel input:disabled { border-color: var(--rule); cursor: default; }
.c-time { font-family: var(--num); color: var(--mute); font-size: 15px; gap: 6px; white-space: nowrap; }
.c-time .d { color: var(--ink); font-weight: 600; }
.sheet.is-flat .thead, .sheet.is-flat .tr:not(.ro) { grid-template-columns: 22px 92px 108px 70px minmax(140px, 1fr) 118px 82px minmax(120px, .9fr) 66px; }

/* 分类：撕掉一角的不干胶标签；真正的下拉框透明地盖在上面 */
.pick { position: relative; align-self: stretch; }
.pick select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.pick select:disabled { cursor: default; }
.sticker { display: inline-block; max-width: 100%; background: var(--c, var(--ink)); color: #fff; font-weight: 700; font-size: 12px; line-height: 1; padding: 6px 12px 6px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 0 100%); }
.sticker.is-unset { background: var(--paper); color: var(--red); box-shadow: inset 0 0 0 2px var(--red); clip-path: none; }
.sticker.is-plain { background: var(--soft); color: var(--mute); clip-path: none; box-shadow: inset 0 0 0 1px var(--rule); }
.pick:hover .sticker { transform: translateY(-1px); }
.pick:focus-within .sticker { outline: 3px solid var(--ink); outline-offset: 2px; }
.who { font-size: 13px; font-weight: 600; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-bottom: 2px solid transparent; }
.who.is-empty { opacity: 0; font-weight: 400; }
.tr:hover .who.is-empty, .pick:focus-within .who.is-empty { opacity: 1; }
.pick:hover .who, .pick:focus-within .who { color: var(--ink); border-bottom-color: var(--ink); }

.c-note input { width: 100%; height: 30px; border: 0; border-bottom: 2px solid transparent; background: transparent; padding: 0; font-weight: 600; text-overflow: ellipsis; }
.c-note input:hover { border-bottom-color: var(--rule); }
.c-note input:focus { outline: 0; border-bottom-color: var(--ink); background: var(--paper); }
.c-note input:disabled { color: var(--mute); border-bottom-color: transparent; }
.c-note input::placeholder { color: var(--mute); font-weight: 400; }

.c-amt { justify-content: flex-end; font-size: 26px; font-weight: 800; line-height: 1; }
.tr.is-in .c-amt .i, .tr.is-in .c-amt .sign { color: var(--green); }
.c-amt .sign { font-family: var(--num); margin-right: 1px; }

.chip { display: inline-block; padding: 3px 8px; font-size: 12px; font-weight: 800; white-space: nowrap; line-height: 1.2; }
.chip.is-todo, .chip.is-hold { padding: 4px 8px 4px 14px; clip-path: polygon(7px 0, 100% 0, 100% 100%, 7px 100%, 0 50%); }
.chip.is-todo { background: var(--red); color: #fff; }
.chip.is-hold { background: var(--ink); color: var(--yellow); }
.chip.is-split { box-shadow: inset 0 0 0 2px var(--ink); }
.chip.is-edited { background: var(--yellow); }
.chip.is-skip { color: var(--mute); box-shadow: inset 0 0 0 1px var(--mute); font-weight: 600; }

.c-desc { border: 0; background: transparent; text-align: left; cursor: pointer; gap: 6px; color: var(--mute); font-size: 12px; width: 100%; height: 100%; padding: 0; }
.c-desc:hover { color: var(--ink); }
.c-desc.is-why { color: var(--ink); font-size: 13px; font-weight: 600; }
.c-desc .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.c-desc .ico { transition: transform .12s; }
.tr.is-open .c-desc .ico { transform: rotate(90deg); }
.c-acts { justify-content: flex-end; }

/* 贴标签、撕标签的那一下 */
@media (prefers-reduced-motion: no-preference) {
  .tr.just-saved .sticker, .tr.just-saved .chip { animation: slap .22s var(--snap); }
  @keyframes slap { from { transform: scale(1.35) rotate(-7deg); } }
  .tr.just-saved .c-amt .amt { animation: bump .22s var(--snap); }
  @keyframes bump { from { transform: translateY(-4px); } }
  .is-tearing { animation: tear .18s cubic-bezier(.5, 0, .9, .4) forwards; transform-origin: left center; }
  .btn.is-tearing { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 0 50%); }   /* 给按钮一个五个点的起始形状，撕的时候才是连续地抹掉 */
  @keyframes tear { to { clip-path: polygon(100% 0, 100% 0, 100% 100%, 100% 100%, 100% 50%); transform: rotate(9deg) translate(6px, -3px); } }
  .detail.just-opened { animation: drop .16s cubic-bezier(.3, 0, .2, 1); }
  @keyframes drop { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }
  .bulk { animation: drop .14s cubic-bezier(.3, 0, .2, 1); }
}

.sum-row { display: none; }

/* ---------- 展开的详情 ---------- */
.detail { background: var(--soft); border-bottom: 3px solid var(--ink); padding: 4px 16px 16px 34px; display: grid; gap: 12px; }
.detail .why { margin: 0; font-weight: 700; max-width: 76ch; display: flex; align-items: flex-start; gap: 8px; }
.detail .why .ico { width: 18px; height: 18px; padding: 2px; background: var(--red); color: #fff; margin-top: 1px; }
.detail.is-skip .why .ico { display: none; }
.facts { display: grid; grid-template-columns: 5.5em minmax(0, 1fr); gap: 5px 12px; margin: 0; max-width: 96ch; font-size: 13px; }
.facts dt { color: var(--mute); }
.facts dd { margin: 0; word-break: break-all; }
.detail-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.pair { background: var(--paper); max-width: 720px; border: 2px solid var(--ink); font-size: 13px; }
.pair div { display: grid; grid-template-columns: 24px 44px minmax(0, 1fr) auto; gap: 10px; padding: 7px 12px; border-bottom: 1px solid var(--rule); align-items: center; }
.pair div:last-child { border-bottom: 0; border-top: 2px solid var(--ink); font-weight: 800; }
.pair .k { background: var(--ink); color: #fff; font-weight: 800; text-align: center; line-height: 24px; }
.pair .k.is-in { background: var(--green); }
.pair .d { color: var(--mute); font-variant-numeric: tabular-nums; }
.pair .x { overflow-wrap: anywhere; }
.pair .a { font-size: 20px; font-weight: 800; display: flex; justify-content: flex-end; }
.kids { background: var(--paper); max-width: 720px; border: 2px solid var(--ink); }
.kids div { display: grid; grid-template-columns: 96px 130px 80px 1fr; gap: 12px; padding: 7px 12px; border-bottom: 1px solid var(--rule); align-items: center; }
.kids div:last-child { border-bottom: 0; }
.kids .a { justify-content: flex-end; font-size: 20px; font-weight: 800; display: flex; }
.kids .none { color: var(--mute); }

/* ---------- 拆分 / 补录 的行内表单 ---------- */
.form { background: var(--paper); border: 3px solid var(--ink); padding: 14px; max-width: 880px; display: grid; gap: 10px; }
.form p { margin: 0; color: var(--mute); max-width: 70ch; }
.form .line { display: grid; grid-template-columns: 110px 150px 124px minmax(0, 1fr) 30px; gap: 6px; }
.form.is-add .line { grid-template-columns: 138px 110px 98px 150px 124px minmax(0, 1fr); }
.form input, .form select { height: 34px; border: 2px solid var(--ink); border-radius: 0; background: var(--paper); padding: 0 9px; min-width: 0; width: 100%; font-weight: 600; }
.form input:focus, .form select:focus { outline: 0; background: var(--yellow-wash); }
.form input[name="amount"] { text-align: right; font-family: var(--num); font-size: 18px; font-weight: 700; }
.form .x { border: 0; background: transparent; color: var(--mute); cursor: pointer; display: grid; place-items: center; }
.form .x:hover { background: var(--ink); color: #fff; }
.form .foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.form .left { margin-right: auto; font-weight: 700; color: var(--green); }
.form .left.is-off { color: var(--red); }
.add-wrap { padding: 16px 0 18px; border-bottom: 3px solid var(--ink); }

/* ---------- 没进台账的（只读） ---------- */
.ro-note { margin: 0; padding: 14px 0; color: var(--mute); border-bottom: 3px solid var(--ink); max-width: none; }
.thead.ro, .tr.ro { grid-template-columns: 104px 118px 100px minmax(200px, 2fr) minmax(180px, 1.4fr); }
.thead.ro { top: calc(var(--cat-h) + var(--bar-h)); }
.tr.ro { font-size: 13px; }
.tr.ro .td { color: var(--mute); }
.tr.ro .c-amt { color: var(--ink); font-size: 20px; }
.tr.ro .wrap { white-space: normal; word-break: break-all; padding: 8px 0; align-items: flex-start; }

/* ---------- 空 / 加载 / 出错 ---------- */
.empty { margin: 0; padding: 48px 0; color: var(--mute); max-width: 60ch; font-size: 15px; line-height: 1.7; }
.empty code { font-family: ui-monospace, Menlo, monospace; font-size: 13px; background: var(--soft); padding: 1px 6px; }
.done { display: grid; justify-items: start; gap: 10px; padding: 48px 0; }
.done b { font-size: 34px; font-weight: 900; line-height: 1.1; background: var(--yellow); padding: 6px 16px 6px 28px; clip-path: polygon(14px 0, 100% 0, 100% 100%, 14px 100%, 0 50%); }
.done span { color: var(--mute); font-size: 15px; }
.skel { height: var(--row); border-bottom: 1px solid var(--rule); display: flex; align-items: center; gap: 28px; }
.skel i { display: block; height: 12px; background: var(--soft); }
@media (prefers-reduced-motion: no-preference) {
  .skel i { animation: pulse 1s steps(2, jump-none) infinite alternate; }
  @keyframes pulse { from { opacity: .5; } to { opacity: 1; } }
}

/* ---------- 登录 ---------- */
body.login { display: grid; place-items: center; min-height: 100vh; background: var(--yellow); }
body.login form { display: grid; gap: 10px; width: min(340px, calc(100vw - 40px)); padding: 28px 24px; background: var(--paper); border: 3px solid var(--ink); }
body.login h1 { font-size: 34px; margin-bottom: 10px; }
body.login label { font-weight: 700; }
body.login input { height: 42px; border: 2px solid var(--ink); border-radius: 0; padding: 0 10px; font-size: 16px; }
body.login input:focus { outline: 0; background: var(--yellow-wash); }
body.login button { height: 44px; border: 0; background: var(--ink); color: var(--yellow); cursor: pointer; font-weight: 800; font-size: 16px; margin-top: 6px; }
body.login button:hover { background: #000; color: #fff; }
.login-error { margin: 0; color: var(--red); font-weight: 700; }

/* ---------- 中等宽度：收起来源列 ---------- */
@media (max-width: 1100px) {
  .thead, .tr { grid-template-columns: 22px 46px 104px 64px minmax(120px, 1fr) 112px 80px minmax(90px, .6fr) 62px; column-gap: 10px; }
  .sheet.is-flat .thead, .sheet.is-flat .tr:not(.ro) { grid-template-columns: 22px 88px 104px 64px minmax(120px, 1fr) 112px 80px minmax(90px, .6fr) 62px; }
}

/* ---------- 窄窗口（≤820）：顶部和工具条收紧 ---------- */
@media (max-width: 820px) {
  :root { --gutter: 14px; }
  .top { padding-top: 10px; gap: 8px 12px; }
  .top-actions .btn { height: 40px; }
  .months button { min-height: 40px; }
  .overview { grid-template-columns: 1fr; padding-bottom: 14px; }
  .ov-price { font-size: 56px; }
  .ov-price .yen { font-size: 24px; margin-top: 6px; }
  .ov-todo { justify-self: start; margin-top: 10px; }
  .catbar button { height: 40px; }
  .cat-step { width: 40px; }
  .toolbar { position: static; }
  .tabs { overflow-x: auto; scrollbar-width: none; max-width: 100%; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { padding: 10px 0; min-height: 40px; }
  .search { height: 40px; }
  main { padding-bottom: 48px; }
  .thead { display: none; }
  .day { top: var(--cat-h); margin: 0 calc(-1 * var(--gutter)); padding: 12px var(--gutter) 8px; }
}

/* ---------- 窄窗口里的桌面用法（561–820）：仍然一行一条、直接在行里改，只是去掉时间和来源文字 ---------- */
@media (min-width: 561px) and (max-width: 820px) {
  .thead, .tr { grid-template-columns: 20px 84px 46px minmax(100px, 1fr) 100px 54px 24px; column-gap: 8px; }
  .tr { min-height: 44px; }
  .tr .c-time { display: none; }
  .sheet.is-flat .thead, .sheet.is-flat .tr:not(.ro) { grid-template-columns: 20px 42px 84px 46px minmax(90px, 1fr) 100px 54px 24px; }
  .sheet.is-flat .tr .c-time { display: flex; }
  /* 细表头：留着“全选”和列名，冻结在分类行下面 */
  .thead { display: grid; top: var(--cat-h); }
  .thead > :nth-child(2), .thead > :nth-child(8) { display: none; }
  .sheet.is-flat .thead > :nth-child(2) { display: block; }
  .thead.ro { display: none; }
  .day { top: calc(var(--cat-h) + 28px); }
  .sheet.is-flat .tr .c-time .h { display: none; }
  .c-amt { font-size: 22px; }
  .c-desc .txt { display: none; }
  .c-desc { justify-content: center; }
  /* 状态签和“确认 / 改写”按钮共用一格：要处理的行显示按钮，其余显示状态 */
  .tr.is-todo .c-status, .tr.is-hold .c-status { display: none; }
  .tr:not(.is-todo):not(.is-hold) .c-acts { display: none; }
  .tr > .td, .tr > .c-desc { grid-row: 1; }
  .c-acts, .c-status { grid-column: -3 / -2; justify-content: flex-end; }
  .tr > .c-desc { grid-column: -2 / -1; }
  .c-acts .btn { padding: 0 8px; height: 30px; }
  .tools { flex-wrap: nowrap; }
  .tabs { flex: 1; min-width: 0; }
  .search { width: 176px; flex: none; margin-left: 0; }
  .tr.ro { grid-template-columns: 96px 100px minmax(120px, 1.4fr) minmax(120px, 1fr); }
  .tr.ro .c-src { display: none; }
}

/* ---------- 手机（≤560）：每条记录两行，点开再改 ---------- */
@media (max-width: 560px) {
  .search { width: 100%; margin: 0; }

  .tr { display: block; min-height: 0; }
  .tr .td, .tr .c-desc { display: none; }
  .sum-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 12px; width: 100%; padding: 10px 0; border: 0; background: transparent; text-align: left; cursor: pointer; min-height: 60px; align-items: center; }
  .sum-row .s-note { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sum-row .s-amt { font-size: 28px; font-weight: 800; line-height: 1; justify-self: end; }
  .sum-row .s-meta { display: flex; gap: 8px; align-items: center; min-width: 0; overflow: hidden; }
  .sum-row .s-meta .t { font-family: var(--num); color: var(--mute); font-size: 14px; }
  .sum-row .s-state { justify-self: end; }
  .tr.is-skip .s-amt .amt { text-decoration: line-through; font-weight: 500; }
  .tr.is-skip .s-amt .dc { color: inherit; }
  .tr.is-in .s-amt .i { color: var(--green); }
  .tr.is-todo, .tr.is-hold, .tr.is-open, .tr.is-selected { margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter); }

  .tr.is-open .cell { display: grid; grid-template-columns: 3.5em minmax(0, 1fr); align-items: center; min-height: 46px; }
  .tr.is-hold.is-open .cell, .tr.is-split.is-open .cell { display: none; }
  .tr.is-open .cell::before { content: attr(data-label); color: var(--mute); font-size: 13px; font-weight: 600; }
  .tr.is-open .pick select { left: 3.5em; width: calc(100% - 3.5em); }
  .tr.is-open .cell .sticker, .tr.is-open .cell .who { justify-self: start; }
  .tr.is-open .who.is-empty { opacity: 1; }
  .tr.is-open .who { border-bottom-color: var(--rule); padding: 6px 0; }
  .tr.is-open .c-note input { height: 40px; border-bottom-color: var(--ink); }
  .detail { padding: 8px var(--gutter) 16px; margin: 0 calc(-1 * var(--gutter)); }
  .facts { grid-template-columns: 4.5em minmax(0, 1fr); }
  .detail-acts .btn { height: 40px; flex: 1 1 auto; }
  .kids div { grid-template-columns: 84px 1fr; gap: 2px 10px; }
  .kids div span:nth-child(n+3) { grid-column: 2; color: var(--mute); font-size: 13px; }

  .form .line, .form.is-add .line { grid-template-columns: 1fr 1fr; gap: 6px; padding-bottom: 10px; border-bottom: 1px dashed var(--rule); }
  .form .line input[name="note"] { grid-column: 1 / -1; }
  .form input, .form select { height: 42px; }
  .form .x { height: 42px; justify-self: end; width: 42px; }
  .form .foot .btn { height: 40px; }

  .thead.ro { display: none; }
  .tr.ro { display: grid; grid-template-columns: 1fr auto; padding: 10px 0; gap: 2px 12px; }
  .tr.ro .td { display: block; }
  .tr.ro .c-src { display: none; }
  .tr.ro .wrap { grid-column: 1 / -1; padding: 0; font-size: 12px; }
}
@media (max-width: 420px) {
  .ov-price { font-size: 48px; }
  h1 { font-size: 18px; }
  .top-actions { margin-left: 0; width: 100%; }
  .top-actions .btn { flex: 1; }
}
