/* ============================================================
   铁马仓库管理系统 · PC 端样式
   对齐 docs/UI-STANDARDS.md 的设计令牌（与小程序端同一套语义色）
   ============================================================ */

:root {
  --tm-bg: #f4f5f7;
  --tm-card: #ffffff;
  --tm-text: #1f1f1f;
  --tm-text-sub: #7a7a7a;
  --tm-line: #e8e8e8;
  --tm-primary: #2b2b2b;
  --tm-accent: #c8a063;
  --tm-danger: #d93025;
  --tm-warning: #e8871e;
  --tm-success: #1a9c5b;
  --tm-info: #2c6bd6;
  --tm-sidebar: #232323;
  --tm-sidebar-hover: #333333;
}

* {
  box-sizing: border-box;
}

html,
body,
#root {
  height: 100%;
  margin: 0;
}

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--tm-text);
  background: var(--tm-bg);
}

button {
  font-family: inherit;
}

code.code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  background: #f2f3f5;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.muted {
  color: var(--tm-text-sub);
}
.small {
  font-size: 12px;
}
.danger-text {
  color: var(--tm-danger);
}

/* ============================================================
   布局
   ============================================================ */
.layout {
  display: flex;
  min-height: 100%;
}

.sidebar {
  width: 208px;
  flex-shrink: 0;
  background: var(--tm-sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 24px 0 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 0 22px;
}

.sidebar-sub {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.42);
  padding: 0 22px 24px;
  letter-spacing: 1px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 10px;
}

.nav-item {
  text-align: left;
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, 0.78);
  padding: 11px 14px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
}

.nav-item:hover {
  background: var(--tm-sidebar-hover);
  color: #fff;
}

.nav-item.nav-on {
  background: var(--tm-accent);
  color: #fff;
  font-weight: 600;
}

.sidebar-foot {
  margin-top: auto;
  padding: 16px 22px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-user {
  font-size: 14px;
  font-weight: 600;
}

.sidebar-role {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 10px;
}

.sidebar-foot .btn {
  width: 100%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.main {
  flex: 1;
  min-width: 0;
  padding: 24px 28px 60px;
}

/* ============================================================
   页头
   ============================================================ */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 16px;
}

.page-title {
  font-size: 21px;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.5px;
}

.page-sub {
  font-size: 13px;
  color: var(--tm-text-sub);
  margin-top: 4px;
}

.page-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  align-items: center;
}

/* ============================================================
   卡片
   ============================================================ */
.card {
  background: var(--tm-card);
  border-radius: 10px;
  border: 1px solid var(--tm-line);
  margin-bottom: 16px;
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 18px;
  border-bottom: 1px solid var(--tm-line);
  background: #fcfcfd;
}

.card-title {
  font-weight: 600;
  font-size: 14px;
}

.card-extra {
  font-size: 13px;
  color: var(--tm-text-sub);
}

.card-body {
  padding: 16px 18px;
}

/* ============================================================
   按钮
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--tm-line);
  background: #fff;
  color: var(--tm-text);
  border-radius: 7px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}

.btn:hover:not(:disabled) {
  border-color: #c9c9c9;
  background: #fafafa;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--tm-primary);
  border-color: var(--tm-primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #3a3a3a;
  border-color: #3a3a3a;
}

.btn-ghost {
  background: transparent;
}

.btn-danger {
  background: var(--tm-danger);
  border-color: var(--tm-danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #c02a20;
  border-color: #c02a20;
}

.btn-lg {
  padding: 11px 20px;
  font-size: 15px;
  width: 100%;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0;
}

.row-ops {
  display: flex;
  gap: 6px;
}

/* ============================================================
   表单
   ============================================================ */
.field {
  display: block;
  margin-bottom: 14px;
}

.field-label {
  display: block;
  font-size: 12px;
  color: var(--tm-text-sub);
  margin-bottom: 5px;
}

.field-label .req {
  color: var(--tm-danger);
  font-style: normal;
}

.input {
  width: 100%;
  border: 1px solid var(--tm-line);
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--tm-text);
}

.input:focus {
  outline: none;
  border-color: var(--tm-accent);
  box-shadow: 0 0 0 3px rgba(200, 160, 99, 0.16);
}

.input:disabled {
  background: #f6f6f6;
  color: var(--tm-text-sub);
}

.textarea {
  resize: vertical;
  min-height: 60px;
}

.field-hint {
  display: block;
  font-size: 12px;
  color: var(--tm-text-sub);
  margin-top: 4px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

/* ============================================================
   表格
   ============================================================ */
.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  text-align: left;
  font-weight: 600;
  color: var(--tm-text-sub);
  padding: 9px 10px;
  border-bottom: 1px solid var(--tm-line);
  background: #fcfcfd;
  white-space: nowrap;
}

.table td {
  padding: 10px;
  border-bottom: 1px solid #f2f2f2;
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tr.clickable {
  cursor: pointer;
}

.table tr.clickable:hover {
  background: #fafbfc;
}

/* ============================================================
   徽标
   ============================================================ */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.7;
  white-space: nowrap;
}

.badge-info {
  background: #eef4ff;
  color: var(--tm-info);
}
.badge-doing {
  background: #fff6e6;
  color: var(--tm-warning);
}
.badge-done {
  background: #e9f8f0;
  color: var(--tm-success);
}
.badge-warn {
  background: #fdecea;
  color: var(--tm-danger);
}
.badge-gray {
  background: #f0f1f2;
  color: var(--tm-text-sub);
}

/* ============================================================
   状态块
   ============================================================ */
.state-box {
  text-align: center;
  padding: 56px 20px;
  color: var(--tm-text-sub);
}

.state-box.state-sm {
  padding: 24px 16px;
}

.state-icon {
  font-size: 34px;
  opacity: 0.3;
  margin-bottom: 8px;
}

.state-text {
  font-size: 14px;
}

.state-hint {
  font-size: 12px;
  margin-top: 6px;
  opacity: 0.8;
}

.spinner {
  width: 22px;
  height: 22px;
  margin: 0 auto 10px;
  border: 2px solid #e2e2e2;
  border-top-color: var(--tm-accent);
  border-radius: 50%;
  animation: tm-spin 0.7s linear infinite;
}

@keyframes tm-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================================
   错误 / 提示
   ============================================================ */
.error-box {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  background: #fdf2f1;
  border: 1px solid #f6d5d1;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
  color: #8c2a22;
  font-size: 13px;
}

.error-code {
  font-size: 12px;
  opacity: 0.75;
  margin-top: 2px;
}

.error-detail {
  font-size: 12px;
  background: rgba(0, 0, 0, 0.04);
  padding: 8px;
  border-radius: 6px;
  margin: 8px 0 0;
  overflow-x: auto;
  max-height: 140px;
}

.notice {
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 13px;
  border-left: 4px solid var(--tm-info);
  background: #eef4ff;
}

.notice-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.notice-warn {
  border-left-color: var(--tm-warning);
  background: #fff8ec;
}

.notice-danger {
  border-left-color: var(--tm-danger);
  background: #fdf2f1;
}

.notice-success {
  border-left-color: var(--tm-success);
  background: #eefaf3;
}

.flash {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
  font-size: 13px;
  animation: tm-fade 0.2s ease;
}

.flash-success {
  background: #e9f8f0;
  color: #14764a;
  border: 1px solid #c7ecd8;
}
.flash-danger {
  background: #fdf2f1;
  color: #8c2a22;
  border: 1px solid #f6d5d1;
}
.flash-warn {
  background: #fff8ec;
  color: #8a5a10;
  border: 1px solid #f5e0bb;
}

@keyframes tm-fade {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

/* ============================================================
   键值行 / 详情
   ============================================================ */
.kv {
  display: flex;
  padding: 7px 0;
  border-bottom: 1px dashed #f0f0f0;
  font-size: 13px;
}

.kv:last-child {
  border-bottom: none;
}

.kv-label {
  width: 118px;
  flex-shrink: 0;
  color: var(--tm-text-sub);
}

.kv-value {
  flex: 1;
  word-break: break-all;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr);
  gap: 16px;
  align-items: start;
}

@media (max-width: 1180px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   筛选 / 工具栏 / 标签页
   ============================================================ */
.filters {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.filters .field {
  margin-bottom: 0;
  min-width: 150px;
}

.filters-spacer {
  flex: 1;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #fafbfc;
  border: 1px solid var(--tm-line);
  border-radius: 8px;
  margin-bottom: 12px;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--tm-line);
  margin-bottom: 16px;
}

.tab {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 9px 14px;
  font-size: 14px;
  color: var(--tm-text-sub);
  cursor: pointer;
  margin-bottom: -1px;
}

.tab:hover {
  color: var(--tm-text);
}

.tab-on {
  color: var(--tm-text);
  font-weight: 600;
  border-bottom-color: var(--tm-accent);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding-top: 14px;
}

/* ============================================================
   区域块 / 时间线
   ============================================================ */
.area-block {
  border: 1px solid var(--tm-line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.area-block:last-child {
  margin-bottom: 0;
}

.area-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.area-head strong {
  font-size: 14px;
}

.area-head .btn {
  margin-left: auto;
}

.timeline {
  position: relative;
  padding-left: 16px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 6px;
  bottom: 6px;
  width: 1px;
  background: var(--tm-line);
}

.timeline-item {
  position: relative;
  padding: 6px 0 10px;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 12px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--tm-accent);
}

.timeline-time {
  font-size: 12px;
  color: var(--tm-text-sub);
  font-variant-numeric: tabular-nums;
}

.timeline-body strong {
  font-size: 13px;
}

.suggestion-row {
  padding: 5px 0;
  border-bottom: 1px dashed rgba(0, 0, 0, 0.07);
  font-size: 13px;
}

.suggestion-row:last-child {
  border-bottom: none;
}

/* ============================================================
   弹窗
   ============================================================ */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 20px 40px;
  overflow-y: auto;
  z-index: 100;
}

.modal {
  background: #fff;
  border-radius: 12px;
  max-width: 100%;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
  animation: tm-fade 0.16s ease;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 20px;
  border-bottom: 1px solid var(--tm-line);
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  background: transparent;
  border: 0;
  font-size: 22px;
  line-height: 1;
  color: var(--tm-text-sub);
  cursor: pointer;
  padding: 0 4px;
}

.modal-body {
  padding: 18px 20px;
  max-height: 66vh;
  overflow-y: auto;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 13px 20px;
  border-top: 1px solid var(--tm-line);
  background: #fcfcfd;
  border-radius: 0 0 12px 12px;
}

/* ============================================================
   登录页
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #232323 0%, #3b3733 52%, #f4f5f7 52.1%, #f4f5f7 100%);
  padding: 24px;
}

.login-card {
  width: 380px;
  max-width: 100%;
  background: #fff;
  border-radius: 14px;
  padding: 34px 32px 26px;
  box-shadow: 0 20px 52px rgba(0, 0, 0, 0.2);
}

.login-brand {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 3px;
}

.login-sub {
  font-size: 12px;
  color: var(--tm-text-sub);
  letter-spacing: 1px;
  margin: 6px 0 26px;
}

.login-form {
  margin-bottom: 6px;
}

.login-tip {
  text-align: center;
  font-size: 12px;
  color: var(--tm-text-sub);
  margin-top: 14px;
}

/* ============================================================
   导入页专用：列识别 chip / 统计卡
   ============================================================ */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-block;
  background: #f2f3f5;
  border: 1px solid var(--tm-line);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 12px;
  color: #4a4a4a;
}

.kv-grid {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  padding: 12px 0 16px;
}

.stat {
  text-align: center;
  min-width: 68px;
}

.stat-num {
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--tm-primary);
}

.good-text {
  color: var(--tm-success);
}
/* ============================================================
   报表页：分组条 / 链接
   ============================================================ */
.report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 1100px) {
  .report-grid {
    grid-template-columns: 1fr;
  }
}

.report-card {
  margin-bottom: 0;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
}

.bar-label {
  width: 118px;
  flex-shrink: 0;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  flex: 1;
  height: 8px;
  background: #f0f1f2;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--tm-accent);
  border-radius: 999px;
}

.bar-value {
  width: 118px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.link {
  color: var(--tm-info);
  text-decoration: none;
  cursor: pointer;
}

.link:hover {
  text-decoration: underline;
}
/* ============================================================
   作业工作台（一屏完成，扫描框常驻）
   ============================================================ */
.wb {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 48px);
}

.wb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--tm-primary);
  color: #fff;
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 12px;
}

.wb-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.wb-sub {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.72);
  margin-top: 3px;
}

.wb-sub .muted {
  color: rgba(255, 255, 255, 0.5) !important;
}

.wb-head-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wb-mode {
  background: var(--tm-accent);
  color: #fff;
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 13px;
  font-weight: 600;
}

.wb-head .btn {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.24);
  color: #fff;
}

.wb-progress {
  margin-bottom: 12px;
}

.wb-bar {
  height: 10px;
  background: #e6e7e9;
  border-radius: 999px;
  overflow: hidden;
}

.wb-bar-inner {
  height: 100%;
  background: var(--tm-accent);
  border-radius: 999px;
  transition: width 0.25s;
}

.wb-progress-text {
  margin-top: 6px;
  font-size: 13px;
  display: flex;
  gap: 4px;
}

/* 扫描区 */
.wb-scanner {
  background: #fff;
  border: 1px solid var(--tm-line);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 14px;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

.wb-scan-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ★ 大号输入框：扫码枪/手套作业都要好点 */
.wb-scan-input {
  flex: 1;
  height: 46px;
  font-size: 17px;
  padding: 0 14px;
  border: 2px solid var(--tm-accent);
  border-radius: 8px;
  font-family: inherit;
  outline: none;
}

.wb-scan-input:focus {
  box-shadow: 0 0 0 3px rgba(200, 160, 99, 0.2);
}

.wb-scan-result {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  border-left: 4px solid var(--tm-info);
  background: #eef4ff;
  font-size: 14px;
}

.wb-scan-result.ok {
  border-left-color: var(--tm-success);
  background: #eefaf3;
  color: #14764a;
}

.wb-scan-result.warn {
  border-left-color: var(--tm-warning);
  background: #fff8ec;
  color: #8a5a10;
}

.wb-scan-result.bad {
  border-left-color: var(--tm-danger);
  background: #fdf2f1;
  color: #8c2a22;
}

.wb-scan-msg {
  font-weight: 600;
}

/* 主体两栏：清单 + 流水 */
.wb-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  flex: 1;
  align-items: start;
}

@media (max-width: 1180px) {
  .wb-body {
    grid-template-columns: 1fr;
  }
}

.wb-lines {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wb-line {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border: 1px solid var(--tm-line);
  border-left: 4px solid transparent;
  border-radius: 10px;
  padding: 12px 16px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.wb-line:hover {
  background: #fafbfc;
}

/* ★ 当前作业项要显著：一次只强调一行 */
.wb-line-active {
  border-left-color: var(--tm-accent);
  background: #fdfaf4;
}

.wb-line-done {
  border-left-color: var(--tm-success);
  opacity: 0.68;
}

.wb-line-blocked {
  border-left-color: var(--tm-danger);
  background: #fdf7f6;
}

.wb-line-main {
  flex: 1;
  min-width: 0;
}

.wb-line-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
}

.wb-line-meta {
  font-size: 12px;
  margin-top: 3px;
}

.wb-line-qty {
  font-size: 13px;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.wb-line-qty .qty {
  font-size: 16px;
}

.wb-line-action {
  flex-shrink: 0;
  max-width: 190px;
  text-align: right;
}

/* 操作流水 */
.wb-logs {
  background: #fff;
  border: 1px solid var(--tm-line);
  border-radius: 10px;
  padding: 14px 16px;
  max-height: 62vh;
  overflow-y: auto;
}

.wb-logs-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 10px;
}

.wb-log {
  border-left: 3px solid var(--tm-line);
  padding: 6px 0 6px 10px;
  font-size: 12.5px;
  margin-bottom: 8px;
}

.wb-log.ok {
  border-left-color: var(--tm-success);
}

.wb-log.bad {
  border-left-color: var(--tm-danger);
  color: #8c2a22;
}

.wb-log-time {
  color: var(--tm-text-sub);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.wb-foot {
  margin-top: 16px;
  padding: 14px 0 40px;
}