:root {
  --bg: #f6f1ea;
  --card: #ffffff;
  --ink: #2b2118;
  --muted: #7a6a5b;
  --line: #e8dfd3;
  --wood: #8a5a2b;
  --wood-dark: #5e3b19;
  --wood-soft: #f1e4d3;
  --green: #2f8f4e;
  --green-soft: #e3f3e8;
  --red: #c4422b;
  --red-soft: #fbe7e2;
  --blue: #2c6db0;
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif; font-size: 16px; line-height: 1.5; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input { font: inherit; }
.wrap { max-width: 520px; margin: 0 auto; padding: 16px 16px 96px; }
.wrap.wide { max-width: 1080px; }

/* 顶栏 */
.top { display: flex; align-items: center; gap: 10px; padding: 14px 16px; background: var(--wood-dark); color: #fff; position: sticky; top: 0; z-index: 5; }
.top h1 { font-size: 18px; margin: 0; flex: 1; font-weight: 600; }
.top .tag { font-size: 12px; background: rgba(255,255,255,.15); padding: 3px 8px; border-radius: 99px; }
.top a, .top button.link { color: #fff; opacity: .85; text-decoration: none; font-size: 14px; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #5fd47f; margin-right: 6px; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* 首页 */
.landing h2 { font-size: 22px; margin: 24px 0 4px; }
.landing p.sub { color: var(--muted); margin: 0 0 20px; }
.role-card { display: flex; align-items: center; gap: 16px; width: 100%; text-align: left; background: var(--card); border-radius: var(--radius); padding: 20px; margin-bottom: 14px; box-shadow: 0 1px 3px rgba(60,40,20,.08); border: 1px solid var(--line); }
.role-card .ico { font-size: 40px; }
.role-card b { font-size: 20px; display: block; }
.role-card span { color: var(--muted); font-size: 14px; }
.hint { font-size: 13px; color: var(--muted); background: var(--wood-soft); border-radius: 12px; padding: 12px 14px; margin-top: 18px; }

/* 工人端 */
.who { display: flex; gap: 8px; overflow-x: auto; margin: 4px 0 16px; padding-bottom: 4px; }
.who button { flex: none; padding: 8px 14px; border-radius: 99px; background: var(--card); border: 2px solid var(--line); font-size: 15px; }
.who button.on { border-color: var(--wood); background: var(--wood-soft); font-weight: 600; }
.mic-big { width: 100%; background: var(--wood); color: #fff; border-radius: 24px; padding: 28px 16px; display: flex; flex-direction: column; align-items: center; gap: 6px; box-shadow: 0 6px 18px rgba(138,90,43,.35); }
.mic-big .ico { font-size: 56px; line-height: 1; }
.mic-big b { font-size: 24px; }
.mic-big span { font-size: 14px; opacity: .85; }
.mic-big.rec { background: var(--red); animation: pulse 1.2s infinite; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 14px; }
.btn-tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 6px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 17px; font-weight: 600; }
.btn-tile .ico { font-size: 34px; }
.samples { margin-top: 14px; }
.samples .lbl { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.chip { display: inline-block; background: var(--card); border: 1px dashed var(--wood); color: var(--wood-dark); border-radius: 12px; padding: 8px 12px; margin: 0 6px 8px 0; font-size: 14px; text-align: left; }
.typebox { display: flex; gap: 8px; margin-top: 4px; }
.typebox input { flex: 1; min-width: 0; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.typebox button { padding: 0 16px; border-radius: 12px; background: var(--wood-soft); color: var(--wood-dark); font-weight: 600; }

.section-title { font-size: 15px; color: var(--muted); margin: 22px 0 8px; font-weight: 600; }
.rec-item { background: var(--card); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); }
.rec-item .ico { font-size: 24px; }
.rec-item .main { flex: 1; min-width: 0; }
.rec-item .main b { display: block; font-size: 15px; }
.rec-item .main small { color: var(--muted); font-size: 12px; }
.rec-item.void { opacity: .45; }
.rec-item.void b { text-decoration: line-through; }
.undo { font-size: 13px; color: var(--red); padding: 6px 10px; border-radius: 8px; background: var(--red-soft); }

/* 弹层 */
.sheet-bg { position: fixed; inset: 0; background: rgba(30,20,10,.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 520px; border-radius: 24px 24px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 92vh; overflow-y: auto; }
.sheet h3 { margin: 0 0 4px; font-size: 20px; }
.sheet .heard { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.step-lbl { font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.opts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.opt { background: var(--card); border: 2px solid var(--line); border-radius: 14px; padding: 14px 8px; font-size: 18px; font-weight: 600; }
.opt.on { border-color: var(--wood); background: var(--wood-soft); }
.confirm-card { background: var(--card); border-radius: var(--radius); padding: 16px; border: 1px solid var(--line); }
.confirm-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 18px; }
.confirm-row:last-child { border-bottom: 0; }
.confirm-row span { color: var(--muted); font-size: 15px; }
.confirm-row b { font-size: 22px; }
.confirm-row b.edit { border-bottom: 2px dotted var(--wood); }
.loss-box { margin-top: 12px; border-radius: 14px; padding: 14px; background: var(--green-soft); color: var(--green); font-size: 16px; }
.loss-box.bad { background: var(--red-soft); color: var(--red); }
.loss-box b { font-size: 24px; }
.actions { display: flex; gap: 10px; margin-top: 16px; }
.btn-ok { flex: 2; background: var(--green); color: #fff; border-radius: 16px; padding: 18px; font-size: 22px; font-weight: 700; }
.btn-ok:disabled { opacity: .4; }
.btn-ghost { flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; font-size: 17px; }
.pad-display { font-size: 40px; font-weight: 700; text-align: center; background: var(--card); border-radius: 14px; padding: 8px; border: 1px solid var(--line); }
.pad-display small { font-size: 18px; color: var(--muted); font-weight: 400; }
.quick { display: flex; gap: 8px; margin: 10px 0; }
.quick button { flex: 1; background: var(--wood-soft); color: var(--wood-dark); border-radius: 12px; padding: 10px 0; font-weight: 600; }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pad button { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 0; font-size: 24px; font-weight: 600; }

.toast { position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%); background: rgba(30,20,10,.92); color: #fff; padding: 14px 20px; border-radius: 14px; z-index: 50; font-size: 16px; max-width: calc(100% - 32px); text-align: center; }

/* 老板端 */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 760px) { .kpis { grid-template-columns: repeat(6, 1fr); } }
.kpi { background: var(--card); border-radius: 14px; padding: 14px; border: 1px solid var(--line); }
.kpi .k { font-size: 13px; color: var(--muted); }
.kpi .v { font-size: 26px; font-weight: 700; line-height: 1.2; margin-top: 2px; }
.kpi .v small { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.kpi .d { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.alert { border-color: var(--red); background: var(--red-soft); }
.kpi.alert .v { color: var(--red); }
.kpi.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0% { background: #fff3c4; } 100% { background: var(--card); } }
.panel { background: var(--card); border-radius: var(--radius); padding: 16px; border: 1px solid var(--line); margin-top: 14px; }
.panel h3 { margin: 0 0 10px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.panel h3 .r { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 400; }
.cols { display: grid; gap: 14px; }
@media (min-width: 900px) { .cols { grid-template-columns: 1.3fr 1fr; } .cols .panel { margin-top: 14px; } }
.ask { display: flex; gap: 8px; }
.ask input { flex: 1; min-width: 0; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); }
.ask button { padding: 0 16px; border-radius: 12px; background: var(--wood); color: #fff; font-weight: 600; }
.answer { margin-top: 10px; background: var(--wood-soft); border-radius: 12px; padding: 12px 14px; font-size: 15px; white-space: pre-line; }
.ask-chips { margin-top: 8px; }
.ask-chips button { font-size: 13px; border: 1px solid var(--line); border-radius: 99px; padding: 4px 10px; margin: 0 6px 6px 0; background: var(--bg); }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 10px; }
.tabs button { flex: none; padding: 6px 12px; border-radius: 99px; background: var(--bg); font-size: 14px; }
.tabs button.on { background: var(--wood); color: #fff; }
.tbl-wrap { overflow-x: auto; max-height: 420px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; position: sticky; top: 0; background: var(--card); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.new td { background: #fff3c4; }
tr.void td { color: var(--muted); text-decoration: line-through; }
.src { font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--wood-soft); color: var(--wood-dark); }
.src.voice { background: #e4eefa; color: var(--blue); }
.bad-txt { color: var(--red); font-weight: 600; }
.stock-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.stock-row:last-child { border-bottom: 0; }
.legend { font-size: 12px; color: var(--muted); display: flex; gap: 14px; margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.foot { text-align: center; font-size: 12px; color: var(--muted); margin-top: 20px; }
.foot button { color: var(--wood); text-decoration: underline; font-size: 12px; }
