:root {
  --bg: #f5f7fa;
  --card: #fff;
  --primary: #005bab;
  --primary-hover: #004a8f;
  --primary-soft: #eaf3fb;
  --accent: #e60012;
  --text: #243447;
  --muted: #8a94a6;
  --line: #e6ebf2;
  --side: #0b2f52;
  --side-mid: #0e3d6b;
  --danger: #d14343;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(15, 35, 60, 0.04), 0 4px 16px rgba(15, 35, 60, 0.04);
  --ctrl-h: 32px;
  --font: 13px;
}

* { box-sizing: border-box; }

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

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }
.hint { color: var(--muted); font-size: 12px; margin: 2px 0 0; line-height: 1.45; }
.error { color: var(--danger); min-height: 18px; font-size: 12px; }
code {
  background: var(--primary-soft);
  color: var(--primary);
  padding: 0 5px;
  border-radius: 3px;
  font-size: 11px;
}

input, select, textarea, button {
  font: inherit;
  border-radius: 6px;
  border: 1px solid var(--line);
  padding: 0 10px;
  height: var(--ctrl-h);
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea {
  height: auto;
  padding: 8px 10px;
  resize: vertical;
  min-height: 72px;
}
input:focus, select:focus, textarea:focus {
  border-color: #7eb3e0;
  box-shadow: 0 0 0 3px rgba(0, 91, 171, 0.12);
}
.upload-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.upload-block {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 2px;
}
.upload-block .upload-main.full,
.upload-main.full { grid-column: 1 / -1; }
.upload-preview {
  width: 72px;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7f9fc;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.upload-preview-empty {
  color: var(--muted);
  font-size: 11px;
}
.upload-main { min-width: 0; display: grid; gap: 4px; }
.upload-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.upload-row input { flex: 1; min-width: 0; }
.upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--ctrl-h);
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid #b7d0e8;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.upload-btn:hover {
  background: #dcecf8;
  border-color: #8fbadf;
}
.upload-meta {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}
.upload-meta.is-file { color: var(--primary); }
.upload-meta.is-error { color: var(--danger); }

.upload-drop {
  display: grid;
  place-items: center;
  gap: 2px;
  padding: 16px 12px;
  border: 1px dashed #b7d0e8;
  border-radius: 8px;
  background: #f7fbfe;
  cursor: pointer;
  text-align: center;
  position: relative;
}
.upload-drop:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
}
.upload-drop-title {
  font-size: 13px;
  color: var(--primary);
  font-weight: 600;
}
.upload-drop-sub {
  font-size: 11px;
  color: var(--muted);
}
button {
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  padding: 0 12px;
  font-size: 13px;
  white-space: nowrap;
}
button:hover { background: var(--primary-hover); }
button.ghost {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}
button.ghost:hover { background: #f7f9fc; border-color: #cfd8e6; }
button.danger { background: var(--danger); }
button.danger:hover { filter: brightness(0.95); }
button.block { width: 100%; }
button:disabled { opacity: .55; cursor: not-allowed; }
.btn-link {
  display: inline-flex;
  align-items: center;
  height: var(--ctrl-h);
  padding: 0 12px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  border-radius: 6px;
  font-size: 13px;
}
.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
}
.spacer { flex: 1; }
.icon-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
}
.icon-btn:hover { color: var(--text); background: #f0f4f8; }

/* 登录 */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(165deg, #edf4fb 0%, #f5f7fa 48%, #eef1f5 100%);
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border-radius: 12px;
  padding: 28px 24px 24px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 8px;
  border: 1px solid rgba(230, 235, 242, 0.9);
}
.login-brand {
  color: var(--primary);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.5px;
}
.login-card h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.login-card .muted { margin: 0 0 6px; }
.login-card label { font-size: 12px; color: var(--muted); }
.login-card button { margin-top: 6px; height: 36px; }

/* 布局 */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 188px 1fr;
}
.sidebar {
  background: linear-gradient(180deg, var(--side) 0%, var(--side-mid) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: sticky;
  top: 0;
}
.side-brand {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.side-name { font-size: 15px; font-weight: 700; letter-spacing: 0.2px; }
.side-sub { margin-top: 4px; font-size: 11px; opacity: 0.65; }
.side-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 10px;
  flex: 1;
}
.nav-item {
  text-align: left;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  border: none;
  border-radius: 6px;
  padding: 0 12px;
  height: 36px;
  font-size: 13px;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav-item.on {
  background: rgba(255, 255, 255, 0.96);
  color: var(--primary);
  font-weight: 600;
}
.side-foot {
  padding: 12px 10px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.side-foot .ghost {
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  border-color: rgba(255, 255, 255, 0.22);
  height: 32px;
  font-size: 12px;
}
.side-foot .ghost:hover { background: rgba(255, 255, 255, 0.08); }

.main-wrap { min-width: 0; display: flex; flex-direction: column; }
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.top strong { display: block; font-size: 15px; font-weight: 650; }
.content { padding: 16px 20px 28px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; min-height: auto; }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
}

.panel {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 16px 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.panel.narrow { max-width: 640px; }
.panel-hd {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 10px;
}
.panel-hd h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
}

.filters, .row, .row2, .actions, .inline {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.filters { margin-bottom: 12px; }
.filters input { flex: 1; min-width: 160px; max-width: 280px; }
.filters select { min-width: 120px; max-width: 160px; }
.row input:not([type="file"]) { flex: 1; }
.row2 > div { flex: 1; display: grid; gap: 4px; min-width: 140px; }
.form { display: grid; gap: 6px; }
.form label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.form label:first-child { margin-top: 0; }

.thumb {
  width: 56px;
  height: 36px;
  border-radius: 4px;
  overflow: hidden;
  background: #eef2f7;
  border: 1px solid var(--line);
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.tag-ok {
  background: #e8f7ef;
  color: #1b7a45;
}
.tag-muted {
  background: #f1f3f6;
  color: #6b7785;
}

.panel-sub { margin: 4px 0 0; }

.cat-toolbar {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 12px;
  margin-bottom: 14px;
  background: #f7f9fc;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.cat-field {
  display: grid;
  gap: 4px;
}
.cat-field.grow { flex: 1; min-width: 180px; }
.cat-field.sort { width: 96px; }
.cat-field label {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}
.cat-btns { display: flex; gap: 6px; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 13px;
}
.data-table th,
.data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.data-table th {
  background: #f7f9fc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fafcfe; }
.data-table .name-cell { font-weight: 600; color: var(--text); }
.data-table .id-cell,
.data-table .sort-cell { color: var(--muted); font-variant-numeric: tabular-nums; }
.data-table .row-actions { display: flex; gap: 6px; }
.danger-text {
  color: var(--danger) !important;
  border-color: #f0c2c2 !important;
}
.danger-text:hover {
  background: #fff5f5 !important;
  border-color: #e8a0a0 !important;
}
.empty-tip {
  margin: 0;
  padding: 28px 12px;
  text-align: center;
  background: #fff;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
}
.chip button {
  background: transparent;
  color: var(--primary);
  padding: 0;
  height: auto;
  font-size: 11px;
}

.progress {
  height: 4px;
  background: #e8eef5;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 2px;
}
.progress-bar {
  height: 100%;
  width: 0;
  background: var(--primary);
  transition: width 0.15s ease;
}

.qr-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 18px;
  align-items: start;
  margin-top: 6px;
}
@media (max-width: 800px) {
  .qr-layout { grid-template-columns: 1fr; }
}
.qr-preview {
  width: 100%;
  min-height: 220px;
  border: 1px dashed #d5deea;
  border-radius: 8px;
  background: #fafbfd;
  display: grid;
  place-items: center;
  padding: 12px;
}
.qr-img {
  width: 180px;
  height: 180px;
  object-fit: contain;
  background: #fff;
}
.qr-empty {
  color: var(--muted);
  text-align: center;
  padding: 16px;
  line-height: 1.6;
  font-size: 12px;
}

/* 弹窗 */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px 24px;
  overflow: auto;
}
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(20, 36, 56, 0.42);
  backdrop-filter: blur(2px);
}
.modal-card {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  max-height: none;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 18px 48px rgba(15, 35, 60, 0.22);
  border: 1px solid rgba(230, 235, 242, 0.9);
}
.modal-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  border-radius: 10px 10px 0 0;
}
.modal-hd h2 { margin: 0; font-size: 14px; font-weight: 650; }
.modal-body { padding: 12px 14px 6px; }
.modal-ft {
  margin: 6px 0 4px;
  padding: 10px 0 8px;
  border-top: 1px solid var(--line);
  background: #fff;
}
body.modal-open { overflow: hidden; }

/* 概览 */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  box-shadow: var(--shadow);
}
.stat-num {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--primary);
  line-height: 1.2;
}
.stat-num.warn { color: #c47a00; font-size: 18px; }
.stat-label {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.tip-warn { color: #b86a00 !important; font-weight: 600; }

/* 环境角标 */
.env-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 22px;
  padding: 0 8px;
  margin-bottom: 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.7);
}
.env-badge.is-debug {
  background: rgba(230, 0, 18, 0.22);
  color: #ffb4b8;
}

/* 自定义下拉 */
.cselect {
  position: relative;
  min-width: 120px;
  max-width: 180px;
}
.cselect-native {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}
.cselect-btn,
.cselect-btn:hover,
.cselect-btn:focus,
.cselect-btn:active {
  width: 100%;
  height: var(--ctrl-h);
  padding: 0 28px 0 10px;
  text-align: left;
  background: #fff !important;
  color: var(--text) !important;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 400;
  position: relative;
  cursor: pointer;
  box-shadow: none;
}
.cselect-btn::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: translateY(-65%) rotate(45deg);
}
.cselect.open .cselect-btn,
.cselect.open .cselect-btn:hover {
  border-color: #7eb3e0;
  box-shadow: 0 0 0 3px rgba(0, 91, 171, 0.12);
}
.cselect-menu {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 100%;
  max-height: 220px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 35, 60, 0.12);
  padding: 4px;
}
.cselect-item,
.cselect-item:hover,
.cselect-item:focus,
.cselect-item:active {
  display: block;
  width: 100%;
  height: 30px;
  padding: 0 10px;
  text-align: left;
  background: transparent !important;
  color: var(--text) !important;
  border: none;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 400;
  cursor: pointer;
  box-shadow: none;
}
.cselect-item:hover,
.cselect-item:focus {
  background: #f3f7fb !important;
  color: var(--text) !important;
}
.cselect-item.on,
.cselect-item.on:hover,
.cselect-item.on:focus {
  background: var(--primary-soft) !important;
  color: var(--primary) !important;
  font-weight: 600;
}
.filters .cselect { max-width: 150px; }
.form .cselect,
.row2 .cselect {
  max-width: none;
  width: 100%;
}

/* 售后引导 */
.guide-box {
  background: #f7fbfe;
  border: 1px solid #d5e6f5;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.guide-title {
  font-size: 13px;
  font-weight: 650;
  color: var(--primary);
  margin-bottom: 6px;
}
.guide-box ol {
  margin: 0;
  padding-left: 18px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.7;
}
.guide-box li { margin: 2px 0; }
.guide-box .btn-sm {
  vertical-align: middle;
  margin-left: 6px;
}
.qr-empty {
  display: grid;
  gap: 6px;
  place-items: center;
}
.qr-empty strong {
  display: block;
  color: var(--text);
  font-size: 13px;
}
.qr-empty span {
  display: block;
  max-width: 160px;
}
.link-btn {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid #b7d0e8;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}
.link-btn:hover { background: #dcecf8; }

/* 分页 */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.pager-info {
  font-size: 12px;
  color: var(--muted);
}
.pager-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.pager-actions .btn-sm[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}
.pager-size {
  height: 28px;
  font-size: 12px;
  padding: 0 8px;
}
