:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #e4e7ec;
  --text: #1f2329;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: #e8f0fe;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
button { font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { width: 100%; resize: vertical; line-height: 1.5; }

/* login */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 32px; width: 360px;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.06);
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card p { margin: 0 0 20px; color: var(--muted); }
.login-card input { width: 100%; margin-bottom: 12px; }

/* layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 200px; background: #fff; border-right: 1px solid var(--line);
  padding: 18px 12px; flex-shrink: 0;
}
.sidebar .brand { font-weight: 700; font-size: 16px; padding: 0 10px 16px; }
.nav-item {
  display: block; width: 100%; text-align: left; background: none;
  border: none; border-radius: 8px; padding: 9px 12px; margin-bottom: 2px;
  color: var(--text);
}
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.main { flex: 1; padding: 24px 28px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.page-head h2 { margin: 0; font-size: 18px; }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
}
.panel h3 { margin: 0 0 14px; font-size: 15px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
}
.stat .n { font-size: 26px; font-weight: 700; }
.stat .l { color: var(--muted); margin-top: 2px; }

.btn {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 8px 14px;
}
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--red); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th { color: var(--muted); font-weight: 600; white-space: nowrap; }
td { font-size: 13px; }
.table-wrap { overflow-x: auto; }

.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; white-space: nowrap; }
.tag.sent { background: #dcfce7; color: var(--green); }
.tag.failed { background: #fee2e2; color: var(--red); }
.tag.none { background: #f3f4f6; color: var(--muted); }
.tag.gift { background: #fef3c7; color: var(--amber); }
.tag.promo { background: #e0e7ff; color: #3730a3; }
.tag.giftcard { background: #fce7f3; color: #be185d; }
.tag.incomplete { background: #ffedd5; color: #c2410c; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input, .filters select { min-width: 130px; }

.pager { display: flex; gap: 8px; align-items: center; margin-top: 14px; justify-content: flex-end; }

.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.shop-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.shop-card h4 { margin: 0 0 10px; display: flex; justify-content: space-between; align-items: center; }
.field { margin-bottom: 10px; }
.field label { display: block; color: var(--muted); margin-bottom: 4px; font-size: 13px; }
.field input { width: 100%; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.muted { color: var(--muted); }
.flex { display: flex; gap: 10px; align-items: center; }
.mt { margin-top: 12px; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 8px;
  opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 80vw;
}
.toast.show { opacity: 1; }
.toast.err { background: var(--red); }

.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.45);
  display: flex; align-items: center; justify-content: center; z-index: 20;
}
.modal {
  background: #fff; border-radius: var(--radius); padding: 22px;
  width: 640px; max-width: 92vw; max-height: 88vh; overflow: auto;
}
.modal h3 { margin: 0 0 16px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
pre.log {
  background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 8px;
  font-size: 12px; max-height: 300px; overflow: auto; white-space: pre-wrap;
}
.switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.switch input { display: none; }
.slider-sw {
  position: absolute; inset: 0; background: #cbd5e1; border-radius: 999px;
  transition: .2s;
}
.slider-sw:before {
  content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider-sw { background: var(--accent); }
.switch input:checked + .slider-sw:before { transform: translateX(18px); }
