/* ============================================================
   车顶箱订单辅助系统 - 现代极简卡片风(黑白主色)
   ============================================================ */
:root {
  --bg: #f5f5f6;
  --card: #ffffff;
  --border: #e8e8ea;
  --border-strong: #d8d8dc;
  --text: #16161a;
  --muted: #8a8a92;
  --faint: #b9b9c0;
  --black: #0d0d0f;
  --black-soft: #2a2a2e;
  --red: #d5372f;
  --red-bg: #fdeeee;
  --green: #1f8f5a;
  --green-bg: #e9f7f0;
  --amber: #b97d10;
  --amber-bg: #fdf4e3;
  --blue: #2563c9;
  --blue-bg: #ecf2fc;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20, 20, 24, 0.04), 0 4px 16px rgba(20, 20, 24, 0.05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--text); }

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

.sidebar {
  width: 232px;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 50;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px 18px;
}
/* logo 横幅样式(原图 600×200,按宽度等比缩放) */
.brand-logo {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.brand-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 600 / 200;
  border-radius: 10px;
  object-fit: cover;
}
.brand-mark {
  width: 40px; height: 40px;
  background: var(--black);
  color: #fff;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; font-weight: 600;
}
.brand-name { font-size: 15px; font-weight: 650; letter-spacing: 0.2px; }
.brand-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }

.nav { flex: 1; padding: 6px 12px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 2px;
  transition: background 0.18s ease, color 0.18s ease;
}
.nav-item:hover { background: #f1f1f3; }
.nav-item.active { background: var(--black); color: #fff; font-weight: 550; }
.nav-badge {
  background: var(--red);
  color: #fff;
  font-size: 11px;
  min-width: 20px; height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600;
}
.nav-item.active .nav-badge { background: #fff; color: var(--black); }

.sidebar-foot { padding: 14px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: #ececef;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 15px;
}
.user-name { font-size: 13px; font-weight: 550; }
.user-role { font-size: 11px; color: var(--muted); }
.btn-logout {
  display: block;
  text-align: center;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--muted);
  transition: all 0.18s ease;
}
.btn-logout:hover { border-color: var(--red); color: var(--red); background: var(--red-bg); }

.sidebar-mask { display: none; }

.main {
  flex: 1;
  margin-left: 232px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 60px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.menu-toggle {
  display: none;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  width: 34px; height: 34px;
  cursor: pointer;
  font-size: 15px;
}
.page-title { font-size: 17px; font-weight: 650; letter-spacing: 0.2px; }
.topbar-right { margin-left: auto; }
.top-date { color: var(--muted); font-size: 13px; }

.content { padding: 24px 28px; max-width: 1320px; width: 100%; margin: 0 auto; }
.app-foot {
  margin-top: auto;
  padding: 18px 28px;
  color: var(--faint);
  font-size: 12px;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 18px;
}
.card-title {
  font-size: 15px;
  font-weight: 650;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.card-title .sub { font-size: 12px; color: var(--muted); font-weight: 400; }

/* ---------- 统计卡 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: -0.5px; }
.stat-value.red { color: var(--red); }
.stat-value.green { color: var(--green); }
.stat-value.amber { color: var(--amber); }
.stat-foot { font-size: 12px; color: var(--faint); margin-top: 4px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
  background: #fafafb;
}
.tbl td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background 0.15s ease; }
.tbl tbody tr:hover { background: #fafafb; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 12.5px; }
.tbl a.row-link { color: var(--blue); font-weight: 550; }
.tbl a.row-link:hover { text-decoration: underline; }
.tbl .muted { color: var(--faint); }

/* ---------- 状态标签 ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 550;
  white-space: nowrap;
  line-height: 20px;
}
.tag-red { background: var(--red-bg); color: var(--red); }
.tag-green { background: var(--green-bg); color: var(--green); }
.tag-amber { background: var(--amber-bg); color: var(--amber); }
.tag-gray { background: #f1f1f3; color: var(--muted); }
.tag-black { background: #efefef; color: var(--black); }
.tag-blue { background: var(--blue-bg); color: var(--blue); }

/* ---------- 投料状态胶囊 ---------- */
.chip-feed {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 550;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  transition: all 0.18s ease;
  line-height: 20px;
  white-space: nowrap;
}
.chip-feed:hover { border-color: var(--black); color: var(--text); }
.chip-feed .dot { width: 7px; height: 7px; border-radius: 50%; background: #d4d4d8; flex: none; }
.chip-feed.state-partial { border-color: var(--amber); color: var(--amber); background: var(--amber-bg); }
.chip-feed.state-partial .dot { background: var(--amber); }
.chip-feed.state-done { background: var(--black); border-color: var(--black); color: #fff; }
.chip-feed.state-done .dot { background: #fff; }
.chip-feed.state-none { border-style: dashed; }
.chip-feed:disabled { opacity: 0.5; cursor: wait; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 550;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}
.btn-primary { background: var(--black); color: #fff; }
.btn-primary:hover { background: var(--black-soft); }
.btn-outline { background: #fff; border-color: var(--border-strong); color: var(--text); }
.btn-outline:hover { border-color: var(--black); }
.btn-danger { background: #fff; border-color: var(--border-strong); color: var(--red); }
.btn-danger:hover { background: var(--red-bg); border-color: var(--red); }
.btn-sm { padding: 5px 12px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 18px; max-width: 640px; }
.form-item { display: flex; flex-direction: column; gap: 6px; }
.form-item.full { grid-column: 1 / -1; }
.form-label { font-size: 13px; font-weight: 550; color: var(--text); }
.form-label .req { color: var(--red); margin-left: 2px; }
.input, .select, .textarea {
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  width: 100%;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--black);
  box-shadow: 0 0 0 3px rgba(13, 13, 15, 0.08);
}
.textarea { resize: vertical; min-height: 70px; }
.form-hint { font-size: 12px; color: var(--muted); }

/* ---------- 筛选栏 ---------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}
.filter-bar .input, .filter-bar .select { width: auto; }
.tabs { display: inline-flex; background: #efeff1; border-radius: 11px; padding: 3px; gap: 2px; }
.tab {
  padding: 6px 16px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 550;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.18s ease;
  border: none;
  background: transparent;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { background: #fff; color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,0.09); }

/* ---------- 分页 ---------- */
.pagination { display: flex; align-items: center; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.page-btn {
  min-width: 32px; height: 32px;
  padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
  transition: all 0.15s ease;
}
.page-btn:hover { border-color: var(--black); }
.page-btn.active { background: var(--black); border-color: var(--black); color: #fff; font-weight: 600; }
.page-btn.disabled { opacity: 0.4; pointer-events: none; }
.page-ellipsis { color: var(--faint); padding: 0 2px; }
.page-info { margin-left: 10px; font-size: 12.5px; color: var(--muted); }

/* ---------- 提示 ---------- */
.flash {
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13.5px;
  border: 1px solid;
}
.flash-success { background: var(--green-bg); color: var(--green); border-color: #cbe9d9; }
.flash-error { background: var(--red-bg); color: var(--red); border-color: #f5c6c3; }
.flash-info { background: var(--blue-bg); color: var(--blue); border-color: #cddcf4; }
.flash-amber { background: var(--amber-bg); color: var(--amber); border-color: #f0e0bf; }

/* ---------- 通用弹窗(标记原因等) ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(13, 13, 15, .34);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: #fff;
  border-radius: 12px;
  width: 420px;
  max-width: calc(100vw - 32px);
  padding: 20px;
  box-shadow: 0 12px 40px rgba(13, 13, 15, .18);
}
.modal-title { font-size: 14.5px; font-weight: 650; margin-bottom: 6px; }
.modal-desc { font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
.modal-textarea { width: 100%; min-height: 76px; resize: vertical; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.empty {
  text-align: center;
  padding: 44px 20px;
  color: var(--faint);
  font-size: 13.5px;
}
.empty .big { font-size: 30px; margin-bottom: 8px; }

/* ---------- 唛头展示 ---------- */
.mark-box {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #17171a;
  color: #fff;
  padding: 8px 18px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0.5px;
  max-width: 100%;
}
.mark-box .copy-btn {
  background: rgba(255,255,255,0.14);
  border: none;
  color: #fff;
  font-size: 11.5px;
  padding: 3px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.mark-box .copy-btn:hover { background: rgba(255,255,255,0.28); }

/* ---------- 订单详情 ---------- */
.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px 22px;
}
.kv .k { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.kv .v { font-size: 13.5px; font-weight: 550; word-break: break-all; }

.mo-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
  transition: border-color 0.18s ease;
}
.mo-card:hover { border-color: var(--border-strong); }
.mo-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.mo-no { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-weight: 650; font-size: 14px; }
.mo-items { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; line-height: 1.8; }
.mo-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.mo-note-input {
  flex: 1;
  min-width: 200px;
  padding: 6px 10px;
  font-size: 12.5px;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
}
.mo-note-input:focus { border-color: var(--black); }
.mo-meta { font-size: 11.5px; color: var(--faint); margin-top: 8px; }

/* ---------- 进度条 ---------- */
.progress {
  height: 6px;
  background: #efeff1;
  border-radius: 999px;
  overflow: hidden;
  min-width: 90px;
}
.progress > i {
  display: block;
  height: 100%;
  background: var(--black);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.progress > i.green { background: var(--green); }
.progress > i.red { background: var(--red); }
.progress > i.amber { background: var(--amber); }

/* ---------- 登录页 ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}
.login-card {
  width: 400px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 36px 34px;
}
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 26px; text-align: center; }
.login-logo { display: block; width: 300px; max-width: 100%; height: auto; aspect-ratio: 600 / 200; border-radius: 12px; object-fit: cover; }
.login-title { font-size: 18px; font-weight: 700; }
.login-sub { font-size: 12.5px; color: var(--muted); }

/* ---------- 安装页 ---------- */
.install-page { min-height: 100vh; background: var(--bg); padding: 40px 20px; }
.install-card {
  max-width: 720px;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 34px 38px;
}
.install-steps { display: flex; gap: 8px; margin-bottom: 28px; }
.install-step {
  flex: 1;
  text-align: center;
  font-size: 12.5px;
  color: var(--faint);
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
  font-weight: 550;
}
.install-step.active { color: var(--text); border-bottom-color: var(--black); }
.install-step.done { color: var(--green); border-bottom-color: var(--green); }

.check-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.check-row:last-child { border-bottom: none; }
.check-ok { color: var(--green); font-weight: 600; font-size: 13px; }
.check-bad { color: var(--red); font-weight: 600; font-size: 13px; }

/* ---------- 上传区 ---------- */
.upload-zone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
  transition: all 0.2s ease;
  background: #fafafb;
}
.upload-zone:hover { border-color: var(--black); background: #f5f5f6; }
.upload-zone .up-icon { font-size: 26px; margin-bottom: 8px; }
.upload-zone .up-text { font-size: 14px; font-weight: 550; }
.upload-zone .up-hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

.import-result { border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; margin-top: 14px; }
.ir-row { display: flex; gap: 26px; flex-wrap: wrap; }
.ir-item .k { font-size: 12px; color: var(--muted); }
.ir-item .v { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,0.18); }
  .main { margin-left: 0; }
  .menu-toggle { display: block; }
  .sidebar-mask.show {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 45;
  }
  .content { padding: 16px 14px; }
  .topbar { padding: 0 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .kv-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

/* ---------- 动画(克制) ---------- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.content > * { animation: fadeInUp 0.28s ease both; }
.content > *:nth-child(2) { animation-delay: 0.04s; }
.content > *:nth-child(3) { animation-delay: 0.08s; }

.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(-60px);
  background: var(--black);
  color: #fff;
  padding: 9px 20px;
  border-radius: 10px;
  font-size: 13.5px;
  z-index: 100;
  opacity: 0;
  transition: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  box-shadow: 0 6px 24px rgba(0,0,0,0.22);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--red); }
