:root {
  --primary: #1f6feb;
  --primary-d: #1a5fd0;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e3e6ea;
  --text: #1f2329;
  --muted: #8a9099;
  --err: #d93025;
  --ok: #1a7f37;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--primary); text-decoration: none; }

/* ---------- 登录页 ---------- */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg,#f0f2f5 0%,#e8ebf0 100%); }
.login-card { background: #fff; border-radius: 14px; box-shadow: 0 8px 40px rgba(20,30,50,.10); padding: 44px 40px 32px; width: 400px; max-width: 92vw; }
.login-brand { text-align: center; margin-bottom: 18px; }
.login-brand img { height: 30px; }
.login-card h1 { font-size: 20px; margin: 0 0 4px; text-align: center; }
.login-sub { text-align: center; color: var(--muted); margin: 0 0 24px; }
.login-card label { display: block; font-size: 13px; color: #444; margin: 14px 0 6px; }
.login-foot { text-align: center; color: var(--muted); font-size: 12px; margin: 26px 0 0; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 210px; background: #1c2333; color: #cfd6e2; display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px; border-bottom: 1px solid rgba(255,255,255,.08); font-weight: 600; color: #fff; }
.side-brand img { height: 20px; filter: brightness(0) invert(1); }
.side-nav { flex: 1; padding: 12px 0; }
.side-nav a { display: block; padding: 11px 20px; color: #cfd6e2; font-size: 14px; border-left: 3px solid transparent; }
.side-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-nav a.active { background: rgba(31,111,235,.18); color: #fff; border-left-color: var(--primary); }
.side-foot { padding: 12px 0; border-top: 1px solid rgba(255,255,255,.08); }
.side-foot a { display: block; padding: 9px 20px; color: #9aa5b5; font-size: 13px; }
.side-foot a:hover { color: #fff; }
.main { flex: 1; margin-left: 210px; display: flex; flex-direction: column; min-width: 0; }
.topbar { background: #fff; border-bottom: 1px solid var(--border); padding: 14px 26px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10; }
.topbar h2 { margin: 0; font-size: 17px; }
.topbar-user { display: flex; align-items: center; gap: 10px; color: #555; font-size: 13px; }
.role-badge { background: #fff4e0; color: #b26a00; border: 1px solid #ffd591; border-radius: 999px; padding: 2px 10px; font-size: 12px; }
.content { padding: 22px 26px 60px; }

/* ---------- 通用组件 ---------- */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; margin-bottom: 18px; }
.panel h3 { margin: 0 0 10px; font-size: 15px; }
.panel-tip { background: #eef5ff; border-color: #cfe2ff; color: #2b4a75; line-height: 1.7; }
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.input { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 13px; background: #fff; color: var(--text); outline: none; min-width: 0; }
.input:focus { border-color: var(--primary); }
.btn { border: 1px solid var(--border); background: #fff; color: var(--text); border-radius: 8px; padding: 8px 14px; font-size: 13px; cursor: pointer; }
.btn:hover { border-color: #c6cdd6; background: #fafbfc; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); border-color: var(--primary-d); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; margin-top: 20px; padding: 11px; font-size: 15px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.alert { border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 14px; }
.alert-err { background: #fdecea; color: var(--err); border: 1px solid #f5c6c0; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input { min-width: 200px; }
.toolbar select.input { min-width: 140px; }

/* ---------- 表格 ---------- */
.table-wrap { background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow: auto; }
.table { width: 100%; border-collapse: collapse; background: #fff; }
.table th { text-align: left; background: #fafbfc; border-bottom: 1px solid var(--border); padding: 10px 12px; font-size: 12px; color: #666; white-space: nowrap; }
.table td { border-bottom: 1px solid #f0f2f5; padding: 9px 12px; vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table .cell-orig { color: #555; max-width: 340px; word-break: break-all; }
.table .cell-cur { max-width: 340px; word-break: break-all; }
.pager { display: flex; align-items: center; gap: 12px; justify-content: flex-end; margin-top: 14px; }
.empty { background: #fff; border: 1px dashed var(--border); border-radius: 10px; color: var(--muted); text-align: center; padding: 60px 0; }

/* ---------- 图片管理 ---------- */
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 14px; }
.img-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.img-thumb { height: 130px; background: #f2f4f7 center/cover no-repeat; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.img-thumb img { max-width: 100%; max-height: 130px; display: block; }
.svg-ph { color: #aab; font-size: 12px; text-align: center; line-height: 1.6; background: repeating-conic-gradient(#f5f6f8 0% 25%, #eceff3 0% 50%) 0 0/16px 16px; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.img-info { padding: 10px 12px 6px; }
.img-badge-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.img-path { font-size: 12px; color: #333; word-break: break-all; line-height: 1.5; max-height: 36px; overflow: hidden; }
.img-meta { font-size: 12px; color: var(--muted); margin-top: 6px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.badge-fmt { background: #eef2ff; color: #3b5bdb; border-radius: 4px; padding: 1px 6px; font-size: 11px; font-weight: 600; }
.img-act { padding: 8px 12px 12px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.img-act input[type=file] { font-size: 12px; max-width: 100%; }
.dim-in { width: 62px !important; padding: 5px 6px; font-size: 12px; }

/* ---------- 分级定位（模块/页面/位置） ---------- */
.crumb { font-size: 13px; color: #666; margin: 0 0 14px; line-height: 1.6; }
.crumb b { color: var(--text); }
.crumb .sep { color: #c0c6cd; margin: 0 2px; }
.ord-badge { display: inline-block; background: var(--primary); color: #fff; border-radius: 4px; padding: 1px 7px; font-size: 11px; font-weight: 700; }
.ord-badge.gray { background: #9aa3ad; }
.ref-badge { display: inline-block; background: #e8f5e9; color: #1a7f37; border: 1px solid #bfe3c4; border-radius: 4px; padding: 1px 7px; font-size: 11px; }
.ctx-line { font-size: 12px; color: #2b4a75; background: #eef5ff; border-radius: 6px; padding: 4px 8px; margin-top: 6px; line-height: 1.5; word-break: break-all; }
select.input:disabled { background: #f5f6f8; color: #9aa0a8; }
.cell-ctx { color: #2b4a75; font-size: 12px; white-space: nowrap; }

/* ---------- 设置页 ---------- */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.logo-preview { background: repeating-conic-gradient(#f5f6f8 0% 25%, #eceff3 0% 50%) 0 0/16px 16px; border: 1px solid var(--border); border-radius: 8px; padding: 18px; display: flex; align-items: center; justify-content: center; min-height: 74px; }
.logo-preview img { max-width: 100%; max-height: 56px; }
.rule-new { margin-top: 12px; }
.rule-new .input { flex: 1; min-width: 150px; }
code { background: #f2f4f7; border-radius: 4px; padding: 1px 5px; font-size: 12px; }

/* ---------- 统计卡 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 20px; display: block; color: var(--text); transition: box-shadow .15s; }
.stat-card:hover { box-shadow: 0 4px 18px rgba(20,30,50,.08); }
.stat-num { font-size: 26px; font-weight: 700; }
.stat-label { margin-top: 4px; color: #444; }
.stat-sub { margin-top: 6px; color: var(--muted); font-size: 12px; }
.tips { margin: 0; padding-left: 18px; color: #555; line-height: 2; }

/* ---------- toast ---------- */
#toast { position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%); background: #1f2329; color: #fff; padding: 10px 20px; border-radius: 8px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 99; max-width: 80vw; }
#toast.show { opacity: .94; }
#toast.err { background: var(--err); }

@media (max-width: 760px) {
  .sidebar { width: 64px; }
  .side-brand span, .side-nav a, .side-foot a { font-size: 0; padding-left: 20px; }
  .side-brand { justify-content: center; padding: 16px 0; }
  .side-nav a::before { content: "●"; font-size: 10px; }
  .main { margin-left: 64px; }
  .content { padding: 14px; }
}

/* ---------- PC/SP 分流变体提示 ---------- */
.var-line { font-size: 12px; line-height: 1.7; color: #8a5a00; background: #fff8e6;
  border: 1px solid #ffe3a3; border-radius: 8px; padding: 7px 10px; margin-top: 8px; }
.var-line b { color: #b25e00; }
.var-chip { display: inline-block; background: #fff; border: 1px solid #ffd98a;
  border-radius: 999px; padding: 1px 9px; margin: 2px 4px 0 0; font-size: 11px;
  color: #6b4a00; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; vertical-align: bottom; }
.var-ck { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #8a5a00;
  background: #fff8e6; border: 1px solid #ffe3a3; border-radius: 8px; padding: 6px 10px;
  margin-top: 8px; cursor: pointer; flex-basis: 100%; }
.var-ck input { accent-color: #b25e00; }
