:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #fafbfc;
  --sidebar: #f0f1f4;
  --line: #e4e6eb;
  --line-strong: #d3d7de;
  --text: #1c1f26;
  --text-2: #5c6370;
  --text-3: #8e95a3;
  --brand: #2f6bed;
  --brand-soft: #eaf1fe;
  --brand-text: #1f4fc4;
  --danger: #e0483f;
  --danger-soft: #fdecea;
  --ok: #17a06a;
  --ok-soft: #e6f6ef;
  --warn: #cf8700;
  --warn-soft: #fdf5e3;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-1: 0 1px 2px rgba(20, 26, 40, .06), 0 1px 3px rgba(20, 26, 40, .04);
  --shadow-2: 0 6px 20px rgba(20, 26, 40, .10), 0 2px 6px rgba(20, 26, 40, .05);
  --shadow-3: 0 18px 50px rgba(20, 26, 40, .18);
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #16181d;
  --panel: #1e2127;
  --panel-2: #23262d;
  --sidebar: #191c21;
  --line: #2e323a;
  --line-strong: #3c414b;
  --text: #e8eaee;
  --text-2: #a3aab6;
  --text-3: #767d8a;
  --brand: #5b8cf7;
  --brand-soft: #1e2a44;
  --brand-text: #a8c3fd;
  --danger: #f2706a;
  --danger-soft: #3a2322;
  --ok: #48c48f;
  --ok-soft: #1c332a;
  --warn: #e5ac48;
  --warn-soft: #362c18;
  --shadow-2: 0 6px 20px rgba(0, 0, 0, .4);
  --shadow-3: 0 18px 50px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* 关键：hidden 属性必须赢过任何 display 规则，
   否则 .btn / .setup 这类自带 display 的元素会「藏不住」 */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 13.5px;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
button:disabled { cursor: not-allowed; opacity: .45; }
::selection { background: var(--brand-soft); }

/* 滚动条 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------------------------------------------------------------- 顶栏 */

.topbar {
  display: flex; align-items: center; gap: 10px;
  height: 54px; flex: 0 0 54px;
  padding: 0 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 9px; padding-right: 6px; user-select: none; }
.brand .mark {
  width: 27px; height: 27px; border-radius: 8px; flex: 0 0 27px;
  background: linear-gradient(145deg, var(--brand), #6f4fe0);
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 2px 6px rgba(47, 107, 237, .32);
}
.brand .mark svg { width: 16px; height: 16px; }
.brand h1 { font-size: 14.5px; font-weight: 650; letter-spacing: .2px; white-space: nowrap; }

.search {
  flex: 1 1 auto; max-width: 380px; position: relative;
}
.search svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--text-3); }
.search input {
  width: 100%; height: 32px; padding: 0 28px 0 29px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel-2); outline: none;
}
.search input:focus { border-color: var(--brand); background: var(--panel); box-shadow: 0 0 0 3px var(--brand-soft); }
.search .clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); color: var(--text-3); padding: 3px; border-radius: 4px; display: none; }
.search .clear:hover { background: var(--line); color: var(--text); }
.search.has-value .clear { display: block; }
.search .clear svg { position: static; transform: none; }

.spacer { flex: 1 1 auto; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line);
  font-size: 12.5px; color: var(--text-2); white-space: nowrap;
  max-width: 190px;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: 0 0 7px; }
.chip .dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.chip .dot.off { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.chip .dot.wait { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.chip .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.device { cursor: pointer; }
.chip.device:hover { border-color: var(--line-strong); color: var(--text); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 13px; border-radius: var(--radius-sm);
  background: var(--panel-2); border: 1px solid var(--line);
  font-size: 13px; font-weight: 500; color: var(--text);
  transition: background .12s, border-color .12s, transform .06s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--panel); border-color: var(--line-strong); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn svg { width: 14px; height: 14px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 550; }
.btn.primary:hover:not(:disabled) { background: #2559d0; border-color: #2559d0; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--line); }
.btn.danger { color: var(--danger); }
.btn.danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }
.btn.sm { height: 27px; padding: 0 9px; font-size: 12.5px; }
.btn.icon { width: 32px; padding: 0; }
.btn.icon.sm { width: 27px; }
.badge-count {
  min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 650;
  display: grid; place-items: center; line-height: 1;
}

/* ---------------------------------------------------------------- 主体 */

.main { flex: 1 1 auto; display: flex; min-height: 0; }

.sidebar {
  flex: 0 0 196px; background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; overflow-y: auto; padding: 10px 8px 14px;
}
.side-title {
  font-size: 11px; font-weight: 650; letter-spacing: .7px; text-transform: uppercase;
  color: var(--text-3); padding: 10px 9px 5px; user-select: none;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  height: 32px; padding: 0 9px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 13px; width: 100%; text-align: left;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: rgba(127, 137, 155, .13); color: var(--text); }
.nav-item.active { background: var(--panel); color: var(--text); font-weight: 550; box-shadow: var(--shadow-1); }
.nav-item svg { width: 15px; height: 15px; flex: 0 0 15px; opacity: .85; }
.nav-item .label { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .num { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.nav-item.active .num { color: var(--brand); }

.dev-item { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 9px; border-radius: 6px; font-size: 12.5px; color: var(--text-2); }
.dev-item:hover { background: rgba(127, 137, 155, .13); }
.dev-item .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); flex: 0 0 7px; }
.dev-item .dot.on { background: var(--ok); }
.dev-item .nm { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev-item .me { font-size: 10.5px; color: var(--brand); border: 1px solid var(--brand); border-radius: 4px; padding: 0 4px; line-height: 15px; }
.dev-item .num { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
/* 被管理员断开的电脑：灰掉，并挂一个红标，免得看错 */
.dev-item.is-off { opacity: .6; }
.dev-item .off { font-size: 10.5px; color: var(--danger); border: 1px solid var(--danger); border-radius: 4px; padding: 0 4px; line-height: 15px; flex: 0 0 auto; }

/* 设置里的「设备管理」面板 */
.devlist { border: 1px solid var(--line); border-radius: var(--radius-sm); max-height: 224px; overflow: auto; background: var(--panel-2); }
.devlist .empty { padding: 11px 12px; font-size: 12px; color: var(--text-3); }
.dev-row { display: flex; align-items: center; gap: 9px; padding: 7px 10px; font-size: 12.5px; color: var(--text-2); border-bottom: 1px solid var(--line); }
.dev-row:last-child { border-bottom: 0; }
.dev-row:hover { background: rgba(127, 137, 155, .10); }
.dev-row input[type=checkbox] { width: 14px; height: 14px; accent-color: var(--brand); flex: 0 0 auto; }
.dev-row .nm { color: var(--text); flex: 0 0 auto; }
.dev-row .meta { flex: 1 1 auto; font-size: 11.5px; color: var(--text-3); text-align: right; }
.dev-row .tag { font-size: 10.5px; border-radius: 4px; padding: 0 5px; line-height: 16px; flex: 0 0 auto; }
.dev-row .tag.me { color: var(--brand); border: 1px solid var(--brand); }
.dev-row .tag.off { color: var(--danger); border: 1px solid var(--danger); }
.dev-row .tag.away { color: var(--text-3); border: 1px solid var(--line-strong); }
.dev-row.is-off .nm { color: var(--text-3); text-decoration: line-through; }

/* 列表 */

.list-col {
  flex: 0 0 336px; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-width: 0;
}
.list-head {
  display: flex; align-items: center; gap: 8px; height: 42px; flex: 0 0 42px;
  padding: 0 8px 0 14px; border-bottom: 1px solid var(--line);
}
.list-head .t { font-size: 13px; font-weight: 600; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-body { flex: 1 1 auto; overflow-y: auto; padding: 6px; }

.card {
  position: relative; padding: 10px 11px 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid transparent; margin-bottom: 3px; cursor: pointer;
  transition: background .1s, border-color .1s;
}
.card:hover { background: var(--panel-2); border-color: var(--line); }
.card.sel { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 35%, transparent); }
.card .row1 { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.card .ttl {
  flex: 1 1 auto; font-size: 13.5px; font-weight: 550; line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card.sel .ttl { color: var(--brand-text); }
.card .prev {
  font-size: 12.5px; color: var(--text-2); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 0; word-break: break-word;
}
.card .meta { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 11.5px; color: var(--text-3); flex-wrap: wrap; }
/* 贴了图的业务：列表上一个小相机徽标，一眼看出这条有图 */
.card .imark { display: inline-flex; align-items: center; gap: 3px; color: var(--text-3); }
.card .imark svg { width: 12px; height: 12px; }
.card .meta .sep { color: var(--line-strong); }
.card .assignee { display: inline-flex; align-items: center; gap: 4px; color: var(--brand-text); max-width: 130px; }
.card .assignee .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .due.over { color: var(--danger); font-weight: 550; }

/* ---- 指派任务回执（收到任务 / 已收到） ---- */

/* 待接收：橙色小按钮，一眼能看出「这条还没接」 */
.card .acceptbtn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px; border: 1px solid var(--warn);
  background: var(--warn-soft); color: var(--warn);
  font-size: 11px; font-weight: 600; line-height: 1.5; cursor: pointer;
}
.card .acceptbtn:hover { filter: brightness(0.96); }
.card .acceptedok {
  display: inline-flex; align-items: center; gap: 4px; color: var(--ok);
}

/* 编辑区顶部那条横幅：待接收 = 橙底，已收到 = 绿底 */
.acceptbar { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.acceptbar[hidden] { display: none; }
.acceptbar.wait { background: var(--warn-soft); border: 1px solid var(--warn); border-radius: 10px; padding: 8px 12px; }
.acceptbar.ok { background: var(--ok-soft, rgba(23, 160, 106, .1)); border: 1px solid var(--ok); border-radius: 10px; padding: 8px 12px; color: var(--ok); }

/* ---- 逾期自动催办：列表上的「已催办 N 次」标记 ---- */
.card .nudgebadge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 7px; border-radius: 20px;
  border: 1px solid var(--danger); background: var(--danger-soft); color: var(--danger);
  font-size: 10.5px; font-weight: 550; line-height: 1.6;
}
/* 催办状态区（设置面板里） */
.nudgestate { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-2); }
.nudgestate b { color: var(--text-1, var(--text)); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---- 单据打印 ----
   平时 .print-root 是空壳且不显示。只有当它里面真的有单子时才接管打印，
   否则用户直接按 Ctrl+P 打印主界面会被藏成一片空白。 */
.print-root { display: none; }

@page { margin: 14mm 12mm; }

@media print {
  .print-root:not(:empty) { display: block; }
  body:has(.print-root:not(:empty)) > *:not(.print-root) { display: none !important; }
  body:has(.print-root:not(:empty)) { background: #fff !important; }

  /* 打印一律黑字白底，不跟随深色主题 */
  .receipt { color: #000; background: #fff; font-family: var(--font-sans); page-break-after: always; }
  .receipt:last-child { page-break-after: auto; }

  .rc-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #000; padding-bottom: 8px; }
  .rc-brand { font-size: 17pt; font-weight: 700; letter-spacing: 1px; }
  .rc-kind { font-size: 11pt; letter-spacing: 6px; margin-top: 3px; }
  .rc-no { text-align: right; font-size: 9pt; line-height: 1.8; }

  .rc-grid { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 10pt; }
  .rc-grid th, .rc-grid td { border: 1px solid #000; padding: 6px 8px; text-align: left; }
  .rc-grid th { width: 12%; background: #f2f2f2; font-weight: 600; }

  .rc-sec { margin-top: 12px; }
  .rc-sec-t { font-size: 9pt; letter-spacing: 4px; color: #555; margin-bottom: 5px; }
  .rc-title { font-size: 13pt; font-weight: 600; margin-bottom: 6px; }
  .rc-tags { font-size: 9pt; color: #444; margin-bottom: 6px; }
  .rc-content { font-size: 10pt; line-height: 1.8; min-height: 62px; border: 1px solid #aaa; border-radius: 3px; padding: 8px 10px; white-space: pre-wrap; }
  /* 单子上贴的图片：跟着内容流排，宽不超出内容框 */
  .rc-content .rc-img { max-width: 100%; max-height: 62mm; margin: 6px 0; border: 1px solid #ccc; display: block; }

  .rc-amount { display: flex; justify-content: space-between; align-items: baseline; margin-top: 14px; border-top: 1px solid #000; border-bottom: 1px solid #000; padding: 9px 4px; }
  .rc-amount-l { font-size: 11pt; letter-spacing: 2px; }
  .rc-amount-v { font-size: 16pt; font-weight: 700; font-variant-numeric: tabular-nums; }

  .rc-sign { display: flex; justify-content: space-between; margin-top: 28px; font-size: 10pt; }
  .rc-foot { margin-top: 16px; font-size: 8pt; color: #666; text-align: right; }
}

/* ---- 置顶 ---- */

/* 置顶的卡片左侧加一条竖杠，一眼能看出是钉住的 */
.card.pinned { background: linear-gradient(90deg, var(--warn-soft) 0, transparent 42%); }
.card.pinned::before {
  content: ''; position: absolute; left: 3px; top: 9px; bottom: 9px; width: 2.5px;
  border-radius: 2px; background: var(--warn);
}
.card.pinned.sel { background: var(--brand-soft); }

/* 位次角标：1 / 2 / 3 */
.card .pinmark {
  flex: 0 0 auto; width: 15px; height: 15px; border-radius: 4px;
  background: var(--warn); color: #fff; font-size: 10px; font-weight: 700;
  display: grid; place-items: center; line-height: 1;
}
.card .pininfo { color: var(--warn); font-weight: 550; }

/* 列表项上的置顶按钮：平时很淡，鼠标移到卡片上才明显 */
.card .pinbtn {
  flex: 0 0 auto; width: 20px; height: 20px; padding: 0; border-radius: 5px;
  border: 1px solid transparent; background: transparent; cursor: pointer;
  color: var(--text-3); opacity: 0; display: grid; place-items: center;
  transition: opacity .12s, color .12s, background .12s, border-color .12s;
}
.card .pinbtn svg { width: 13px; height: 13px; }
.card:hover .pinbtn { opacity: .55; }
.card .pinbtn:hover { opacity: 1; color: var(--warn); background: var(--warn-soft); border-color: var(--warn); }
.card .pinbtn.on { opacity: 1; color: var(--warn); }
.card .pinbtn.on:hover { background: var(--warn-soft); border-color: var(--warn); }
.card .row1 .pinbtn { margin-left: 2px; }
.card .ttl { margin-right: 2px; }

/* 编辑区里标题旁那颗置顶按钮点亮时 */
#btnPin.on { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }
#btnOnTop.on { color: var(--brand); border-color: var(--brand); background: var(--brand-soft); }

/* 置顶提示行 */
.hintline {
  display: flex; align-items: center; gap: 6px; margin-top: 8px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  background: var(--warn-soft); color: var(--warn);
  font-size: 12px; font-weight: 500;
}

/* 设置面板里的开关行 */
.toggle-row { display: flex; align-items: flex-start; gap: 9px; }
.toggle-row input[type=checkbox] {
  width: 15px; height: 15px; margin-top: 2px; flex: 0 0 auto; accent-color: var(--brand);
}
.toggle-row .txt { min-width: 0; }
.toggle-row .t { font-size: 12.5px; font-weight: 550; }
.toggle-row .d { font-size: 11.5px; color: var(--text-3); margin-top: 3px; line-height: 1.6; }

.pill {
  display: inline-flex; align-items: center; height: 19px; padding: 0 7px; border-radius: 5px;
  font-size: 11px; font-weight: 550; white-space: nowrap; letter-spacing: .1px;
}
.pill.todo { background: var(--line); color: var(--text-2); }
.pill.doing { background: var(--brand-soft); color: var(--brand-text); }
.pill.done { background: var(--ok-soft); color: var(--ok); }
.pill.high { background: var(--danger-soft); color: var(--danger); }
.pill.low { background: var(--line); color: var(--text-3); }
.pill.deleted { background: var(--danger-soft); color: var(--danger); }
.pill.act { background: var(--line); color: var(--text-2); }
.pill.act.create { background: var(--ok-soft); color: var(--ok); }
.pill.act.delete, .pill.act.purge { background: var(--danger-soft); color: var(--danger); }
.pill.act.restore, .pill.act.undelete { background: var(--brand-soft); color: var(--brand-text); }
.pill.act.conflict { background: var(--warn-soft); color: var(--warn); }
.card .dotmark { width: 6px; height: 6px; border-radius: 50%; flex: 0 0 6px; }

.empty {
  padding: 46px 22px; text-align: center; color: var(--text-3); font-size: 12.5px; line-height: 1.9;
}
.empty svg { width: 34px; height: 34px; opacity: .4; margin-bottom: 10px; }

/* 详情 */

.detail-col { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; background: var(--panel); }
.detail-empty { flex: 1 1 auto; display: grid; place-items: center; color: var(--text-3); text-align: center; padding: 30px; }
.detail-empty .box { max-width: 340px; line-height: 2; }
.detail-empty svg { width: 44px; height: 44px; opacity: .35; margin-bottom: 12px; }
.kbd { font-family: var(--mono); font-size: 11.5px; background: var(--panel-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px; color: var(--text-2); }

.detail-head {
  flex: 0 0 auto; border-bottom: 1px solid var(--line); padding: 12px 16px 0;
}
.detail-head .title-row { display: flex; align-items: flex-start; gap: 10px; }
.detail-head .actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
#fTitle {
  flex: 1 1 auto; font-size: 18.5px; font-weight: 650; line-height: 1.35;
  border: none; background: transparent; outline: none; padding: 3px 0;
  resize: none; overflow: hidden; width: 100%; font-family: inherit;
}
#fTitle::placeholder { color: var(--text-3); font-weight: 500; }

.tabs { display: flex; gap: 2px; margin-top: 8px; }
.tab {
  position: relative; padding: 7px 12px 9px; font-size: 13px; color: var(--text-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand-text); border-bottom-color: var(--brand); font-weight: 550; }
.tab .n { font-size: 11px; color: var(--text-3); margin-left: 4px; }

.detail-body { flex: 1 1 auto; overflow-y: auto; display: flex; flex-direction: column; }
.pane { padding: 14px 16px 26px; }
.pane[hidden] { display: none; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px 14px; margin-bottom: 14px; }
.field label { display: block; font-size: 11.5px; color: var(--text-3); margin-bottom: 4px; font-weight: 550; letter-spacing: .2px; }
.control {
  width: 100%; height: 32px; padding: 0 9px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--panel-2); outline: none;
}
select.control { appearance: none; background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e95a3' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; background-size: 13px; padding-right: 26px; }
.control:focus { border-color: var(--brand); background: var(--panel); box-shadow: 0 0 0 3px var(--brand-soft); }

#fContent {
  width: 100%; min-height: 300px; padding: 11px 12px; resize: none; outline: none;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel-2);
  line-height: 1.75; font-size: 13.5px; font-family: inherit;
}
#fContent:focus { border-color: var(--brand); background: var(--panel); box-shadow: 0 0 0 3px var(--brand-soft); }

/* ---- 贴进来的图片 ---- */

/* 编辑区下方的图片条 */
.imgbar {
  display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap;
  margin-top: 8px; padding: 8px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
  background: var(--panel-2);
}
.imgbar .imgitem {
  position: relative; width: 74px; height: 74px;
  border-radius: 8px; overflow: hidden; border: 1px solid var(--line-strong);
  background: var(--panel);
}
.imgbar .imgitem img {
  width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in;
}
.imgbar .imgdel {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px;
  border: 0; border-radius: 50%; cursor: pointer;
  background: rgba(20, 20, 20, .62); color: #fff;
  font-size: 10px; line-height: 18px; padding: 0; text-align: center;
}
.imgbar .imgdel:hover { background: var(--danger); }
.imgbar .imgmore { align-self: center; font-size: 11.5px; color: var(--text-3); padding: 0 4px; }

/* 内容渲染时（便签 / 预览）贴在文字流里的图 */
.cimg {
  max-width: 100%; border-radius: 8px; margin: 4px 0;
  border: 1px solid var(--line-strong); cursor: zoom-in; display: block;
}

.hintline { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 11.5px; color: var(--text-3); flex-wrap: wrap; }
.savestate { display: inline-flex; align-items: center; gap: 5px; }
.savestate .d { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); }
.savestate.dirty .d { background: var(--warn); }
.savestate.saved .d { background: var(--ok); }
.savestate.err .d { background: var(--danger); }

/* 历史时间线 */

.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 1.5px; background: var(--line); }
.rev { position: relative; padding: 9px 11px; border-radius: var(--radius-sm); border: 1px solid transparent; margin-bottom: 4px; }
.rev:hover { background: var(--panel-2); border-color: var(--line); }
.rev::before {
  content: ''; position: absolute; left: -18.5px; top: 15px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--panel); border: 2px solid var(--line-strong);
}
.rev.cur::before { border-color: var(--brand); background: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.rev .r1 { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.rev .who { font-size: 12.5px; font-weight: 600; }
.rev .when { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.rev .r2 { margin-top: 5px; font-size: 12px; color: var(--text-2); line-height: 1.75; }
.rev .chg { display: flex; gap: 5px; padding: 1px 0; }
.rev .chg .k { color: var(--text-3); flex: 0 0 auto; min-width: 52px; }
.rev .chg .v { word-break: break-word; }
.rev .chg .old { color: var(--danger); text-decoration: line-through; opacity: .8; }
.rev .chg .arrow { color: var(--text-3); }
.rev .chg .new { color: var(--ok); }
.rev .r3 { margin-top: 7px; display: flex; gap: 6px; }
.rev .snap { margin-top: 7px; padding: 9px 10px; border-radius: 7px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12.5px; white-space: pre-wrap; word-break: break-word; max-height: 260px; overflow: auto; line-height: 1.7; }

/* 设置弹窗 */

.mask {
  position: fixed; inset: 0; background: rgba(16, 20, 30, .48);
  display: grid; place-items: center; z-index: 100; padding: 20px;
  animation: fade .13s ease;
}
@keyframes fade { from { opacity: 0 } }
.mask[hidden] { display: none; }
.dialog {
  background: var(--panel); border-radius: 14px; box-shadow: var(--shadow-3);
  width: 100%; max-width: 480px; max-height: 88vh; display: flex; flex-direction: column;
  animation: pop .16s cubic-bezier(.2, .9, .3, 1);
}
@keyframes pop { from { transform: translateY(8px) scale(.985); opacity: 0 } }
.dialog header { display: flex; align-items: center; gap: 10px; padding: 15px 17px 12px; border-bottom: 1px solid var(--line); }
.dialog header h2 { font-size: 15px; font-weight: 650; flex: 1 1 auto; }
.dialog .content { padding: 15px 17px; overflow-y: auto; }
.dialog footer { padding: 12px 17px 15px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); }
.dialog .note { font-size: 11.5px; color: var(--text-3); margin-top: 5px; line-height: 1.7; }
.dialog .group { margin-bottom: 15px; }
.dialog .group > label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; }

.kv { display: grid; grid-template-columns: 104px 1fr; gap: 6px 10px; font-size: 12.5px; }
.kv .k { color: var(--text-3); }
.kv .v { font-family: var(--mono); font-size: 11.5px; word-break: break-all; }

.toast-wrap { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  padding: 9px 15px; border-radius: 9px; font-size: 13px; box-shadow: var(--shadow-2);
  background: #22262e; color: #fff; animation: toastin .2s cubic-bezier(.2, .9, .3, 1);
  max-width: 460px; line-height: 1.6;
}
@keyframes toastin { from { transform: translateY(10px); opacity: 0 } }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }
.toast.warn { background: var(--warn); }

.banner {
  display: flex; align-items: center; gap: 9px; padding: 9px 14px; font-size: 12.5px;
  background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--line);
}
.banner[hidden] { display: none; }
.banner.err { background: var(--danger-soft); color: var(--danger); }
.banner svg { width: 15px; height: 15px; flex: 0 0 15px; }
.banner .msg { flex: 1 1 auto; }

/* 首次配置引导 */
.setup { flex: 1 1 auto; display: grid; place-items: center; padding: 30px; }
.setup .box { width: 100%; max-width: 440px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 26px; box-shadow: var(--shadow-2); }
.setup h2 { font-size: 17px; font-weight: 650; margin-bottom: 6px; }
.setup p { font-size: 12.5px; color: var(--text-2); line-height: 1.85; margin-bottom: 16px; }
.setup .row { display: flex; gap: 8px; }

.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* 多选删除 */
.list-head .btn { flex: 0 0 auto; }
.selbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 0 0 auto;
  padding: 7px 10px; border-bottom: 1px solid var(--line); background: var(--panel-2);
  font-size: 12px;
}
.selbar[hidden] { display: none; }
.selbar .selall { display: flex; align-items: center; gap: 5px; cursor: pointer; user-select: none; font-size: 12px; }
.selbar .selall input { width: 14px; height: 14px; accent-color: var(--brand); cursor: pointer; }
.selbar .selnum { color: var(--text-2); font-variant-numeric: tabular-nums; }
.card .pick {
  flex: 0 0 auto; width: 15px; height: 15px; margin-right: 2px;
  accent-color: var(--brand); cursor: pointer;
}
.card.picked { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 45%, transparent); }
.card.picked .ttl { color: var(--brand-text); }

/* 侧栏里带警示色的数字（逾期） */
.nav-item .num.warn { color: var(--danger); background: var(--danger-soft); }
.nav-item.active .num.warn { color: #fff; background: var(--danger); }
.side-title { display: flex; align-items: center; gap: 6px; }

/* 筛选增强：金额区间 / 截止日期区间 / 客户 */
.filterbar {
  display: flex; flex-direction: column; gap: 7px; flex: 0 0 auto;
  padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2);
}
.filterbar[hidden] { display: none; }
.filterbar .frow { display: flex; align-items: center; gap: 7px; font-size: 12px; }
.filterbar .flabel { flex: 0 0 58px; color: var(--text-2); }
.filterbar .fdash { color: var(--text-3); }
.filterbar .fnum { width: 84px; flex: 0 0 auto; }
.filterbar .fdate { width: 132px; flex: 0 0 auto; }
.filterbar .fsel { flex: 0 1 200px; }
.filterbar .fhint { color: var(--text-3); font-size: 11.5px; }
.btn .fcount {
  display: inline-block; margin-left: 5px; min-width: 15px; padding: 0 4px;
  border-radius: 999px; background: var(--brand); color: #fff;
  font-size: 10.5px; line-height: 15px; text-align: center; font-variant-numeric: tabular-nums;
}
.btn .fcount[hidden] { display: none; }

/* ================= 业务提醒条 ================= */
.alertbar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 9px 12px; margin: 0;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid var(--danger);
  background: var(--danger-soft);
  color: var(--text); font-size: 12.5px;
  cursor: pointer; user-select: none;
}
.alertbar[hidden] { display: none; }
.alertbar:hover { filter: brightness(.98); }
.alertbar svg { width: 14px; height: 14px; flex: 0 0 auto; color: var(--danger); }
.alertbar b { font-variant-numeric: tabular-nums; }
.alertbar .sep { color: var(--text-3); }
.alertbar .go { margin-left: auto; color: var(--danger); font-weight: 600; white-space: nowrap; }
.alertbar.calm { border-left-color: var(--ok); background: var(--ok-soft); cursor: default; }
.alertbar.calm svg, .alertbar.calm .go { color: var(--ok); }

/* 列表卡片上的客户名与金额 */
.card .cust {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 6px; border-radius: 5px;
  background: var(--brand-soft); color: var(--brand-text);
  font-size: 11px; font-weight: 500; max-width: 130px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card .cust svg { width: 10px; height: 10px; }
.card .amt {
  font-weight: 600; font-size: 11.5px; color: var(--warn);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.card.picked .cust { background: var(--panel); }

/* ================= 经营统计看板 ================= */
.stats-col {
  flex: 1 1 auto; display: flex; flex-direction: column;
  min-width: 0; background: var(--bg); overflow: hidden;
}
.stats-head {
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 11px 16px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.stats-head .t { font-size: 14px; font-weight: 600; }
.stats-time { font-size: 11.5px; color: var(--text-3); }
.range { display: flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.rbtn {
  border: 0; background: transparent; color: var(--text-2);
  font-family: inherit; font-size: 12px; padding: 4px 11px;
  border-radius: 6px; cursor: pointer; white-space: nowrap;
}
.rbtn:hover { color: var(--text); }
.rbtn.active { background: var(--panel); color: var(--brand-text); font-weight: 600; box-shadow: var(--shadow-1); }

.stats-body {
  flex: 1 1 auto; overflow: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 14px;
}
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(126px, 1fr)); gap: 10px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi .n { font-size: 23px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }
.kpi .s { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.kpi.danger .n { color: var(--danger); }
.kpi.warn .n { color: var(--warn); }
.kpi.ok .n { color: var(--ok); }
.kpi.brand .n { color: var(--brand); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel > h3 {
  font-size: 13px; font-weight: 600; margin: 0;
  padding: 11px 14px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 7px;
}
.panel > h3 svg { width: 14px; height: 14px; color: var(--text-3); flex: 0 0 auto; }
.panel > h3 .sub { font-weight: 400; font-size: 11.5px; color: var(--text-3); margin-left: auto; }
.panel .pbody { padding: 12px 14px; }
.panel .pbody.flush { padding: 0; }

.ptable { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ptable th {
  text-align: left; font-weight: 500; color: var(--text-3); font-size: 11.5px;
  padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel-2);
}
.ptable td { padding: 9px 12px; border-bottom: 1px solid var(--line); }
.ptable tbody tr:last-child td { border-bottom: 0; }
.ptable tbody tr:hover td { background: var(--panel-2); }
.ptable .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ptable .nm { font-weight: 500; }
.ptable .nm button {
  border: 0; background: transparent; padding: 0; margin: 0;
  font: inherit; color: var(--brand-text); cursor: pointer;
  border-bottom: 1px dashed color-mix(in srgb, var(--brand) 45%, transparent);
}
.ptable .nm button:hover { border-bottom-style: solid; }
.ptable .nm .plain { color: var(--text); }
.ptable td.danger { color: var(--danger); font-weight: 600; }
.ptable .none { color: var(--text-3); }

.bar { display: block; height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; min-width: 46px; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: var(--brand); }
.bar.danger > i { background: var(--danger); }
.bar.warn > i { background: var(--warn); }

.stats-note { font-size: 11.5px; color: var(--text-3); line-height: 1.7; }
.stats-empty { text-align: center; color: var(--text-3); font-size: 12.5px; padding: 26px 0; }

/* 柱状图 */
.panelrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(370px, 1fr)); gap: 14px; }
.chartwrap { width: 100%; overflow-x: auto; }
.chartsvg { display: block; }
.chartsvg .doneline { fill: none; stroke: var(--ok); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chartsvg .lbl.today { fill: var(--brand-text); font-weight: 700; }
.chartsvg .gl { stroke: var(--line); stroke-width: 1; }
.chartsvg .lbl { font-size: 10px; fill: var(--text-3); }
.chartsvg .bopen { fill: color-mix(in srgb, var(--brand) 32%, transparent); }
.chartsvg .bdone { fill: var(--ok); }
.chartsvg .bover { fill: var(--danger); }
.chartsvg .leg { font-size: 10.5px; fill: var(--text-2); }
.chartsvg .hit { fill: transparent; cursor: pointer; }
.chartsvg .hit:hover + .barhi { opacity: 1; }
.chartsvg .barhi { opacity: 0; transition: opacity .12s; }
.chartlegend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-2); margin-top: 8px; }
.chartlegend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* 中等宽度（平板/窄窗口）：侧栏收成纯图标窄条。
   注意下限 701px —— 手机布局（≤700px）里侧栏是抽屉，抽屉里必须显示文字，
   这条规则绝不能命中手机，否则抽屉里只剩图标没有字。 */
@media (min-width: 701px) and (max-width: 1080px) {
  .sidebar { flex-basis: 60px; padding: 10px 6px; }
  .sidebar .side-title, .nav-item .label, .nav-item .num, .dev-item .nm, .dev-item .num, .dev-item .me { display: none; }
  .nav-item, .dev-item { justify-content: center; padding: 0; }
  .list-col { flex-basis: 300px; }
}

/* ================= 桌面便签 =================
   ?sticky=记录ID 时，整个窗口就是一张贴在桌面上的小便签。
   v1.10.1 起改成素雅白纸：纯白纸面 + 极细边框 + 柔和层次，不再用大片饱和黄
   （满黄显土、蓝红绿标签在黄底上也打架）。深色主题下便签同样是白纸 —— 它就是一张实体贴纸。
   标题栏上三颗按钮：图钉（钉在最上面）、收起成一条、收掉这张便签；
   降级成 Edge 应用窗口模式时（客户端会带 ?chrome=1），那种窗口自带系统标题栏，
   我们这排按钮就重复了，用 body.native-bar 整排藏掉。 */
#sticky {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfd 100%);
  color: #374151;
  box-shadow: inset 0 0 0 1px #e5e8ee;
}

.sticky-bar {
  display: flex; align-items: center; gap: 6px;
  /* 高度写死：桌面客户端就是按这个高度把窗口缩成「一条」的（client.py 里的 STICKY_BAR_H），
     改这里务必同步改那边，否则收起后会露出半截正文。 */
  height: 40px; flex: 0 0 40px;
  padding: 0 6px 0 10px;
  font-size: 12px; font-weight: 700; color: #5b6472;
  background: #fafbfc;
  position: relative;
  user-select: none; -webkit-user-select: none;
  cursor: default;
}
.sticky-bar::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: #eceff3;
}
.sticky-bar .s-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 7px; flex: 0 0 auto;
  background: #eef1f5; color: #667085;
  box-shadow: inset 0 0 0 1px #e3e7ed;
}
.sticky-bar .s-ico svg { width: 13px; height: 13px; }
.sticky-bar .t { letter-spacing: .8px; }
.sticky-bar .sp { flex: 1 1 auto; }

.sticky-bar .sbtn {
  border: 0; background: transparent; color: #7b8494;
  width: 26px; height: 26px; border-radius: 8px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s, color .15s;
}
.sticky-bar .sbtn svg { width: 14px; height: 14px; }
.sticky-bar .sbtn:hover { background: #eceff3; color: #2b3444; }
.sticky-bar .sbtn:active { transform: translateY(1px); }
/* 图钉点亮 = 这张便签钉在最上面 */
#stickyPin.on {
  background: #1f6feb; color: #fff;
  box-shadow: 0 1px 3px rgba(31, 111, 235, .35);
}
#stickyPin.on:hover { background: #1a5fd0; color: #fff; }
/* 收起按钮：收起来的时候箭头翻上去 */
#stickyMin svg { transition: transform .2s ease; }
#stickyMin.on svg { transform: rotate(180deg); }
/* Edge 应用窗口降级模式：系统标题栏自带最小化/关闭，我们这排按钮整排隐藏 */
body.native-bar .sticky-bar .sbtn { display: none; }

.sticky-body { flex: 1 1 auto; overflow: auto; padding: 13px 16px 12px; }
#sticky .sticky-body::-webkit-scrollbar-thumb { background: #cfd4dc; }
#sticky .sticky-body::-webkit-scrollbar-thumb:hover { background: #b8bfc9; }

.s-gone { padding: 26px 8px; text-align: center; font-size: 13px; line-height: 2; color: #9aa3af; }
.s-title { font-size: 16.5px; font-weight: 700; line-height: 1.45; color: #141b26; margin-bottom: 8px; word-break: break-all; letter-spacing: .2px; }
.s-meta {
  display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 12px;
  padding-bottom: 12px; border-bottom: 1px solid #eef1f5;
}
.s-tag {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 11px; line-height: 1.5; font-weight: 600;
  background: #f2f4f7; color: #4a5566;
  border: 1px solid #e6e9ef;
}
.s-tag.hot { background: #fdeeec; color: #c0392b; border-color: #f9dcd8; }
.s-tag.money { background: #e9f7f1; color: #0f7a51; border-color: #d3eee1; }
.s-tag.over { background: #fdeeec; color: #c0392b; border-color: #f9dcd8; }
.s-content {
  font-size: 14px; line-height: 1.88; white-space: pre-wrap; word-break: break-word;
  color: #3c4653;
}
/* 页脚：更新时间挪到正文下面，标题栏就清爽了 */
.sticky-foot {
  flex: 0 0 auto; padding: 6px 24px 8px 16px;
  font-size: 10.5px; line-height: 1.6; color: #9aa3af;
  text-align: right; letter-spacing: .3px;
  border-top: 1px solid #f1f3f6;
}

/* 收起成一条：只留标题栏，正文和页脚都收起来（窗口高度由客户端改） */
body.sticky-collapsed .sticky-body,
body.sticky-collapsed .sticky-foot { display: none; }

/* 便签里的状态徽章沿用主界面的 .pill 配色，但压成白纸色调 */
#sticky .pill { background: #f2f4f7; color: #4a5566; }
#sticky .pill.done { background: #e9f7f1; color: #0f7a51; }
#sticky .pill.doing { background: #eaf1fe; color: #1a56db; }
#sticky .pill.todo { background: #f2f4f7; color: #4a5566; }

/* 铃声提醒开关（工具栏）：关掉时半透明，一眼能看出不在岗 */
#btnBell.off { opacity: .42; }
#btnBell:not(.off) svg { color: var(--warn, #d99a2b); }

/* ================= 手机端适配（v1.11.0） =================
   断点 700px 以下进入手机布局。桌面端样式完全不受影响 ——
   以下规则全部收在媒体查询里，或带「手机才显示」的显式 display:none。
   手机布局三件事：
   ① 侧栏 → 左侧抽屉（顶栏汉堡按钮唤出，带遮罩）
   ② 列表/详情互斥全屏（选中即进详情，左上角返回）
   ③ 触控目标加大 + 右下角悬浮「新建」大按钮 */

/* 手机专属元素：桌面上一律不显示 */
#btnSide, #btnBack, #fabNew, #sideMask { display: none; }
/* 手机媒体查询里给遮罩写了 display:block，这里保底：hidden 时必须真隐藏 */
#sideMask[hidden] { display: none !important; }

/* hidden 属性保底：显式 display 不能把 hidden 翻出来（统计视图切换依赖它） */
.detail-col[hidden], .list-col[hidden], .stats-col[hidden] { display: none !important; }

@media (max-width: 700px) {
  #app { height: 100dvh; }

  /* ---- 顶栏改成两行：第一行 汉堡+品牌+状态+图标按钮，第二行 搜索框独占整行 ----
     一行塞不下（390px 屏会把最右边的设置按钮挤出屏幕），搜索框也没有可用的宽度。 */
  .topbar {
    flex-wrap: wrap; height: auto; flex-basis: auto;
    padding: calc(6px + env(safe-area-inset-top)) 10px 6px;
    row-gap: 8px;
  }
  .brand { min-width: 0; }
  .brand h1 { font-size: 13px; max-width: 34vw; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .brand .mark { width: 24px; height: 24px; flex-basis: 24px; }
  .topbar .spacer { display: none; }
  #connChip { order: 5; margin-left: auto; min-width: 0; }
  #btnSettings { order: 6; }
  .btn.icon { width: 36px; height: 36px; flex: 0 0 36px; }
  .search { order: 10; flex: 1 1 100%; max-width: none; min-width: 0; }
  .search input { height: 36px; font-size: 16px; }   /* 16px 起，iOS 聚焦才不会放大整个页面 */
  /* 手机顶栏只留：汉堡 / 品牌 / 连接状态 / 设置。
     flex-wrap 是「放不下就换行」而不是收缩，所以第一行必须是确定放得下的一组 ——
     立即同步（3 秒自动同步，出错有横幅）和深色切换（低频）收掉，免得设置键被挤下一行。 */
  #deviceChip, #btnBell, #btnOnTop, #btnNew, #btnSync, #btnTheme { display: none; }

  #btnSide {
    display: inline-flex; width: 36px; height: 36px; flex: 0 0 36px;
    align-items: center; justify-content: center;
  }

  /* ---- 侧栏 → 抽屉 ----
     锚在 .main 里（absolute），不用再猜顶栏多高 —— 顶栏已经两行了。 */
  .main { position: relative; }
  .sidebar {
    position: absolute; top: 0; bottom: 0; left: 0; z-index: 46;
    width: min(78vw, 264px); flex: none;
    transform: translateX(-103%);
    transition: transform .22s ease;
    box-shadow: 8px 0 28px rgba(16, 22, 35, .18);
    padding-top: 12px;
  }
  body.side-open .sidebar { transform: none; }
  #sideMask {
    display: block; position: absolute; top: 0; bottom: 0; left: 0; right: 0;
    z-index: 45; background: rgba(15, 20, 32, .42);
  }
  .nav-item { height: 42px; font-size: 14px; }
  .dev-item { height: 38px; font-size: 13px; }

  /* ---- 列表 / 详情互斥 ---- */
  body.show-detail .list-col { display: none; }
  body:not(.show-detail) .detail-col { display: none; }
  body.show-detail .detail-col:not([hidden]) { display: flex; }
  /* 必须用 ID 覆盖：桌面那条 #btnBack{display:none} 是 ID 选择器，
     用 .back-btn（类）盖不过它 —— 这就是手机上「进了详情回不去」的老 bug */
  #btnBack { display: inline-flex; flex: 0 0 36px; width: 36px; height: 36px; }

  .list-col { flex: 1 1 auto; }

  /* 列表头：标题+计数一行，按钮放不下就换行（高度不能再写死） */
  .list-head {
    height: auto; min-height: 42px; flex: 0 0 auto;
    flex-wrap: wrap; row-gap: 6px; padding: 8px 12px;
  }
  .list-head .t { font-size: 15px; }
  .list-head .btn { height: 32px; }
  .list-body { padding: 8px 10px calc(86px + env(safe-area-inset-bottom)); }  /* 底部给 FAB 让位 */
  .card { padding: 12px 13px; margin-bottom: 8px; }
  .card .t { font-size: 15px; }
  /* 触屏没有 hover：置顶小按钮平时就显示，否则永远点不到 */
  .card .pinbtn { opacity: .5; }

  /* ---- 详情/编辑：按钮单独一行换行排，标题拿整行宽度 ---- */
  .detail-head { padding: 10px 12px 8px; }
  .detail-head .title-row { flex-wrap: wrap; }
  .detail-head .actions { flex: 1 1 100%; flex-wrap: wrap; margin-top: 6px; }
  .detail-head .actions .btn { height: 34px; }
  #fTitle { font-size: 16px; }
  #btnSticky { display: none; }   /* 桌面便签在手机上没有意义 */
  .tabs .tab { height: 38px; font-size: 13.5px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid .field.span { grid-column: 1 / -1; }   /* 截止日期（日期+时刻两个框）独占一行 */
  .field label { font-size: 12px; }
  .control { min-height: 40px; font-size: 16px; }  /* 16px 防 iOS 聚焦放大 */
  select.control { min-height: 40px; }
  #fContent { min-height: 220px; font-size: 15px; }
  .detail-empty .box { margin: 0 18px; }

  /* ---- 筛选条：日期框改成弹性宽度，360px 屏也不撑破 ---- */
  .filterbar .fdate { flex: 1 1 0; width: auto; min-width: 0; }
  .filterbar .fsel { flex: 1 1 auto; }
  .filterbar .frow { flex-wrap: wrap; }

  /* ---- 统计：图表面板单列排，不再按 370px 最小宽硬撑 ---- */
  .stats-head { flex-wrap: wrap; gap: 8px; }
  .stats-body { padding: 12px; }
  .panelrow { grid-template-columns: minmax(0, 1fr); }

  /* ---- 悬浮新建按钮 ---- */
  #fabNew {
    display: grid; place-items: center;
    position: fixed; right: 16px;
    bottom: calc(18px + env(safe-area-inset-bottom));
    width: 56px; height: 56px; border-radius: 50%;
    background: linear-gradient(145deg, var(--brand), #6f4fe0); color: #fff;
    box-shadow: 0 6px 18px rgba(47, 107, 237, .42), 0 2px 5px rgba(16, 22, 35, .22);
    z-index: 42; border: none; cursor: pointer;
    transition: transform .12s;
  }
  #fabNew:active { transform: scale(.94); }
  #fabNew svg { width: 24px; height: 24px; }

  /* ---- 弹窗全屏化 ---- */
  .mask { padding: 0; }
  .mask .dialog {
    width: 100%; height: 100%; max-width: none; max-height: none;
    border-radius: 0; border: none;
  }
  .dialog header { padding: 13px 14px 10px; }
  .dialog .content { padding: 13px 14px; }
  .dialog footer { padding: 10px 14px 12px; }
  .kv { grid-template-columns: 88px 1fr; }
  .toast { max-width: calc(100vw - 30px); }

  /* ---- 首次配置引导 ---- */
  .setup { padding: 16px; }
  .setup .box { padding: 18px; }

  /* ---- 便签模式（?sticky=）：手机上整页就是便签本身，不出现主界面元素 ---- */
  body.sticky-mode #fabNew, body.sticky-mode #btnSide { display: none; }
  /* 详情页有自己的保存/返回，悬浮新建按钮会多余还容易误触 */
  body.show-detail #fabNew { display: none; }
}

/* 深色主题下抽屉遮罩略深一点 */
body.dark #sideMask { background: rgba(0, 0, 0, .55); }

/* 打印不受手机布局影响：打印时永远按桌面结构输出 */
@media print {
  #btnSide, #btnBack, #fabNew, #sideMask { display: none !important; }
  body.show-detail .list-col { display: block; }
  body:not(.show-detail) .detail-col { display: flex; }
}

/* 拍照 / 相册选图按钮行：编辑区内容框上方，手机桌面上都在 */
.imgtools { display: flex; gap: 8px; margin: 0 0 8px; align-items: center; }
.imgtools .btn { gap: 5px; }
@media (max-width: 700px) {
  .imgtools .btn { height: 38px; font-size: 13.5px; }
}
