* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: var(--fs-md);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ---------- 布局 ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 208px; flex: 0 0 208px; background: var(--surface);
  border-right: 1px solid var(--line); padding: var(--space-4) var(--space-3);
  display: flex; flex-direction: column; gap: var(--space-1); position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; background: var(--brand);
  color: var(--on-brand); display: grid; place-items: center; font-weight: 700; font-size: 16px;
}
.brand-name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--ink-500); }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--ink-700); cursor: pointer; border: 0; background: none; text-align: left; width: 100%;
}
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--brand-weak); color: var(--brand-dark); font-weight: 600; }
.nav-item .ico { width: 18px; text-align: center; }
.sidebar-foot { margin-top: auto; font-size: 11px; color: var(--ink-300); padding: 8px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 var(--space-5); background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-store { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.topbar-right { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-500); }
.view { padding: var(--space-5); max-width: 1180px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: var(--space-4); }
.page-head p { color: var(--ink-500); font-size: 13px; margin-top: 2px; }

/* ---------- 卡片与统计 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: var(--space-4); box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: var(--space-4); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-3); }
.grid { display: grid; gap: var(--space-4); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-4); }
.stat .label { font-size: 12px; color: var(--ink-500); }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat .hint { font-size: 12px; color: var(--ink-300); margin-top: 2px; }

/* ---------- 缺项红字 ---------- */
.gap-list { display: flex; flex-direction: column; gap: 8px; }
.gap {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: #FFFBEB;
}
.gap.danger { background: #FDF0EE; border-color: #F3C9C2; }
.gap.info { background: #F2F6FB; border-color: #D8E3F0; }
.gap .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; background: var(--warning); flex: 0 0 8px; }
.gap.danger .dot { background: var(--danger); }
.gap.info .dot { background: #3E6FB0; }
.gap .t { font-weight: 600; color: var(--danger); }
.gap.info .t { color: #2D5A96; }
.gap.warn .t { color: #8a5a00; }
.gap .h { font-size: 12px; color: var(--ink-500); }

/* ---------- 表单与按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-900);
  padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-300); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-deep); border-color: var(--brand-deep); }
.btn.danger { color: var(--danger); border-color: #EBC5BF; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--ink-500); }
input[type=text], input[type=password], input[type=number], input[type=email], select, textarea {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; background: var(--card);
  min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-weak); border-color: var(--brand); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 12px; color: var(--muted); font-weight: 500; background: var(--bg); }
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- 徽标 ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 12px; background: var(--bg); color: var(--ink-700); }
.badge.green { background: #E8F4EE; color: var(--success); }
.badge.orange { background: #FDF0E6; color: #A8601B; }
.badge.red { background: #FBEAE7; color: var(--danger); }
.badge.blue { background: #EAF0F8; color: #2D5A96; }
.badge.gray { background: #EFF1F4; color: var(--ink-500); }

/* ---------- 订单卡片 ---------- */
.order-list { display: flex; flex-direction: column; gap: 12px; }
.order-card { border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); padding: 14px; }
.order-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.order-no { font-weight: 700; font-variant-numeric: tabular-nums; }
.order-meta { font-size: 12px; color: var(--ink-500); }
.order-items { font-size: 13px; }
.order-item { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px dotted var(--line); }
.order-item:last-child { border-bottom: 0; }
.order-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.amount { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- 提示 ---------- */
.empty { padding: 36px 16px; text-align: center; color: var(--ink-300); font-size: 13px; }
#toast { position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%); z-index: 99; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast-item { background: rgba(31,35,41,.92); color: #fff; padding: 9px 16px; border-radius: 99px; font-size: 13px; box-shadow: var(--shadow-md); }
.toast-item.error { background: rgba(192,57,43,.96); }

/* ---------- 弹层 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(17,20,24,.45); z-index: 80;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 560px;
  max-height: 82vh; display: flex; flex-direction: column; box-shadow: var(--shadow-md);
}
.modal-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.icon-btn { border: 0; background: none; font-size: 18px; cursor: pointer; color: var(--ink-500); line-height: 1; padding: 4px; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, var(--brand-50), var(--bg) 60%); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: var(--radius-lg); padding: 28px; box-shadow: var(--shadow-md); }
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card .sub { color: var(--ink-500); font-size: 13px; margin-bottom: 20px; }

/* ---------- 移动端 ---------- */
.sidebar-toggle { display: none; }
@media (max-width: 960px) {
  .sidebar {
    position: fixed; z-index: 60; left: -230px; transition: left .2s ease; box-shadow: var(--shadow-md);
  }
  .sidebar.open { left: 0; }
  .sidebar-toggle { display: inline-flex; }
  .view { padding: var(--space-4); }
  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 var(--space-4); }
  body { padding-bottom: env(safe-area-inset-bottom); }
}
