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

:root {
  --pri: #0f766e;
  --pri-d: #0b5f59;
  --pri-l: #e6f4f2;
  --bg: #f2f5f7;
  --card: #ffffff;
  --txt: #1b2733;
  --txt2: #6b7a8c;
  --line: #e8edf2;
  --red: #d92d20;
  --orange: #e8841c;
  --green: #12905f;
  --blue: #2563eb;
  --radius: 14px;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--txt);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------------- 登录 ---------------- */
#login {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #0f766e 0%, #0e5d6b 45%, #123c4d 100%);
  position: relative;
  overflow: hidden;
}
#login::before, #login::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, .07);
}
#login::before { width: 320px; height: 320px; top: -110px; right: -110px; }
#login::after { width: 220px; height: 220px; bottom: -80px; left: -70px; }

.login-box {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}
.login-logo {
  width: 64px; height: 64px; border-radius: 20px;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .28);
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; margin: 0 auto 16px;
  backdrop-filter: blur(6px);
}
.login-title { color: #fff; text-align: center; font-size: 21px; font-weight: 600; letter-spacing: .5px; }
.login-sub { color: rgba(255, 255, 255, .72); text-align: center; font-size: 13px; margin: 8px 0 28px; }

.login-card {
  background: #fff;
  border-radius: 20px;
  padding: 22px 20px 20px;
  box-shadow: 0 18px 40px rgba(0, 20, 30, .25);
}
.login-card label { display: block; font-size: 13px; color: var(--txt2); margin: 0 0 6px; }
.login-card .ipt {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 14px;
  background: #f8fafb;
  margin-bottom: 16px;
  outline: none;
  transition: .2s;
}
.login-card .ipt:focus { border-color: var(--pri); background: #fff; }
.login-btn {
  width: 100%; height: 48px; border: 0; border-radius: 10px;
  background: linear-gradient(135deg, #12a095, #0f766e);
  color: #fff; font-size: 16px; font-weight: 600; letter-spacing: 1px;
  box-shadow: 0 6px 16px rgba(15, 118, 110, .3);
}
.login-btn:active { transform: translateY(1px); }
.login-tip { text-align: center; font-size: 12px; color: rgba(255, 255, 255, .6); margin-top: 18px; line-height: 1.8; }

/* ---------------- 主体布局 ---------------- */
#app { display: none; min-height: 100vh; padding-bottom: 66px; }
#app.on { display: block; }

.topbar {
  position: sticky; top: 0; z-index: 6;
  background: linear-gradient(135deg, #0f766e, #0e6b78);
  color: #fff;
  padding: 12px 16px 14px;
  box-shadow: 0 2px 10px rgba(15, 118, 110, .18);
}
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; letter-spacing: .3px; }
.topbar .who { display: flex; align-items: center; gap: 8px; font-size: 12px; opacity: .95; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(255, 255, 255, .22);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.subline { margin-top: 8px; font-size: 12px; color: rgba(255, 255, 255, .78); display: flex; gap: 12px; flex-wrap: wrap; }
.subline span { background: rgba(255, 255, 255, .13); padding: 3px 9px; border-radius: 20px; }

.page { padding: 12px 14px 20px; max-width: 1180px; margin: 0 auto; }

/* ---------------- 通用组件 ---------------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 14px;
  margin-bottom: 12px;
}
.card-title { font-size: 15px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-title small { font-weight: 400; color: var(--txt2); font-size: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 36px; padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--line); background: #fff; color: var(--txt);
  font-size: 13px; font-weight: 500; white-space: nowrap;
}
.btn:active { opacity: .8; }
.btn-primary { background: var(--pri); border-color: var(--pri); color: #fff; }
.btn-soft { background: var(--pri-l); border-color: #cfe8e5; color: var(--pri); }
.btn-danger { background: #fff; border-color: #f3c8c4; color: var(--red); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.chip {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; background: var(--pri-l); color: var(--pri); margin-right: 4px;
}
.chip.gray { background: #eef1f5; color: #64748b; }

.search-row { display: flex; gap: 8px; margin-bottom: 10px; }
.search-box { position: relative; flex: 1; }
.search-box input {
  width: 100%; height: 42px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; padding: 0 36px 0 38px; outline: none;
}
.search-box input:focus { border-color: var(--pri); }
.search-box .icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  font-size: 16px; color: var(--txt2);
}
.search-box .clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; border: 0; background: #eef1f5; border-radius: 50%;
  color: #64748b; font-size: 13px; display: none; line-height: 1;
}
.search-box input:not(:placeholder-shown) + .clear { display: block; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 8px; text-align: center;
}
.stat b { display: block; font-size: 18px; font-weight: 700; line-height: 1.3; }
.stat span { font-size: 11px; color: var(--txt2); }
.stat.red b { color: var(--red); }
.stat.orange b { color: var(--orange); }
.stat.green b { color: var(--green); }

/* ---------------- 物料表格 ---------------- */
.tbl-wrap {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch;
}
.tbl-wrap table { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }
.tbl-wrap th, .tbl-wrap td {
  padding: 9px 10px; font-size: 12.5px; white-space: nowrap;
  border-bottom: 1px solid var(--line); text-align: left;
}
.tbl-wrap thead th {
  background: #f1f5f7; color: #43526b; font-weight: 600; font-size: 12px;
  border-bottom: 1px solid #dfe6ee;
}
.tbl-wrap th:first-child, .tbl-wrap td:first-child {
  position: sticky; left: 0; z-index: 3; background: #fff;
  box-shadow: 2px 0 4px -2px rgba(15, 40, 60, .12);
  min-width: 104px; max-width: 150px; white-space: normal;
}
.tbl-wrap thead th:first-child { background: #f1f5f7; z-index: 4; }
.tbl-wrap tbody tr:last-child td { border-bottom: 0; }
.tbl-wrap tbody tr:active td { background: #f6faf9; }
.tbl-wrap td.name-cell { font-weight: 600; }
.tbl-wrap td.name-cell i { display: block; font-style: normal; font-weight: 400; color: var(--txt2); font-size: 11px; margin-top: 2px; }
.qty-cell { font-weight: 700; color: var(--pri); font-variant-numeric: tabular-nums; }
.qty-cell.zero { color: var(--red); }
.num { font-variant-numeric: tabular-nums; }
.t-red { color: var(--red); font-weight: 700; }
.t-orange { color: var(--orange); font-weight: 600; }
.t-green { color: var(--green); }
.t-gray { color: #98a2b3; }
.tip-scroll { font-size: 11px; color: var(--txt2); text-align: center; margin: 6px 0 0; }

/* 卡片视图 */
.mlist { display: flex; flex-direction: column; gap: 10px; }
.mcard {
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px;
}
.mcard-h { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.mcard-h b { font-size: 15px; }
.mcard-h .code { font-size: 11px; color: var(--txt2); }
.mcard-g { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin-top: 9px; }
.mcard-g div { font-size: 12px; color: var(--txt2); }
.mcard-g em { font-style: normal; color: var(--txt); }
.mcard-g div.full { grid-column: 1 / -1; }

/* ---------------- 列表 ---------------- */
.row-item {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 10px;
}
.row-item .h { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.row-item .h b { font-size: 15px; }
.row-item .meta { font-size: 12px; color: var(--txt2); margin-top: 6px; line-height: 1.9; }
.row-item .actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

.status { font-size: 11px; padding: 2px 9px; border-radius: 20px; white-space: nowrap; }
.st-pending { background: #fff4e5; color: #b45309; }
.st-partial { background: #eef4ff; color: #1d4ed8; }
.st-approved { background: #e8f7ef; color: #0f7a52; }
.st-rejected { background: #fdecec; color: #c0271c; }
.st-cancelled { background: #eef1f5; color: #64748b; }

.empty { text-align: center; padding: 46px 10px; color: #9aa8b8; font-size: 13px; }
.empty .big { font-size: 40px; display: block; margin-bottom: 8px; opacity: .5; }

/* ---------------- 底部导航 ---------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; background: rgba(255, 255, 255, .96);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  backdrop-filter: blur(10px);
}
.tabbar button {
  flex: 1; border: 0; background: none; padding: 8px 0 7px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: #8a97a8; font-size: 11px; position: relative;
}
.tabbar button .ic { font-size: 19px; line-height: 1.1; }
.tabbar button.on { color: var(--pri); font-weight: 600; }
.tabbar .dot {
  position: absolute; top: 3px; left: 50%; margin-left: 8px;
  min-width: 16px; height: 16px; border-radius: 9px; background: var(--red);
  color: #fff; font-size: 10px; line-height: 16px; padding: 0 4px;
  font-style: normal;
}
.tabbar .dot-orange { background: var(--orange); }
.tabbar .dot-red { background: var(--red); }

/* ---------------- 危化品 / 提醒 ---------------- */
.hz {
  display: inline-block; font-size: 10px; line-height: 15px;
  padding: 0 5px; border-radius: 4px; background: #fdecec; color: #c0271c;
  border: 1px solid #f7cdc9; vertical-align: 1px; font-weight: 600;
}
.notice {
  background: #fff8e6; border: 1px solid #f6e0a8; color: #8a5a08;
  border-radius: 12px; padding: 11px 13px; margin-bottom: 12px;
  font-size: 12.5px; line-height: 1.7;
}
.notice b { color: #b45309; }
.alert-item {
  padding: 11px 0; border-bottom: 1px solid #f0f4f8;
}
.alert-item:last-child { border-bottom: 0; }
.alert-item .h { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.alert-item .h b { font-size: 14px; }
.alert-item .sub { font-size: 11.5px; color: var(--txt2); margin-top: 3px; }
.alert-item .qty-cell { font-size: 16px; }

.approve-box {
  border: 1px solid #e8edf2; border-radius: 12px; padding: 12px; margin-bottom: 10px;
  background: #fff;
}
.approve-box .h { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.approve-box .h b { font-size: 14.5px; }
.approve-box .sub { font-size: 11.5px; color: var(--txt2); margin-top: 3px; }
.approve-box .meta { font-size: 12px; color: var(--txt2); margin-top: 7px; line-height: 1.9; }
.approve-progress { margin-top: 9px; }
.pbar { height: 5px; background: #eef1f5; border-radius: 3px; overflow: hidden; }
.pbar i { display: block; height: 100%; background: linear-gradient(90deg, #12a095, #0f766e); border-radius: 3px; }
.ptxt { font-size: 11.5px; color: var(--txt2); margin-top: 5px; }
.approve-box .actions { display: flex; gap: 8px; margin-top: 10px; }
.done-tip {
  margin-top: 10px; font-size: 12px; color: #1d4ed8; background: #eef4ff;
  border-radius: 8px; padding: 8px 10px; text-align: center;
}

.switch-line {
  display: flex; align-items: center; gap: 8px; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 13px;
}
/* 放在 .field 里时要压过 .field label / .field input 的默认样式 */
.field .switch-line {
  display: flex; align-items: center; gap: 8px; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  font-size: 13px; color: var(--txt); margin-bottom: 0; cursor: pointer;
}
.field .switch-line input[type=checkbox] {
  flex: 0 0 auto; width: 18px; height: 18px; margin: 0; padding: 0;
  accent-color: var(--pri);
}
.field .switch-line span { line-height: 1.5; }

/* ---------------- 弹层 ---------------- */
.mask {
  position: fixed; inset: 0; background: rgba(15, 25, 40, .45);
  z-index: 30; display: flex; align-items: flex-end; justify-content: center;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.sheet {
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  background: #f7f9fb; border-radius: 18px 18px 0 0;
  padding: 0 0 calc(14px + env(safe-area-inset-bottom));
  animation: up .22s cubic-bezier(.2, .8, .3, 1);
}
@keyframes up { from { transform: translateY(30px); opacity: .6 } to { transform: none; opacity: 1 } }
.sheet-h {
  position: sticky; top: 0; background: #fff; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line); border-radius: 18px 18px 0 0;
}
.sheet-h b { font-size: 16px; }
.sheet-h .x { border: 0; background: none; font-size: 20px; color: #98a2b3; line-height: 1; padding: 4px; }
.sheet-b { padding: 14px 16px; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--txt2); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; height: 42px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; padding: 0 12px; outline: none;
}
.field textarea { height: 68px; padding: 10px 12px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--pri); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-size: 11px; color: var(--txt2); margin-top: 4px; line-height: 1.6; }

.kv { border-top: 1px solid var(--line); }
.kv div {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px;
}
.kv div span:first-child { color: var(--txt2); flex: none; }
.kv div span:last-child { text-align: right; word-break: break-all; }

.roles-check { display: flex; gap: 8px; flex-wrap: wrap; }
.roles-check label {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 13px; color: var(--txt);
}
.roles-check input { width: auto; height: auto; }

/* ---------------- 提示 ---------------- */
#toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(10px);
  background: rgba(20, 32, 44, .92); color: #fff; font-size: 13px;
  padding: 10px 18px; border-radius: 10px; z-index: 60; max-width: 82vw;
  opacity: 0; pointer-events: none; transition: .22s; line-height: 1.5; text-align: center;
}
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

.file-drop {
  border: 1.5px dashed #c3d2dd; border-radius: 12px; background: #fff;
  padding: 22px 14px; text-align: center; color: var(--txt2); font-size: 13px;
}
.file-drop.picked { border-color: var(--pri); background: var(--pri-l); color: var(--pri); }
.file-drop .big { font-size: 28px; display: block; margin-bottom: 6px; }
input[type=file] { display: none; }

.seg { display: flex; background: #eef1f5; border-radius: 10px; padding: 3px; }
.seg button {
  flex: 1; border: 0; background: none; height: 32px; border-radius: 8px;
  font-size: 13px; color: var(--txt2);
}
.seg button.on { background: #fff; color: var(--pri); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }

/* ---------------- 批量领用 ---------------- */
.pick-row {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; margin-bottom: 8px;
}
.pick-info { flex: 1; min-width: 0; }
.pick-info b { font-size: 14px; }
.pick-info .sub { font-size: 11.5px; color: var(--txt2); margin-top: 3px; line-height: 1.6; }
.pick-qty { display: flex; align-items: center; gap: 6px; flex: none; }
.pick-qty input {
  width: 68px; height: 36px; border: 1px solid var(--line); border-radius: 9px;
  text-align: center; font-weight: 700; color: var(--pri); background: #fff; outline: none;
}
.pick-qty input:focus { border-color: var(--pri); }
.pick-qty input:disabled { background: #f5f7fa; color: #b0bcc9; }
.pick-qty span { font-size: 11px; color: var(--txt2); }
.pick-bar {
  position: sticky; bottom: 64px; z-index: 4;
  display: flex; align-items: center; gap: 10px;
  background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px; margin-top: 10px;
  box-shadow: 0 -3px 12px rgba(15, 40, 60, .08);
}
.pick-bar .pick-sum { flex: 1; font-size: 12.5px; color: var(--txt2); }
.pick-bar .pick-sum b { color: var(--pri); }
.pick-bar .btn { height: 40px; padding: 0 22px; }

.req-items { margin: 8px 0 2px; }
.item-line {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 6px 0; border-bottom: 1px dashed #eef1f5; font-size: 12.5px;
}
.item-line:last-child { border-bottom: 0; }
.item-line .idx {
  flex: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--pri-l); color: var(--pri); font-size: 11px; line-height: 18px; text-align: center;
}
.item-line .nm { flex: 1; min-width: 0; }
.item-line .nm em { display: block; font-style: normal; font-size: 11px; color: var(--txt2); margin-top: 2px; }
.item-line b { white-space: nowrap; color: var(--pri); }
.row-item .h > div { min-width: 0; }
.row-item .sub { font-size: 11px; color: var(--txt2); margin-top: 2px; }

.uniq-lb { font-size: 12px; color: var(--txt2); margin-bottom: 8px; }
.uniq-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.uniq-chips .chip { margin-right: 0; font-size: 12px; padding: 4px 10px; font-variant-numeric: tabular-nums; }

@media (min-width: 760px) {
  body { font-size: 14px; }
  .stats { grid-template-columns: repeat(4, 1fr); }
}
