/* ==========================================================================
   拼豆 · 豆子批次记录 —— 管理后台样式
   视觉规格对齐小程序原型（主色 #0b8ff3 / 圆角 8px / 分割线 #e4e4e4 / 浅色主题）
   桌面端宽屏布局，不套用手机窄屏结构
   ========================================================================== */

:root {
  --accent: #0b8ff3;
  --accent-dark: #0a7ed9;
  --accent-soft: #eaf4fe;
  --danger: #e04a3f;
  --danger-soft: #fdecea;
  --warning: #ff8a1f;
  --warning-soft: #fff4e8;
  --success: #1f9d55;
  --success-soft: #eaf7ef;
  --text: #1a1a1a;
  --text-2: #5b5b5b;
  --text-3: #9a9a9a;
  --line: #e4e4e4;
  --line-soft: #efefef;
  --page: #f4f5f7;
  --panel: #ffffff;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
  --shadow-sm: 0 2px 8px rgba(20, 24, 32, 0.06);
  --radius: 8px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3, h4, p { margin: 0; }
table { border-collapse: collapse; }

/* ---------------- 顶部导航 ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 32px;
  height: 60px;
  padding: 0 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), #4fc3f7);
  box-shadow: 0 2px 6px rgba(11, 143, 243, 0.32);
}

.brand-sub {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-3);
  padding-left: 10px;
  margin-left: 2px;
  border-left: 1px solid var(--line);
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.nav-item {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 60px;
  padding: 0 16px;
  border: 0;
  background: none;
  color: var(--text-2);
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}

.nav-item:hover { color: var(--text); }

.nav-item.active { color: var(--accent); font-weight: 600; }

.nav-item.active::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
}

.topbar-user {
  font-size: 13px;
  color: var(--text-2);
}

.topbar-user b { color: var(--text); font-weight: 600; }

/* ---------------- 页面骨架 ---------------- */

.page {
  max-width: 1560px;
  margin: 0 auto;
  padding: 24px;
}

.section { display: none; }

.section.active { display: block; }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.section-desc {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 4px;
}

.section-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------------- 卡片 ---------------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

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

/* ---------------- 数据概览 ---------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
}

.stat-card.danger::before { background: var(--danger); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.success::before { background: var(--success); }

.stat-label {
  font-size: 13px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-value {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.5px;
  font-variant-numeric: tabular-nums;
}

.stat-card.danger .stat-value { color: var(--danger); }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.success .stat-value { color: var(--success); }

.stat-hint { font-size: 12px; color: var(--text-3); }

/* ---------------- 按钮 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid #d9d9d9;
  background: #fff;
  border-radius: 4px;
  padding: 7px 18px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, opacity .15s ease;
}

.btn:hover { border-color: #c4c4c4; background: #fafafa; }

.btn:active { opacity: 0.8; }

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

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

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

.btn.ghost-danger { color: var(--danger); border-color: #f0c4c0; background: #fff; }
.btn.ghost-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn.small { padding: 5px 12px; font-size: 13px; }

.btn.icon-only { padding: 6px 10px; }

/* ---------------- 表单控件 ---------------- */

.select,
.text-input {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  background: #fff;
  padding: 6px 26px 6px 10px;
  font-size: 13px;
  color: var(--text);
  max-width: 100%;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='7' viewBox='0 0 10 7'><path d='M1 1l4 4 4-4' fill='none' stroke='%23666' stroke-width='1.4' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.text-input {
  background-image: none;
  padding-right: 10px;
  cursor: text;
}

.select:focus, .text-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(11, 143, 243, 0.12); }

.select:disabled, .text-input:disabled { color: var(--text-3); background-color: #fbfbfb; cursor: default; }

.text-input.num { width: 76px; text-align: right; }

/* ---------------- 表格 ---------------- */

.table-card { overflow: hidden; }

.table-scroll { overflow-x: auto; }

table.data {
  width: 100%;
  font-size: 13.5px;
  min-width: 1080px;
}

table.data th,
table.data td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

table.data thead th {
  background: #fafafa;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}

table.data tbody tr:hover { background: #fcfdff; }

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

table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }

table.data td.actions { text-align: right; white-space: nowrap; }

table.data td.actions .btn + .btn { margin-left: 6px; }

.qty-zero {
  color: var(--danger);
  font-weight: 700;
}

/* 色号单元格 */

.code-cell { display: flex; align-items: center; gap: 9px; }

.color-chip {
  flex: none;
  min-width: 44px;
  height: 28px;
  padding: 0 8px;
  border-radius: 5px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.color-chip.unset { background: #fff !important; color: #333; }

.code-meta { display: flex; flex-direction: column; line-height: 1.35; }

.code-meta .code-name { font-weight: 600; }

.code-meta .code-sub { font-size: 12px; color: var(--text-3); }

/* 状态标签 */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 4px;
  padding: 2px 9px;
  font-size: 12.5px;
  line-height: 19px;
  white-space: nowrap;
}

.tag.pending { color: var(--warning); background: var(--warning-soft); }
.tag.arrived { color: var(--success); background: var(--success-soft); }
.tag.accent { color: var(--accent); background: var(--accent-soft); }
.tag.danger { color: var(--danger); background: var(--danger-soft); }
.tag.plain { color: var(--text-2); background: #f2f3f5; }

.code-tags { display: flex; flex-wrap: wrap; gap: 5px; max-width: 420px; }

.code-tag {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 7px;
  font-size: 12px;
  line-height: 18px;
  color: var(--text);
  background: #fff;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.code-tag .swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  flex: none;
}

.code-tag .swatch.unset { background: #fff; }

/* ---------------- 空态 / 错误态 ---------------- */

.empty {
  padding: 56px 20px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

.empty .empty-title { font-size: 15px; color: var(--text-2); margin-bottom: 6px; font-weight: 600; }

.empty .btn { margin-top: 14px; }

.error-state {
  margin: 16px 0;
  padding: 12px 16px;
  border: 1px solid #f3c4bf;
  background: var(--danger-soft);
  color: #a8372d;
  border-radius: var(--radius);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.error-state .btn { margin-left: auto; }

.loading-state {
  padding: 40px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

/* ---------------- 弹窗 ---------------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn .16s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

@keyframes popIn { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: scale(1); } }

.dialog {
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: popIn .16s ease;
}

.dialog.wide { max-width: 640px; }

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  font-size: 16px;
  font-weight: 600;
  border-bottom: 1px solid var(--line-soft);
  flex: none;
}

.dialog-head .close {
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--text-3);
  padding: 4px;
  display: inline-flex;
  border-radius: 4px;
}

.dialog-head .close:hover { color: var(--text); background: #f4f5f7; }

.dialog-body { padding: 16px 18px; overflow-y: auto; }

.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--line-soft);
  flex: none;
}

.dialog-foot .btn { min-width: 84px; }

.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
  min-height: 38px;
}

.form-row > .label { font-size: 14px; color: var(--text); flex: none; width: 92px; }

.form-row .grow { flex: 1; min-width: 0; }

.dialog .hint { font-size: 12px; color: var(--text-3); margin-top: 8px; line-height: 1.6; }

.dialog .form-error {
  margin-top: 10px;
  font-size: 13px;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: 6px;
  padding: 8px 10px;
}

/* ---------------- 弹窗内表格 / 选择器 ---------------- */

.picker-group { border-bottom: 1px solid var(--line-soft); }
.picker-group:last-child { border-bottom: 0; }

.picker-group-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 2px;
  border: 0;
  background: none;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  text-align: left;
}

.picker-group-head .count { font-size: 12px; font-weight: 500; color: var(--accent); }

.picker-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 8px;
  padding: 2px 0 12px;
}

.swatch-btn {
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.16);
  font-size: 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  position: relative;
  color: #fff;
}

.swatch-btn.unset { background: #fff !important; color: #333; }

.swatch-btn.selected {
  border: 2.5px solid var(--accent);
  box-shadow: 0 0 0 2px rgba(11, 143, 243, 0.22);
}

.swatch-btn .tick {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid #fff;
}

.mini-table { width: 100%; font-size: 13px; margin-top: 4px; }

.mini-table th,
.mini-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
}

.mini-table th { color: var(--text-2); font-weight: 600; font-size: 12.5px; background: #fafafa; }

.mini-table td.num { text-align: right; }

.mini-table .cell-code { display: flex; align-items: center; gap: 8px; }

.mini-table .qty-input {
  width: 62px;
  text-align: right;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 13px;
  background: #fff;
}

.mini-table .qty-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(11, 143, 243, 0.12); }

.mini-table .remove {
  border: 0;
  background: none;
  color: var(--danger);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 12px;
}

.mini-table .remove:hover { background: var(--danger-soft); }

.empty-inline { padding: 22px; text-align: center; color: var(--text-3); font-size: 13px; }

/* ---------------- Toast ---------------- */

.toast-host {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 6px;
  box-shadow: var(--shadow);
  animation: popIn .16s ease;
  max-width: 60vw;
}

.toast.success { background: rgba(31, 157, 85, 0.94); }
.toast.error { background: rgba(224, 74, 63, 0.94); }
.toast.warn { background: rgba(255, 138, 31, 0.95); }

/* ==========================================================================
   登录页
   ========================================================================== */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: var(--page);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(20, 24, 32, 0.1);
  padding: 32px 30px 28px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

.login-brand .brand-mark { width: 32px; height: 32px; border-radius: 9px; }

.login-brand .login-brand-text { display: flex; flex-direction: column; line-height: 1.3; }

.login-brand .login-brand-text b { font-size: 17px; letter-spacing: 0.3px; }

.login-brand .login-brand-text span { font-size: 12px; color: var(--text-3); }

.login-title {
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 4px;
}

.login-desc { font-size: 13px; color: var(--text-3); margin-bottom: 22px; }

.login-field { margin-bottom: 16px; }

.login-field label {
  display: block;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 6px;
}

.login-field .text-input {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  cursor: text;
}

.login-field .text-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(11, 143, 243, 0.12); }

.login-submit {
  width: 100%;
  padding: 10px 0;
  font-size: 15px;
  margin-top: 6px;
}

.login-error {
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid #f3c4bf;
  border-radius: 6px;
  padding: 9px 12px;
}

.login-error[hidden] { display: none; }

.login-tip {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
}
