:root {
  --ink: #1B1C1A;
  --muted: #7C7F78;
  --faint: #A7AAA3;
  --line: #E6E7E2;
  --bg: #F4F5F2;
  --card: #FFFFFF;
  --brand: #1F3D36;
  --brand-soft: #EDF1EE;
  --accent: #B45B33;
  --accent-soft: #FBEEE7;
  --gold: #C9A227;
  --ok: #3F6E5A;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

.layout { display: flex; min-height: 100vh; }

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: 216px; flex-shrink: 0; background: var(--brand); color: #E9EDE7;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 18px; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 10px; background: #2C524A;
  display: flex; align-items: center; justify-content: center;
  color: #EFE9D8; font-size: 18px; letter-spacing: 1px;
}
.brand-name { font-size: 15px; font-weight: 600; letter-spacing: 1px; color: #F4F1E7; }
.brand-sub { font-size: 10px; color: rgba(233, 237, 231, 0.45); letter-spacing: 2px; margin-top: 2px; }

.nav { flex: 1; overflow-y: auto; padding: 6px 10px 10px; }
.nav-group {
  font-size: 10px; color: rgba(233, 237, 231, 0.35); letter-spacing: 2px;
  padding: 16px 10px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px; color: rgba(233, 237, 231, 0.78);
  text-decoration: none; font-size: 13px; position: relative; cursor: pointer;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-item.active { background: rgba(255, 255, 255, 0.12); color: #fff; font-weight: 500; }
.nav-item.active::before {
  content: ""; position: absolute; left: -10px; top: 9px; bottom: 9px;
  width: 3px; border-radius: 2px; background: var(--gold);
}
.ni-ico {
  width: 20px; height: 20px; border-radius: 6px; background: rgba(255, 255, 255, 0.09);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: rgba(255, 255, 255, 0.72); flex-shrink: 0;
}
.ni-badge {
  margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--accent); color: #fff;
  font-size: 10px; font-style: normal; line-height: 18px; text-align: center;
  display: none;
}
.ni-badge.show { display: block; }

.side-foot { padding: 14px 18px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.sf-line { font-size: 10px; color: rgba(233, 237, 231, 0.55); line-height: 1.8; }
.sf-line.dim { color: rgba(233, 237, 231, 0.3); }

/* ---------- 主区 ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 62px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; position: sticky; top: 0; z-index: 20;
}
.tb-left { display: flex; align-items: baseline; gap: 12px; }
.tb-left h1 { font-size: 17px; font-weight: 600; letter-spacing: 0.5px; }
.tb-sub { font-size: 11px; color: var(--faint); }
.tb-right { display: flex; align-items: center; gap: 14px; }
.search input {
  width: 260px; height: 34px; border: 1px solid var(--line); border-radius: 8px;
  padding: 0 12px; font-size: 12px; background: #FAFAF8; outline: none;
}
.search input:focus { border-color: var(--brand); background: #fff; }
.tb-chip {
  height: 26px; padding: 0 10px; border-radius: 6px; background: var(--brand-soft);
  color: var(--brand); font-size: 11px; display: flex; align-items: center;
  letter-spacing: 0.5px;
}
.tb-user { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--brand);
  color: #EFE9D8; font-size: 12px; display: flex; align-items: center; justify-content: center;
}
.tb-user-name { font-size: 12px; font-weight: 500; }
.tb-user-role { font-size: 10px; color: var(--faint); }

.view { padding: 22px 24px 48px; }

/* ---------- 通用块 ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px;
}
.card + .card { margin-top: 14px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.card-title { font-size: 13px; font-weight: 600; letter-spacing: 0.5px; }
.card-title .bar {
  display: inline-block; width: 3px; height: 12px; background: var(--accent);
  border-radius: 2px; margin-right: 8px; vertical-align: -1px;
}
.card-sub { font-size: 11px; color: var(--faint); }
.grid { display: grid; gap: 14px; }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.g-2-1 { grid-template-columns: 1.55fr 1fr; }
.g-1-2 { grid-template-columns: 1fr 1.6fr; }
.row { display: flex; align-items: center; gap: 10px; }
.between { display: flex; align-items: center; justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 11px; }
.bold { font-weight: 600; }
.mt8 { margin-top: 8px; }
.mt14 { margin-top: 14px; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.accent { color: var(--accent); }

/* ---------- KPI ---------- */
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.kpi-label { font-size: 11px; color: var(--muted); letter-spacing: 0.5px; }
.kpi-value { font-size: 26px; font-weight: 600; margin-top: 8px; letter-spacing: -0.5px; }
.kpi-value small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.kpi-foot { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 11px; }
.up { color: var(--accent); }
.down { color: var(--ok); }
.kpi-spark { height: 26px; margin-top: 8px; }

/* ---------- 按钮 ---------- */
.btn {
  height: 32px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-size: 12px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-family: inherit;
}
.btn:hover { border-color: #C9CCC6; background: #FCFCFB; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #F4F1E7; }
.btn-primary:hover { background: #274B42; border-color: #274B42; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: #A0512C; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #F3F4F1; color: var(--ink); }
.btn-sm { height: 26px; padding: 0 10px; font-size: 11px; border-radius: 6px; }
.btn-link { border: none; background: none; color: var(--brand); font-size: 12px; cursor: pointer; padding: 0; }
.btn-link.danger { color: var(--accent); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 11px; font-weight: 500; color: var(--muted);
  padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
  background: #FBFBF9;
}
tbody td {
  padding: 12px; border-bottom: 1px solid #F1F2EE; font-size: 12px; vertical-align: middle;
}
tbody tr:hover td { background: #FBFBF8; }
tbody tr:last-child td { border-bottom: none; }
.t-right { text-align: right; }
.t-center { text-align: center; }

/* ---------- 小元素 ---------- */
.tag {
  display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 10px;
  background: #F2F3EF; color: #6C6F68; letter-spacing: 0.3px; white-space: nowrap;
}
.tag-brand { background: var(--brand-soft); color: var(--brand); }
.tag-accent { background: var(--accent-soft); color: var(--accent); }
.tag-gold { background: #FBF4DF; color: #8A6E14; }
.tag-gray { background: #F0F1ED; color: #8A8D86; }
.tag-red { background: #FBEAEA; color: #A6403C; }

.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot-ok { background: var(--ok); }
.dot-warn { background: var(--gold); }
.dot-accent { background: var(--accent); }
.dot-gray { background: #C6C9C2; }

.swatch {
  width: 40px; height: 50px; border-radius: 6px; position: relative; overflow: hidden;
  flex-shrink: 0; border: 1px solid rgba(0, 0, 0, 0.06);
}
.swatch::after {
  content: ""; position: absolute; inset: 0;
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,.16) 0, rgba(255,255,255,.16) 1px, transparent 1px, transparent 3px),
    repeating-linear-gradient(90deg, rgba(0,0,0,.1) 0, rgba(0,0,0,.1) 1px, transparent 1px, transparent 3px);
  opacity: .5;
}
.swatch-lg { width: 56px; height: 70px; }
.prod { display: flex; align-items: center; gap: 10px; }
.prod-name { font-size: 12px; font-weight: 500; }
.prod-meta { font-size: 10px; color: var(--faint); margin-top: 3px; }

.bars { display: flex; align-items: center; gap: 8px; }
.bar-track { flex: 1; height: 6px; border-radius: 3px; background: #F0F1ED; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; background: var(--brand); }
.bar-fill.alt { background: var(--accent); }
.bar-fill.gold { background: var(--gold); }
.bar-val { width: 40px; text-align: right; font-size: 11px; color: var(--muted); }

.seg { display: inline-flex; background: #F0F1ED; border-radius: 8px; padding: 3px; gap: 2px; }
.seg button {
  height: 26px; padding: 0 12px; border: none; background: none; border-radius: 6px;
  font-size: 11px; color: var(--muted); cursor: pointer; font-family: inherit;
}
.seg button.on { background: #fff; color: var(--brand); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.06); }

.empty { text-align: center; padding: 40px 0; color: var(--faint); font-size: 12px; }
.empty-ico {
  width: 40px; height: 40px; border-radius: 50%; background: #F0F1ED;
  margin: 0 auto 10px; display: flex; align-items: center; justify-content: center;
  color: var(--faint); font-size: 14px;
}

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-item { display: flex; flex-direction: column; gap: 6px; }
.form-item.full { grid-column: 1 / -1; }
.form-item label { font-size: 11px; color: var(--muted); }
.form-item input, .form-item select, .form-item textarea {
  height: 34px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px;
  font-size: 12px; font-family: inherit; outline: none; background: #fff; color: var(--ink);
}
.form-item textarea { height: 68px; padding: 8px 10px; resize: vertical; }
.form-item input:focus, .form-item select:focus, .form-item textarea:focus { border-color: var(--brand); }

/* ---------- 模态 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20, 26, 24, 0.42); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal {
  background: #fff; border-radius: 14px; width: 560px; max-width: 100%;
  max-height: 88vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(20, 26, 24, 0.2);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.modal-title { font-size: 14px; font-weight: 600; }
.modal-close { border: none; background: none; font-size: 18px; color: var(--faint); cursor: pointer; line-height: 1; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--line);
}
.modal-wide { width: 720px; }

.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: rgba(27, 28, 26, 0.92); color: #fff; padding: 9px 18px;
  border-radius: 8px; font-size: 12px; z-index: 200;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

/* ---------- 图表 ---------- */
.chart { width: 100%; height: 200px; display: block; }
.chart-legend { display: flex; gap: 16px; margin-top: 10px; }
.lg { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.lg i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

.donut-wrap { display: flex; align-items: center; gap: 18px; }
.donut { width: 132px; height: 132px; flex-shrink: 0; }
.donut-list { flex: 1; display: flex; flex-direction: column; gap: 9px; }
.dl { display: flex; align-items: center; font-size: 11px; gap: 6px; }
.dl i { width: 8px; height: 8px; border-radius: 2px; }
.dl span { flex: 1; color: var(--muted); }
.dl b { font-weight: 600; }

/* ---------- 详情行 ---------- */
.kv { display: flex; padding: 9px 0; border-bottom: 1px dashed #F0F1ED; font-size: 12px; }
.kv:last-child { border-bottom: none; }
.kv-k { width: 90px; color: var(--muted); flex-shrink: 0; }
.kv-v { flex: 1; }
.steps { display: flex; margin: 6px 0 16px; }
.step { flex: 1; display: flex; flex-direction: column; align-items: center; position: relative; }
.step::before {
  content: ""; position: absolute; top: 5px; left: -50%; width: 100%; height: 1px; background: var(--line);
}
.step:first-child::before { display: none; }
.step-dot { width: 11px; height: 11px; border-radius: 50%; background: #E2E4DE; position: relative; z-index: 2; }
.step.on .step-dot { background: var(--brand); box-shadow: 0 0 0 3px rgba(31, 61, 54, 0.1); }
.step-txt { font-size: 10px; color: var(--faint); margin-top: 7px; }
.step.on .step-txt { color: var(--brand); font-weight: 500; }

@media (max-width: 1200px) {
  .g-4 { grid-template-columns: repeat(2, 1fr); }
  .g-2-1, .g-1-2, .g-3 { grid-template-columns: 1fr; }
}

/* 修复 hidden 属性被 display:flex 覆盖 */
[hidden] { display: none !important; }

/* ---------- 登录 ---------- */
.login-mask {
  position: fixed; inset: 0; z-index: 300;
  background: linear-gradient(160deg, #17332C 0%, #1F3D36 45%, #2C524A 100%);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  width: 380px; background: #fff; border-radius: 16px; padding: 30px 28px 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-logo {
  width: 42px; height: 42px; border-radius: 12px; background: #1F3D36;
  color: #EFE9D8; display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.login-name { font-size: 16px; font-weight: 600; letter-spacing: 0.5px; }
.login-sub { font-size: 11px; color: var(--faint); margin-top: 3px; }
.login-field { margin-bottom: 14px; }
.login-field label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.login-field input {
  width: 100%; height: 38px; border: 1px solid var(--line); border-radius: 8px;
  padding: 0 12px; font-size: 13px; outline: none; font-family: inherit;
}
.login-field input:focus { border-color: var(--brand); }
.login-btn {
  width: 100%; height: 40px; margin-top: 8px; border: none; border-radius: 8px;
  background: var(--brand); color: #F4F1E7; font-size: 13px; letter-spacing: 1px;
  cursor: pointer; font-family: inherit;
}
.login-btn:hover { background: #274B42; }
.login-btn:disabled { background: #9AA9A3; cursor: default; }
.login-msg { font-size: 11px; color: var(--muted); min-height: 16px; margin-top: 10px; line-height: 1.6; }
.login-foot {
  display: flex; align-items: center; gap: 8px; margin-top: 14px; padding-top: 12px;
  border-top: 1px dashed var(--line); font-size: 10px; color: var(--faint);
}
.login-foot code { font-size: 10px; color: var(--muted); background: #F5F6F3; padding: 2px 6px; border-radius: 4px; }
