:root {
  --brand: #8c1c2b;
  --brand-ink: #ffffff;
  --brand-soft: #f6e9eb;
  --bg: #f4f2ef;
  --card: #ffffff;
  --ink: #1f1a17;
  --muted: #6f6660;
  --line: #e6e1dc;
  --ok: #1f7a4d;
  --ok-soft: #e3f3ea;
  --warn: #b85c00;
  --warn-soft: #fbefe1;
  --bad: #b3261e;
  --bad-soft: #fbe7e5;
  --gray-soft: #eeebe8;
  --accent: #c98a3a;
  --overlay: rgba(20, 14, 12, .45);
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  --radius: 12px;
  --tab-h: 60px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #c9485a;
    --brand-soft: #3a2226;
    --bg: #161312;
    --card: #211d1b;
    --ink: #f1ece8;
    --muted: #a69c95;
    --line: #36302d;
    --ok: #5cc28d; --ok-soft: #1d3328;
    --warn: #f0a24b; --warn-soft: #3a2b1a;
    --bad: #f07b72; --bad-soft: #3c1f1d;
    --gray-soft: #2c2724;
    --accent: #d9a35a;
    --overlay: rgba(0, 0, 0, .6);
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- 布局 ---------- */
.app { min-height: 100vh; }
.sidebar { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  height: 52px; padding: 0 16px;
  background: var(--brand); color: var(--brand-ink);
}
.topbar .back { font-size: 22px; width: 28px; cursor: pointer; background: none; border: 0; color: inherit; padding: 0; }
.topbar h1 { font-size: 17px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .who { font-size: 13px; opacity: .9; cursor: pointer; background: rgba(255,255,255,.15); border: 0; border-radius: 999px; padding: 4px 10px; color: inherit; }
.main { padding: 12px 16px calc(var(--tab-h) + 24px); max-width: 1400px; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: var(--card); border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 11px; color: var(--muted); gap: 2px; position: relative;
}
.tabbar a .ico { font-size: 20px; line-height: 1; }
.tabbar a.on { color: var(--brand); font-weight: 600; }
.badge {
  display: inline-block; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--bad); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 600;
}
.tabbar .badge { position: absolute; top: 6px; left: 50%; margin-left: 6px; }
.proto-tag {
  font-size: 11px; background: rgba(255,255,255,.2); padding: 2px 6px; border-radius: 4px;
}

@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 220px 1fr; }
  .sidebar {
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
    background: #2a1a1c; color: #efe6e3; padding: 16px 10px; overflow-y: auto;
  }
  .sidebar .logo { font-weight: 700; font-size: 16px; padding: 4px 10px 16px; }
  .sidebar .logo small { display: block; font-weight: 400; font-size: 12px; opacity: .6; }
  .sidebar .grp { font-size: 12px; opacity: .5; padding: 12px 10px 4px; }
  .sidebar a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; font-size: 14px; opacity: .85; }
  .sidebar a:hover { background: rgba(255,255,255,.06); opacity: 1; }
  .sidebar a.on { background: var(--brand); opacity: 1; }
  .sidebar a .badge { margin-left: auto; }
  .tabbar { display: none; }
  .topbar { background: var(--card); color: var(--ink); border-bottom: 1px solid var(--line); height: 56px; padding: 0 24px; }
  .topbar .who { background: var(--gray-soft); }
  .topbar .back { display: none; }
  .topbar .proto-tag { background: var(--brand-soft); color: var(--brand); }
  .main { padding: 20px 24px 40px; }
}

/* ---------- 通用组件 ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; border: 1px solid var(--line); }
.card h3 { margin: 0 0 10px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card h3 .act { margin-left: auto; font-weight: 400; font-size: 13px; color: var(--brand); cursor: pointer; }
.grid { display: grid; gap: 12px; }
.grid > * { min-width: 0; }
.main { min-width: 0; overflow-x: clip; }
.col { min-width: 0; }
.g2 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 900px) {
  .g4 { grid-template-columns: repeat(4, 1fr); }
  .g3 { grid-template-columns: repeat(3, 1fr); }
  .gd-2 { grid-template-columns: 1fr 1fr; }
  .gd-side { grid-template-columns: 1fr 340px; align-items: start; }
}
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi .v { font-size: clamp(17px, 5.2vw, 22px); font-weight: 700; margin-top: 2px; overflow-wrap: anywhere; line-height: 1.25; }
.kpi .s { font-size: 12px; color: var(--muted); }
.kpi.click { cursor: pointer; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); cursor: pointer; font-weight: 500; white-space: nowrap;
}
.btn.pri { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; min-height: 48px; font-size: 16px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.big-cta {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--brand); color: #fff; border-radius: var(--radius); min-height: 64px; font-size: 18px; font-weight: 600;
  margin-bottom: 12px; box-shadow: var(--shadow);
}

.tag { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; font-weight: 500; white-space: nowrap; }
.tag.s-out { background: var(--warn-soft); color: var(--warn); }
.tag.s-pay { background: #e6eefb; color: #2a5bb5; }
.tag.s-part { background: var(--ok-soft); color: var(--ok); }
.tag.s-me { background: var(--brand); color: var(--brand-ink); }
/* 等我处理的订单：左边一条酒红色 */
.list-card.me-row { border-left: 4px solid var(--brand); }
table.t tr.me-row td:first-child { box-shadow: inset 4px 0 0 var(--brand); }
.list-card .row1 .tag + .tag { margin-left: 0; }
.seg .badge { margin-left: 2px; vertical-align: 1px; }
@media (prefers-color-scheme: dark) { .tag.s-pay { background: #1d2a40; color: #8fb3f0; } }
.tag.s-done { background: var(--ok-soft); color: var(--ok); }
.tag.s-back { background: var(--bad-soft); color: var(--bad); }
.tag.s-gray { background: var(--gray-soft); color: var(--muted); }

.seg { display: inline-flex; background: var(--gray-soft); border-radius: 10px; padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex-shrink: 0; white-space: nowrap; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .search { flex: 1; min-width: 160px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 40px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card);
}
textarea.input { min-height: 70px; resize: vertical; }
.input:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field label .req { color: var(--bad); }
.field label.btn { display: flex; margin: 0; color: var(--ink); font-size: 15px; }
/* 折叠卡片：不用浏览器自带的三角 */
details > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; }
details > summary::-webkit-details-marker { display: none; }
details > summary .i { margin-left: auto; width: 18px; height: 18px; color: var(--muted); transition: transform .2s; }
details[open] > summary .i { transform: rotate(180deg); }
input[type="search"].input { appearance: none; -webkit-appearance: none; }
input[type="date"].input { appearance: none; -webkit-appearance: none; display: flex; align-items: center; }
input[type="date"]::-webkit-calendar-picker-indicator { opacity: .5; cursor: pointer; }
.radio-row { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-row label {
  display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; cursor: pointer; background: var(--card); color: var(--ink); margin: 0; font-size: 14px;
}
.radio-row label.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.radio-row input { display: none; }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--card); }
.stepper button { width: 36px; height: 36px; border: 0; background: var(--gray-soft); cursor: pointer; font-size: 18px; }
.stepper input { width: 56px; height: 36px; border: 0; text-align: center; background: transparent; }

/* 表格 / 卡片切换 */
.only-m { display: block; }
.only-d { display: none; }
@media (min-width: 900px) { .only-m { display: none !important; } .only-d { display: block; } }

table.t { width: 100%; border-collapse: collapse; background: var(--card); }
.t-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow); }
table.t th, table.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; font-size: 14px; }
table.t th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--gray-soft); position: sticky; top: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--brand-soft); }
table.t tr:last-child td { border-bottom: 0; }
table.t td.r, table.t th.r { text-align: right; }
table.t tfoot td { font-weight: 700; background: var(--gray-soft); }

.list-card {
  display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow);
}
.list-card .row1 { display: flex; align-items: center; gap: 8px; }
.list-card .row1 .t1 { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-card .row2 { font-size: 13px; color: var(--muted); margin-top: 4px; }
.list-card .row3 { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-top: 6px; }
.list-card .row3 > :last-child { white-space: nowrap; flex-shrink: 0; }
.list-card .amt { font-weight: 700; font-size: 16px; }
.list-card.sel { outline: 2px solid var(--brand); }

.kv { display: grid; grid-template-columns: 90px 1fr; gap: 6px 10px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
@media (min-width: 900px) { .kv.two { grid-template-columns: 90px 1fr 90px 1fr; } }

/* 时间线 */
.tl { list-style: none; margin: 0; padding: 0; }
.tl li { position: relative; padding: 0 0 14px 24px; }
.tl li::before { content: ""; position: absolute; left: 6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.tl li::after { content: ""; position: absolute; left: 10px; top: 18px; bottom: -2px; width: 2px; background: var(--line); }
.tl li:last-child::after { display: none; }
.tl li.done::before { background: var(--ok); }
.tl li.cur::before { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.tl li.back::before { background: var(--bad); }
.tl .n { font-weight: 600; font-size: 14px; }
.tl .d { font-size: 12px; color: var(--muted); }

/* 下单 */
.line-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 10px; background: var(--card); }
.line-item .hd { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.line-item .hd select { flex: 1; }
.line-item .x { border: 0; background: none; color: var(--bad); font-size: 20px; cursor: pointer; width: 32px; }
.line-item .qrow { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.line-item .qrow .lbl { font-size: 12px; color: var(--muted); display: block; margin-bottom: 2px; }
.line-item .calc { display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 8px; }
.line-item .calc b { color: var(--ink); }
.line-item.err { border-color: var(--bad); background: var(--bad-soft); }
.add-line { width: 100%; border: 1px dashed var(--brand); color: var(--brand); background: transparent; border-radius: 10px; min-height: 42px; cursor: pointer; font-weight: 600; }

.sum-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; background: var(--card); border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 12px;
}
.sum-bar .s { flex: 1; }
.sum-bar .s .v { font-size: 20px; font-weight: 700; color: var(--brand); }
.sum-bar .s .c { font-size: 12px; color: var(--muted); }
.sum-bar .btn { min-height: 46px; padding: 0 24px; }
.has-sumbar .tabbar { display: none; }
.sum-side .row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; }
.sum-side .row.total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; font-size: 18px; font-weight: 700; color: var(--brand); }
@media (min-width: 900px) { .sum-bar { display: none; } .sum-side { position: sticky; top: 76px; } }

.action-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; background: var(--card); border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); display: flex; gap: 10px;
}
.action-bar .btn { flex: 1; min-height: 46px; }
@media (min-width: 900px) {
  .action-bar { position: static; border: 0; padding: 0; background: none; justify-content: flex-end; margin-top: 12px; }
  .action-bar .btn { flex: 0 0 auto; }
}

/* 图表：横向条形图，手机电脑同一种写法；条长只表达相对大小，数字写在旁边 */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bars .b { display: grid; grid-template-columns: 5.5em minmax(0, 1fr) 7.5em; align-items: center; gap: 10px; font-size: 13px; }
@media (min-width: 900px) { .bars .b { grid-template-columns: 7em minmax(0, 1fr) 9em; } }
.bars .b > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .b .v { text-align: right; line-height: 1.3; white-space: nowrap; }
.bars .b .v .small { display: block; white-space: normal; }
.bars .track { height: 14px; background: var(--gray-soft); border-radius: 7px; overflow: hidden; }
.bars .fill { height: 100%; background: var(--brand); border-radius: 7px; }
.bars .fill.alt { background: var(--accent); }
.bars .fill.ok { background: var(--ok); }
.bars .pair { display: flex; flex-direction: column; gap: 3px; }
.bars .pair .track { height: 9px; }
.chart-legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin: -2px 0 10px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; background: var(--brand); }
.chart-legend i.ok { background: var(--ok); }

.pivot th:first-child, .pivot td:first-child { position: sticky; left: 0; z-index: 1; background: var(--card); box-shadow: 1px 0 0 var(--line); }
.pivot th:first-child { background: var(--gray-soft); z-index: 2; }

/* 提成矩阵 */
.matrix input { width: 64px; min-height: 32px; padding: 4px 6px; text-align: right; border: 1px solid var(--line); border-radius: 6px; background: var(--card); }
.matrix input.set { border-color: var(--brand); background: var(--brand-soft); font-weight: 600; }
.matrix input::placeholder { color: var(--muted); opacity: .7; }
.matrix th.grp-h { text-align: center; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 6px 0 10px; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; border: 1px solid var(--line); }
.legend i.set { background: var(--brand-soft); border-color: var(--brand); }
.src { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--gray-soft); color: var(--muted); }

/* 弹层：手机从底部滑出，电脑居中；自己画的，不用浏览器自带控件 */
body.locked { overflow: hidden; }
.mask {
  position: fixed; inset: 0; z-index: 50; background: var(--overlay);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; transition: opacity .2s ease;
}
.mask.in { opacity: 1; }
.sheet {
  position: relative; background: var(--card); width: 100%; max-height: 88vh; overflow: auto; overscroll-behavior: contain;
  border-radius: 20px 20px 0 0; padding: 8px 18px calc(18px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .26s cubic-bezier(.2, .8, .2, 1);
  box-shadow: 0 -8px 30px rgba(0,0,0,.18);
}
.mask.in .sheet { transform: none; }
.sheet-grab { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 2px auto 12px; }
.sheet-x {
  position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border-radius: 50%;
  border: 0; background: var(--gray-soft); color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.sheet-x .i { width: 16px; height: 16px; }
.sheet h3 { margin: 0 44px 14px 0; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.sheet .acts { display: flex; gap: 10px; margin-top: 18px; position: sticky; bottom: calc(-18px - env(safe-area-inset-bottom)); background: var(--card); padding: 10px 0 0; }
.sheet .acts .btn { flex: 1; min-height: 46px; }
@media (min-width: 900px) {
  .mask { align-items: center; }
  .sheet { width: 480px; max-height: 82vh; border-radius: 18px; padding: 22px 24px 24px; transform: translateY(12px) scale(.97); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
  .sheet-grab { display: none; }
  .sheet .acts { bottom: -24px; padding-bottom: 4px; }
  .sheet .acts .btn { min-height: 42px; }
}

/* 选择器：替代浏览器自带下拉框 */
select.pk-native { display: none !important; }
.pick {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 40px; padding: 6px 10px 6px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); cursor: pointer; text-align: left;
}
.pick.auto { width: auto; max-width: 100%; }
.pick:focus-visible, .pick.open { outline: 2px solid var(--brand); outline-offset: -1px; }
.pick .lb { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick .lb.ph { color: var(--muted); }
.pick .lb small { color: var(--muted); margin-left: 6px; font-size: 12px; }
.pick .i { width: 16px; height: 16px; color: var(--muted); transition: transform .15s; }
.pick.open .i { transform: rotate(180deg); }
.pop {
  position: fixed; z-index: 70; background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.18); padding: 6px; display: flex; flex-direction: column; max-height: 340px;
  opacity: 0; transform: translateY(-4px); transition: opacity .12s, transform .12s;
}
.pop.in { opacity: 1; transform: none; }
.opt-search { position: relative; margin: 2px 2px 6px; flex-shrink: 0; }
.opt-search .i { position: absolute; left: 10px; top: 50%; margin-top: -8px; width: 16px; height: 16px; color: var(--muted); }
.opt-search input { width: 100%; min-height: 38px; padding: 6px 10px 6px 32px; border-radius: 9px; border: 1px solid var(--line); background: var(--gray-soft); }
.opt-search input:focus { outline: 2px solid var(--brand); outline-offset: -1px; background: var(--card); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 2px 8px; flex-shrink: 0; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex-shrink: 0; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px; padding: 6px 14px; font-size: 14px; cursor: pointer; white-space: nowrap; }
.chips button.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.sheet .chips button { padding: 8px 16px; font-size: 15px; }
.sheet .chips + .opts { min-height: 46vh; }
.pop .chips + .opts { min-height: 180px; }
.opts { overflow-y: auto; overscroll-behavior: contain; }
.opt {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: none;
  cursor: pointer; text-align: left; color: var(--ink);
}
.opt .tx { flex: 1; min-width: 0; }
.opt .tx b { font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opt .tx small { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opt .i { width: 18px; height: 18px; color: var(--brand); visibility: hidden; flex-shrink: 0; }
.opt .rt { font-size: 13px; color: var(--muted); white-space: nowrap; }
.opt.on { background: var(--brand-soft); }
.opt.on .tx b { color: var(--brand); font-weight: 600; }
.opt.on .i { visibility: visible; }
.opt.hl:not(.on) { background: var(--gray-soft); }
.opt:disabled { opacity: .4; cursor: not-allowed; }
.opt-add { color: var(--brand); border-bottom: 1px solid var(--line); border-radius: 8px 8px 0 0; margin-bottom: 4px; }
.opt-add .i { visibility: visible; }
.opt-add .tx b { font-weight: 600; }
.opts-empty { padding: 18px; text-align: center; color: var(--muted); font-size: 13px; }
.sheet .opts { margin: 0 -8px; }
.sheet .opt { padding: 13px 12px; font-size: 16px; border-radius: 10px; }

/* 管理分类 */
.cat-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.cat-row:last-child { border-bottom: 0; }
.cat-row .t1 { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-row .input { flex: 1; min-width: 0; }

/* 待处理清单 */
.todo a { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); font-size: 14px; }
.todo a:last-child { border-bottom: 0; }
.todo a .i { width: 18px; height: 18px; color: var(--muted); }
.todo a .n { margin-left: auto; font-weight: 700; }
.todo a .n.hot { color: var(--brand); }
.todo a .chev { width: 14px; height: 14px; color: var(--muted); margin-left: 4px; }
.cta-row { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; margin-bottom: 12px; }
.cta-row .big-cta { margin: 0; }
.big-cta.alt { background: var(--card); color: var(--brand); border: 1px solid var(--brand); box-shadow: none; }
.paybar { height: 8px; background: var(--gray-soft); border-radius: 4px; overflow: hidden; margin: 8px 0 4px; }
.paybar > div { height: 100%; background: var(--ok); }

.toast { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); background: rgba(30,25,22,.92); color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 80; font-size: 14px; max-width: calc(100vw - 32px); }

.who-list button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); margin-bottom: 8px; cursor: pointer; text-align: left; }
.who-list button.on { border-color: var(--brand); background: var(--brand-soft); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; flex-shrink: 0; }
.menu-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.menu-grid a { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 4px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; font-size: 13px; }
.menu-grid a .ico { font-size: 24px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.note { font-size: 12px; color: var(--muted); background: var(--gray-soft); border-radius: 8px; padding: 8px 10px; margin-bottom: 12px; }
.warn-row td { color: var(--bad); }
.text-bad { color: var(--bad); }
.text-ok { color: var(--ok); }
.text-brand { color: var(--brand); }

/* 打印 */
.print-only { display: none; }
@media print {
  .sidebar, .tabbar, .topbar, .action-bar, .sum-bar, .no-print { display: none !important; }
  .app { display: block; }
  .print-only { display: block; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border: 0; }
}

/* 矢量图标 */
.i { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.2em; flex-shrink: 0; }
.btn .i, .big-cta .i { width: 18px; height: 18px; }
.big-cta .i { width: 22px; height: 22px; stroke-width: 2; }
.card h3 .i { width: 18px; height: 18px; }
.tabbar a .ico .i { width: 22px; height: 22px; display: block; }
.sidebar a .i { width: 18px; height: 18px; opacity: .9; }
.menu-grid a .ico .i { width: 26px; height: 26px; display: block; color: var(--brand); }
.kpi .v .i { width: 26px; height: 26px; color: var(--brand); }
.text-ok .i, .text-bad .i { width: 14px; height: 14px; stroke-width: 2.4; }

/* 登录页 */
.app.auth { display: block; }
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 28px 24px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 20px; margin: 10px 0 2px; }
.auth-logo { width: 52px; height: 52px; display: block; }
.who-list button .i { width: 20px; height: 20px; color: var(--muted); }

.sidebar .logo { display: flex; align-items: center; gap: 10px; }
.sidebar .logo img { width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0; }
.more-grp { font-size: 13px; color: var(--muted); margin: 14px 2px 8px; }
.more-grp:first-child { margin-top: 0; }
.menu-grid a { position: relative; }
.menu-grid a .badge { position: absolute; top: 6px; right: 10px; }
.action-bar .btn.cancel { flex: 0 0 auto; color: var(--bad); }

/* 手机上连点按钮不触发双击放大 */
button, a, label, .input { touch-action: manipulation; }
.nw { white-space: nowrap; }

/* ---------- 同步状态（app.js 的 sync / syncUI；状态挂在 <html> 的 sync-busy / sync-offline / sync-error 上） ---------- */
/* 顶栏底边的跑光：正在和服务器通信时出现，很快结束的请求不闪 */
.topbar::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--accent), transparent) no-repeat;
  background-size: 40% 100%; background-position: -70% 0;
  opacity: 0; transition: opacity .2s;
}
html.sync-busy .topbar::after { opacity: 1; transition-delay: .15s; animation: sync-sweep 1.2s ease-in-out infinite; }
@keyframes sync-sweep { from { background-position: -70% 0; } to { background-position: 170% 0; } }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex-shrink: 0; }
html.sync-busy .sync-dot { background: var(--accent); animation: sync-pulse 1s ease-in-out infinite; }
html.sync-offline .sync-dot { background: var(--warn); animation: none; }
html.sync-error .sync-dot { background: var(--bad); animation: none; }
@keyframes sync-pulse { 50% { opacity: .35; } }
/* 断网或同步失败：顶栏下方一条提示，写明显示的是几点的数据 */
.syncbar { display: none; align-items: center; gap: 8px; position: sticky; top: 52px; z-index: 19; padding: 8px 16px; font-size: 13px; background: var(--warn-soft); color: var(--warn); }
html.sync-error .syncbar { background: var(--bad-soft); color: var(--bad); }
html.sync-offline .syncbar, html.sync-error .syncbar { display: flex; }
.syncbar button { margin-left: auto; flex-shrink: 0; border: 1px solid currentColor; background: none; color: inherit; border-radius: 999px; padding: 2px 12px; font-size: 13px; cursor: pointer; }
/* 电脑侧边栏底部常驻状态，点一下立即同步 */
.sync-foot { display: none; }
@media (min-width: 900px) {
  .syncbar { top: 56px; padding: 8px 24px; }
  .sidebar .sync-foot { display: flex; align-items: center; gap: 8px; margin-top: auto; position: sticky; bottom: -16px; padding: 12px 10px 14px; border: 0; border-radius: 0; background: inherit; color: inherit; font-size: 12px; cursor: pointer; text-align: left; }
  .sidebar .sync-foot [data-sync-t] { opacity: .7; }
  .sidebar .sync-foot:hover [data-sync-t] { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  html.sync-busy .topbar::after { animation: none; background-size: 100% 100%; background-position: 0 0; opacity: .6; }
  html.sync-busy .sync-dot { animation: none; }
}
