:root {
  --bg: #f4f5f7; --card: #fff; --ink: #18202b; --muted: #6b7480; --line: #e3e6ea;
  --brand: #e2711d; --brand-ink: #fff; --in: #13804a; --out: #c2362b; --warn: #b7791f;
  --in-bg: #e7f5ed; --out-bg: #fbeceb; --warn-bg: #fdf3e1; --me: #fff2e6;
  --r: 12px; --nav: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11161c; --card: #1a2129; --ink: #e8ecf0; --muted: #98a2ad; --line: #2b343e;
    --in: #4cc483; --out: #f07167; --warn: #e5b04f; --in-bg: #16301f; --out-bg: #3a1d1b; --warn-bg: #3a2e16; --me: #3a2a1c; color-scheme: dark; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 18px 4px 8px; color: var(--muted); font-weight: 600; }
small { color: var(--muted); font-weight: 400; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.err { color: var(--out); }
.empty { color: var(--muted); text-align: center; padding: 24px 0; }
.in { color: var(--in); } .out { color: var(--out); } .warnc { color: var(--warn); }

input, select, textarea { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; min-width: 0; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
button { cursor: pointer; border: 0; background: none; }
.primary { background: var(--brand); color: var(--brand-ink); border-radius: 10px; padding: 9px 16px; font-weight: 600; }
.primary:disabled { opacity: .5; }
.primary.big { padding: 12px 20px; font-size: 16px; }
.ghost { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 9px 14px; }
.wide { width: 100%; margin-top: 10px; }
.link { color: var(--brand); padding: 4px 6px; }
.btnlink { display: inline-block; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; color: var(--ink); text-decoration: none; margin: 0 6px 6px 0; }

/* 登录 */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--card); border-radius: 16px; padding: 24px; width: min(360px, 100%); display: grid; gap: 14px; box-shadow: 0 6px 24px rgb(0 0 0 / .06); }
.login-card label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.brand { display: flex; gap: 10px; align-items: center; }
.brand small { display: block; }
.logo { width: 32px; height: 32px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; }

/* 框架 */
.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--card); border-bottom: 1px solid var(--line); }
.who { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
main { max-width: 760px; margin: 0 auto; padding: 12px 16px calc(32px + env(safe-area-inset-bottom)); }
.bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; justify-content: center; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.bottom button { flex: 1; max-width: 190px; height: var(--nav); display: grid; place-content: center; gap: 2px; font-size: 12px; color: var(--muted); }
.bottom button span { font-size: 20px; line-height: 1; }
.bottom button.on { color: var(--brand); font-weight: 600; }
.card { background: var(--card); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }

/* 库存 */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.kpi { background: var(--card); border-radius: var(--r); padding: 10px 8px; text-align: center; }
.kpi b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 12px; color: var(--muted); }
.kpi.warn { background: var(--out-bg); cursor: pointer; } .kpi.warn b { color: var(--out); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 12px 0 4px; scrollbar-width: none; }
.chips button { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; white-space: nowrap; }
.chips button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chips button.on small { color: inherit; opacity: .7; }
.tools { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.tools input[type=search] { flex: 1; }
.check { display: flex; gap: 4px; align-items: center; white-space: nowrap; font-size: 13px; color: var(--muted); }
.check input { width: auto; }
.group h3 small { margin-left: 4px; }
.item { width: 100%; display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: var(--r); padding: 8px 12px 8px 8px; margin-bottom: 6px; text-align: left; border: 1px solid transparent; }
.item img, .noimg { width: 52px; height: 52px; border-radius: 8px; object-fit: contain; background: #fff; flex: none; }
.noimg { display: grid; place-items: center; color: var(--muted); background: var(--bg); font-weight: 700; }
.meta { flex: 1; min-width: 0; display: grid; }
.meta b { font-size: 15px; overflow-wrap: anywhere; }
.meta span { font-size: 13px; color: var(--muted); }
.meta small { font-size: 12px; }
.qty { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 48px; text-align: right; }
.item.neg { border-color: var(--out); } .item.neg .qty { color: var(--out); }
.item.low { border-color: var(--warn); } .item.low .qty { color: var(--warn); }

/* 弹层 */
dialog { border: 0; border-radius: 16px; padding: 16px; width: min(560px, calc(100% - 24px)); max-height: 85dvh; background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgb(0 0 0 / .4); }
.phead { display: flex; gap: 12px; align-items: center; }
.phead img { width: 84px; height: 84px; object-fit: contain; background: #fff; border-radius: 10px; }
.phead h2 { margin: 0; } .phead p { margin: 2px 0; color: var(--muted); }
.line { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.line span { min-width: 0; overflow-wrap: anywhere; }
.line b { margin-left: auto; font-variant-numeric: tabular-nums; }
.warn-in { width: 76px; flex: none; padding: 5px 8px; }

/* 录入 */
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--card); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { padding: 8px; border-radius: 8px; color: var(--muted); }
.seg button.on { background: var(--ink); color: var(--bg); font-weight: 600; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.where { display: block; width: 100%; text-align: left; margin: 10px 0 8px; padding: 8px 12px; border-radius: 10px; background: var(--card); color: var(--muted); }
.where b { color: var(--ink); }
.where small { color: var(--brand); }
.where.miss { background: var(--warn-bg); }
.where-edit { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; background: var(--card); border-radius: 10px; padding: 10px; margin-bottom: 10px; }
.where-edit label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.code-btn { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px 6px 6px; }
.code-btn img, .code-btn .noimg { width: 44px; height: 44px; border-radius: 8px; object-fit: contain; background: #fff; flex: none; }
.code-btn .noimg { background: var(--bg); }
.code-btn div:last-child { display: grid; min-width: 0; }
.code-btn b { overflow-wrap: anywhere; }
.tried .code-btn.miss { border-color: var(--warn); background: var(--warn-bg); }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-size: 22px; line-height: 1; }
.stepper input { width: 80px; text-align: center; font-size: 20px; font-weight: 700; padding: 7px 4px; }
.stepper span { color: var(--muted); }
.tried .stepper.miss input { border-color: var(--warn); background: var(--warn-bg); }
.more-link { justify-self: start; font-size: 13px; color: var(--muted); padding: 2px 0; }
.more { display: grid; gap: 6px; }
.pick-list { display: grid; gap: 6px; margin-top: 10px; max-height: 60dvh; overflow-y: auto; }
.pick-item { display: flex; gap: 10px; align-items: center; text-align: left; padding: 6px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); }
.pick-item img, .pick-item .noimg { width: 48px; height: 48px; border-radius: 8px; object-fit: contain; background: #fff; flex: none; }
.pick-item div:last-child { display: grid; }

.chat-log { display: grid; gap: 10px; align-content: start; max-height: min(52dvh, 520px); min-height: 120px; overflow-y: auto; overscroll-behavior: contain; padding: 4px 2px 8px; }
.chat-empty { background: var(--card); border-radius: var(--r); padding: 14px; display: grid; gap: 8px; justify-items: start; }
.chat-empty p { margin: 0; color: var(--muted); }
.chip-btn { border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; text-align: left; }
.msg { max-width: 92%; border-radius: 14px; padding: 10px 12px; }
.msg p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.me { justify-self: end; background: var(--me); border-bottom-right-radius: 4px; }
.msg.me img { max-width: 220px; max-height: 260px; border-radius: 8px; display: block; margin-bottom: 6px; cursor: zoom-in; }
.msg.ai { justify-self: start; background: var(--card); border-bottom-left-radius: 4px; width: 92%; }
.msg .meta { display: block; margin-top: 6px; font-size: 11px; }
.msg .qs { margin: 8px 0 0; padding-left: 18px; color: var(--warn); font-size: 13px; }
.msg .done { color: var(--in); margin-top: 8px; }
.chat-tools { text-align: center; }
.drafts { display: grid; gap: 8px; margin-top: 10px; }
.draft { border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: grid; gap: 6px; background: var(--bg); }
.tried .draft.bad { border-color: var(--warn); }
.tried .draft select.miss { border-color: var(--warn); background: var(--warn-bg); }
.draft-top { display: flex; gap: 8px; align-items: center; }
.draft-top input { width: 90px; flex: none; }
.dir { flex: 1; display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.dir button { padding: 10px 22px; background: var(--card); font-size: 16px; font-weight: 600; }
.dir button.in.on { background: var(--in); color: #fff; }
.dir button.out.on { background: var(--out); color: #fff; }
.tried .dir.miss { border-color: var(--warn); }
.del { margin-left: auto; color: var(--muted); font-size: 18px; }
.pname { font-size: 12px; min-height: 1em; }
.confirm-bar { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.confirm-bar span { flex: 1; color: var(--muted); font-size: 13px; }

.composer { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 4px; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer-row textarea { resize: none; max-height: 140px; }
.composer .hint { margin-top: 4px; font-size: 11px; }
.icon-btn { flex: none; width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-size: 20px; cursor: pointer; }
.photo-preview { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.photo-preview img { height: 64px; border-radius: 8px; }
#mode-manual { padding-bottom: 20px; }
#mode-manual .draft { background: var(--card); margin-bottom: 8px; }

/* 流水 */
.mv { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 10px; padding: 8px 10px; margin-bottom: 5px; }
.mv.void { opacity: .45; } .mv.void b { text-decoration: line-through; }
.badge { flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.badge.in { background: var(--in-bg); color: var(--in); } .badge.out { background: var(--out-bg); color: var(--out); }
.mv-main { flex: 1; min-width: 0; display: grid; }
.mv-main b { overflow-wrap: anywhere; }
.mv-main small { font-size: 12px; overflow-wrap: anywhere; }
.ph { text-decoration: none; }

.toast { position: fixed; left: 50%; bottom: calc(var(--nav) + 90px); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; z-index: 20; max-width: calc(100% - 32px); }
.toast.bad { background: var(--out); color: #fff; }

@media (max-width: 420px) {
  .kpi b { font-size: 18px; }
  .kpi span { font-size: 11px; }
  .row3 { grid-template-columns: 1fr; }
}
@media (max-width: 420px) { .where-edit { grid-template-columns: 1fr 1fr; } .where-edit button { grid-column: span 2; } }
#sendBtn { flex: none; white-space: nowrap; padding: 10px 16px; }
.pin { -webkit-text-security: disc; text-security: disc; font-size: 22px; letter-spacing: 6px; text-align: center; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad button { height: 52px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); font-size: 22px; font-weight: 600; }
.keypad button.fn { font-size: 15px; color: var(--muted); font-weight: 400; }
.keypad button:active { background: var(--line); }

/* 单页布局 */
.chat-card { padding: 12px; border: 1px solid var(--line); box-shadow: 0 4px 18px rgb(0 0 0 / .05); }
.chat-head { display: flex; gap: 8px; align-items: center; }
.chat-head .where { margin: 0; flex: 1; min-width: 0; background: var(--bg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ghost.small { padding: 8px 12px; white-space: nowrap; flex: none; }
.ghost.small.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chat-card .where-edit { background: var(--bg); margin: 8px 0 0; }
.chat-card .msg.ai { background: var(--bg); }
.chat-card .draft { background: var(--card); }
.chat-empty { background: var(--bg); }
.manual-box { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 4px; }
.manual-box h3 { margin: 8px 2px; }
.manual-box .draft { margin-bottom: 8px; }
.sec-title { font-size: 18px; margin: 22px 2px 10px; }
#stockSec .chips { padding-top: 4px; }

.cd-line { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px 6px 6px; }
.cd-line img, .cd-line .noimg { width: 40px; height: 40px; border-radius: 8px; object-fit: contain; background: #fff; flex: none; }
.cd-main { flex: 1; min-width: 0; display: grid; }
.cd-main b { overflow-wrap: anywhere; }
.cd-main small { font-size: 12px; }
.cd-edit { color: var(--brand); font-size: 13px; flex: none; }
.drafts { gap: 6px; }
/* 聊天 / 手动填 */
#modeSeg { margin-bottom: 8px; background: var(--bg); }
#modeSeg button { padding: 10px; font-size: 16px; }
.chat-card > .where { margin: 0 0 8px; background: var(--bg); }
.manual { display: grid; gap: 10px; padding: 4px 0; }
.dir.big { flex: none; }
.dir.big button { padding: 14px; font-size: 18px; }
.manual .code-btn { padding: 8px 12px 8px 8px; }
.manual .code-btn img, .manual .code-btn .noimg { width: 56px; height: 56px; }
.m-row { display: flex; gap: 8px; align-items: center; }
.m-row input { width: 110px; flex: none; font-size: 22px; font-weight: 700; text-align: center; padding: 10px 6px; }
.m-row span { color: var(--muted); }
.m-row .primary { flex: 1; }
.m-done { display: grid; gap: 4px; }
.m-done-line { font-size: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.m-done-line.undone { color: var(--muted); text-decoration: line-through; }
/* 手动填：表格 */
.tbl-wrap { max-height: min(60dvh, 600px); overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl thead th { position: sticky; top: 0; z-index: 1; background: var(--card); padding: 8px 6px; text-align: left; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); }
.tbl th.in { color: var(--in); } .tbl th.out { color: var(--out); }
.tbl td { padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr.cat td { background: var(--bg); color: var(--muted); font-size: 12px; font-weight: 600; padding: 5px 8px; }
.tbl .num { text-align: center; width: 64px; font-variant-numeric: tabular-nums; }
.tbl td.num.out { color: var(--out); font-weight: 600; }
.tbl .tc { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tbl .tc img, .tbl .tc .noimg { width: 34px; height: 34px; border-radius: 6px; object-fit: contain; background: #fff; flex: none; }
.tbl .tc div { display: grid; min-width: 0; }
.tbl .tc b { font-size: 13px; overflow-wrap: anywhere; }
.tbl .tc small { font-size: 11px; line-height: 1.2; }
.tbl input { width: 58px; padding: 7px 4px; text-align: center; font-size: 16px; font-weight: 600; }
.tbl input.in.filled { border-color: var(--in); background: var(--in-bg); color: var(--in); }
.tbl input.out.filled { border-color: var(--out); background: var(--out-bg); color: var(--out); }
.t-bar { display: flex; align-items: center; gap: 10px; }
.t-bar span { flex: 1; color: var(--muted); font-size: 13px; }
.t-bar .primary:disabled { opacity: .4; }

/* ===== 宽屏（电脑）===== */
main { max-width: 1400px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); margin: 14px 0; }
.lower { display: grid; gap: 14px; }
.lower .card { padding: 12px; margin: 0; }
.sec-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.sec-head h2 { margin: 0 auto 0 2px; font-size: 18px; }
.sec-head input[type=search] { flex: 1 1 180px; width: auto; }
.sec-head select, .sec-head input[type=month] { width: auto; }
.tbl-wrap.tall { max-height: 70dvh; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--bg); }
.tbl td.neg { color: var(--out); font-weight: 700; background: var(--out-bg); }
.tbl td.low { color: var(--warn); font-weight: 700; background: var(--warn-bg); }
.tbl td.total { font-weight: 700; }
.tbl td.desc { color: var(--muted); font-size: 13px; }
.tbl td.code { font-weight: 600; overflow-wrap: anywhere; }
.tbl td.note, .tbl td.muted { color: var(--muted); font-size: 12px; }
.tbl .nowrap { white-space: nowrap; }
.tbl tr.void td { opacity: .45; }
.tbl tr.void td.code { text-decoration: line-through; }
.tbl .badge { width: 24px; height: 24px; font-size: 12px; }
.wide-only { display: none; }
@media (min-width: 900px) {
  .wide-only { display: table-cell; }
  .narrow-only { display: none !important; }
  .kpi b { font-size: 26px; }
  .chat-log { max-height: 42dvh; }
  .msg.ai { width: auto; max-width: 780px; min-width: 50%; }
  .msg.me { max-width: 60%; }
  .tbl { font-size: 14px; }
  .tbl .tc b { font-size: 14px; }
}
@media (min-width: 1150px) {
  .lower { grid-template-columns: 1.15fr 1fr; align-items: start; }
}

/* ===== 聊天卡片（顶部） ===== */
.chat-title { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.chat-title > b { font-size: 16px; flex: none; }
.chat-title .where { margin: 0; flex: 1; min-width: 0; background: var(--bg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-card .chat-log { max-height: 34dvh; min-height: 64px; }
.chat-empty { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px; }
.draft-row { display: grid; grid-template-columns: 90px 1fr 1fr; gap: 6px; }
.draft-row input, .draft-row select { padding: 8px; }

/* ===== Excel 一样的表 ===== */
.sheet-card { padding: 0; overflow: hidden; }
.sheet-tabs { display: flex; gap: 2px; padding: 8px 10px 0; background: var(--bg); border-bottom: 1px solid var(--line); }
.sheet-tabs button { padding: 8px 18px; border: 1px solid var(--line); border-bottom: 0; border-radius: 8px 8px 0 0; background: var(--bg); color: var(--muted); font-weight: 600; }
.sheet-tabs button.on { background: var(--card); color: var(--ink); position: relative; top: 1px; }
.sheet-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px; }
.sheet-tools input[type=search] { flex: 1 1 200px; width: auto; }
.sheet-tools input[type=month] { width: auto; }
.sheet-tools .btnlink { margin: 0; padding: 7px 12px; }
.sheet-sum { font-size: 14px; color: var(--muted); }
.sheet-sum b { color: var(--ink); }
.sheet-sum b.in { color: var(--in); } .sheet-sum b.out { color: var(--out); }
.sheet-card .hint { padding: 0 10px 10px; }
.grid-wrap { overflow: auto; max-height: 72dvh; border-top: 1px solid var(--line); }
.grid-wrap.short { max-height: 60dvh; }
.grid { border-collapse: separate; border-spacing: 0; font-size: 13px; font-variant-numeric: tabular-nums; }
.grid th, .grid td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0; height: 32px; white-space: nowrap; background: var(--card); }
.grid thead th { position: sticky; z-index: 2; background: #eef1f4; color: var(--ink); font-weight: 600; padding: 0 6px; text-align: center; }
.grid thead tr:first-child th { top: 0; height: 30px; }
.grid thead tr:nth-child(2) th { top: 31px; height: 26px; font-size: 12px; font-weight: 500; }
.grid th.io.in { color: var(--in); } .grid th.io.out { color: var(--out); }
.grid th.weekend { background: #e6e9ee; }
.grid th.today, .grid td.today { background: #fff4e0; }
.grid thead th.today { background: #ffe2b8; }
.grid .frz { position: sticky; z-index: 1; }
.grid thead .frz { z-index: 3; }
.grid .frz-last { box-shadow: 2px 0 0 #cfd5dc; }
.grid td.c-code { min-width: 190px; max-width: 220px; padding: 0 8px 0 4px; cursor: pointer; }
.grid td.c-code img { width: 26px; height: 26px; object-fit: contain; vertical-align: middle; margin-right: 6px; background: #fff; border-radius: 4px; }
.grid td.c-code b { font-weight: 600; }
.grid td.c-code:hover b { color: var(--brand); text-decoration: underline; }
.grid td.c-name { min-width: 150px; padding: 0 8px; color: var(--muted); }
.grid .c-n { min-width: 64px; padding: 0 8px; text-align: right; }
.grid th.c-n { text-align: center; white-space: normal; line-height: 1.2; }
.grid td.remain { font-weight: 700; background: #f6f8fa; }
.grid td.remain.neg { color: var(--out); background: var(--out-bg); }
.grid td.remain.low { color: var(--warn); background: var(--warn-bg); }
.grid td.sep { border-right: 1px solid #cfd5dc; }
.grid input.cell { width: 46px; height: 31px; border: 0; border-radius: 0; padding: 0 4px; text-align: right; background: transparent; font: inherit; }
.grid input.cell:focus { outline: 2px solid var(--brand); outline-offset: -2px; background: #fff; }
.grid input.cell.in { color: var(--in); font-weight: 600; }
.grid input.cell.out { color: var(--out); font-weight: 600; }
.grid input.cell.ai { background: radial-gradient(circle at 5px 5px, #3b82f6 2.5px, transparent 3px); }
.grid input.cell.saving { background: #fff8d6; }
.grid input.cell.saved { background: #dcf5e5; transition: background .6s; }
.grid input.cell.warn { width: 56px; text-align: center; color: var(--warn); }
.grid input.cell[readonly] { cursor: default; }
.grid td.empty { padding: 20px; }
@media (prefers-color-scheme: dark) {
  .grid thead th { background: #232c36; }
  .grid th.weekend { background: #2a333d; }
  .grid th.today, .grid td.today { background: #3a2e16; }
  .grid thead th.today { background: #4a3a1c; }
  .grid td.remain { background: #1f2730; }
  .grid input.cell:focus { background: var(--card); }
}
#movesBox summary { cursor: pointer; padding: 4px 2px; }
#movesBox[open] summary { margin-bottom: 6px; }
#movesBox .tbl td, #movesBox .tbl th { white-space: nowrap; }
@media (max-width: 700px) {
  .grid td.c-code { min-width: 140px; }
  .grid td.c-name { min-width: 110px; white-space: normal; font-size: 12px; }
  .chat-title > b { display: none; }
}

/* 大字说明，紧贴在要用的东西上面 */
.guide { font-size: 17px; line-height: 1.55; margin: 18px 4px 8px; color: var(--ink); display: flex; gap: 10px; align-items: flex-start; }
.guide b { color: var(--brand); }
.guide .step { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px; margin-top: 1px; }
main > .guide:first-child { margin-top: 6px; }
.chat-card { padding: 12px; }
.chat-card .chat-log { max-height: 38dvh; }
.chat-card .msg p { font-size: 15px; line-height: 1.6; }
.composer-row textarea { font-size: 16px; }
@media (max-width: 700px) { .guide { font-size: 15px; } }

/* 表格：不要内部上下滚动，全部行直接展开（左右仍可滑动看日期） */
.grid-wrap#gridWrap { max-height: none; overflow-y: visible; overflow-x: auto; }
.sheet-card { margin-top: 14px; }

/* 对话改表 */
.badge.set { background: #fff3d6; color: #9a5b00; }
.cd-line.done-line { cursor: default; }
.cd-line.done-line.struck .cd-main b { text-decoration: line-through; opacity: .6; }
@media (prefers-color-scheme: dark) { .badge.set { background: #4a3a12; color: #ffd27a; } }

/* 弹窗：右上角关闭，滚动时一直在 */
.sheet-close { position: sticky; top: 0; height: 0; display: flex; justify-content: flex-end; z-index: 3; margin: 0; }
.sheet-close button { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 18px; line-height: 1; cursor: pointer; box-shadow: 0 2px 8px rgb(0 0 0 / .15); }
.sheet-close button:hover { filter: brightness(.95); }
#sheetBody h2:first-child, #sheetBody > div > h2:first-child { padding-right: 52px; }

/* 拖图片进聊天框 */
.chat-card { position: relative; }
.chat-card.drop-on { outline: 3px dashed var(--brand); outline-offset: -6px; }
.chat-card.drop-on::after { content: '松开，把图片放进来'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 22px; font-weight: 700; color: var(--brand); background: color-mix(in srgb, var(--card) 85%, transparent); border-radius: inherit; pointer-events: none; z-index: 5; }
