/* ============ 后台管理系统 · 设计系统 ============ */
:root {
  --green: #576532; --green-deep: #3E4A1E; --brand: #D12C1D; --gold: #9E0A15;
  --bg: #FAF3EE; --card: #ffffff; --ink: #1A1A1A; --ink-soft: #8A8378; --line: #EFDFD6;
  --red: #B03A2E; --blue: #5c7fa3; --pink: #9E0A15;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; }
button { font-family: inherit; border: none; background: none; cursor: pointer; color: inherit; }
input, select, textarea { font-family: inherit; outline: none; }
img { display: block; }
a { color: var(--brand); text-decoration: none; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #9E0A15, #D12C1D 55%, #E0654F); }
.login-card { width: 380px; background: rgba(255,255,255,.97); border-radius: 22px; padding: 38px 36px; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.login-card h1 { font-size: 21px; color: #9E0A15; }
.login-card .sub { font-size: 12px; color: var(--ink-soft); margin: 6px 0 24px; }
.login-card input { width: 100%; height: 44px; border: 1.5px solid var(--line); border-radius: 12px; padding: 0 14px; font-size: 14px; margin-bottom: 14px; background: #fbfaf6; }
.login-card input:focus { border-color: var(--green); }
.login-card .btn-login { width: 100%; height: 44px; border-radius: 12px; background: linear-gradient(135deg, #D12C1D, #9E0A15); color: #fff; font-size: 15px; font-weight: 600; }
.login-hint { margin-top: 18px; font-size: 11.5px; color: var(--ink-soft); line-height: 2; background: #f7f4ec; border-radius: 10px; padding: 10px 14px; }
.login-hint b { color: var(--green); }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 218px; background: linear-gradient(180deg, #262626, #141414); color: #EDE8E0; padding: 20px 12px; flex: none; display: flex; flex-direction: column; }
.sidebar .logo { padding: 0 10px 18px; border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: 14px; }
.sidebar .logo b { font-size: 16px; color: #fff; }
.sidebar .logo p { font-size: 11px; opacity: .55; margin-top: 3px; }
.menu-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; font-size: 13.5px; margin-bottom: 2px; opacity: .8; transition: .15s; width: 100%; text-align: left; }
.menu-item svg { width: 17px; height: 17px; flex: none; }
.menu-item:hover { background: rgba(255,255,255,.08); opacity: 1; }
.menu-item.on { background: rgba(209,44,29,.28); opacity: 1; font-weight: 600; }
.menu-item .badge { margin-left: auto; background: var(--brand); color: #fff; font-size: 10px; min-width: 17px; height: 17px; border-radius: 9px; display: grid; place-items: center; padding: 0 5px; }
.sidebar .foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid rgba(255,255,255,.12); font-size: 12px; display: flex; align-items: center; gap: 8px; }
.sidebar .foot .role-chip { font-size: 10px; background: rgba(255,255,255,.15); padding: 2px 8px; border-radius: 999px; }
.sidebar .foot button { margin-left: auto; opacity: .7; font-size: 12px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 56px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 24px; gap: 14px; }
.topbar h2 { font-size: 16px; }
.topbar .sim-link { margin-left: auto; font-size: 12px; }
.content { padding: 22px 24px 40px; flex: 1; }

/* ---------- 通用 ---------- */
.card { background: var(--card); border-radius: 16px; padding: 18px 20px; box-shadow: 0 2px 10px rgba(43,43,38,.05); }
.card + .card { margin-top: 16px; }
.card h3 { font-size: 15px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.card h3::before { content: ''; width: 4px; height: 14px; border-radius: 2px; background: linear-gradient(var(--brand), var(--gold)); }
.grid { display: grid; gap: 16px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: 10px; font-size: 13px; font-weight: 600; background: var(--green); color: #fff; }
.btn.brand { background: var(--brand); }
.btn.ghost { background: #fff; color: var(--green); border: 1.5px solid var(--green); }
.btn.sm { padding: 5px 11px; font-size: 12px; border-radius: 8px; }
.btn.danger { background: var(--red); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 600; color: var(--ink-soft); font-size: 12px; padding: 9px 10px; border-bottom: 1.5px solid var(--line); white-space: nowrap; }
.tbl td { padding: 11px 10px; border-bottom: 1px solid #f0ebdf; vertical-align: middle; }
.tbl tr:hover td { background: #faf8f2; }
.tag { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.tag.green { background: #e9f3ec; color: var(--green); }
.tag.orange { background: #fdf1e3; color: #b0713a; }
.tag.red { background: #fbeaea; color: var(--red); }
.tag.blue { background: #eaf0f6; color: var(--blue); }
.tag.gray { background: #f0ede4; color: #8a8577; }
.tag.pink { background: #f9eef4; color: var(--pink); }
.tag.gold { background: #fbf3df; color: #a4741f; }
.avatar-s { width: 34px; height: 34px; border-radius: 50%; }
.flex { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; }
.muted { color: var(--ink-soft); font-size: 12px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input, .toolbar select { height: 36px; border: 1.5px solid var(--line); border-radius: 10px; padding: 0 12px; font-size: 13px; background: #fff; }
.toolbar .spacer { flex: 1; }
.empty { text-align: center; color: var(--ink-soft); padding: 36px 0; font-size: 13px; }
.wb-toast { position: fixed; left: 50%; top: 12%; transform: translate(-50%, -8px); background: rgba(30,28,24,.9); color: #fff; padding: 11px 22px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 999; max-width: 70%; }
.wb-toast.show { opacity: 1; transform: translate(-50%, 0); }
.wb-toast.error { background: rgba(178,52,38,.92); }

/* ---------- 看板 ---------- */
.stat-cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 16px; }
.stat-card { background: #fff; border-radius: 14px; padding: 16px; box-shadow: 0 2px 10px rgba(43,43,38,.05); }
.stat-card p { font-size: 12px; color: var(--ink-soft); }
.stat-card b { font-size: 26px; display: block; margin-top: 6px; color: var(--green-deep); }
.stat-card .delta { font-size: 11px; color: var(--brand); margin-top: 4px; display: block; }
.chart-title { font-size: 13px; font-weight: 600; margin-bottom: 12px; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.bar-row .bl { width: 90px; font-size: 12px; color: var(--ink-soft); text-align: right; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bt { flex: 1; height: 18px; background: #f3efe4; border-radius: 9px; overflow: hidden; }
.bar-row .bt i { display: block; height: 100%; border-radius: 9px; background: linear-gradient(90deg, var(--green), #5cae7c); min-width: 2px; transition: width .6s; }
.bar-row .bv { width: 56px; font-size: 12px; font-weight: 600; color: var(--green-deep); }
.funnel-step { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.funnel-step .fb { height: 34px; border-radius: 8px; display: flex; align-items: center; padding: 0 12px; color: #fff; font-size: 12px; font-weight: 600; min-width: 60px; transition: width .6s; }
.funnel-step .fl { font-size: 12px; color: var(--ink-soft); width: 110px; flex: none; }
.line-chart { width: 100%; }

/* ---------- CMS ---------- */
.cms-layout { display: grid; grid-template-columns: 240px 1fr; gap: 16px; align-items: start; }
.page-tree .pt-item { padding: 9px 12px; border-radius: 10px; font-size: 13px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.page-tree .pt-item.on { background: #F6EAE2; color: #D12C1D; font-weight: 600; }
.slot-item { border: 1.5px solid var(--line); border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; }
.slot-item .sh { display: flex; align-items: center; gap: 10px; }
.slot-item .sh b { font-size: 14px; }
.slot-item .sh .type { font-size: 10px; background: #f0ebdf; color: #8a8577; padding: 2px 8px; border-radius: 999px; }
.slot-items-editor { margin-top: 12px; }
.si-row { display: flex; gap: 8px; align-items: center; padding: 8px; border: 1px dashed var(--line); border-radius: 10px; margin-bottom: 8px; background: #fbfaf6; }
.si-row img { width: 56px; height: 38px; border-radius: 6px; object-fit: cover; flex: none; }
.si-row input { height: 32px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; font-size: 12px; background: #fff; min-width: 0; }
.si-row .f-src { flex: 2; }
.si-row .f-title { flex: 1.2; }
.si-row .f-link { flex: 1.5; }
.si-row .del { color: var(--red); flex: none; font-size: 16px; padding: 4px 8px; }

/* ---------- 弹层 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(25,23,18,.5); display: flex; align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(2px); }
.modal-panel { width: min(760px, 94vw); max-height: 88vh; overflow-y: auto; background: #fff; border-radius: 18px; padding: 24px; animation: up .25s cubic-bezier(.16,1,.3,1); }
.modal-panel.narrow { width: min(440px, 92vw); }
@keyframes up { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-panel h3 { font-size: 16px; margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.fg-row { display: flex; flex-direction: column; gap: 6px; }
.fg-row.full { grid-column: 1 / -1; }
.fg-row label { font-size: 12px; color: var(--ink-soft); }
.fg-row input, .fg-row select, .fg-row textarea { height: 38px; border: 1.5px solid var(--line); border-radius: 10px; padding: 0 12px; font-size: 13px; background: #fbfaf6; }
.fg-row textarea { height: auto; padding: 10px 12px; resize: vertical; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

@media (max-width: 900px) {
  .sidebar { width: 64px; }
  .sidebar .logo b, .sidebar .logo p, .menu-item span, .sidebar .foot .who { display: none; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .cms-layout { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

/* ===== v1.4 品控现场分区编辑器 ===== */
.vz-sec { border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; background: #fbfaf6; }
.vz-head { font-size: 13px; font-weight: 600; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; color: var(--green-deep); }
.vz-head input { height: 32px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; font-size: 13px; width: 200px; background: #fff; }

.si-empty { width: 56px; height: 38px; border-radius: 6px; background: #F0EBDF; color: #8A8378; font-size: 11px; display: flex; align-items: center; justify-content: center; flex: none; }

/* ===== v2.6 后台视觉打磨 ===== */
.sidebar .menu-group { padding: 16px 18px 6px; font-size: 11px; letter-spacing: 2px; color: rgba(255,255,255,.42); user-select: none; }
.sidebar .menu-item { position: relative; }
.sidebar .menu-item:hover { background: rgba(255,255,255,.07); }
.sidebar .menu-item.on::before { content: ''; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: linear-gradient(#D12C1D, #9E0A15); }
.sidebar .menu-item.on { background: rgba(209,44,29,.28); }
.badge { background: #D12C1D; color: #fff; }
.topbar { position: sticky; top: 0; z-index: 5; background: linear-gradient(#ffffff, #FDFBF6); border-bottom: 1px solid #F0EAE0; }
.content { max-width: 1280px; }
.card { border: 1px solid rgba(0,0,0,.03); }
table th { background: #FAF6EF; font-size: 12px; }
table tbody tr { transition: background .15s; }
table tbody tr:hover { background: #FBF7F1; }
.btn.brand { background: linear-gradient(135deg, #D12C1D, #9E0A15); }

/* ===== v2.8 素材直传 ===== */
.si-row .up { color: #D12C1D; font-size: 12px; font-weight: 600; padding: 6px 10px; border: 1.5px solid #D12C1D; border-radius: 8px; flex: none; background: #fff; }
.si-row .up:hover { background: #D12C1D; color: #fff; }
.fg-row .flex { gap: 8px; }

/* ===== v3.1 上传裁剪框 ===== */
.crop-stage { position: relative; margin: 0 auto; overflow: hidden; border: 2px dashed #D12C1D; border-radius: 8px; touch-action: none; cursor: grab; }
.crop-stage:active { cursor: grabbing; }
.crop-stage img { position: absolute; left: 0; top: 0; user-select: none; -webkit-user-drag: none; pointer-events: none; }
