:root {
  --bg: #f5f7f6; --surface: #ffffff; --surface-2: #f0f4f2; --ink: #14231f; --ink-2: #4a5a55; --ink-3: #7d8b86;
  --line: #e2e8e5; --line-2: #cfd9d5; --brand: #1f6f5c; --brand-2: #2b8a73; --brand-soft: #e3f1ec;
  --warn: #b86e00; --warn-soft: #fff4e0; --danger: #c23b3b; --danger-soft: #fdeceb; --ok: #2f8a4c;
  --shadow: 0 1px 2px rgba(20, 35, 31, .06), 0 4px 16px rgba(20, 35, 31, .06);
  --radius: 10px; --font: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1614; --surface: #161f1c; --surface-2: #1c2723; --ink: #e6eeeb; --ink-2: #b2c0bb; --ink-3: #82918c;
    --line: #26332f; --line-2: #33433e; --brand: #4fb89c; --brand-2: #63c9ad; --brand-soft: #1c3a32;
    --warn: #e0a440; --warn-soft: #3a2e17; --danger: #ef6b6b; --danger-soft: #3d1f1f; --ok: #5fc27c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* ---------- 布局 ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 12px; font-weight: 700; font-size: 17px; letter-spacing: .5px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 15px; }
.side .new-btn { margin: 4px 14px 10px; }
.lists { flex: 1; overflow-y: auto; padding: 4px 8px; }
.list-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; cursor: pointer; color: var(--ink-2); }
.list-item:hover { background: var(--surface-2); }
.list-item.active { background: var(--brand-soft); color: var(--ink); font-weight: 600; }
.list-item .n { margin-left: auto; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.list-item .dot { width: 8px; height: 8px; border-radius: 3px; background: var(--line-2); flex: none; }
.list-item.active .dot { background: var(--brand); }
.side-foot { border-top: 1px solid var(--line); padding: 12px 14px; font-size: 12px; color: var(--ink-3); display: grid; gap: 8px; }
.code { font-family: ui-monospace, Consolas, monospace; color: var(--ink); font-size: 13px; letter-spacing: 1px; }
.link { background: none; border: 0; padding: 0; color: var(--brand); }
.link:hover { text-decoration: underline; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.top { display: flex; align-items: center; gap: 10px; padding: 14px 22px 10px; flex-wrap: wrap; }
.btn.menu-btn { display: none; }
.title { font-size: 20px; font-weight: 700; border: 1px solid transparent; border-radius: 8px; padding: 2px 8px; margin-left: -8px; background: transparent; min-width: 80px; max-width: 420px; }
.title:hover { border-color: var(--line); }
.title:focus { outline: none; border-color: var(--brand); background: var(--surface); }
.spacer { flex: 1; }

/* ---------- 按钮/输入 ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.danger { color: var(--danger); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn svg { width: 16px; height: 16px; }
.input { height: 34px; border: 1px solid var(--line-2); border-radius: 8px; padding: 0 10px; background: var(--surface); outline: none; min-width: 0; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.search { width: 220px; }
kbd { font: 11px ui-monospace, Consolas, monospace; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; color: var(--ink-3); }

/* ---------- 一句话录入 ---------- */
.quick { margin: 0 22px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 10px 12px; }
.quick-row { display: flex; gap: 8px; align-items: center; }
.quick input { flex: 1; border: 0; outline: none; font-size: 16px; height: 36px; background: transparent; min-width: 0; }
.quick .hint { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; min-height: 0; margin-top: 6px; }
.chips:empty { display: none; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.chip b { color: var(--ink); font-weight: 600; margin-left: 3px; }
.chip.emb { border-style: dashed; }

/* ---------- 工具条 ---------- */
.bar { display: flex; align-items: center; gap: 8px; padding: 0 22px 10px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 0 12px; height: 30px; color: var(--ink-2); }
.seg button.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.bulk { display: flex; align-items: center; gap: 8px; background: var(--brand-soft); border-radius: 8px; padding: 4px 6px 4px 12px; }

/* ---------- 表格 ---------- */
.table-wrap { flex: 1; overflow: auto; margin: 0 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; min-height: 120px; }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-variant-numeric: tabular-nums; }
.grid th, .grid td { border-bottom: 1px solid var(--line); padding: 0; text-align: left; height: 38px; }
.grid th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); font-weight: 600; color: var(--ink-2); font-size: 13px; user-select: none; }
.grid th .th { display: flex; align-items: center; gap: 4px; padding: 0 10px; height: 38px; cursor: pointer; white-space: nowrap; }
.grid th .th:hover { color: var(--ink); }
.grid th .arrow { font-size: 10px; color: var(--brand); }
.grid td .cell { padding: 0 10px; min-height: 38px; display: flex; align-items: center; cursor: text; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 340px; }
.grid td.num .cell, .grid th.num .th { justify-content: flex-end; }
.grid td.sel, .grid th.sel { width: 36px; text-align: center; }
.grid td.calc { background: var(--surface-2); }
.grid td.calc .cell { cursor: default; }
.grid td.act { width: 36px; }
.grid tr:hover td { background: var(--surface-2); }
.grid tr.picked td { background: var(--brand-soft); }
.grid tr.flash td { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: #c9eedd; } to { background: transparent; } }
.grid tr.dup td { background: var(--warn-soft); }
.grid td input.ed, .grid td select.ed { width: 100%; height: 36px; border: 2px solid var(--brand); border-radius: 4px; padding: 0 8px; background: var(--surface); outline: none; }
.grid .del { opacity: 0; border: 0; background: none; color: var(--ink-3); width: 30px; height: 30px; border-radius: 6px; }
.grid tr:hover .del { opacity: 1; }
.grid .del:hover { background: var(--danger-soft); color: var(--danger); }
.cb { width: 18px; height: 18px; accent-color: var(--brand); cursor: pointer; vertical-align: middle; }
tr.done td:not(.sel):not(.act) .cell { color: var(--ink-3); text-decoration: line-through; }
tr.done td.ck .cell { text-decoration: none; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.tag.t-高, .tag.t-重复, .tag.t-异常, .tag.overdue { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.tag.t-可疑重复, .tag.t-待复核, .tag.soon { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag.t-正常, .tag.t-收入 { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.add-row { padding: 8px 12px; }
.empty { padding: 48px 20px; text-align: center; color: var(--ink-3); }
.empty b { color: var(--ink); display: block; font-size: 16px; margin-bottom: 6px; }
.month-head td { background: var(--bg) !important; font-size: 12px; color: var(--ink-3); height: 28px; }
.month-head td div { padding: 0 10px; display: flex; gap: 12px; }

/* ---------- 底部统计 ---------- */
.foot { display: flex; gap: 18px; padding: 10px 22px 14px; color: var(--ink-2); font-size: 13px; flex-wrap: wrap; align-items: center; }
.foot b { color: var(--ink); font-variant-numeric: tabular-nums; }
.foot .cats { display: flex; gap: 6px; flex-wrap: wrap; }
.bar-mini { display: inline-block; height: 6px; border-radius: 3px; background: var(--brand); vertical-align: middle; margin-right: 4px; opacity: .7; }

/* ---------- 发票拖放 ---------- */
.drop { margin: 0 22px 10px; border: 2px dashed var(--line-2); border-radius: 12px; padding: 16px; text-align: center; color: var(--ink-2); background: var(--surface); transition: .15s; }
.drop.over { border-color: var(--brand); background: var(--brand-soft); }
.drop small { color: var(--ink-3); }
.progress { height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; background: var(--brand); width: 0; transition: width .2s; }

/* ---------- 菜单/弹窗/提示 ---------- */
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: 38px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; min-width: 200px; z-index: 30; }
.menu-pop button { display: flex; width: 100%; gap: 10px; align-items: center; border: 0; background: none; padding: 8px 10px; border-radius: 6px; text-align: left; }
.menu-pop button:hover { background: var(--surface-2); }
.menu-pop small { color: var(--ink-3); margin-left: auto; font-size: 12px; }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.mask { position: fixed; inset: 0; background: rgba(10, 20, 17, .38); display: grid; place-items: center; z-index: 50; padding: 16px; }
.dialog { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); width: min(760px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.dialog.sm { width: min(460px, 100%); }
.dialog header { display: flex; align-items: center; padding: 16px 18px 8px; font-weight: 700; font-size: 16px; gap: 10px; }
.dialog .body { padding: 6px 18px 12px; overflow: auto; }
.dialog footer { display: flex; gap: 8px; justify-content: flex-end; padding: 10px 18px 16px; }
.dialog textarea { width: 100%; min-height: 160px; border: 1px solid var(--line-2); border-radius: 8px; padding: 10px; background: var(--surface); outline: none; resize: vertical; }
.dialog textarea:focus { border-color: var(--brand); }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-top: 10px; }
.tpl { text-align: left; border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--surface); display: grid; gap: 4px; }
.tpl:hover { border-color: var(--brand); box-shadow: var(--shadow); }
.tpl .name { font-weight: 600; }
.tpl .desc { font-size: 12px; color: var(--ink-3); }
.tpl .cols { font-size: 11px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tpl .grp { font-size: 11px; color: var(--brand); }
.muted { color: var(--ink-3); font-size: 13px; }
.preview { margin-top: 10px; max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.preview table { border-collapse: collapse; width: 100%; font-size: 13px; }
.preview th, .preview td { border-bottom: 1px solid var(--line); padding: 5px 8px; text-align: left; white-space: nowrap; }
.preview th { background: var(--surface-2); position: sticky; top: 0; }
.col-row { display: grid; grid-template-columns: 1fr 120px auto; gap: 6px; align-items: center; margin-bottom: 6px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); display: flex; gap: 14px; align-items: center; z-index: 60; max-width: calc(100vw - 32px); }
.toast .link { color: #7fe0c3; font-weight: 600; }
.pill-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 12px; }
.inv-note { font-size: 12px; color: var(--warn); }
/* ---------- 大清单分批渲染 ---------- */
.more-row td, div.more-row { text-align: center; padding: 6px; }
.more-row .more { color: var(--brand); }

/* ---------- 列宽 / 行拖拽 ---------- */
.grid th { position: sticky; }
.grid th .col-rs { position: absolute; top: 0; right: -3px; width: 7px; height: 100%; cursor: col-resize; z-index: 3; }
.grid th .col-rs:hover, body.resizing .grid th .col-rs { background: linear-gradient(90deg, transparent 2px, var(--brand) 2px, var(--brand) 4px, transparent 4px); }
body.resizing { cursor: col-resize; user-select: none; }
.grid .drag { cursor: grab; color: var(--ink-3); font-size: 12px; letter-spacing: -2px; margin-right: 4px; user-select: none; opacity: 0; }
.grid tr:hover .drag { opacity: 1; }
.grid td.sel { white-space: nowrap; width: 52px; }
.grid tr.dragging td { opacity: .45; }
.grid tr.drop-before td { box-shadow: inset 0 2px 0 var(--brand); }
.grid tr.drop-after td { box-shadow: inset 0 -2px 0 var(--brand); }

/* ---------- 离线待同步 ---------- */
.grid tr.pending td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.grid tr.pending td .cell, .card.pending .card-title { color: var(--ink-2); font-style: italic; }
.card.pending { box-shadow: inset 3px 0 0 var(--warn); }
#syncBadge { white-space: nowrap; }

/* ---------- 手机卡片 ---------- */
.cards { display: grid; gap: 0; }
.card { display: flex; align-items: flex-start; gap: 10px; padding: 12px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.card:active { background: var(--surface-2); }
.card.picked { background: var(--brand-soft); }
.card.dup { background: var(--warn-soft); }
.card .cb { margin-top: 3px; flex: none; }
.card-main { flex: 1; min-width: 0; }
.card-top { display: flex; gap: 8px; align-items: baseline; }
.card-title { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.card-amt.inc { color: var(--brand); }
.card-sub { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 4px; font-size: 12px; color: var(--ink-3); align-items: center; }
.card.done .card-title { text-decoration: line-through; color: var(--ink-3); }
.card-month { padding: 8px 12px 4px; font-size: 12px; color: var(--ink-3); background: var(--bg); font-weight: 600; }
.row-form { display: grid; gap: 10px; }
.row-field { display: grid; grid-template-columns: 84px 1fr; gap: 8px; align-items: center; font-size: 14px; }
.row-field > span { color: var(--ink-2); }
.row-field .input { width: 100%; }
.sm-input { height: 30px; padding: 0 8px; font-size: 13px; }
#monthPick.on { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); font-weight: 600; }
.flt-chips { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.flt-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.flt-chip .x { border: 0; background: none; color: inherit; padding: 0 2px; font-size: 14px; line-height: 1; }
.grid th .flt { border: 0; background: none; color: var(--ink-3); padding: 0 2px; margin-left: 2px; font-size: 11px; opacity: 0; border-radius: 4px; }
.grid th:hover .flt, .grid th .flt.on { opacity: 1; }
.grid th .flt.on { color: #fff; background: var(--brand); }
.flt-pop { position: fixed; z-index: 45; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 10px; width: 260px; }
.flt-list { max-height: 220px; overflow: auto; display: grid; gap: 2px; margin-bottom: 6px; }
.flt-list label { display: flex; align-items: center; gap: 6px; padding: 2px 4px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.flt-list label:hover { background: var(--surface-2); }
.flt-row { display: flex; gap: 6px; align-items: center; }
.flt-row .input { flex: 1; min-width: 0; }
.flt-foot { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; }
@media (hover: none) { .grid th .flt { opacity: 1; } }
.trip { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.trip-head { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; margin-bottom: 6px; }
table.rep { width: 100%; border-collapse: collapse; font-size: 13px; }
table.rep td { border-top: 1px solid var(--line); padding: 5px 6px; vertical-align: top; }
table.rep td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- 手机 ---------- */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 82vw; max-width: 300px; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .btn.menu-btn { display: inline-flex; }
  .top { padding: 10px 16px 8px; }
  .quick, .bar, .table-wrap, .drop { margin-left: 16px; margin-right: 16px; }
  .bar { padding: 0 16px 8px; margin: 0; }
  .foot { padding: 8px 16px 12px; gap: 10px; }
  .search { width: 100%; order: 10; }
  .top .spacer { display: none; }
  .top { gap: 6px; }
  .top .btn { padding: 0 10px; }
  .quick .hint { display: none; }
  .title { font-size: 18px; flex: 1; min-width: 0; max-width: none; }
  .grid td .cell { max-width: 200px; }
  .hide-m { display: none !important; }
}

/* ---------- 打印 ---------- */
.print-only { display: none; }
@media print {
  @page { size: A4 landscape; margin: 12mm; }
  body { background: #fff; color: #000; }
  .side, .quick, .bar, .foot, .drop, .top .btn, .top .menu, .add-row, .sel, .act, .toast, .menu-btn, .search { display: none !important; }
  .app { display: block; height: auto; }
  .main, .table-wrap { overflow: visible; border: 0; margin: 0; }
  .title { border: 0; font-size: 18pt; }
  .grid th { background: #eee !important; position: static; }
  .grid th, .grid td { border: 1px solid #999; height: auto; }
  .grid td .cell { max-width: none; white-space: normal; padding: 4px 6px; }
  tr.done td .cell { text-decoration: none !important; color: #000 !important; }
  .print-only { display: block; }
  .sign { display: flex; justify-content: space-between; margin-top: 18mm; font-size: 11pt; }
}
/* 分享链接管理 */
.share-list { display: flex; flex-direction: column; gap: 8px; min-width: min(520px, 80vw); }
.share-item { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.share-meta { flex: 1; min-width: 0; }
.share-url { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bill-big { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
/* 统计图：单系列用品牌色；文字用正文色，不用系列色 */
.st-hero { display: flex; gap: 28px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.st-num { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.st-num.sm { font-size: 18px; }
.st-sub { font-size: 13px; color: var(--ink-2); font-weight: 600; margin: 6px 0; }
.st-chart { position: relative; width: min(640px, 82vw); }
.st-svg { width: 100%; height: auto; display: block; }
.st-grid { stroke: var(--line); stroke-width: 1; }
.st-grid.base { stroke: var(--line-2); }
.st-ax { fill: var(--ink-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.st-ax.on { fill: var(--ink); font-weight: 700; }
.st-bar { fill: var(--brand); opacity: .45; }
.st-bar.on { opacity: 1; }
.st-hit { fill: transparent; cursor: pointer; outline: none; }
.st-hit:hover, .st-hit:focus-visible { fill: var(--ink); fill-opacity: .05; }
.st-tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 10px; font-size: 12px; box-shadow: var(--shadow); white-space: nowrap; color: var(--ink); font-variant-numeric: tabular-nums; }
.st-cats { margin-top: 10px; width: min(640px, 82vw); }
.st-row { display: grid; grid-template-columns: 5.5em 1fr auto auto; align-items: center; gap: 10px; padding: 3px 0; font-size: 13px; }
.st-k { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-track { height: 10px; }
.st-track i { display: block; height: 100%; background: var(--brand); border-radius: 0 4px 4px 0; }
.st-v { font-variant-numeric: tabular-nums; text-align: right; min-width: 8em; }
.st-v small { color: var(--ink-3); margin-left: 6px; display: inline-block; min-width: 2.6em; }
.st-table { margin-top: 12px; font-size: 13px; }
.st-table summary { cursor: pointer; color: var(--brand); }
.st-table table { border-collapse: collapse; margin-top: 6px; width: 100%; }
.st-table th, .st-table td { padding: 4px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.st-table .num { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 480px) { .st-hero { gap: 18px; } .st-num { font-size: 22px; } .st-num.sm { font-size: 16px; } .st-chart, .st-cats { width: 100%; } }
/* 月预算：状态色只用于状态，并且总带图标 + 文字 */
.bud.warn { color: var(--warn); }
.bud.over { color: var(--danger); }
.st-bud { margin: 0 0 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 13px; width: min(640px, 82vw); box-sizing: border-box; }
.st-bud-head { display: flex; align-items: center; gap: 10px; font-weight: 600; flex-wrap: wrap; }
.st-bud-head .link { margin-left: auto; font-weight: 400; }
.bud-st { font-size: 12px; font-weight: 600; font-style: normal; }
.bud-st.ok { color: var(--ok); } .bud-st.warn { color: var(--warn); } .bud-st.over { color: var(--danger); }
.bud-track { height: 8px; background: var(--surface-2); border-radius: 4px; margin: 8px 0 6px; overflow: hidden; }
.bud-track i { display: block; height: 100%; border-radius: 4px; }
.bud-track i.ok { background: var(--ok); } .bud-track i.warn { background: var(--warn); } .bud-track i.over { background: var(--danger); }
.st-track { position: relative; }
.bud-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--ink); border-radius: 1px; }
.st-n em { font-style: normal; font-size: 12px; white-space: nowrap; }
.bud-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px 12px; }
.bud-grid label { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.bud-grid label span { width: 4.5em; flex: none; }
.bud-grid .input { width: 100%; min-width: 0; }
@media (max-width: 480px) { .st-bud { width: 100%; } }
.st-cats.has-cb .st-n { width: 8.5em; } .st-cats:not(.has-cb) .st-row { grid-template-columns: 5.5em 1fr auto; } .st-cats:not(.has-cb) .st-n { display: none; }
.rec-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 14px; } .rec-now { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.due-item { width: 100%; background: var(--surface); text-align: left; cursor: pointer; color: var(--ink); font: inherit; } .due-item:hover { border-color: var(--brand); }

/* ---------- 图标：按用途着色的圆角底块 + 线性图标 ---------- */
:root {
  --hue-green: #1f6f5c; --hue-green-bg: #e3f1ec; --hue-blue: #2563a8; --hue-blue-bg: #e6eef9;
  --hue-amber: #a35a00; --hue-amber-bg: #fdf0dc; --hue-violet: #6a4cb8; --hue-violet-bg: #efeafb;
  --hue-rose: #b23a57; --hue-rose-bg: #fbe8ed; --hue-slate: #4d5c57; --hue-slate-bg: #edf1ef;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --hue-green: #5cc4a6; --hue-green-bg: #18352d; --hue-blue: #7fb0ea; --hue-blue-bg: #172a40;
    --hue-amber: #e7a750; --hue-amber-bg: #3a2b15; --hue-violet: #b39cf0; --hue-violet-bg: #2a2242;
    --hue-rose: #ef8aa2; --hue-rose-bg: #3d1d26; --hue-slate: #b2c0bb; --hue-slate-bg: #222d29;
  }
}
.ico { width: 40px; height: 40px; border-radius: 11px; display: inline-grid; place-items: center; flex: none; }
.ico svg { width: 22px; height: 22px; }
.ico.sm { width: 22px; height: 22px; border-radius: 6px; }
.ico.sm svg { width: 14px; height: 14px; }
.ico.xs { width: 18px; height: 18px; border-radius: 5px; background: transparent !important; color: currentColor !important; }
.ico.xs svg { width: 16px; height: 16px; }
.hue-green { color: var(--hue-green); background: var(--hue-green-bg); }
.hue-blue { color: var(--hue-blue); background: var(--hue-blue-bg); }
.hue-amber { color: var(--hue-amber); background: var(--hue-amber-bg); }
.hue-violet { color: var(--hue-violet); background: var(--hue-violet-bg); }
.hue-rose { color: var(--hue-rose); background: var(--hue-rose-bg); }
.hue-slate { color: var(--hue-slate); background: var(--hue-slate-bg); }
.list-item .li-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item.home-item { margin-bottom: 6px; }
.tpl .tpl-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
a.brand { color: inherit; text-decoration: none; }
.side-links { font-size: 12px; }
.btn.home-btn { padding: 0 8px; }
.btn.home-btn svg { width: 20px; height: 20px; }

/* ---------- 首页 ---------- */
.main.home-mode > :not(#home) { display: none !important; }
.main:not(.home-mode) > #home { display: none; }
.home { overflow-y: auto; padding: 28px 32px 24px; }
.home > * { max-width: 1120px; margin-left: auto; margin-right: auto; }
.home-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  padding: 26px 28px; border-radius: 16px; background: linear-gradient(135deg, var(--brand-soft), var(--surface)); border: 1px solid var(--line); }
.home-hero h1 { margin: 0 0 6px; font-size: 28px; letter-spacing: 1px; }
.home-hero p { margin: 0; color: var(--ink-2); max-width: 560px; font-size: 15px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hero-actions .btn { height: 40px; padding: 0 18px; font-size: 15px; }
.home-sec { margin-top: 28px; }
.home-sec h2 { font-size: 17px; margin: 0 0 12px; }
.hgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.hcard { display: flex; align-items: center; gap: 14px; text-align: left; padding: 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); min-width: 0; transition: border-color .12s, box-shadow .12s, transform .12s; }
.hcard:hover { border-color: var(--brand); box-shadow: var(--shadow); transform: translateY(-1px); }
.hcard:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.hc-body { display: grid; gap: 2px; min-width: 0; }
.hc-body b { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hc-body small { color: var(--ink-3); font-size: 12.5px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tpl-group + .tpl-group { margin-top: 14px; }
.tg-name { font-size: 12px; color: var(--ink-3); margin: 0 0 8px 2px; letter-spacing: 1px; }
.about { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.about-card { display: flex; gap: 14px; align-items: flex-start; padding: 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.about-card h2 { margin: 0 0 6px; font-size: 16px; }
.about-card p { margin: 0 0 8px; color: var(--ink-2); line-height: 1.7; }
.about-card .contact { color: var(--ink); }
.about-card a, .home-foot a { color: var(--brand); }
.home-foot { margin-top: 28px; padding: 16px 0 8px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-3); text-align: center; }
.sync-code { font: 600 22px/1.4 ui-monospace, Consolas, monospace; letter-spacing: 3px; text-align: center; padding: 14px; margin: 12px 0; border-radius: 10px; background: var(--surface-2); }
@media (max-width: 760px) {
  .home { padding: 16px; }
  .home-hero { padding: 20px 18px; }
  .home-hero h1 { font-size: 24px; }
  .hgrid { grid-template-columns: 1fr; gap: 10px; }
  .about { grid-template-columns: 1fr; }
  .main.home-mode .menu-btn { display: none; }
}
@media (max-width: 760px) {
  /* 手机：功能和模板两列紧凑排，图标在上、说明一行，少滚屏 */
  .hgrid.compact { grid-template-columns: 1fr 1fr; gap: 8px; }
  .hgrid.compact .hcard { flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px; }
  .hgrid.compact .hc-body b { font-size: 14px; white-space: normal; }
  .hgrid.compact .hc-body small { -webkit-line-clamp: 1; }
}

/* ---------- 操作引导 ---------- */
/* 高亮"下一步该点/该填"的部件：品牌色光环，先轻轻跳三下再常亮；系统要求减少动效时不跳 */
.cue { position: relative; box-shadow: 0 0 0 2px var(--brand), 0 0 0 6px color-mix(in srgb, var(--brand) 22%, transparent) !important;
  border-color: var(--brand) !important; animation: cue-pulse 1.6s ease-in-out 3; z-index: 1; }
@keyframes cue-pulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--brand), 0 0 0 6px color-mix(in srgb, var(--brand) 22%, transparent); }
  50% { box-shadow: 0 0 0 2px var(--brand), 0 0 0 11px color-mix(in srgb, var(--brand) 6%, transparent); }
}
@media (prefers-reduced-motion: reduce) { .cue { animation: none; } }
.quick.cue input::placeholder { color: var(--brand); opacity: .85; }
.drop.cue { background: var(--brand-soft); border-style: solid; }
.guide { display: flex; align-items: center; gap: 10px; margin: 0 22px 10px; padding: 8px 10px 8px 8px; border-radius: 10px;
  background: var(--brand-soft); color: var(--ink); font-size: 13.5px; }
.g-badge { flex: none; font-size: 12px; font-weight: 700; color: #fff; background: var(--brand); border-radius: 6px; padding: 2px 8px; }
.g-text { flex: 1; min-width: 0; line-height: 1.5; }
.guide .btn.cue { animation: none; }
.g-help { flex: none; font-size: 12.5px; }
.g-x { flex: none; border: 0; background: transparent; color: var(--ink-3); width: 26px; height: 26px; border-radius: 6px; }
.g-x:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink); }
.btn.help-btn { padding: 0 8px; }
.btn.help-btn svg { width: 20px; height: 20px; }
.eg-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 12px 0 4px; }
.btn.eg { border-style: dashed; color: var(--brand); border-color: var(--brand); background: var(--surface); }
.btn.eg:hover { background: var(--brand-soft); }
.eg-alt { margin-top: 12px; font-size: 12.5px; }
.help-list { margin: 4px 0 0; padding-left: 20px; line-height: 1.75; color: var(--ink-2); }
.help-keys { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; font-size: 12.5px; color: var(--ink-3); }
.help-keys kbd { font: 12px ui-monospace, Consolas, monospace; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; padding: 0 6px; margin-right: 5px; color: var(--ink); background: var(--surface); }
.steps { list-style: none; padding: 0; margin: 14px auto 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; counter-reset: st; }
.steps li { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); counter-increment: st; position: relative; }
.steps li::before { content: counter(st); position: absolute; top: -8px; left: -6px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.steps b { display: block; font-size: 14px; }
.steps span { font-size: 12.5px; color: var(--ink-3); line-height: 1.5; }
@media (max-width: 760px) {
  .guide { margin: 0 16px 8px; flex-wrap: wrap; }
  .g-text { flex-basis: calc(100% - 90px); }
  .steps { grid-template-columns: 1fr; gap: 12px; }
}
.link.cue { padding: 2px 8px; border-radius: 6px; background: var(--brand-soft); }
@media (max-width: 760px) { .btn.help-btn { display: none; } .top .btn.home-btn, .top .btn.menu-btn { padding: 0 6px; } }
.g-badge, .steps li::before { color: var(--surface); }  /* 深色模式下品牌色变浅，用底色当字色保证对比 */
