/* ============================================================
   杨玉环 · 总部端 PC 后台
   设计基调：餐饮暖橙 + 深色侧边栏 + 浅色工作区
   ============================================================ */

:root {
  --brand: #c8102e;
  --brand-dark: #9e0b23;
  --brand-soft: #fdeef0;
  --ink: #1f2329;
  --ink-2: #4e5969;
  --ink-3: #86909c;
  --line: #e8eaed;
  --bg: #f5f6f8;
  --card: #ffffff;
  --ok: #00a870;
  --warn: #ed7b2f;
  --bad: #d54941;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 24, 31, .06), 0 6px 20px rgba(20, 24, 31, .05);
}

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

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

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

.sidebar {
  width: 216px;
  flex: 0 0 216px;
  background: #1d2129;
  color: #c9cdd4;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  padding: 20px 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.brand h1 { font-size: 17px; color: #fff; letter-spacing: .5px; }
.brand h1 span { color: var(--brand); }
.brand p { font-size: 11px; color: #6b7280; margin-top: 3px; letter-spacing: .4px; }

.nav { padding: 10px 10px; overflow-y: auto; flex: 1; }
.nav-group { font-size: 11px; color: #5c6370; padding: 14px 10px 6px; letter-spacing: .6px; }
.nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 11px; border-radius: 8px;
  color: #c9cdd4; text-decoration: none;
  font-size: 13.5px; cursor: pointer; transition: all .14s;
  margin-bottom: 1px;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.active { background: var(--brand); color: #fff; font-weight: 500; }
.nav a .ic { width: 18px; text-align: center; font-size: 14px; }
.nav a .badge {
  margin-left: auto; background: rgba(255, 255, 255, .16);
  font-size: 11px; padding: 1px 7px; border-radius: 9px;
}
.nav a.active .badge { background: rgba(255, 255, 255, .28); }

.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 22px; gap: 14px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h2 { font-size: 16px; font-weight: 600; }
.topbar .spacer { flex: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--brand-soft); color: var(--brand-dark);
  padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500;
}
.user { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--brand);
  color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 600;
}

.content { padding: 20px 22px 40px; flex: 1; }
.home-banner-preview { width: min(100%, 750px); aspect-ratio: 750 / 430; overflow: hidden; border: 1px dashed #d9cba9; border-radius: 12px; background: #fffaf0; display: grid; place-items: center; }
.home-banner-preview img { width: 100%; height: 100%; object-fit: cover; }
.home-banner-empty { color: #8c7a5c; font-size: 14px; }

/* ---------------- 通用组件 ---------------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px;
}
.card-h { display: flex; align-items: center; margin-bottom: 14px; }
.card-h h3 { font-size: 14.5px; font-weight: 600; }
.card-h .sub { font-size: 12px; color: var(--ink-3); margin-left: 10px; }
.card-h .spacer { flex: 1; }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 1280px) { .g5 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(2, 1fr); } }

/* KPI 卡 */
.kpi {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; position: relative; overflow: hidden;
}
.kpi::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--brand); opacity: .85;
}
.kpi .label { font-size: 12.5px; color: var(--ink-3); display: flex; align-items: center; gap: 5px; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 7px; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: 14px; font-weight: 500; color: var(--ink-3); margin-left: 2px; }
.kpi .foot { font-size: 12px; color: var(--ink-3); margin-top: 6px; }
.kpi.alt::before { background: #4080ff; }
.kpi.ok::before { background: var(--ok); }
.kpi.warn::before { background: var(--warn); }

/* 涨跌 */
.up { color: var(--bad); font-weight: 600; }
.down { color: var(--ok); font-weight: 600; }
.flat { color: var(--ink-3); }

/* 表格 */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; padding: 10px 10px; color: var(--ink-3);
  font-weight: 500; font-size: 12.5px; border-bottom: 1px solid var(--line);
  white-space: nowrap; background: #fafbfc;
}
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--brand); }
thead th .ar { font-size: 9px; opacity: .45; margin-left: 3px; }
thead th.sorted .ar { opacity: 1; color: var(--brand); }
tbody td { padding: 11px 10px; border-bottom: 1px solid #f2f3f5; }
tbody tr:hover { background: #fafbfc; }
tbody tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; }

/* 标签 */
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 5px;
  font-size: 11.5px; font-weight: 500; line-height: 1.6; white-space: nowrap;
}
.tag.gray { background: #f2f3f5; color: var(--ink-2); }
.tag.blue { background: #e8f3ff; color: #1d6fd4; }
.tag.green { background: #e8fff4; color: #00875a; }
.tag.orange { background: #fff4e8; color: #c25b12; }
.tag.red { background: #ffece8; color: #cb2634; }
.tag.purple { background: #f5e8ff; color: #7a3ec2; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 14px; border-radius: 7px; border: 1px solid var(--line);
  background: #fff; color: var(--ink-2); font-size: 13px; cursor: pointer;
  transition: all .14s; font-family: inherit;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 500; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.sm { padding: 3px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-3); }
.btn-ghost:hover { color: var(--brand); border-color: transparent; }

/* 表单 */
select, input[type=text], input[type=number], input[type=search] {
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 7px;
  font-size: 13px; background: #fff; color: var(--ink); font-family: inherit;
  outline: none; transition: border-color .14s;
}
select:focus, input:focus { border-color: var(--brand); }
label.fld { display: inline-flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--ink-3); }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }

/* 进度条 */
.bar { height: 7px; border-radius: 4px; background: #eef0f3; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 4px; transition: width .4s; }
.bar.blue > i { background: #4080ff; }
.bar.green > i { background: var(--ok); }

/* 空状态 & 加载 */
.empty { text-align: center; color: var(--ink-3); padding: 46px 0; font-size: 13px; }
.empty .e-ic { font-size: 34px; display: block; margin-bottom: 10px; opacity: .5; }
.loading { text-align: center; padding: 40px; color: var(--ink-3); font-size: 13px; }
.spin {
  width: 22px; height: 22px; border: 2.5px solid #e8eaed; border-top-color: var(--brand);
  border-radius: 50%; animation: spin .7s linear infinite; margin: 0 auto 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 图表容器
   注意：Chart.js（responsive 模式）会按 canvas 的「父容器尺寸」回写 canvas 的
   属性宽高。若直接给 canvas 设 height，属性尺寸与 CSS 尺寸会互相反馈，
   导致图表每帧放大一次（无限变大）。正确做法：外层给固定高度 + position:relative，
   canvas 用 100% 铺满，且不要再给 canvas 单独的 height。 */
.chart-box { position: relative; width: 100%; height: 240px; }
.chart-box > canvas { width: 100% !important; height: 100% !important; display: block; }
.chart-box.sm { height: 200px; }

/* 公告/提示条 */
.note {
  background: #fff8e6; border: 1px solid #ffe4a3; color: #8a6100;
  padding: 10px 14px; border-radius: 8px; font-size: 12.5px; margin-bottom: 14px;
}
.note.info { background: #eef6ff; border-color: #c9e0ff; color: #1d5fa8; }
.note code { background: rgba(0, 0, 0, .05); padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }

/* 登录页 */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(135deg, #1d2129 0%, #2b3139 55%, #3a2a22 100%);
}
.login-box {
  width: 372px; background: #fff; border-radius: 14px; padding: 34px 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.login-box h1 { font-size: 22px; text-align: center; margin-bottom: 4px; }
.login-box h1 span { color: var(--brand); }
.login-box .sub { text-align: center; color: var(--ink-3); font-size: 12.5px; margin-bottom: 26px; }
.login-box .row { margin-bottom: 14px; }
.login-box .row label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; }
.login-box input { width: 100%; padding: 10px 12px; }
.login-box .btn { width: 100%; justify-content: center; padding: 10px; margin-top: 6px; font-size: 14px; }
.login-err { color: var(--bad); font-size: 12.5px; min-height: 18px; margin-top: 10px; text-align: center; }
.login-tip { font-size: 11.5px; color: var(--ink-3); text-align: center; margin-top: 16px; line-height: 1.7; }
.login-tip code { background: #f5f6f8; padding: 1px 5px; border-radius: 4px; }

/* 详情抽屉 */
.drawer-mask {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 100;
  display: none;
}
.drawer-mask.show { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 520px; max-width: 92vw;
  background: #fff; z-index: 101; box-shadow: -8px 0 40px rgba(0, 0, 0, .18);
  transform: translateX(100%); transition: transform .26s cubic-bezier(.4, 0, .2, 1);
  display: flex; flex-direction: column;
}
.drawer.show { transform: translateX(0); }
.drawer-h {
  padding: 18px 22px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center;
}
.drawer-h h3 { font-size: 15px; }
.drawer-h .close { margin-left: auto; cursor: pointer; color: var(--ink-3); font-size: 20px; line-height: 1; }
.drawer-h .close:hover { color: var(--ink); }
.drawer-b { padding: 20px 22px; overflow-y: auto; flex: 1; }

.kv { display: grid; grid-template-columns: 96px 1fr; gap: 9px 12px; font-size: 13px; }
.kv dt { color: var(--ink-3); }
.kv dd { color: var(--ink); word-break: break-all; }

/* 算价步骤 */
.steps { list-style: none; counter-reset: st; }
.steps li {
  counter-increment: st; padding: 9px 0 9px 30px; position: relative;
  font-size: 13px; border-bottom: 1px dashed #eef0f3; color: var(--ink-2);
}
.steps li:last-child { border-bottom: none; }
.steps li::before {
  content: counter(st); position: absolute; left: 0; top: 9px;
  width: 19px; height: 19px; border-radius: 50%; background: var(--brand-soft);
  color: var(--brand-dark); font-size: 11px; display: grid; place-items: center; font-weight: 600;
}

.footer-note {
  text-align: center; color: var(--ink-3); font-size: 11.5px; padding: 18px 0 6px;
}

/* ============================================================
   定向发券（营销中心）
   ============================================================ */
.seg-form {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end;
}
.seg-form label.fld { min-width: 160px; }
.seg-form input[type="text"], .seg-form input[type="number"], .seg-form select {
  height: 32px; padding: 0 10px; border: 1px solid var(--line);
  border-radius: 6px; font-size: 13px; background: #fff; color: var(--ink); outline: none;
}
.seg-form input:focus, .seg-form select:focus { border-color: var(--brand); }
.seg-actions { display: flex; gap: 8px; margin-left: auto; }
.seg-levels { display: inline-flex; gap: 10px; padding-top: 4px; }
.seg-chk { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.seg-hit { font-size: 13px; color: var(--ink-2); padding: 8px 0 4px; }
.seg-hit b { color: var(--brand); font-size: 16px; margin: 0 2px; }
.seg-list { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 0 4px; }
.seg-chip {
  display: inline-flex; flex-direction: column; gap: 2px;
  padding: 6px 11px; background: var(--brand-soft); border-radius: 8px;
  font-size: 12.5px; color: var(--ink-2);
}
.seg-chip i { font-style: normal; font-size: 11px; color: var(--ink-3); }
.seg-done {
  padding: 10px 14px; background: #e8f8f0; border-radius: 8px;
  font-size: 13px; color: var(--ok); border-left: 3px solid var(--ok);
}
.seg-done b { font-size: 15px; }
.muted { color: var(--ink-3); font-size: 12.5px; }

/* 活动表单 · 满减阶梯行 */
.ac-rule-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px;
}
.ac-rule-row input {
  height: 30px; padding: 0 8px; border: 1px solid var(--line);
  border-radius: 6px; font-size: 13px; width: 84px; outline: none;
}
.ac-rule-row input:focus { border-color: var(--brand); }
