/* 昭程智能 ERP · 网页版
   配色与小程序保持一致：主色 #1f3864 / 辅助 #2f75b5 / 底色 #f4f7fc */

:root {
  --navy: #1f3864;
  --blue: #2f75b5;
  --bg: #f4f7fc;
  --text: #1f2937;
  --muted: #7a8394;
  --line: #e3e9f2;
  --white: #fff;
  --red: #d93025;
  --green: #12805c;
  --amber: #b45309;
  --amber-bg: #fff4e5;
  --radius: 14px;
  --shadow: 0 4px 18px rgba(31, 56, 100, 0.06);
  --shadow-lg: 0 18px 50px rgba(15, 30, 60, 0.18);
}

* { box-sizing: border-box; }

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

button, input, select, textarea { font-family: inherit; font-size: 14px; }

/* ================= 登录页 ================= */
.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 15% 10%, #2a4a7d 0%, transparent 60%),
    radial-gradient(900px 500px at 85% 90%, #1b3157 0%, transparent 55%),
    #101d31;
  z-index: 800;
}
.login-card {
  width: 100%;
  max-width: 358px;
  background: #fff;
  border-radius: 18px;
  padding: 30px 26px 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}
.login-brand {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: 1px;
}
.login-sub {
  margin-top: 7px;
  font-size: 12.5px;
  color: var(--muted);
}
.login-card form { margin-top: 22px; }
.login-card .field-label { color: #5b6478; }
.login-card .input { padding: 10px 12px; }
.login-btn { width: 100%; margin-top: 6px; padding: 11px; font-size: 15px; letter-spacing: 4px; }
.login-error {
  min-height: 18px;
  margin: 4px 0 8px;
  font-size: 12.5px;
  color: var(--red);
  line-height: 1.5;
}
.login-hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}
.login-foot {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: #9aa3b2;
  line-height: 1.6;
  text-align: center;
}
.who-account {
  font-size: 11.5px;
  color: rgba(255, 255, 255, .55);
  margin-bottom: 6px;
}
.logout-btn {
  margin-top: 10px;
  width: 100%;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .06);
  color: rgba(255, 255, 255, .78);
  font-size: 12px;
  cursor: pointer;
}
.logout-btn:hover { background: rgba(255, 255, 255, .14); color: #fff; }

/* ================= 云端同步状态 ================= */

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  padding: 4px 9px 4px 7px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(255, 255, 255, .07);
  color: rgba(255, 255, 255, .72);
  font-size: 11.5px;
  line-height: 1.4;
  cursor: pointer;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: inherit;
  text-align: left;
}
.sync-pill:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.sync-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: none;
  background: #4ade80;
}
.sync-pill.local .dot { background: #94a3b8; }
.sync-pill.saving .dot { background: #fbbf24; animation: syncPulse 1s ease-in-out infinite; }
.sync-pill.warn {
  border-color: rgba(251, 191, 36, .45);
  background: rgba(251, 191, 36, .16);
  color: #fde68a;
}
.sync-pill.warn .dot { background: #fbbf24; }

@keyframes syncPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .25; }
}

/* 冲突提示条：插在页面最上面 */
.sync-conflict {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 13px 15px;
  border-radius: 12px;
  border: 1px solid #f3d38a;
  background: #fffaeb;
  color: #7a5200;
  font-size: 13px;
  line-height: 1.65;
}
.sync-conflict-text { flex: 1 1 320px; min-width: 0; }
.sync-conflict .btn-row { margin: 0; flex: none; }
.sync-conflict .btn { padding: 7px 13px; font-size: 12.5px; }

/* 登录页里的小链接与代码 */
.login-link {
  color: var(--brand, #2563eb);
  text-decoration: none;
  border-bottom: 1px dashed currentColor;
  cursor: pointer;
}
.login-link:hover { opacity: .78; }
.login-code {
  display: inline-block;
  margin: 6px 0;
  padding: 5px 9px;
  border-radius: 6px;
  background: #eef2f8;
  color: #1f3864;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
}

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

.sidebar {
  width: 224px;
  flex: 0 0 224px;
  background: linear-gradient(180deg, #1b3157 0%, #16283f 100%);
  color: #fff;
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.brand { padding: 0 8px 20px; }
.brand-name { font-size: 19px; font-weight: 700; letter-spacing: 1px; }
.brand-sub { margin-top: 6px; font-size: 11px; color: rgba(255, 255, 255, .55); letter-spacing: .5px; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: rgba(255, 255, 255, .72);
  cursor: pointer;
  font-size: 14px;
  border: none;
  background: none;
  text-align: left;
  width: 100%;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav-item.on { background: rgba(255, 255, 255, .16); color: #fff; font-weight: 600; }
.nav-icon { width: 18px; display: flex; align-items: center; justify-content: center; opacity: .9; }
.nav-icon svg { display: block; }
.nav-badge {
  margin-left: auto;
  background: rgba(255, 255, 255, .2);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 11px;
}

.sidebar-foot { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid rgba(255, 255, 255, .1); }
.who { font-size: 12px; color: rgba(255, 255, 255, .8); }
.who-role { margin-top: 4px; font-size: 11px; color: rgba(255, 255, 255, .45); }
.storage-hint { margin-top: 10px; font-size: 11px; line-height: 1.6; color: rgba(255, 255, 255, .4); }

.main { flex: 1; min-width: 0; padding: 26px 30px 60px; }
.container { max-width: 1180px; margin: 0 auto; }

/* ================= 通用 ================= */
.hero {
  padding: 22px 24px;
  border-radius: 18px;
  background: linear-gradient(135deg, #1f3864 0%, #2f75b5 100%);
  color: #fff;
  margin-bottom: 20px;
  box-shadow: 0 10px 30px rgba(31, 56, 100, .16);
}
.hero-title { font-size: 21px; font-weight: 700; letter-spacing: .5px; }
.hero-sub { margin-top: 8px; font-size: 13px; opacity: .86; line-height: 1.6; }
.hero-row { margin-top: 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.role-pill {
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .18);
  font-size: 12px;
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-title { font-size: 15px; font-weight: 700; color: var(--navy); }
.card-hint { margin-top: 6px; font-size: 12px; color: var(--muted); line-height: 1.6; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 700; }
.red { color: var(--red); }
.green { color: var(--green); }
.mono { font-variant-numeric: tabular-nums; }

/* ================= KPI ================= */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 4px; }
.kpi {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 16px 14px;
  border-left: 3px solid var(--blue);
}
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value { margin-top: 8px; font-size: 24px; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }
.kpi-value.warn { color: var(--red); }
.kpi-note { margin-top: 5px; font-size: 11px; color: var(--muted); }

/* ================= 按钮 ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 13px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  line-height: 1.3;
  transition: filter .15s, background .15s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(.97); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-blue { background: #e8f1fb; border-color: #cfe2f6; color: #1769e0; }
.btn-ghost { background: #f7f9fc; border-color: var(--line); color: #43506b; }
.btn-warn { background: var(--amber-bg); border-color: #f6ddb8; color: var(--amber); }
.btn-danger { background: #fdecea; border-color: #f8cfcb; color: var(--red); }
.btn-mini { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }

/* ================= 表单 ================= */
.field { margin-bottom: 13px; }
.field-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.input, .select, .textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 117, 181, .12);
}
.textarea { min-height: 66px; resize: vertical; line-height: 1.6; }
.field-row { display: flex; gap: 10px; }
.field-row > * { flex: 1; min-width: 0; }

.search-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.search-input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  outline: none;
}
.search-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47, 117, 181, .12); }

.chip-row { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  padding: 6px 13px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: #4a5568;
  cursor: pointer;
  font-size: 12.5px;
  transition: all .15s;
}
.chip:hover { border-color: #c9d7ea; }
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 600; }

/* ================= 标签 ================= */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  line-height: 1.7;
  background: #eef2f8;
  color: #4a5568;
  white-space: nowrap;
}
.tag-red { background: #fdecea; color: var(--red); }
.tag-green { background: #e6f5ef; color: var(--green); }
.tag-blue { background: #e8f1fb; color: #1769e0; }
.tag-amber { background: var(--amber-bg); color: var(--amber); }
.tag-grey { background: #eef2f8; color: #6b7688; }

/* ================= 表格 ================= */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.tb { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tb th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: #fafcff;
}
table.tb td {
  padding: 11px 10px;
  border-bottom: 1px solid #f1f5fb;
  vertical-align: middle;
}
table.tb tr:last-child td { border-bottom: none; }
table.tb tbody tr:hover { background: #fafcff; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ================= 库存卡 ================= */
.prod-row-sku { font-weight: 700; letter-spacing: .3px; color: var(--navy); }
.prod-row-name { font-size: 12px; color: var(--muted); margin-top: 3px; }

.shoplink-box {
  margin-top: 5px;
  padding: 7px 9px;
  border-radius: 8px;
  background: #f7f9fc;
  border: 1px dashed var(--line);
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.7;
}
.shoplink-box.on { background: #f2f8ff; border-color: #d7e6f8; }
.shoplink-line { display: flex; gap: 8px; flex-wrap: wrap; }
.shoplink-pid { color: #43506b; font-variant-numeric: tabular-nums; }
.shoplink-flag { color: var(--amber); }

/* ================= 弹窗 ================= */
.mask {
  position: fixed;
  inset: 0;
  background: rgba(16, 26, 44, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 900;
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: pop .18s ease;
}
@keyframes pop { from { transform: translateY(12px) scale(.98); opacity: 0 } to { transform: none; opacity: 1 } }
.modal.wide { max-width: 760px; }
.modal-head {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 700; color: var(--navy); }
.modal-x { border: none; background: none; font-size: 20px; color: var(--muted); cursor: pointer; line-height: 1; padding: 4px; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 9px; }

/* 小程序原生弹窗的网页复刻 */
.wx-modal-mask {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1200;
}
.wx-modal { background: #fff; border-radius: 14px; width: 320px; overflow: hidden; }
.wx-modal-title { padding: 20px 20px 0; font-size: 16px; font-weight: 600; text-align: center; }
.wx-modal-body { padding: 12px 20px 20px; font-size: 13.5px; color: #4a5568; line-height: 1.7; text-align: center; white-space: pre-wrap; }
.wx-modal-foot { display: flex; border-top: 1px solid var(--line); }
.wx-modal-btn { flex: 1; padding: 13px; border: none; background: none; font-size: 15px; color: #5b6478; cursor: pointer; }
.wx-modal-btn.primary { color: var(--navy); font-weight: 600; border-left: 1px solid var(--line); }

.wx-toast {
  position: fixed;
  left: 50%;
  bottom: 64px;
  transform: translateX(-50%) translateY(12px);
  background: rgba(28, 36, 52, .92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  max-width: 76vw;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 1500;
}
.wx-toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ================= 图片上传 ================= */
.img-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.img-cell {
  position: relative;
  width: 74px;
  height: 74px;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #f7f9fc;
}
.img-cell img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.img-del {
  position: absolute;
  top: 1px; right: 1px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  border: none;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
  padding: 0;
}
.img-add {
  width: 74px; height: 74px;
  border-radius: 9px;
  border: 1px dashed #c9d7ea;
  background: #f7faff;
  color: var(--blue);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  font-size: 11px;
}
.img-add-plus { font-size: 20px; line-height: 1; }

/* ================= 其他 ================= */
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.log-row { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px dashed #eef2f8; font-size: 12.5px; }
.log-row:last-child { border-bottom: none; }
.log-at { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.log-act { font-weight: 600; color: var(--navy); white-space: nowrap; }
.log-detail { color: #4a5568; }

.banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 15px;
  border-radius: 11px;
  font-size: 12.5px;
  line-height: 1.7;
  margin-bottom: 16px;
}
.banner-warn { background: var(--amber-bg); color: #8a4b06; border: 1px solid #f6ddb8; }
.banner-info { background: #eef5fd; color: #1c5185; border: 1px solid #d5e6f8; }
.banner b { font-weight: 700; }

.dl { display: grid; grid-template-columns: 92px 1fr; gap: 8px 14px; font-size: 13px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }

.stat-inline { display: flex; gap: 22px; flex-wrap: wrap; }
.stat-inline > div { font-size: 12px; color: var(--muted); }
.stat-inline b { display: block; font-size: 18px; color: var(--navy); margin-top: 3px; font-variant-numeric: tabular-nums; }

.pager { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 14px; font-size: 13px; color: var(--muted); }

.preview-mask {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .88);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000; cursor: zoom-out; padding: 30px;
}
.preview-mask img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }

/* ================= 响应式 ================= */
@media (max-width: 1080px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex: none;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 12px 14px;
    flex-direction: column;
    gap: 10px;
  }
  .brand { padding: 0 4px 2px; display: flex; align-items: baseline; gap: 10px; }
  .brand-name { font-size: 16px; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
  .nav-item { flex: 0 0 auto; width: auto; padding: 8px 12px; font-size: 13px; white-space: nowrap; }
  .nav-icon { display: none; }
  /* 手机上也要能看到同步状态和退出按钮，收成一行 */
  .sidebar-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    border-top: none;
  }
  .sidebar-foot .sync-pill { margin-bottom: 0; }
  .sidebar-foot .who-account,
  .sidebar-foot .who,
  .sidebar-foot .who-role { display: none; }
  .sidebar-foot .logout-btn { margin-top: 0; width: auto; padding: 6px 12px; }
  .main { padding: 16px 14px 40px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .modal { max-height: 92vh; }
  .field-row { flex-direction: column; }
  .search-bar { flex-wrap: wrap; }
  .search-bar .search-input { flex: 1 1 100%; }
  .card { padding: 15px 14px; }
  table.tb th, table.tb td { padding: 9px 8px; }
  .prod-row-sku { white-space: nowrap; }
}
