/* ============================================================
   货找宝 管理后台 · 样式
   设计：浅色主题 + 品牌红点缀，信息层级清晰，提示醒目
   ============================================================ */
:root {
  --primary: #e8392b;
  --primary-dark: #c72e22;
  --primary-soft: rgba(232, 57, 43, 0.1);
  --gold: #ffb020;
  --green: #16a34a;
  --green-soft: rgba(22, 163, 74, 0.12);
  --blue: #2563eb;
  --blue-soft: rgba(37, 99, 235, 0.12);
  --orange: #f97316;
  --orange-soft: rgba(249, 115, 22, 0.12);
  --text: #1a1d23;
  --text-2: #5b6472;
  --text-3: #8b95a5;
  --line: #e8ebef;
  --bg: #f4f6f9;
  --card: #ffffff;
  --sidebar: #1b2130;
  --sidebar-2: #232b3d;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 8px 24px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 24px 64px rgba(16, 24, 40, 0.22);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }

/* ---------------- 登录 ---------------- */
#login {
  display: flex; align-items: center; justify-content: center; height: 100vh;
  background: radial-gradient(1200px 600px at 20% 10%, #2b3244 0%, #171c28 55%, #0f131c 100%);
}
.login-box {
  width: 380px; background: #fff; border-radius: 18px; padding: 34px 32px 28px;
  box-shadow: var(--shadow-lg);
}
.login-box h1 { font-size: 21px; letter-spacing: .5px; }
.login-box .sub { color: var(--text-3); font-size: 12.5px; margin: 6px 0 24px; }
.login-tip {
  margin-top: 16px; font-size: 12.5px; color: var(--text-3); text-align: center;
}

/* ---------------- 布局 ---------------- */
#layout { display: none; min-height: 100vh; }
.sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; width: 232px; background: var(--sidebar);
  color: #c8d0dd; display: flex; flex-direction: column; z-index: 30;
}
.brand { padding: 20px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand b { color: #fff; font-size: 16px; letter-spacing: .5px; }
.brand span { display: block; color: #7d8798; font-size: 11.5px; margin-top: 3px; }
.nav { flex: 1; overflow-y: auto; padding: 10px 0 20px; }
.nav-group { padding: 14px 20px 6px; font-size: 11px; color: #6d768a; letter-spacing: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 20px; cursor: pointer;
  font-size: 13.5px; border-left: 3px solid transparent; color: #c8d0dd;
}
.nav-item:hover { background: var(--sidebar-2); color: #fff; }
.nav-item.on { background: var(--sidebar-2); color: #fff; border-left-color: var(--primary); font-weight: 600; }
.nav-badge {
  margin-left: auto; background: var(--primary); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 20px; height: 20px; line-height: 20px; text-align: center; border-radius: 10px; padding: 0 6px;
}
.nav-badge.gray { background: #4a5568; }
.who {
  padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.07); font-size: 12.5px; color: #8b95a5;
  display: flex; align-items: center; justify-content: space-between;
}
.main { margin-left: 232px; padding: 22px 26px 60px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h2 { font-size: 19px; }
.page-head .desc { color: var(--text-3); font-size: 12.5px; }
.spacer { flex: 1; }

/* ---------------- 卡片 / 指标 ---------------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card > h3 { font-size: 15px; margin-bottom: 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; cursor: default; }
.stat.clickable { cursor: pointer; transition: transform .12s, box-shadow .12s; }
.stat.clickable:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(16,24,40,.12); }
.stat .k { color: var(--text-3); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 25px; font-weight: 750; margin-top: 6px; letter-spacing: -.4px; }
.stat.warn .v { color: var(--orange); }
.stat.danger .v { color: var(--primary); }
.stat.ok .v { color: var(--green); }

/* ---------------- 表单控件 ---------------- */
.field { margin-bottom: 15px; }
.field > label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 7px; font-weight: 600; }
.field .help { font-size: 12px; color: var(--text-3); margin-top: 5px; }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px;
  background: #fff; color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.textarea { min-height: 92px; resize: vertical; }
.inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline > .input, .inline > .select { width: auto; min-width: 160px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.btn {
  border: none; border-radius: 9px; padding: 9px 16px; cursor: pointer; font-weight: 600;
  background: var(--primary); color: #fff; transition: background .15s, opacity .15s, transform .05s;
}
.btn:hover { background: var(--primary-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--text); border: 1px solid var(--line); }
.btn.ghost:hover { background: #f5f7fa; }
.btn.ok { background: var(--green); } .btn.ok:hover { background: #12833c; }
.btn.warn { background: var(--orange); } .btn.warn:hover { background: #e2660c; }
.btn.danger { background: var(--primary); }
.btn.blue { background: var(--blue); }
.btn.sm { padding: 5px 11px; font-size: 12.5px; border-radius: 7px; }
.btn.link { background: none; color: var(--primary); padding: 4px 6px; }
.btn.link:hover { background: var(--primary-soft); }

/* 开关 */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { display: none; }
.switch i {
  position: absolute; inset: 0; background: #cfd6df; border-radius: 999px; transition: background .18s; cursor: pointer;
}
.switch i::after {
  content: ''; position: absolute; width: 20px; height: 20px; border-radius: 50%; background: #fff;
  top: 3px; left: 3px; transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + i { background: var(--green); }
.switch input:checked + i::after { transform: translateX(20px); }

/* 标签编辑器 */
.tags { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tag {
  display: inline-flex; align-items: center; gap: 6px; background: #f1f4f8; border: 1px solid var(--line);
  color: var(--text); border-radius: 999px; padding: 5px 8px 5px 12px; font-size: 13px;
}
.tag b { font-weight: 600; }
.tag .x {
  width: 18px; height: 18px; line-height: 16px; text-align: center; border-radius: 50%;
  background: #dfe4ea; color: var(--text-2); cursor: pointer; font-size: 13px;
}
.tag .x:hover { background: var(--primary); color: #fff; }
.tag-add { display: flex; gap: 8px; align-items: center; }
.tag-add .input { width: 150px; }

/* 角标 */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.gray { background: #eff1f4; color: var(--text-2); }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.red { background: var(--primary-soft); color: var(--primary); }
.pill.orange { background: var(--orange-soft); color: var(--orange); }
.pill.blue { background: var(--blue-soft); color: var(--blue); }
.pill.gold { background: rgba(255,176,32,.16); color: #a86a00; }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--line); }
table.tb { width: 100%; border-collapse: collapse; background: #fff; }
table.tb th, table.tb td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tb th { background: #fafbfc; color: var(--text-2); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
table.tb tbody tr:hover { background: #fafbfd; }
table.tb tbody tr:last-child td { border-bottom: none; }
table.tb td.actions { white-space: nowrap; }
table.tb .muted { color: var(--text-3); font-size: 12.5px; }
table.tb .strong { font-weight: 650; }
table.tb img.thumb { width: 46px; height: 46px; border-radius: 8px; object-fit: cover; background: #f1f3f6; }

.empty { padding: 46px 20px; text-align: center; color: var(--text-3); }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.pager .info { color: var(--text-3); font-size: 12.5px; margin-right: auto; }
.pager .pg { min-width: 34px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.pager .pg.on { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 700; }

/* ---------------- 提示（醒目） ---------------- */
#toasts {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 9999;
  display: flex; flex-direction: column; gap: 10px; align-items: center; pointer-events: none;
}
.toast {
  pointer-events: auto; min-width: 330px; max-width: 620px; display: flex; gap: 11px; align-items: flex-start;
  padding: 14px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); color: #fff; font-size: 14.5px; font-weight: 600;
  animation: toastIn .22s ease-out;
}
.toast .ico { font-size: 17px; line-height: 1.2; }
.toast .txt { flex: 1; word-break: break-word; }
.toast .close { cursor: pointer; opacity: .85; font-weight: 700; }
.toast.success { background: linear-gradient(135deg, #16a34a, #12833c); }
.toast.error { background: linear-gradient(135deg, #e8392b, #b92114); }
.toast.warn { background: linear-gradient(135deg, #f59e0b, #d97706); }
.toast.info { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.toast.hide { animation: toastOut .18s ease-in forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px); } }

/* ---------------- 弹窗 ---------------- */
.mask {
  position: fixed; inset: 0; background: rgba(17, 24, 39, .48); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 9000; padding: 24px;
}
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 640px; max-height: 88vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); animation: pop .18s ease-out;
}
.modal.wide { max-width: 920px; }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(8px); } to { opacity: 1; transform: none; } }
.modal .m-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal .m-head h3 { font-size: 16px; flex: 1; }
.modal .m-head .x { cursor: pointer; color: var(--text-3); font-size: 20px; line-height: 1; }
.modal .m-head .x:hover { color: var(--primary); }
.modal .m-body { padding: 20px; overflow-y: auto; }
.modal .m-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.confirm-text { font-size: 15px; line-height: 1.7; }
.confirm-text .warn-tip {
  margin-top: 12px; background: var(--primary-soft); color: #a9180d; border-radius: 9px; padding: 10px 12px; font-size: 13px; font-weight: 600;
}

/* 右侧抽屉 */
.drawer-mask { position: fixed; inset: 0; background: rgba(17,24,39,.42); z-index: 9100; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 560px; max-width: 94vw; background: #fff; z-index: 9101;
  display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: slideIn .2s ease-out;
}
@keyframes slideIn { from { transform: translateX(28px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer .d-head { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.drawer .d-head h3 { flex: 1; font-size: 16px; }
.drawer .d-head .x { cursor: pointer; color: var(--text-3); font-size: 20px; }
.drawer .d-body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer .d-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }

/* 详情键值表 */
.kv { display: grid; grid-template-columns: 132px 1fr; gap: 9px 14px; font-size: 13.5px; }
.kv .k { color: var(--text-3); }
.kv .v { color: var(--text); word-break: break-all; }
.section-title { font-size: 13px; font-weight: 700; color: var(--text-2); margin: 18px 0 10px; padding-left: 9px; border-left: 3px solid var(--primary); }

/* 图片上传 */
.uploader { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.uploader .preview { width: 96px; height: 96px; border-radius: 10px; border: 1px solid var(--line); object-fit: cover; background: #f6f8fa; }
.uploader .hint { font-size: 12px; color: var(--text-3); }

/* 加载 */
.loading { padding: 40px; text-align: center; color: var(--text-3); }
.spin {
  width: 26px; height: 26px; border: 3px solid #e3e8ee; border-top-color: var(--primary); border-radius: 50%;
  display: inline-block; animation: sp .7s linear infinite; vertical-align: -6px; margin-right: 9px;
}
@keyframes sp { to { transform: rotate(360deg); } }

/* 迷你趋势柱 */
.mini-bars { display: flex; align-items: flex-end; gap: 4px; height: 76px; margin-top: 6px; }
.mini-bars i { flex: 1; background: linear-gradient(180deg, #ff8a73, var(--primary)); border-radius: 4px 4px 2px 2px; min-height: 3px; }
.mini-bars i.g { background: linear-gradient(180deg, #6ee7a8, var(--green)); }
.bar-x { display: flex; gap: 4px; color: var(--text-3); font-size: 10.5px; margin-top: 4px; }
.bar-x span { flex: 1; text-align: center; }
