* { box-sizing: border-box; }
:root {
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --bg: #f5f6fa;
  --line: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
}
html, body { margin:0; padding:0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
  -webkit-text-size-adjust: 100%;
}
.login-body { background: linear-gradient(135deg,#312e81 0%,#4f46e5 55%,#818cf8 100%); }

.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 190px; flex: none; background: #1e1b4b; color: #c7d2fe;
  display: flex; flex-direction: column; padding: 18px 12px;
}
.brand { font-size: 16px; font-weight: 700; color: #fff; padding: 4px 8px 18px; display:flex; align-items:center; gap:8px; }
.brand .dot { width:9px; height:9px; border-radius:50%; background:#34d399; box-shadow:0 0 0 3px rgba(52,211,153,.22); }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar nav button {
  background: transparent; border: 0; color: #c7d2fe; text-align: left;
  padding: 10px 12px; border-radius: 8px; font-size: 13.5px; cursor: pointer;
}
.sidebar nav button:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar nav button.active { background: var(--brand); color: #fff; font-weight: 600; }
.side-foot { border-top: 1px solid rgba(255,255,255,.12); padding-top: 12px; }
.who { font-size: 12.5px; color: #a5b4fc; padding: 0 4px 8px; }

.main { flex: 1; padding: 20px 24px 40px; min-width: 0; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h2 { margin: 0 0 4px; font-size: 19px; }
.hint { font-size: 12.5px; color: var(--muted); }

.card { background: #fff; border-radius: 12px; padding: 16px 18px; box-shadow: 0 1px 3px rgba(15,23,42,.06); margin-bottom: 16px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background:#fff; border-radius:12px; padding:16px 18px; box-shadow:0 1px 3px rgba(15,23,42,.06); }
.stat .n { font-size: 26px; font-weight: 800; line-height: 1.1; }
.stat .t { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.stat.warn .n { color: #dc2626; }
.stat.ok .n { color: #059669; }
.stat.brand .n { color: var(--brand); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid #f1f5f9; font-size: 13px; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; background: #fafbfc; white-space: nowrap; }
tbody tr:hover { background: #fafbff; }
td.actions { white-space: nowrap; }

.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 8px; padding: 9px 14px; font-size: 13.5px; cursor: pointer;
}
.btn:hover { background: #f9fafb; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,.25); color: #e0e7ff; }
.btn.sm { padding: 6px 10px; font-size: 12.5px; border-radius: 7px; }
.btn:disabled { opacity: .6; cursor: default; }
.btn.warn { color: #b45309; border-color: #fde68a; background: #fffbeb; }
.btn.warn:hover { background: #fef3c7; }

/* 时效条 */
.aging-box {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  border-radius: 8px; padding: 9px 12px; margin-bottom: 12px; font-size: 12.5px;
}
.aging-box.ok { background: #f0fdf4; border: 1px solid #bbf7d0; }
.aging-box.late { background: #fef2f2; border: 1px solid #fecaca; }
.aging-k { color: #6b7280; margin-right: 6px; }
.aging-v { font-weight: 700; color: #111827; }

/* 推进状态：红色加粗说明 */
.stage-hint-red {
  font-size: 13px; font-weight: 700; color: #dc2626;
  background: #fff1f2; border: 1px solid #fecdd3;
  border-radius: 8px; padding: 9px 11px; margin-bottom: 10px; line-height: 1.6;
}
/* 非本仓业务转派按钮：绿色填充 + 白色字体 */
.btn.transfer-btn {
  background: #16a34a; border-color: #15803d; color: #fff;
  font-weight: 700;
}
.btn.transfer-btn:hover { background: #15803d; color: #fff; }

.detail-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.detail-no { font-size: 16px; font-weight: 800; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
/* 推进状态里的操作按钮：更宽、更矮 */
.btn-row .btn {
  min-width: 190px; height: 30px; padding: 0 18px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; line-height: 1;
}
/* 两行文字按钮 */
.btn-row .btn.btn-2line {
  width: 128px; min-width: 128px; height: auto; min-height: 44px;
  padding: 6px 8px; white-space: normal; text-align: center;
  font-size: 12.5px; line-height: 1.35; letter-spacing: 0;
}
/* 提示与按钮之间的手指指引（与按钮等宽对齐） */
.hand-hint { display: flex; gap: 8px; margin: 0 0 5px; user-select: none; }
.hand-hint span {
  width: 128px; text-align: center; font-size: 20px; line-height: 1;
  animation: handBob 1.5s ease-in-out infinite;
}
.hand-hint span:nth-child(2) { animation-delay: .25s; }
@keyframes handBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}

.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.tag.gray { background:#f3f4f6; color:#4b5563; }
.tag.blue { background:#eff6ff; color:#1d4ed8; }
.tag.green { background:#ecfdf5; color:#047857; }
.tag.amber { background:#fffbeb; color:#b45309; }
.tag.red { background:#fef2f2; color:#b91c1c; }
.tag.purple { background:#f5f3ff; color:#6d28d9; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
select, input[type="text"], input[type="number"], input[type="date"], textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13.5px;
  background: #fff; color: var(--text); outline: none; font-family: inherit;
}
select:focus, input:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
textarea { resize: vertical; }

.empty { padding: 28px; text-align: center; color: #9ca3af; font-size: 13px; }
.scroll-hint { display: none; font-size: 11.5px; color: #9ca3af; text-align: center; padding: 0 0 6px; }

.thumbs { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.thumb { position: relative; width: 88px; text-decoration: none; display: block; }
.thumb img {
  width: 88px; height: 88px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--line); display: block; background: #f8fafc;
}
.thumb-x {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%;
  border: 0; background: #ef4444; color: #fff; font-size: 13px; line-height: 1; cursor: pointer;
}
.thumb-n {
  font-size: 11px; color: var(--muted); margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 大图预览 */
.img-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.86); z-index: 100;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 24px;
}
.img-overlay img {
  max-width: 92vw; max-height: 76vh; border-radius: 8px; background: #fff;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.img-actions { display: flex; gap: 12px; }
.img-actions .btn { background: #fff; border-color: #fff; color: #111827; text-decoration: none; display: inline-flex; align-items: center; }
.img-actions .btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.55);
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px;
  overflow: auto; z-index: 50;
}
.modal-mask.hidden { display: none; }
.modal {
  background: #fff; border-radius: 14px; width: 780px; max-width: 100%;
  padding: 20px 22px 16px; box-shadow: 0 30px 70px rgba(15,23,42,.35);
}
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid #f1f5f9; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; color: #374151; margin-bottom: 5px; }
.field input, .field select, .field textarea { width: 100%; }

.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 11px 20px; border-radius: 10px;
  font-size: 13.5px; z-index: 90; box-shadow: 0 10px 30px rgba(0,0,0,.3);
}
.toast.hidden { display: none; }
.toast.error { background: #b91c1c; }

.timeline { position: relative; padding-left: 22px; }
.timeline::before { content:''; position:absolute; left:7px; top:4px; bottom:4px; width:2px; background:#e5e7eb; }
.tl-item { position: relative; padding-bottom: 14px; }
.tl-item::before {
  content:''; position:absolute; left:-19px; top:4px; width:10px; height:10px; border-radius:50%;
  background: var(--brand); box-shadow: 0 0 0 2px #fff, 0 0 0 3px #dbeafe;
}
.tl-item .a { font-size: 13px; font-weight: 600; }
.tl-item .d { font-size: 12.5px; color: #4b5563; margin-top: 2px; white-space: pre-wrap; }
.tl-item .m { font-size: 12px; color: #9ca3af; margin-top: 3px; }

.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; }
.kv .k { font-size: 12.5px; color: var(--muted); }
.kv .v { font-size: 13.5px; color: var(--text); word-break: break-all; }

@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; flex-direction: row; align-items: center; gap: 8px;
    padding: 8px 10px; overflow-x: auto; position: sticky; top: 0; z-index: 20;
  }
  .brand { padding: 0 6px 0 2px; font-size: 13.5px; white-space: nowrap; gap: 5px; }
  .brand .bname { display: none; }
  .brand .dot { width: 7px; height: 7px; }
  .sidebar nav { flex-direction: row; flex: none; gap: 1px; }
  .sidebar nav button { padding: 7px 7px; font-size: 12.5px; white-space: nowrap; }
  .side-foot { border: 0; padding: 0; margin-left: auto; display: flex; align-items: center; }
  .who { display: none; }
  .side-foot .btn { padding: 5px 8px; font-size: 12px; white-space: nowrap; }

  .main { padding: 12px 12px 28px; }
  .page-head { margin-bottom: 12px; }
  .page-head h2 { font-size: 17px; }
  .page-head .btn.primary { width: 100%; }

  .card { padding: 12px; border-radius: 10px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .card table { min-width: 720px; }
  .scroll-hint { display: block; }
  th, td { padding: 8px 6px; font-size: 12.5px; }

  .cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 12px; }
  .stat .n { font-size: 22px; }

  .filters { gap: 8px; }
  .filters select, .filters input[type="text"] { width: 100% !important; }
  .filters .btn { flex: 1; }

  /* 弹窗：贴近全屏，底部按钮常驻 */
  .modal-mask { padding: 0; align-items: flex-end; }
  .modal {
    width: 100%; max-width: 100%; max-height: 94vh; overflow-y: auto;
    border-radius: 16px 16px 0 0; padding: 16px 14px 0;
  }
  .modal h3 { font-size: 15px; margin-bottom: 10px; }
  .modal .foot {
    position: sticky; bottom: 0; background: #fff; padding: 10px 0 14px;
    margin-top: 10px; box-shadow: 0 -6px 12px rgba(255,255,255,.95);
  }
  .modal .foot .btn { flex: 1; }

  .detail-head { gap: 8px; }
  .detail-no { font-size: 15px; }
  .detail-head .btn.sm { padding: 6px 10px; }

  .kv { grid-template-columns: 1fr 1fr; gap: 8px 10px; }
  .kv .k { font-size: 11.5px; }
  .kv .v { font-size: 12.5px; }
  .form-grid { grid-template-columns: 1fr; }

  /* 推进状态：按钮两列铺满，触摸区域更高 */
  .btn-row { gap: 8px; }
  .btn-row .btn, .btn-row .btn.btn-2line {
    flex: 1 1 calc(50% - 4px); width: auto; min-width: 0;
    height: 42px; min-height: 42px; font-size: 12.5px; padding: 4px 6px;
  }
  .hand-hint { gap: 8px; }
  .hand-hint span { flex: 1 1 calc(50% - 4px); width: auto; font-size: 18px; }

  .stage-hint-red, .aging-box { font-size: 12px; line-height: 1.55; }
  .aging-box { gap: 8px 14px; }

  .thumbs { gap: 8px; }
  .thumb, .thumb img { width: 76px; }
  .thumb img { height: 76px; }

  .img-overlay img { max-width: 96vw; max-height: 70vh; }
  .img-actions { width: 100%; padding: 0 12px; }
  .img-actions .btn { flex: 1; }

  .toast { left: 12px; right: 12px; bottom: 20px; transform: none; text-align: center; }

  /* iOS：输入框字号小于 16px 会在聚焦时自动放大页面 */
  select, input[type="text"], input[type="number"], input[type="date"],
  input[type="password"], input[type="file"], textarea { font-size: 16px; }
}

@media (max-width: 380px) {
  .btn-row .btn, .btn-row .btn.btn-2line { flex-basis: 100%; }
  .hand-hint span { flex-basis: 100%; }
  .cards { grid-template-columns: 1fr; }
}
