:root {
  --bg: #121212;
  --bg1: #141414;
  --card: #1e1e1e;
  --card2: #252525;
  --line: rgba(0, 230, 118, 0.22);
  --line2: rgba(255, 255, 255, 0.08);
  --text: #f0f0f0;
  --muted: rgba(240, 240, 240, 0.55);
  --accent: #00e676;
  --accent2: #00c853;
  --ok: #00e676;
  --warn: #ffb020;
  --bad: #ff4d4d;
  --input: #2a2a2a;
  --input-border: #3a3a3a;
  --row: #1a1a1a;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(900px 520px at 12% 0%, rgba(0, 200, 83, 0.07), transparent 55%),
    radial-gradient(700px 420px at 100% 10%, rgba(0, 230, 118, 0.04), transparent 50%),
    linear-gradient(180deg, #121212, #161616);
  color: var(--text);
  min-height: 100vh;
  color-scheme: dark;
}
.top {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 24px; border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: linear-gradient(180deg, #1a1a1a, #151515);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.brand {
  font-weight: 700;
  letter-spacing: .04em;
  white-space: nowrap;
  color: #ecfdf5;
}
.brand::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(0, 230, 118, 0.6);
  vertical-align: middle;
}
nav { display: flex; flex-wrap: wrap; gap: 4px 0; justify-content: flex-end; }
nav a { color: var(--muted); margin-left: 16px; text-decoration: none; white-space: nowrap; }
nav a:hover { color: var(--accent); }
.wrap {
  width: min(1680px, 98vw);
  max-width: 1680px;
  margin: 0 auto;
  padding: 22px 18px 60px;
}

/* 总后台 / 代理商 左右布局 */
.admin-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.admin-side {
  position: sticky;
  top: 72px;
  background: linear-gradient(180deg, #1c1c1c, #151515);
  border: 1px solid var(--line2);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.admin-side-head {
  display: none;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  color: #ecfdf5;
}
.admin-menu {
  display: grid;
  gap: 8px;
}
.admin-menu-item {
  width: 100%;
  text-align: left;
  background: var(--row);
  border: 1px solid var(--line2);
  color: var(--muted);
  font-weight: 600;
  position: relative;
}
.admin-menu-item.active,
.admin-menu-item:hover {
  background: rgba(0, 230, 118, 0.12);
  border-color: var(--line);
  color: var(--text);
}
.admin-menu-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, #a8ffd0, #00e676);
}
.admin-side-mask {
  display: none;
}
.admin-main {
  min-width: 0;
}
.admin-topbar {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}
.admin-menu-btn {
  display: none;
  flex-shrink: 0;
}
.admin-panel { display: none; }
.admin-panel.active { display: block; }
.admin-panel > .box:first-child,
.admin-panel > .form.box:first-child { margin-top: 12px; }
.scroll-list-tall { max-height: 1260px; min-height: 1260px; }

.hero-card, .panel .box, .form.box {
  background: var(--card);
  border: 1px solid var(--line2);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}
h1 { margin: 0 0 8px; font-size: 1.6rem; color: #ecfdf5; }
h2 { margin: 0 0 12px; font-size: 1.1rem; color: #ecfdf5; }
.muted { color: var(--muted); }
.form { display: grid; gap: 12px; margin-top: 16px; }
.form label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.form input, .form select, label input, label select {
  width: 100%;
  max-width: 100%;
  padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--input-border);
  background: var(--input); color: var(--text);
}
.form input:focus, .form select:focus, label input:focus, label select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 230, 118, 0.15);
}
button {
  border: 0; border-radius: 8px; padding: 10px 14px;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  color: #0a120d; font-weight: 700; cursor: pointer;
}
button:hover { filter: brightness(1.06); }
button.ghost {
  background: transparent;
  border: 1px solid var(--line2);
  color: var(--muted);
  font-weight: 600;
}
button.ghost:hover {
  border-color: var(--line);
  color: var(--accent);
  filter: none;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 0; }
.box { margin-top: 16px; }
.code {
  background: #0d0d0d; border: 1px solid var(--line2); border-radius: 8px;
  padding: 12px; overflow: auto; max-height: 360px; font-size: 12px; line-height: 1.45;
  white-space: pre-wrap; word-break: break-all;
  color: #b8f5d0;
}
.badge {
  display: inline-block; margin: 8px 0 0; padding: 6px 10px; border-radius: 999px;
  background: rgba(0, 230, 118, .12); color: var(--ok); font-size: 13px;
  border: 1px solid var(--line);
}
.form.inline { grid-template-columns: 1fr auto; align-items: end; }

.entry-grid { display:grid; grid-template-columns:1fr 1fr; gap:14px; margin-top:18px; }
.entry {
  display:flex; flex-direction:column; gap:8px; padding:18px; border-radius:12px;
  border:1px solid var(--line2); background:var(--row); color:var(--text); text-decoration:none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.entry:hover {
  border-color: var(--line);
  box-shadow: 0 0 0 1px rgba(0, 230, 118, 0.12), var(--shadow);
}
.entry strong { font-size:1.15rem; color: #ecfdf5; }
.entry span { color:var(--muted); font-size:13px; }
.entry em { color:var(--accent); font-style:normal; font-size:12px; word-break:break-all; }
.grid3 { display:grid; grid-template-columns:1fr 1.4fr 1fr; gap:12px; }
select {
  padding:10px 12px; border-radius:8px; border:1px solid var(--input-border);
  background:var(--input); color:var(--text);
}
a { color: var(--accent); }

.product-list { display: grid; gap: 10px; }
.product-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--line2); border-radius: 10px; background: var(--row);
}
.tag { display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.tag.ok { background: rgba(0,230,118,.15); color: var(--ok); }
.tag.off { background: rgba(255,77,77,.12); color: #ff8e8e; }
button.danger {
  background: linear-gradient(135deg, #c62828, #ff4d4d);
  color: #fff;
}
button.danger:hover { filter: brightness(1.08); }

.data-list { display: grid; gap: 10px; }
.data-row {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--line2); border-radius: 10px; background: var(--row);
}
.data-row .meta { color: var(--muted); font-size: 12px; line-height: 1.55; margin-top: 4px; }
.data-row .title { font-weight: 600; }
.table-wrap { overflow: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line2); border-radius: 10px; }
.data-table { width: 100%; min-width: 720px; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--line2); text-align: left; vertical-align: top;
}
.data-table th { background: #161616; color: var(--muted); font-weight: 600; white-space: nowrap; }
.data-table tr:hover td { background: rgba(0, 230, 118, 0.04); }
.data-table tr:last-child td { border-bottom: 0; }
.data-table .mono { font-family: Consolas, monospace; font-size: 12px; word-break: break-all; }
.data-table input[type=checkbox] {
  width: 16px; height: 16px; margin: 0; cursor: pointer; accent-color: var(--accent);
}
#batchDeleteCards:disabled,
#batchDeleteUsers:disabled,
#batchDeleteProducts:disabled,
#batchDeleteAgents:disabled { opacity: 0.45; cursor: not-allowed; }

.note-edit {
  display: flex; align-items: center; gap: 6px; min-width: 160px;
}
.note-edit .note-input {
  flex: 1; min-width: 120px; max-width: 220px;
  height: 32px; padding: 0 8px; border-radius: 8px;
  border: 1px solid var(--input-border); background: var(--input); color: var(--text);
  font-size: 12px;
}
.note-edit .note-input:focus {
  outline: none; border-color: var(--accent);
}
.note-edit button { white-space: nowrap; padding: 4px 10px; font-size: 12px; }

.tag.warn { background: rgba(255,176,32,.15); color: var(--warn); }

.check-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  max-height: 3900px;
  overflow: auto;
}
.check-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border: 1px solid var(--line2); border-radius: 8px;
  background: var(--row); font-size: 13px; cursor: pointer;
}
.check-item:hover { border-color: var(--line); }
.check-item input { width: auto; margin: 0; accent-color: var(--accent); }

.fold-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin-bottom: 0;
}
.fold-head h2 { margin: 0; flex: 1; }
.fold-toggle {
  flex-shrink: 0; min-width: 88px; padding: 6px 12px; font-size: 13px;
}
.fold-body { margin-top: 12px; }
.fold-panel.is-collapsed .fold-body { display: none; }
.fold-panel.is-collapsed .fold-head { margin-bottom: 0; }
.scroll-list {
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--line2);
  border-radius: 10px;
  padding: 2px;
  background: #141414;
}
.scroll-list.scroll-list-tall {
  max-height: 1260px;
  min-height: 1260px;
}
.scroll-list .table-wrap {
  border: 0;
  border-radius: 0;
  max-height: none;
  overflow: visible;
}

@media (max-width: 1100px) {
  .wrap { width: min(100%, 98vw); padding: 18px 14px 48px; }
  .admin-shell { grid-template-columns: 190px minmax(0, 1fr); gap: 14px; }
  .grid3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-menu-btn { display: inline-flex; }
  .admin-side {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(280px, 84vw);
    z-index: 40;
    border-radius: 0;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    overflow-y: auto;
  }
  .admin-side.open { transform: translateX(0); }
  .admin-side-head { display: flex; }
  .admin-side-mask {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 35;
  }
  .admin-side-mask.show { display: block; }
}
@media (max-width: 800px) {
  .top { padding: 12px 14px; flex-wrap: wrap; }
  nav a { margin-left: 12px; font-size: 13px; }
  .wrap { width: 100%; max-width: none; padding: 14px 10px 40px; }
  .hero-card, .panel .box, .form.box { padding: 16px; border-radius: 12px; }
  h1 { font-size: 1.3rem; }
  .grid2, .grid3, .entry-grid, .form.inline { grid-template-columns: 1fr; }
  .product-row, .data-row {
    flex-direction: column;
    align-items: stretch;
  }
  .fold-head { flex-wrap: wrap; }
  .fold-toggle { width: 100%; }
  .check-list { grid-template-columns: 1fr; max-height: 3300px; }
  .scroll-list { max-height: 55vh; }
  .scroll-list-tall,
  .scroll-list.scroll-list-tall { max-height: 165vh; min-height: 840px; }
  .data-table { min-width: 640px; font-size: 12px; }
  button { width: auto; }
}
@media (max-width: 480px) {
  .brand { font-size: 15px; }
  nav a { margin-left: 10px; }
  .data-table { min-width: 560px; }
  .admin-topbar { flex-direction: column; }
  .admin-menu-btn { width: 100%; }
}

.quota-product-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin: 6px 0;
}
.quota-each-wrap {
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}
