:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --border: #e7eaf0;
  --text: #111827;
  --muted: #6b7280;
  --primary: #2f6fed;
  --primary-600: #2563eb;
  --primary-soft: #eaf1fe;
  --sidebar: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #e2e8f0;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --info: #2563eb;
  --info-soft: #dbeafe;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --indigo: #6366f1;
  --indigo-soft: #e0e7ff;
  --gray-soft: #f3f4f6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .12);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ===== 布局 ===== */
#app { display: flex; min-height: 100vh; }
.sidebar {
  width: 224px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 18px 16px; }
.logo {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, #3b82f6, #2563eb 60%, #1d4ed8);
  color: #fff; font-size: 19px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(37, 99, 235, .35);
}
.brand-title { color: #f8fafc; font-size: 16px; font-weight: 700; letter-spacing: .5px; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--sidebar-text); margin-top: 2px; }
nav { flex: 1; padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 9px;
  color: var(--sidebar-text); text-decoration: none; font-weight: 500; cursor: pointer; user-select: none;
  transition: background .12s, color .12s;
}
.nav-item svg { width: 17px; height: 17px; stroke: currentColor; stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.nav-item:hover { background: rgba(148, 163, 184, .12); color: var(--sidebar-active); }
.nav-item.active { background: rgba(59, 130, 246, .16); color: #fff; }
.nav-item.active svg { stroke: #60a5fa; }
.sidebar-foot { padding: 14px 18px; font-size: 11px; color: #64748b; line-height: 1.75; border-top: 1px solid rgba(148, 163, 184, .15); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 28px; position: sticky; top: 0; z-index: 5;
}
.spacer { flex: 1; }
.merchant-name { font-weight: 600; }
.mode-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: var(--gray-soft); }
.mode-switch .seg {
  border: 0; background: transparent; padding: 6px 14px; font-size: 13px; cursor: pointer; color: var(--muted);
  transition: background .12s, color .12s;
}
.mode-switch .seg.active { background: var(--panel); color: var(--primary); font-weight: 600; box-shadow: 0 1px 2px rgba(16,24,40,.08); }
#envBadge { display: inline-flex; align-items: center; }
#envBadge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 6px; }

.view { padding: 26px 28px 40px; max-width: 1120px; width: 100%; }
.view h2 { margin: 0 0 4px; font-size: 21px; letter-spacing: .2px; }
.view .sub { color: var(--muted); margin: 0 0 22px; font-size: 13px; }

/* ===== 统计卡 ===== */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; display: flex; gap: 14px; align-items: flex-start;
}
.stat-icon { width: 42px; height: 42px; border-radius: 11px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon svg { width: 21px; height: 21px; stroke: currentColor; stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.stat-icon.green { background: var(--ok-soft); color: var(--ok); }
.stat-icon.blue { background: var(--info-soft); color: var(--info); }
.stat-icon.amber { background: var(--warn-soft); color: var(--warn); }
.stat-icon.indigo { background: var(--indigo-soft); color: var(--indigo); }
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 3px; letter-spacing: .3px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat .value.small { font-size: 22px; }
.stat .value.acc { color: var(--ok); }

.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 22px; margin-bottom: 18px;
}
.panel h3 { margin: 0 0 14px; font-size: 15px; }
.panel .more { color: var(--primary); font-size: 13px; text-decoration: none; font-weight: 500; }
.panel .more:hover { color: var(--primary-600); }

/* ===== 表格 ===== */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; background: #f8fafc; }
th:first-child { border-top-left-radius: 8px; }
th:last-child { border-top-right-radius: 8px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fafc; }
td.money { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
td.time { color: var(--muted); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.empty { color: var(--muted); text-align: center; padding: 32px 0; }

/* ===== 徽标 ===== */
.badge { display: inline-flex; align-items: center; padding: 3px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.paid, .badge.production { background: var(--ok-soft); color: var(--ok); }
.badge.pending { background: var(--warn-soft); color: var(--warn); }
.badge.awaiting { background: var(--info-soft); color: var(--info); }
.badge.closed { background: var(--gray-soft); color: var(--muted); }
.badge.refunded { background: var(--danger-soft); color: var(--danger); }
.badge.sandbox { background: var(--warn-soft); color: var(--warn); }

/* ===== 按钮 ===== */
.btn {
  border: 1px solid var(--border); background: var(--panel); color: var(--text); border-radius: 9px;
  padding: 7px 14px; font-size: 13px; font-weight: 500; cursor: pointer; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--gray-soft); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-600); }
.btn.ghost { border: 0; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--gray-soft); color: var(--text); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; }
input[type="password"], input[type="text"] {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; font-size: 14px; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47, 111, 237, .12); }

/* ===== 过滤器 ===== */
.filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-chip {
  border: 1px solid var(--border); background: var(--panel); border-radius: 999px; padding: 6px 15px;
  font-size: 13px; color: var(--muted); cursor: pointer; transition: all .12s;
}
.filter-chip:hover { color: var(--text); border-color: #cbd5e1; }
.filter-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ===== 空态 / 提示 ===== */
.note {
  background: var(--primary-soft); color: #1e40af; border: 1px solid #d6e3fd; border-radius: 10px;
  padding: 13px 15px; font-size: 13px; margin-bottom: 16px; line-height: 1.65;
}
.note.warn { background: var(--warn-soft); color: #92400e; border-color: #fde9c8; }
.empty-state { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty-state .big { font-size: 15px; color: var(--text); margin-bottom: 6px; font-weight: 600; }

/* ===== 登录弹窗 ===== */
.overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal { background: #fff; border-radius: 16px; padding: 28px; width: 400px; max-width: 92vw; box-shadow: var(--shadow-lg); }
.modal h2 { margin: 0 0 6px; font-size: 19px; }
.modal .muted { color: var(--muted); font-size: 13px; margin: 0 0 16px; line-height: 1.6; }
.login-err { color: var(--danger); font-size: 13px; min-height: 18px; margin: 8px 0 4px; }

/* ===== 定义列表（店铺） ===== */
.dl { display: grid; grid-template-columns: 190px 1fr; row-gap: 11px; column-gap: 18px; font-size: 14px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; word-break: break-all; }

/* ===== 订单行 ===== */
.order-subject { font-weight: 500; }
.order-no { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--muted); }
.order-detail { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

.hidden { display: none !important; }
.loading {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(243, 244, 246, .75); backdrop-filter: blur(2px); z-index: 60;
  font-size: 15px; color: var(--muted);
}
.foot-note { margin-top: 26px; font-size: 12px; color: var(--muted); line-height: 1.7; }

@media (max-width: 720px) {
  .sidebar { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .topbar { padding: 0 14px; }
  .view { padding: 16px; }
  .dl { grid-template-columns: 110px 1fr; }
}
