/* 自动提货 · 取件码面单
   热敏纸白底，墨黑粗框线切分区块，驿站绿只给成功 / 当前 / 主操作，红只给错误，琥珀只给缺货和待处理。 */

@font-face {
  font-family: "Barlow Condensed";
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/barlow-condensed-600.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow Condensed";
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/barlow-condensed-700.woff2") format("woff2");
}

:root {
  --paper: #ffffff;
  --wash: #f4f4f1;
  --ink: #141414;
  --ink-2: #545450;
  --ink-3: #74746f;
  --hair: #dededa;
  --field: #8b8b85;

  --green: #0a7a43;
  --green-deep: #075e33;
  --green-wash: #e6f3eb;
  --red: #bf2a1d;
  --red-wash: #fbebe9;
  --amber: #8a4f00;
  --amber-wash: #fdf0d9;

  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --num: "Barlow Condensed", "Arial Narrow", var(--sans);
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, "Courier New", monospace;

  --rule: 2px solid var(--ink);
  --r: 3px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light;
  accent-color: var(--green);
  scrollbar-color: #b9b9b3 transparent;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--green-wash); color: var(--green-deep); }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--green); }
h1, h2, h3 { margin: 0; line-height: 1.3; font-weight: 700; }
p { margin: 0; }
b { font-weight: 700; }
code, .mono { font-family: var(--mono); font-size: .94em; }
code { background: var(--wash); padding: 1px 5px; border-radius: 2px; }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.muted { color: var(--ink-2); }
.small { font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
[hidden] { display: none !important; }

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding-inline: 20px; }

/* ---------------------------------------------------------------- 表单 */
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--paper);
  border: 1.5px solid var(--field);
  border-radius: var(--r);
  padding: 7px 10px;
  min-width: 0;
  min-height: 38px;
  caret-color: var(--green);
  transition: border-color .15s, box-shadow .15s;
}
textarea { width: 100%; resize: vertical; line-height: 1.55; }
select { padding-right: 28px; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-2); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--green-wash); }
::placeholder { color: var(--ink-3); opacity: 1; }
input[type=checkbox] { width: 16px; height: 16px; min-height: 0; margin: 0; vertical-align: middle; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
label.field > input, label.field > select, label.field > textarea { color: var(--ink); font-size: 14px; font-weight: 400; }
.hint { font-size: 12px; color: var(--ink-2); }

/* ---------------------------------------------------------------- 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px;
  padding: 6px 14px;
  border: 1.5px solid var(--ink);
  border-radius: var(--r);
  background: var(--paper);
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .15s, color .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--wash); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-deep); border-color: var(--green-deep); color: #fff; }
.btn.danger { color: var(--red); border-color: var(--red); }
.btn.danger:hover { background: var(--red-wash); color: var(--red); }
.btn.danger-solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger-solid:hover { background: #9e2117; color: #fff; }
.btn.ghost { border-color: transparent; }
.btn.ghost:hover { border-color: var(--hair); }
.btn.big { min-height: 48px; padding: 8px 24px; font-size: 16px; }
.btn.sm { min-height: 30px; padding: 2px 10px; font-size: 13px; }
.btn:disabled, .btn.disabled { opacity: .45; cursor: not-allowed; transform: none; pointer-events: none; }
.btn svg { flex: none; }
/* 行内小按钮：复制、重新下载 */
.btn-inline {
  display: inline-flex; align-items: center; gap: 4px;
  margin-left: 6px; padding: 0 6px;
  border: 1px solid var(--field); border-radius: 2px;
  background: var(--paper); color: var(--ink);
  font: inherit; font-size: 12px; font-weight: 600; line-height: 20px;
  text-decoration: none; cursor: pointer;
}
.btn-inline:hover { border-color: var(--ink); color: var(--ink); }
.btn-inline.disabled, .btn-inline:disabled { opacity: .35; pointer-events: none; }
.link-btn { border: 0; background: none; padding: 0; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: 13px; }
.link-btn:hover { color: var(--ink); }

/* ---------------------------------------------------------------- 印章式状态标签 */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 0 6px;
  border: 1.5px solid currentColor;
  border-radius: 2px;
  font-size: 12px; font-weight: 700; line-height: 18px;
  white-space: nowrap;
  color: var(--ink-2);
}
.tag.ok { color: var(--green); }
.tag.warn { color: var(--amber); }
.tag.bad { color: var(--red); }
.tag.ink { color: var(--ink); }
.tag.solid.ok { background: var(--green); border-color: var(--green); color: #fff; }

/* ---------------------------------------------------------------- 提示条 */
.alert {
  margin-top: 12px;
  padding: 10px 14px;
  border: 1.5px solid currentColor;
  border-radius: var(--r);
  font-weight: 500;
}
.alert.ok { color: var(--green-deep); background: var(--green-wash); }
.alert.warn { color: var(--amber); background: var(--amber-wash); }
.alert.bad { color: var(--red); background: var(--red-wash); }
.alert .help-line { display: block; margin-top: 4px; font-weight: 400; color: var(--ink-2); }

/* ---------------------------------------------------------------- 面单 */
.slip { border: var(--rule); border-radius: var(--r); background: var(--paper); }
.slip-head {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 18px;
  border-bottom: var(--rule);
}
.slip-head h2, .slip-head h1 { font-size: 17px; }
.slip-body { padding: 18px; }
.slip + .slip { margin-top: 20px; }

/* 条码：手排的不重复条宽，只在面单头部做标识，不承载信息 */
.barcode {
  display: inline-block; flex: none;
  width: 116px; height: 26px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 116 26' preserveAspectRatio='none'%3E%3Cg fill='%23141414'%3E%3Crect x='0' width='2' height='26'/%3E%3Crect x='4' width='2' height='26'/%3E%3Crect x='7' width='2' height='26'/%3E%3Crect x='11' width='1' height='26'/%3E%3Crect x='13' width='2' height='26'/%3E%3Crect x='17' width='2' height='26'/%3E%3Crect x='20' width='1' height='26'/%3E%3Crect x='22' width='1' height='26'/%3E%3Crect x='26' width='2' height='26'/%3E%3Crect x='29' width='1' height='26'/%3E%3Crect x='32' width='2' height='26'/%3E%3Crect x='35' width='1' height='26'/%3E%3Crect x='38' width='4' height='26'/%3E%3Crect x='44' width='4' height='26'/%3E%3Crect x='49' width='1' height='26'/%3E%3Crect x='51' width='1' height='26'/%3E%3Crect x='53' width='1' height='26'/%3E%3Crect x='55' width='3' height='26'/%3E%3Crect x='60' width='1' height='26'/%3E%3Crect x='63' width='3' height='26'/%3E%3Crect x='67' width='4' height='26'/%3E%3Crect x='74' width='2' height='26'/%3E%3Crect x='78' width='1' height='26'/%3E%3Crect x='82' width='1' height='26'/%3E%3Crect x='84' width='1' height='26'/%3E%3Crect x='87' width='4' height='26'/%3E%3Crect x='93' width='1' height='26'/%3E%3Crect x='95' width='2' height='26'/%3E%3Crect x='98' width='2' height='26'/%3E%3Crect x='102' width='3' height='26'/%3E%3Crect x='106' width='4' height='26'/%3E%3C/g%3E%3C/svg%3E") center / 100% 100% no-repeat;
}

/* 撕线：面单打印出来时的齿孔 */
.tear { position: relative; height: 0; border-top: 2px dashed var(--ink); margin: 0 10px; }
.tear::before, .tear::after {
  content: ""; position: absolute; top: -9px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--paper); border: var(--rule);
}
.tear::before { left: -20px; clip-path: inset(0 0 0 50%); }
.tear::after { right: -20px; clip-path: inset(0 50% 0 0); }

/* 字段：面单上「收件人」那种小标签 + 内容 */
.fl { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); letter-spacing: .02em; }

/* 统计条：同尺寸格子共用一条基线，竖线分隔 */
.ledger {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  border: var(--rule); border-radius: var(--r);
  margin-bottom: 20px;
  overflow: hidden;
}
.ledger > div { padding: 12px 16px 10px; border-right: 1px solid var(--hair); box-shadow: 0 1px 0 var(--hair); min-height: 86px; }
.ledger > div:last-child { border-right: 0; }
.ledger .v { display: block; margin-top: 2px; font-family: var(--num); font-weight: 700; font-size: 34px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.ledger .v small { font-size: 15px; font-weight: 600; color: var(--ink-2); margin-left: 3px; }
.ledger .v.mono { font-family: var(--mono); font-size: 18px; font-weight: 600; line-height: 1.9; }
.ledger .sub { display: block; font-size: 12px; color: var(--ink-2); }

/* ---------------------------------------------------------------- 表格：说明书参数表的密度 */
.table-wrap { overflow-x: auto; margin-top: 14px; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 9px 10px; vertical-align: top; }
th { font-size: 12px; font-weight: 700; color: var(--ink-2); white-space: nowrap; border-bottom: var(--rule); }
td { border-bottom: 1px solid var(--hair); }
tbody tr:hover td { background: #fafaf8; }
td.num, th.num { text-align: right; }
td.num { font-family: var(--num); font-size: 16px; font-weight: 600; }
td.empty { color: var(--ink-2); padding: 22px 10px; text-align: center; }
/* ---------------------------------------------------------------- 图表 */
.chart-wrap { position: relative; }
#chart svg { display: block; width: 100%; height: auto; }
#chart .grid { stroke: var(--hair); stroke-width: 1; }
#chart .baseline { stroke: var(--ink); stroke-width: 1.5; }
#chart .ytick, #chart .xtick, #chart .daytotal {
  font-family: var(--sans); font-variant-numeric: tabular-nums; fill: var(--ink-2);
}
#chart .ytick { font-size: 11px; text-anchor: end; }
#chart .xtick { font-size: 11px; text-anchor: middle; }
#chart .daytotal { font-size: 11px; font-weight: 700; text-anchor: middle; fill: var(--ink); }
#chart .hit { fill: transparent; }
#chart .hit:hover { fill: rgb(20 20 20 / .04); }
.empty-chart { padding: 48px 0; text-align: center; color: var(--ink-2); }

.chart-tip {
  position: absolute; top: 4px; z-index: 5;
  min-width: 150px; padding: 8px 10px;
  border: 1.5px solid var(--ink); border-radius: var(--r);
  background: var(--paper); box-shadow: 0 6px 18px rgb(20 20 20 / .14);
  font-size: 12px; line-height: 1.7; pointer-events: none;
}
.chart-tip > b { display: block; font-family: var(--num); font-size: 15px; margin-bottom: 2px; }
.tip-row { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.tip-row b { margin-left: auto; font-variant-numeric: tabular-nums; }
.tip-row i, .legend i { width: 10px; height: 10px; flex: none; border-radius: 2px; }
.tip-total { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--hair); color: var(--ink-2); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 13px; }
.lg { display: inline-flex; align-items: center; gap: 6px; }

/* 指标切换 */
.seg { display: inline-flex; margin-left: auto; border: 1.5px solid var(--ink); border-radius: var(--r); overflow: hidden; }
.seg button {
  border: 0; border-left: 1px solid var(--hair); background: var(--paper); color: var(--ink-2);
  padding: 5px 12px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.seg button:first-child { border-left: 0; }
.seg button:hover { background: var(--wash); color: var(--ink); }
.seg button.on { background: var(--ink); color: #fff; }

/* 销售每日明细：日期行用浅底和上框线分组 */
tr.day-head td { border-top: 2px solid var(--ink); background: #fafaf8; }
tr.day-head + tr td { border-top: 0; }
table.wide { min-width: 1080px; }
table.wide td:first-child { min-width: 120px; }
td .sub { display: block; font-size: 12px; color: var(--ink-2); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 14px; }

/* ---------------------------------------------------------------- 验证码 */

/* ---------------------------------------------------------------- 弹窗 & 提示 */
dialog {
  width: min(520px, calc(100% - 32px));
  padding: 0;
  border: var(--rule); border-radius: var(--r);
  background: var(--paper); color: var(--ink);
  box-shadow: 0 18px 48px rgb(20 20 20 / .22);
}
dialog::backdrop { background: rgb(20 20 20 / .4); }
dialog .dlg-head { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-bottom: var(--rule); }
dialog .dlg-head h2 { font-size: 16px; flex: 1; }
dialog .dlg-body { padding: 16px 18px; }
dialog .dlg-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 0 18px 16px; }
dialog[open] { animation: dlg-in .22s var(--ease); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px); } }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 100;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 9px 18px;
  border-radius: var(--r);
  background: var(--ink); color: #fff; font-weight: 500;
  animation: toast-in .25s var(--ease);
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------------------------------------------------------------- 后台框架（站长 / 代理共用） */
.console-top { border-bottom: var(--rule); background: var(--paper); position: sticky; top: 0; z-index: 20; }
.console-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding-block: 12px; }
.console-title { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; }
.console-title .tag { font-size: 12px; }
.console-who { font-size: 13px; color: var(--ink-2); }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; margin-bottom: -2px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: none;
  padding: 9px 14px 11px;
  border: 0; border-bottom: 3px solid transparent;
  background: none; color: var(--ink-2);
  font-weight: 600; cursor: pointer;
}
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--ink); border-bottom-color: var(--green); }
.console-main { padding-block: 24px 72px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.section-title h2 { font-size: 16px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.toolbar .sel { font-size: 13px; color: var(--ink-2); margin-right: auto; }

.drop {
  display: grid; place-items: center; gap: 4px;
  min-height: 132px; padding: 22px;
  border: 2px dashed var(--field); border-radius: var(--r);
  text-align: center; cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.drop:hover, .drop.over { border-color: var(--green); background: var(--green-wash); }
.progress { height: 6px; margin-top: 10px; background: var(--wash); border-radius: 1px; overflow: hidden; }
.progress > div { height: 100%; background: var(--green); transform: scaleX(0); transform-origin: left; transition: transform .2s; }
.codes-out { min-height: 168px; font-family: var(--mono); font-size: 13px; background: var(--wash); }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
pre.preview { max-height: 62vh; margin: 0; padding: 12px; overflow: auto; background: var(--wash); border-radius: 2px; white-space: pre-wrap; word-break: break-all; font-family: var(--mono); font-size: 12px; }
.ua { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 设置页「上传 API」：左边配置，右边调用示例，窄屏上下排 */
.api-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.api-grid pre.preview { margin-top: 6px; }
@media (max-width: 860px) { .api-grid { grid-template-columns: minmax(0, 1fr); } }

/* 登录：一张小面单 */
.login { max-width: 400px; margin: 10vh auto 0; padding-inline: 16px; }
.login form { display: flex; flex-direction: column; gap: 12px; }

@media (max-width: 640px) {
  .wrap { padding-inline: 16px; }
  .slip-head { padding: 10px 14px; }
  .slip-body { padding: 14px; }
  .ledger { grid-template-columns: repeat(2, 1fr); }
  .ledger > div:nth-child(2n) { border-right: 0; }
  .ledger > div:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .ledger .v { font-size: 28px; }
  .console-bar { gap: 10px; }
  /* 后台表单在手机上一项一行 */
  .console-main form.row > label.field,
  .console-main form.row > input { flex: 1 1 100%; width: 100% !important; }
  .console-main form.row label.field > input,
  .console-main form.row label.field > select { width: 100% !important; }
  .console-main form.row > .btn { flex: 1; }

  /* 代理表：每个代理折成一张单据。名字 + 状态 / 六格数字 / 最近 / 操作 */
  table.agents { min-width: 0; }
  table.agents thead { display: none; }
  table.agents, table.agents tbody { display: block; }
  table.agents tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 8px; padding: 14px 0; border-bottom: 1px solid var(--hair); }
  table.agents td { padding: 0; border: 0; background: none !important; }
  table.agents td.empty { grid-column: 1 / -1; }
  table.agents .a-name { grid-column: 1 / 3; min-width: 0; }
  table.agents .a-state { grid-column: 3; justify-self: end; }
  table.agents td.num { text-align: left; }
  table.agents td[data-label]::before { content: attr(data-label); display: block; font-family: var(--sans); font-size: 12px; font-weight: 600; color: var(--ink-2); }
  table.agents .a-recent, table.agents .a-actions { grid-column: 1 / -1; }
  table.agents .a-actions .row { min-width: 0 !important; }
  table.agents .a-actions .btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
