/* ==========================================================================
   当先软件*建材系统 · 手机端优先样式
   主色：橙 #f97316 / 底 #f5f6f8 / 白底圆角卡片
   尺寸用 px，375px 宽手机上为基准；桌面端居中成 680px 的“手机视口”。
   ========================================================================== */

:root {
  --brand: #f97316;
  --brand2: #fb923c;
  --brand-d: #ea580c;
  --brand-l: #fff4ec;
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #eef0f3;
  --line2: #e4e7ec;
  --t1: #1f2329;
  --t2: #3d444d;
  --t3: #6b7280;
  --t4: #9aa1ab;
  --ok: #16a34a;
  --red: #e11d48;
  --amber: #d97706;
  --radius: 14px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html {
  height: 100%;
  /* 🔴 全站禁止整页左右拖动：
     · overflow-x: hidden —— 任何比视口宽的元素都不再给整页一个横向滚动区；
     · overscroll-behavior-x: none —— 顺带禁掉 iOS / 安卓的横向橡皮筋回弹；
     · width / max-width: 100% —— 防止子元素把根元素撑宽。 */
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--t2);
  background: #eceef2;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#nav, #screen, #tabbar {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
}

/* ---------------- 顶部导航 ---------------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  height: calc(50px + var(--safe-t));
  padding: var(--safe-t) 8px 0;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.nav__side { width: 72px; display: flex; align-items: center; }
.nav__side--r { justify-content: flex-end; }
.nav__title {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--t1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav__back { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; color: var(--t1); border-radius: 10px; cursor: pointer; }
.nav__back:active { background: #f3f4f7; }
.nav__btn {
  font-size: 14px;
  font-weight: 600;
  color: var(--brand-d);
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
}
.nav__btn:active { background: var(--brand-l); }
.ico { display: block; }

/* ---------------- 页面容器 ---------------- */
.screen {
  flex: 1;
  padding-bottom: 28px;
  min-height: calc(100vh - 50px);
  background: var(--bg);
  /* clip 不会新建纵向滚动容器（用 hidden 会）—— 只把横向溢出的内容裁掉 */
  overflow-x: clip;
}
body.has-tab .screen { padding-bottom: calc(66px + var(--safe-b)); }
.screen--withbar { padding-bottom: 90px; }

.pad { padding: 12px; }

/* ---------------- 底部标签栏 ---------------- */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  height: calc(56px + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(255, 255, 255, .97);
  backdrop-filter: saturate(180%) blur(8px);
  border-top: 1px solid var(--line);
}
.tabbar__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #9aa1ab;
  font-size: 11px;
  cursor: pointer;
  transition: color .15s;
}
.tabbar__item.is-on { color: var(--brand); }
.tabbar__item.is-on .ico { transform: translateY(-1px); }

/* ---------------- 首页 ---------------- */
.hero {
  background: linear-gradient(140deg, #fb923c 0%, #f97316 58%, #ea580c 100%);
  padding: 16px 16px 46px;
  color: #fff;
  border-radius: 0 0 22px 22px;
  position: relative;
  /* 🔴 右上装饰圆是 right:-40px，会把文档撑宽 40px（首页能左右拖的根因）⇒ 裁在容器里 */
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  right: -40px; top: -40px;
  width: 160px; height: 160px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
}
.hero__top { display: flex; align-items: flex-start; justify-content: space-between; }
.hero__hi { font-size: 17px; font-weight: 600; letter-spacing: .3px; }
.hero__shop { font-size: 12px; opacity: .9; margin-top: 3px; }
.hero__date { font-size: 12px; opacity: .9; padding-top: 3px; }
.hero__grid {
  display: flex;
  margin-top: 18px;
  background: rgba(255, 255, 255, .16);
  border-radius: 14px;
  padding: 12px 0;
  position: relative;
  z-index: 1;
}
.hero__cell { flex: 1; text-align: center; }
.hero__cell + .hero__cell { border-left: 1px solid rgba(255, 255, 255, .22); }
.hero__cell span { display: block; font-size: 11.5px; opacity: .92; }
.hero__cell b { display: block; margin-top: 3px; font-size: 17px; font-weight: 700; letter-spacing: .3px; }

.grid-menu {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  background: #fff;
  border-radius: var(--radius);
  padding: 14px 6px 8px;
  margin-top: -34px;
  position: relative;
  z-index: 2;
  box-shadow: 0 4px 16px rgba(24, 30, 45, .06);
}
.menu-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 8px 2px 12px;
  border-radius: 12px;
  cursor: pointer;
  position: relative;
}
.menu-item:active { background: #fafbfc; }
.menu-item__ico {
  width: 42px; height: 42px;
  border-radius: 13px;
  background: var(--brand-l);
  color: var(--brand-d);
  display: flex; align-items: center; justify-content: center;
}
.menu-item__txt { font-size: 12.5px; color: var(--t2); }
.menu-item .dot {
  position: absolute; top: 6px; right: 50%; margin-right: -22px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--red);
}

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  margin: 12px;
  box-shadow: 0 2px 10px rgba(24, 30, 45, .045);
}
.pad > .card { margin: 12px 0; }
.card--plain { box-shadow: none; background: transparent; text-align: center; }
.card--hint { background: var(--brand-l); box-shadow: none; }
.card__hd { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.card__title { font-size: 14.5px; font-weight: 600; color: var(--t1); }
.card__more { font-size: 12.5px; color: var(--brand-d); cursor: pointer; padding: 2px 2px; }
.hint__t { font-size: 13.5px; font-weight: 600; color: var(--brand-d); margin-bottom: 4px; }
.hint__b { font-size: 12.5px; color: #7c5a3a; line-height: 1.65; }
.card--hint .hint__b { color: #8a5a2b; }

/* 列表行 */
.li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.li:last-child { border-bottom: none; }
.li__main { flex: 1; min-width: 0; }
.li__t { font-size: 14px; color: var(--t1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li__s { font-size: 11.5px; color: var(--t4); margin-top: 2px; }
.li__r { text-align: right; flex: none; }
.li__amt { font-size: 14.5px; font-weight: 600; color: var(--t1); }
.li__amt--warn { color: var(--red); }

.empty { text-align: center; color: var(--t4); font-size: 13px; padding: 34px 16px; }

/* ---------------- 工具栏 / 搜索 ---------------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 4px;
}
.search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--line2);
  border-radius: 11px;
  padding: 0 10px;
  height: 38px;
  color: var(--t4);
}
.search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  color: var(--t1);
  min-width: 0;
}
.tool-btn {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: #fff;
  border: 1px solid var(--line2);
  border-radius: 11px;
  color: var(--t3);
  cursor: pointer;
}
.tool-btn:active { background: #f3f4f7; }

.sumline { padding: 8px 12px 6px; font-size: 12px; color: var(--t3); }
.sumline b { color: var(--brand-d); font-weight: 600; }
.warn-text { color: var(--red); }

/* ---------------- 分段标签 ---------------- */
.tabs {
  display: flex;
  gap: 4px;
  background: #eef0f4;
  padding: 4px;
  border-radius: 12px;
  margin: 10px 12px 2px;
}
.tab {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  font-size: 13px;
  color: var(--t3);
  border-radius: 9px;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
}
.tab.is-on { background: #fff; color: var(--t1); font-weight: 600; box-shadow: 0 1px 4px rgba(24, 30, 45, .08); }
.tab__num {
  font-style: normal;
  font-size: 10px;
  background: var(--brand);
  color: #fff;
  border-radius: 8px;
  padding: 0 4px;
  margin-left: 3px;
  vertical-align: 1px;
}

/* ---------------- 表格 ---------------- */
.tw {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 6px 12px 0;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(24, 30, 45, .045);
}
.table { display: table; width: 100%; border-collapse: separate; border-spacing: 0; }
.tr { display: table-row; }
.th, .td {
  display: table-cell;
  padding: 10px 9px;
  font-size: 12.8px;
  color: var(--t2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  vertical-align: middle;
}
.tr:last-child .td { border-bottom: none; }
.th {
  background: #fafbfc;
  color: var(--t3);
  font-weight: 500;
  font-size: 12px;
  border-bottom: 1px solid var(--line2);
}
.th--num, .td.th--num { text-align: right; }
.tr--head .th:first-child { position: sticky; left: 0; z-index: 3; background: #fafbfc; }
.td:first-child { position: sticky; left: 0; z-index: 2; background: #fff; }
.tr--warn .td { background: #fff7ed; color: var(--red); }
.tr--sum .td { font-weight: 600; color: var(--t1); background: #fafbfc; }
.tr[data-id], .tr[data-doc] { cursor: pointer; }
.tr[data-id]:active .td, .tr[data-doc]:active .td { background: #f7f8fa; }
.arrow { font-style: normal; font-size: 9px; margin-left: 3px; color: var(--brand); }

/* ---------------- 产品列表：采购量直接填 ---------------- */
/* 采购列吸在右边：产品列很多时手机不用左右滑也能改数量 */
/* 有采购列时单元格收紧一点，给左侧资料列多留出可视宽度 */
.table--buy .td, .table--buy .th { padding: 10px 7px; }
.td--buy, .th--buy {
  position: sticky;
  right: 0;
  z-index: 2;
  background: #fff;
  /* 左侧投影：告诉用户右边这列是「钉住」的，不是把前一列截断了 */
  box-shadow: -7px 0 9px -7px rgba(24, 30, 45, .22);
}
.tr--head .th--buy { z-index: 3; background: #fafbfc; box-shadow: -7px 0 9px -7px rgba(24, 30, 45, .16); }
.td--buy.is-on { background: var(--brand-l); }
.qty-in {
  width: 62px;
  height: 30px;
  padding: 0 7px;
  border: 1px solid var(--line2);
  border-radius: 8px;
  background: #fafbfc;
  color: var(--t1);
  font-family: inherit;
  font-size: 13px;
  text-align: right;
  outline: none;
}
.qty-in::placeholder { color: #c2c7cf; }
.qty-in:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(249, 115, 22, .12); }
.td--buy.is-on .qty-in { border-color: var(--brand2); background: #fff; color: var(--brand-d); font-weight: 600; }
.qty-in:disabled { background: #f3f4f7; color: var(--t4); }

/* 离开输入框即保存：保存中给个轻轻的呼吸，存好闪一下绿色，让用户知道真写进库了 */
.td--buy.is-saving .qty-in {
  border-color: var(--brand2);
  background: #fff;
  /* 保存请求在路上，边框脉冲提示「正在写」 */
  animation: qty-saving .75s ease-in-out infinite;
}
.td--buy.is-saved { background: #eefaf1; }
.td--buy.is-saved .qty-in { border-color: var(--ok); background: #fff; }
@keyframes qty-saving {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251, 146, 60, .38); }
  50% { box-shadow: 0 0 0 4px rgba(251, 146, 60, .06); }
}
/* 关闭动效的系统偏好下不做脉冲 */
@media (prefers-reduced-motion: reduce) {
  .td--buy.is-saving .qty-in { animation: none; box-shadow: 0 0 0 3px rgba(251, 146, 60, .16); }
}

/* 采购汇总条：只在填了数量后出现，贴在屏幕底部 */
.pbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  z-index: 45;
  width: 100%;
  max-width: 680px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px calc(9px + var(--safe-b));
  background: rgba(255, 255, 255, .98);
  backdrop-filter: saturate(180%) blur(8px);
  border-top: 1px solid var(--line2);
  box-shadow: 0 -6px 18px rgba(24, 30, 45, .07);
}
.pbar__info { flex: 1; min-width: 0; font-size: 12px; color: var(--t3); line-height: 1.4; }
.pbar__info b { color: var(--brand-d); font-size: 15px; font-weight: 700; }
.pbar__btn {
  flex: none;
  height: 38px;
  padding: 0 15px;
  border: 1px solid var(--brand);
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.pbar__btn:active { background: var(--brand-d); }
.pbar__btn--ghost { background: #fff; border-color: var(--line2); color: var(--t3); font-weight: 500; }
.pbar__btn--ghost:active { background: #f3f4f7; }
/* 字段设置：有改动没保存时的提醒条 */
.pbar--warn { border-top-color: #fcd34d; }
.pbar--warn .pbar__info { color: #b45309; font-weight: 600; font-size: 13px; }

/* ---------------- 单据卡片 ---------------- */
.doc {
  background: #fff;
  border-radius: 13px;
  margin: 10px 12px 0;
  padding: 12px 13px;
  box-shadow: 0 2px 10px rgba(24, 30, 45, .045);
  cursor: pointer;
}
.doc:active { background: #fcfcfd; }
.doc__hd { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.doc__no { font-size: 13.5px; font-weight: 600; color: var(--t1); letter-spacing: .3px; }
.doc__mid { display: flex; align-items: baseline; justify-content: space-between; margin-top: 7px; }
.doc__cust { font-size: 14px; color: var(--t1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc__date { font-size: 11.5px; color: var(--t4); flex: none; margin-left: 8px; }
.doc__ft {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 9px; padding-top: 9px; border-top: 1px dashed var(--line2);
}
.doc__items { font-size: 11.5px; color: var(--t4); }
.doc__amt { font-size: 16px; font-weight: 700; color: var(--brand-d); }
.doc__debt { font-size: 11.5px; color: var(--red); margin-top: 3px; text-align: right; }

/* ---------------- 单据详情 ---------------- */
.doc-hero {
  background: linear-gradient(140deg, #fb923c, #f97316 60%, #ea580c);
  color: #fff;
  padding: 18px 16px 20px;
  border-radius: 0 0 22px 22px;
}
.doc-hero__no { font-size: 18px; font-weight: 700; letter-spacing: .5px; }
.doc-hero__cust { font-size: 13px; opacity: .95; margin-top: 4px; }
.doc-hero__row { display: flex; margin-top: 16px; background: rgba(255,255,255,.16); border-radius: 12px; padding: 10px 0; }
.doc-hero__row > div { flex: 1; text-align: center; }
.doc-hero__row > div + div { border-left: 1px solid rgba(255,255,255,.2); }
.doc-hero__row span { display: block; font-size: 11px; opacity: .9; }
.doc-hero__row b { font-size: 15px; }

.kv { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.kv:last-child { border-bottom: none; }
.kv__k { color: var(--t3); }
.kv__v { color: var(--t1); font-weight: 600; }
.kv__v--warn { color: var(--red); }

/* ---------------- 财务统计 ---------------- */
.fin-stats {
  display: flex;
  gap: 8px;
  padding: 12px 12px 2px;
}
.fin-stat {
  flex: 1;
  background: #fff;
  border-radius: 13px;
  padding: 11px 10px;
  box-shadow: 0 2px 10px rgba(24, 30, 45, .045);
}
.fin-stat span { display: block; font-size: 11.5px; color: var(--t4); }
.fin-stat b { display: block; font-size: 16px; margin-top: 3px; color: var(--t1); letter-spacing: .2px; }
.fin-stat b.ok { color: var(--ok); }
.fin-stat b.warn { color: var(--red); }

/* ---------------- 查询打印 ---------------- */
.qp-filters { padding: 12px 12px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 7px 13px;
  border-radius: 20px;
  background: #fff;
  border: 1px solid var(--line2);
  font-size: 13px;
  color: var(--t3);
  cursor: pointer;
}
.chip.is-on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.date-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.date-row .input { flex: 1; background: #fff; }
.date-row__sep { color: var(--t4); font-size: 12px; }
.btn-row { display: flex; gap: 9px; margin-top: 12px; }
.btn-row .btn { flex: 1; margin: 0; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line2);
  border-radius: 12px;
  background: #fff;
  color: var(--t1);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: linear-gradient(135deg, #fb923c, #f97316);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 16px rgba(249, 115, 22, .28);
}
.btn--danger { background: #fff5f6; border-color: #ffd9e0; color: var(--red); }
.btn--ghost { background: #f7f8fa; border-color: var(--line2); color: var(--t2); }
.btn--full { width: 100%; }

/* ---------------- 表单 ---------------- */
.form { background: #fff; border-radius: var(--radius); padding: 14px; box-shadow: 0 2px 10px rgba(24, 30, 45, .045); }
.fld { display: block; margin-bottom: 13px; }
.fld:last-child { margin-bottom: 0; }
.fld__label { display: block; font-size: 12.5px; color: var(--t3); margin-bottom: 6px; }
.fld__label .req { color: var(--red); font-style: normal; margin-left: 2px; }
.input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line2);
  border-radius: 10px;
  background: #fbfbfd;
  font-size: 16px;
  color: var(--t1);
  font-family: inherit;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.input:focus { border-color: var(--brand); background: #fff; }
.input[readonly] { background: #f3f4f7; color: var(--brand-d); font-weight: 600; }
textarea.input { resize: vertical; min-height: 62px; line-height: 1.5; }
select.input {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa1ab' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.fld-row { display: flex; gap: 10px; }
.fld-row .fld { flex: 1; margin-bottom: 13px; }
.switch { position: relative; display: inline-block; width: 48px; height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0; border-radius: 28px; background: #d8dce3;
  transition: .18s; cursor: pointer;
}
.switch span::before {
  content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px; transition: .18s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::before { transform: translateX(20px); }

/* ---------------- 团队 ---------------- */
.person {
  display: flex; align-items: center; gap: 11px;
  background: #fff; border-radius: 13px; padding: 12px;
  margin: 10px 12px 0;
  box-shadow: 0 2px 10px rgba(24, 30, 45, .045);
  cursor: pointer;
}
.pad .person { margin: 10px 0 0; }
.person__av {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #fdba74, #f97316);
  color: #fff; font-size: 16px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; flex: none;
}
.person__main { flex: 1; min-width: 0; }
.person__t { font-size: 14.5px; color: var(--t1); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.person__s { font-size: 11.5px; color: var(--t4); margin-top: 2px; }
.person__r { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.person__post { font-size: 11.5px; color: var(--t4); }

/* ---------------- 我的 ---------------- */
.me {
  display: flex; align-items: center; gap: 13px;
  background: #fff; border-radius: var(--radius); padding: 16px;
  box-shadow: 0 2px 10px rgba(24, 30, 45, .045);
}
.me__av {
  width: 52px; height: 52px; border-radius: 16px;
  background: linear-gradient(135deg, #fdba74, #f97316);
  color: #fff; font-size: 22px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.me__name { font-size: 17px; font-weight: 600; color: var(--t1); }
.me__sub { font-size: 12px; color: var(--t4); margin-top: 3px; }
.menu-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 2px; border-bottom: 1px solid var(--line);
  font-size: 14px; color: var(--t1); cursor: pointer;
}
.menu-row:last-child { border-bottom: none; }
.menu-row i { color: var(--t4); font-style: normal; }
.link-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.link-item {
  background: #f7f8fa; border-radius: 10px; padding: 10px 8px;
  text-align: center; font-size: 13px; color: var(--t2); cursor: pointer;
}
.link-item span { display: block; font-size: 10.5px; color: var(--t4); margin-top: 2px; }
.bk { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.bk:last-child { border-bottom: none; }
.bk__t { font-size: 12.5px; color: var(--t1); }
.bk__s { font-size: 11px; color: var(--t4); margin-top: 2px; }
.bk__ops { display: flex; gap: 8px; flex: none; }
.mini { font-size: 12px; color: var(--brand-d); cursor: pointer; padding: 2px 0; }
.mini--danger { color: var(--red); }
.mini--off { color: var(--t4); cursor: default; }
.about { font-size: 12.5px; color: var(--t3); line-height: 1.8; }
.about span { color: var(--t4); font-size: 11.5px; }

/* ---------------- 字段设置 ---------------- */
.frow { background: #fff; border-radius: 12px; padding: 11px; margin-bottom: 9px; box-shadow: 0 1px 6px rgba(24, 30, 45, .04); }
.frow__hd { display: flex; align-items: center; gap: 8px; }
.frow__label { flex: 1; font-size: 15px; }
.frow__key { font-size: 10.5px; color: var(--t4); font-family: ui-monospace, Menlo, Consolas, monospace; flex: none; }
.frow__opts { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.input--sm { width: auto; padding: 6px 9px; font-size: 12.5px; border-radius: 8px; flex: none; }
.ck { display: flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--t3); }
.ck input { accent-color: var(--brand); }
.frow__ops { display: flex; gap: 12px; margin-top: 8px; }

/* ---------------- 弹层 / 提示 ---------------- */
.mask {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(15, 20, 30, .42);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadein .16s ease-out;
}
.mask--center { align-items: center; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: 100%; max-width: 680px;
  background: #fff;
  border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(18px + var(--safe-b));
  max-height: 86vh;
  overflow-y: auto;
  animation: slideup .2s ease-out;
}
@keyframes slideup { from { transform: translateY(30px); } to { transform: translateY(0); } }
.sheet__title { font-size: 16px; font-weight: 600; color: var(--t1); margin-bottom: 6px; }
.sheet__tip { font-size: 13px; color: var(--t3); line-height: 1.7; margin-bottom: 12px; }
.sheet__btns { display: flex; gap: 10px; margin-top: 16px; }
.sheet__btn {
  flex: 1; text-align: center; padding: 12px; border-radius: 11px;
  background: #f3f4f7; color: var(--t2); font-size: 15px; font-weight: 600; cursor: pointer;
}
.sheet__btn--primary { background: linear-gradient(135deg, #fb923c, #f97316); color: #fff; }
.sheet__btn--danger { background: #fff1f3; color: var(--red); }
.col-pick { max-height: 46vh; overflow-y: auto; }
.col-pick__row {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 2px; border-bottom: 1px solid var(--line); font-size: 14px;
}
.col-pick__row input { width: 17px; height: 17px; accent-color: var(--brand); }
.help p { font-size: 13px; color: var(--t2); line-height: 1.75; margin: 0 0 10px; }
.help b { color: var(--t1); }

.dlg {
  background: #fff; border-radius: 16px; padding: 26px 30px;
  min-width: 150px; text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
}
.dlg__body { font-size: 13.5px; color: var(--t2); margin-top: 12px; }
.spinner {
  width: 30px; height: 30px; margin: 0 auto;
  border: 3px solid #ffe3cc; border-top-color: var(--brand);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast-wrap {
  position: fixed; left: 0; right: 0; bottom: 120px;
  z-index: 80; display: flex; flex-direction: column;
  align-items: center; gap: 8px; pointer-events: none;
}
.toast {
  background: rgba(24, 28, 36, .9);
  color: #fff;
  font-size: 13.5px;
  padding: 9px 16px;
  border-radius: 20px;
  max-width: 80%;
  text-align: center;
  animation: fadein .16s;
}

/* ---------------- 徽章 ---------------- */
.badge {
  display: inline-block;
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 7px;
  background: #f1f2f5;
  color: var(--t3);
  white-space: nowrap;
}
.badge--ok { background: #eaf8ef; color: var(--ok); }
.badge--warn { background: var(--brand-l); color: var(--brand-d); }
.badge--off { background: #f3f4f7; color: var(--t4); }
.badge--primary { background: var(--brand-l); color: var(--brand-d); }

/* ---------------- 登录 ---------------- */
.login { min-height: calc(100vh - 50px); padding: 34px 22px 30px; background: #fff; text-align: center; }
.login__logo {
  width: 66px; height: 66px; border-radius: 20px; margin: 0 auto 14px;
  background: linear-gradient(135deg, #fb923c, #ea580c);
  color: #fff; font-size: 30px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 24px rgba(249, 115, 22, .3);
}
.login__title { font-size: 19px; font-weight: 700; color: var(--t1); letter-spacing: .3px; }
.login__sub { font-size: 12.5px; color: var(--t4); margin-top: 6px; }
.login__card { margin-top: 26px; text-align: left; }
.lg__row { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line2); padding: 12px 2px; }
.lg__row span { font-size: 13.5px; color: var(--t3); width: 44px; flex: none; }
.lg__row input { flex: 1; border: none; outline: none; font-size: 16px; background: transparent; color: var(--t1); min-width: 0; }
.lg__btn {
  width: 100%; margin-top: 24px; padding: 13px; border: none; border-radius: 12px;
  background: linear-gradient(135deg, #fb923c, #f97316);
  color: #fff; font-size: 16px; font-weight: 600; cursor: pointer;
  box-shadow: 0 8px 20px rgba(249, 115, 22, .3);
  font-family: inherit;
}
.lg__btn:disabled { opacity: .7; }
.login__tip { margin-top: 24px; font-size: 11.5px; color: var(--t4); line-height: 1.75; text-align: left; }
.login__foot { margin-top: 22px; font-size: 11px; color: #c2c7cf; }


/* 单据里的产品行 */
.sellines { margin-top: 2px; }
.selline {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer;
}
.selline:last-child { border-bottom: none; }
.selline__l { flex: 1; min-width: 0; }
.selline__l b { display: block; font-size: 13.5px; font-weight: 500; color: var(--t1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selline__l span { display: block; font-size: 11.5px; color: var(--t4); margin-top: 2px; }
.selline__r { text-align: right; flex: none; }
.selline__r b { display: block; font-size: 14px; color: var(--t1); }
.selline__r .badge { margin-top: 3px; }

/* ---------------- 打印 ---------------- */
#print-area { display: none; width: 100%; }
.pr-sheet { color: #000; font-size: 12px; width: 100%; }
.pr-head { text-align: center; margin-bottom: 8px; }
.pr-shop { font-size: 20px; font-weight: 700; letter-spacing: 2px; }
.pr-title { font-size: 15px; margin-top: 2px; letter-spacing: 4px; }
.pr-sub { font-size: 11px; color: #333; margin-top: 2px; }
.pr-meta { font-size: 10.5px; color: #444; margin-top: 2px; }
.pr-info { font-size: 11.5px; margin: 8px 0; }
.pr-table { width: 100%; border-collapse: collapse; }
.pr-table th, .pr-table td { border: 1px solid #666; padding: 4px 6px; font-size: 11.5px; }
.pr-table th { background: #f2f2f2; font-weight: 600; }
.pr-table .r { text-align: right; }
.pr-table tbody tr:nth-child(even) td { background: #fafafa; }
.pr-sign { display: flex; justify-content: space-between; margin-top: 22px; font-size: 12px; }
.pr-note { margin-top: 16px; font-size: 10.5px; color: #333; }
.pr-foot { margin-top: 6px; font-size: 10px; color: #555; text-align: right; }

@media print {
  @page { size: A4 portrait; margin: 12mm; }
  html, body { background: #fff !important; display: block !important; }
  body.is-printing > * { display: none !important; }
  body.is-printing #print-area { display: block !important; }
  .pr-table { page-break-inside: auto; }
  .pr-table thead { display: table-header-group; }
  .pr-table tr { page-break-inside: avoid; }
  .pr-table th, .pr-table td { border-color: #333; }
}

/* ---------------- 打印预览（手机没有打印面板时走这条） ---------------- */
body.is-pv { overflow: hidden; }
.prview {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  background: #eef0f4;
}
.prview__top {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + var(--safe-t)) 14px 10px;
  background: #fff;
  border-bottom: 1px solid var(--line2);
}
.prview__t { font-size: 15px; font-weight: 600; color: var(--t1); }
.prview__x { font-size: 14px; color: var(--brand); padding: 4px 8px; margin-right: -8px; }
.prview__body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
}
.prview__paper {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 14px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 12px rgba(24, 30, 45, .08);
  /* 真实打印是 A4 竖版，手机上塞不下这么多列：宁可左右滑，也别把每列挤成一字一行 */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.prview__paper .pr-table { min-width: 460px; }
/* 预览时整张单据缩一点：A4 的 8 列在手机上塞不下，缩到能看全，比左右滑更直观。
   zoom 在 Chrome / Edge / Safari 都支持；不支持时上面的 overflow-x 兜底，不会截断。 */
.prview__paper .pr-sheet { zoom: .72; }
.prview__bar {
  flex: none;
  padding: 10px 14px calc(10px + var(--safe-b));
  background: #fff;
  border-top: 1px solid var(--line2);
}
.prview__hint { font-size: 11.5px; line-height: 1.65; color: var(--t3); margin-bottom: 9px; }
.prview__btns { display: flex; gap: 10px; }
.prview__btn {
  flex: 1;
  height: 44px;
  border: 1px solid var(--line2);
  border-radius: 12px;
  background: #fff;
  color: var(--t1);
  font-family: inherit;
  font-size: 15px;
}
.prview__btn--main { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

/* ---------------- 桌面端：把界面收成手机宽度 ---------------- */
@media (min-width: 720px) {
  body { background: #e9ecf1; }
  #nav, #screen, #tabbar { box-shadow: 0 0 30px rgba(24, 30, 45, .06); }
  .screen { min-height: calc(100vh - 50px); }
  .toast-wrap { bottom: 90px; }
}
