* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  color: #2b2623;
  background: #f7f4ef;
}
h1 { font-size: 22px; margin: 12px 0 8px; letter-spacing: .2px; }
h2 { font-size: 18px; margin: 16px 0 8px; color: #1f1b18; }
h3 { font-size: 15px; margin: 4px 0 8px; color: #2b2623; }
h4 { font-size: 14px; margin: 10px 0 4px; color: #554c46; }
ul, ol { margin: 6px 0; padding-left: 20px; }
li { margin: 4px 0; }
code { background: #f0ebe3; padding: 1px 5px; border-radius: 4px; font-size: 13px; }

button {
  font: inherit;
  padding: 6px 13px;
  border: 1px solid #cfc6bc;
  border-radius: 7px;
  background: #fff;
  color: #2b2623;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, box-shadow .15s;
}
button:hover:not(:disabled) { background: #f5f0e8; border-color: #b5a99c; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: #2663c7; color: #fff; border-color: #2663c7; }
button.primary:hover:not(:disabled) { background: #1d53ab; border-color: #1d53ab; }
button.danger { background: #c53028; color: #fff; border-color: #c53028; }
button.danger:hover:not(:disabled) { background: #a8251e; border-color: #a8251e; }
button.ghost { background: transparent; border-color: transparent; color: #665d55; }
button.ghost:hover:not(:disabled) { background: #eee8df; color: #222; }
button.big { padding: 10px 22px; font-size: 16px; font-weight: 600; }
button.small { padding: 3px 9px; font-size: 12px; }

input, select, textarea {
  font: inherit;
  padding: 7px 9px;
  border: 1px solid #cfc6bc;
  border-radius: 6px;
  width: 100%;
  background: #fff;
  color: #2b2623;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #2663c7;
  box-shadow: 0 0 0 2px rgba(38, 99, 199, .15);
}
input[type=radio], input[type=checkbox] { width: auto; }

.small { font-size: 12.5px; }
.muted { color: #756b62; }
.hidden { display: none !important; }
.card {
  background: #fff;
  border: 1px solid #e6dfd5;
  border-radius: 10px;
  padding: 14px 16px;
  margin: 10px 0;
  box-shadow: 0 1px 3px rgba(43, 38, 35, .04);
}
.empty-box { text-align: center; padding: 24px 14px; color: #8c8278; }
.note { background: #fff9e6; border-left: 4px solid #e2ae26; padding: 8px 12px; border-radius: 0 6px 6px 0; }
.hint { background: #eaf2ff; color: #1f4c99; padding: 7px 14px; font-size: 13px; border-bottom: 1px solid #d4e3fc; }
.error { color: #c53028; font-weight: 600; min-height: 1em; }
.req { color: #c53028; font-size: 12px; margin-left: 4px; font-weight: 600; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; background: #ece6de; color: #4e463f; vertical-align: middle; }
.tag.unc { background: #fff0d6; color: #944f00; border: 1px solid #f0b860; }
.test-badge { font-size: 11px; background: #3b3530; color: #fff; padding: 2px 8px; border-radius: 10px; font-weight: 500; }
#main { padding: 4px 16px 24px; max-width: 1120px; }

.login-wrap { max-width: 780px; margin: 22px auto; padding: 0 16px; }
.entry-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; margin-bottom: 12px; }
.entry-btn { text-align: left; padding: 12px 14px; border-radius: 9px; line-height: 1.45; }
.entry-btn.master-btn { border-color: #2663c7; background: #f2f7ff; }
#login-form label { display: block; margin-bottom: 10px; font-weight: 500; }

.hdr {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid #e6dfd5;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .03);
}
.hdr-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.hdr nav { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.hdr nav button { padding: 5px 10px; font-size: 13px; }
.hdr nav button.on { background: #2b2623; color: #fff; border-color: #2b2623; }

.ack { margin: 10px 16px 4px; padding: 12px 16px; border-radius: 10px; max-width: 1120px; }
.ack.idle { background: #edf7ef; border: 1px solid #cde5d1; }
.ack.readonly { background: #f1ede7; border: 1px solid #e2dbd0; }
.ack.ringing { background: #fff0f0; border: 3px solid #d50000; animation: flash 1s infinite; }
.ack .ring-title { font-size: 19px; font-weight: 700; color: #b00020; }
.ack .ring-brief { margin: 4px 0; font-size: 15px; }
.ack button.big { margin: 8px 0; font-size: 20px; padding: 10px 38px; }
@keyframes flash { 50% { border-color: #ffb3b3; } }
.waiting { margin-top: 8px; background: #fff; padding: 8px 12px; border-radius: 7px; border: 1px solid #eee; }
.wait-count { margin: 6px 0 4px; font-size: 15px; font-weight: 600; }

.pack-box { border-left: 4px solid #2663c7; background: #f8fbff; }
.summary-bar { background: #f2f7ff; border-color: #cfe0fa; font-size: 15px; }

.order {
  display: flex;
  gap: 14px;
  background: #fff;
  border: 1px solid #e6dfd5;
  border-radius: 10px;
  padding: 12px 14px;
  margin: 10px 0;
  box-shadow: 0 1px 3px rgba(43, 38, 35, .04);
}
.order.blue { border: 2px solid #2663c7; background: #eef5ff; }
.order.red { border: 2.5px solid #d50000; background: #fff4f4; }
.order.done { opacity: .78; }
.order.cancelled { opacity: .7; border-color: #bbb; background: #f2f0ed; }
.order .body { flex: 1; min-width: 0; }
.order[data-layout="single-row"] { padding: 8px 10px; margin: 6px 0; gap: 10px; align-items: flex-start; }
.order[data-layout="single-row"] .thumb { width: 58px; height: 58px; border-radius: 6px; }
.order[data-layout="single-row"] .ohead { margin-bottom: 4px; gap: 6px; }
.order[data-layout="single-row"] .actions { margin-top: 6px; gap: 6px; }
.order[data-layout="single-row"] .actions button { min-height: 34px; padding: 4px 10px; font-size: 13px; }
.row-dl { display: flex; flex-wrap: wrap; gap: 2px 10px; margin: 2px 0 4px; font-size: 12.5px; align-items: baseline; }
.row-dl dt { display: inline; color: #756b62; font-size: 12px; }
.row-dl dt::after { content: '：'; }
.row-dl dd { display: inline; margin: 0 6px 0 0; }
.row-status { display: flex; flex-wrap: wrap; gap: 3px 12px; list-style: none; padding: 4px 8px; margin: 4px 0; font-size: 12px; }
.bluetag { background: #2663c7; color: #fff; padding: 2px 8px; border-radius: 10px; font-weight: 600; font-size: 12px; }
.date-divider { display: flex; align-items: center; gap: 10px; margin: 12px 0 6px; color: #5c534a; font-size: 12.5px; font-weight: 600; }
.date-divider::before, .date-divider::after { content: ''; flex: 1; border-top: 1px dashed #c8bfb2; }
.thumb { width: 104px; height: 104px; object-fit: cover; border-radius: 8px; border: 1px solid #e2dbd0; flex: none; background: #faf8f5; }
.thumb.empty { display: flex; align-items: center; justify-content: center; color: #9c9288; font-size: 12px; }
.ohead { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.serial { font-weight: 700; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; color: #1f1b18; background: #f3eee6; padding: 2px 8px; border-radius: 6px; }
.redtag { background: #d50000; color: #fff; padding: 2px 10px; border-radius: 10px; font-weight: 600; font-size: 12.5px; }
.canceltag { background: #6b645e; color: #fff; padding: 2px 10px; border-radius: 10px; font-weight: 600; font-size: 12.5px; }
.cancel-text { color: #c53028; }

dl { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; margin: 4px 0 8px; }
dt { color: #756b62; font-size: 13px; }
dd { margin: 0; word-break: break-word; }
ul.status { margin: 6px 0; padding: 8px 10px 8px 24px; background: #faf8f5; border-radius: 7px; font-size: 13px; }
b.ok { color: #1b7f2a; }
b.off { color: #8c8278; }
.actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px 16px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }
.form-grid .full { grid-column: 1 / -1; }
.auto { padding: 7px 9px; background: #f3eee6; border-radius: 6px; color: #5c534a; font-size: 13px; font-weight: 400; }
.nearby-box { background: #edf5ff; border-left: 3px solid #2663c7; padding: 6px 9px; border-radius: 4px; color: #243b5e; font-weight: 400; }
.receipt-wrap { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.receipt-thumb { width: 80px; height: 80px; }
.prod-item { display: flex; gap: 14px; align-items: center; }
.prod-item .body { flex: 1; }
.search-results { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.search-item { display: flex; align-items: center; gap: 8px; text-align: left; padding: 5px 8px; background: #f5f9ff; border: 1px solid #c5d8f7; border-radius: 6px; }
.search-item img { width: 32px; height: 32px; object-fit: cover; border-radius: 4px; }
.sub-field { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; padding: 9px; background: #faf7f2; border: 1px solid #eae2d7; border-radius: 7px; font-weight: 400; }

.inline-add { display: flex; gap: 8px; margin-top: 8px; max-width: 420px; }
.inline-add input { flex: 1; }
.pwd-wrap { display: flex; gap: 6px; align-items: center; }
.pwd-wrap input { flex: 1; }
.pwd-inline { display: inline-flex; gap: 4px; align-items: center; }
.pwd-mask { width: 92px; padding: 2px 6px; font-size: 12.5px; background: #f5f2ed; }
.eye-btn { padding: 5px 9px; flex: none; }

.inline-range { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-top: 10px; }
.inline-range label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }
.inline-range input { width: auto; }
.rep-search-label { display: block; margin-top: 10px; font-weight: 500; max-width: 420px; }
.rep-tbl { width: 100%; border-collapse: collapse; margin-top: 4px; font-size: 12.5px; }
.rep-tbl th, .rep-tbl td { border: 1px solid #e5ded4; padding: 4px 7px; text-align: left; }
.rep-tbl th { background: #f5f0e8; font-weight: 600; color: #3d352e; }
.rep-tbl tbody tr:nth-child(even) { background: #fbf9f6; }

fieldset { border: 1px solid #e2dbd0; border-radius: 10px; }
fieldset legend { font-weight: 600; padding: 0 6px; color: #3d352e; }

.modal-back { position: fixed; inset: 0; background: rgba(25, 20, 15, .42); display: flex; align-items: center; justify-content: center; z-index: 20; }
.modal { background: #fff; border-radius: 12px; padding: 18px 22px; width: min(520px, 94vw); box-shadow: 0 10px 30px rgba(0, 0, 0, .18); }

#soundlog { margin: 12px 16px 32px; font-size: 12.5px; max-width: 1120px; }
#soundlog summary { cursor: pointer; color: #6b6158; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #2b2623; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 50; max-width: 90vw; box-shadow: 0 4px 14px rgba(0, 0, 0, .2); }
.toast.err { background: #c53028; }

@media (max-width: 820px) {
  body { font-size: 13.5px; }
  .hdr { padding: 8px 10px; gap: 6px; }
  .hdr nav button { padding: 5px 8px; min-height: 34px; font-size: 12.5px; }
  #main { padding: 4px 10px 20px; }
  .card { padding: 10px 12px; margin: 8px 0; }
  .order[data-layout="single-row"] .thumb { width: 52px; height: 52px; }
}
@media (max-width: 560px) {
  .order { flex-direction: column; }
  .thumb { width: 88px; height: 88px; }
  #main { padding: 4px 10px 20px; }
  .ack { margin: 8px 10px 4px; }
}

.layers-box { background: #faf7f2; border: 1px dashed #d3c9bc; border-radius: 6px; padding: 6px 8px; margin-bottom: 6px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.layer-picker { display: flex; gap: 6px; align-items: center; }
.layer-picker select { flex: 1; }
.layer-chip { display: inline-flex; align-items: center; gap: 4px; background: #eaf2ff; color: #1f4c99; border: 1px solid #c5dafc; border-radius: 12px; padding: 2px 8px; font-size: 12.5px; }
.chip-x { border: 0; background: transparent; padding: 0 3px; color: #1f4c99; font-weight: 700; cursor: pointer; }
.cf-config-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 8px 0; }
.cf-config-row select { width: auto; }
.cf-multi-box { display: flex; flex-direction: column; gap: 4px; }

.receipt-modal { width: min(460px, 95vw); }
.receipt-paper {
  width: 80mm;
  max-width: 100%;
  margin: 10px auto;
  padding: 12px 10px;
  background: #fffdf8;
  border: 1px dashed #999;
  font-family: ui-monospace, SFMono-Regular, Menlo, "PingFang SC", monospace;
  font-size: 13px;
  line-height: 1.5;
  color: #111;
}
.rcp-title { text-align: center; font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.rcp-sep { text-align: center; color: #777; margin: 4px 0; overflow: hidden; }
.rcp-row { display: flex; gap: 4px; margin: 3px 0; }
.rcp-k { flex: none; font-weight: 600; }
.rcp-v { word-break: break-all; }
.rcp-foot { text-align: center; font-size: 12px; color: #555; margin-top: 4px; }
.query-count { margin: 8px 0; }
.query-form { margin-bottom: 12px; }
.query-range-box { background: #faf7f2; border: 1px solid #eae2d7; border-radius: 8px; padding: 10px 12px; }
.query-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.batch-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; background: #fff9f2; border-color: #f0d7ba; }
.query-check-wrap { margin-right: 4px; font-weight: 600; }

.zoomable { cursor: zoom-in; }
.zoom-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 13, 11, .86);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.zoom-close {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 62;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .45);
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.zoom-stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  touch-action: none;
}
.zoom-content {
  transform-origin: center center;
  transition: transform .05s linear;
  max-width: 94vw;
  max-height: 86vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.zoom-img {
  max-width: 92vw;
  max-height: 84vh;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .45);
}
.zoom-receipt {
  margin: 0;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .45);
}
.zoom-hint {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  color: #e6dfd5;
  background: rgba(0, 0, 0, .5);
  padding: 4px 12px;
  border-radius: 12px;
  pointer-events: none;
}

.offline-banner {
  background: #c53028;
  color: #fff;
  text-align: center;
  padding: 9px 14px;
  font-weight: 600;
  font-size: 13.5px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.sound-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  font-size: 13px;
  border-bottom: 1px solid #e6dfd5;
}
.sound-bar.locked { background: #fff7e6; }
.sound-bar.unlocked { background: #eef9f0; }
