:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #1d2636;
  --muted: #7c8aa5;
  --line: #e7eef6;
  --primary: #5d87ff;
  --primary-dark: #466ee6;
  --soft: #ecf2ff;
  --success: #13deb9;
  --warning: #ffae1f;
  --danger: #fa896b;
  --shadow: 0 10px 30px rgba(42, 53, 71, 0.06);
  --radius: 16px;
  --sidebar: 248px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); color: var(--text); background: var(--bg); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--primary); }

.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 0.9fr; }
.auth-brand { padding: 72px; color: white; background: linear-gradient(145deg, #5d87ff 0%, #49beff 55%, #13deb9 140%); display: flex; flex-direction: column; justify-content: center; }
.auth-brand h1 { margin: 0 0 12px; font-size: 42px; letter-spacing: 1px; }
.auth-brand p { max-width: 460px; line-height: 1.7; opacity: 0.95; }
.auth-brand ul { padding-left: 18px; line-height: 1.9; }
.auth-card { display: flex; align-items: center; justify-content: center; padding: 32px; }
.panel { width: min(440px, 100%); background: white; border-radius: 24px; box-shadow: var(--shadow); padding: 36px; }
.panel h2 { margin: 0 0 8px; }
.hint { color: var(--muted); margin: 0 0 22px; line-height: 1.6; }
label { display: block; margin: 14px 0 6px; color: #5f6b84; font-size: 13px; }
input, select, textarea { width: 100%; border: 1px solid var(--line); background: #fbfcfe; border-radius: 10px; padding: 11px 12px; outline: none; }
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); background: white; box-shadow: 0 0 0 4px rgba(93, 135, 255, 0.12); }
.captcha-row { display: grid; grid-template-columns: 1fr 180px; gap: 10px; align-items: center; }
.captcha-row img { width: 180px; height: 64px; border-radius: 10px; border: 1px solid var(--line); cursor: pointer; }
.btn { border: 0; border-radius: 10px; padding: 11px 16px; background: var(--primary); color: white; font-weight: 650; }
.btn:hover { background: var(--primary-dark); }
.btn.block { width: 100%; margin-top: 18px; }
.btn.ghost { background: var(--soft); color: var(--primary); }
.btn.warn { background: #fff4ec; color: #d97706; }
.btn.danger { background: #fff1ee; color: #e35d4a; }
.btn.small { padding: 7px 10px; border-radius: 8px; font-size: 13px; }

.layout { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) 1fr; }
.sidebar { background: white; border-right: 1px solid var(--line); padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.brand { display: flex; gap: 12px; align-items: center; padding: 8px 10px 20px; }
.logo { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; color: white; font-weight: 800; background: linear-gradient(135deg, #5d87ff, #49beff); }
.brand b { display: block; }
.brand small { color: var(--muted); }
.group-label { color: #9aa6bd; font-size: 12px; margin: 16px 12px 6px; }
.nav-btn { width: 100%; text-align: left; border: 0; background: transparent; color: #445067; border-radius: 12px; padding: 11px 12px; display: flex; gap: 10px; align-items: center; }
.nav-btn.active { background: var(--soft); color: var(--primary); font-weight: 700; }
.main { min-width: 0; }
.header { height: 68px; display: flex; align-items: center; justify-content: space-between; padding: 0 28px; background: rgba(255,255,255,.9); border-bottom: 1px solid var(--line); position: sticky; top: 0; backdrop-filter: blur(10px); }
.header h1 { font-size: 18px; margin: 0; }
.content { padding: 24px 28px 40px; }
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.card, .section { background: white; border-radius: var(--radius); box-shadow: var(--shadow); }
.card { padding: 18px 18px 16px; }
.card span, .muted { color: var(--muted); font-size: 13px; }
.card strong { display: block; margin-top: 8px; font-size: 28px; }
.section { padding: 18px; margin-top: 16px; }
.section h3 { margin: 0 0 14px; font-size: 16px; }
.grid-2 { display: grid; grid-template-columns: 1.3fr 0.7fr; gap: 16px; }
.bars { height: 180px; display: flex; align-items: end; gap: 12px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: end; }
.bar i { display: block; width: 100%; max-width: 36px; border-radius: 8px 8px 4px 4px; background: linear-gradient(#49beff, #5d87ff); }
.bar em { font-style: normal; color: var(--muted); font-size: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 600; background: #f8fafc; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 8px; font-size: 12px; background: #f2f4f8; color: #526178; }
.badge.pending, .badge.checking { background: #fff6e8; color: #b7791f; }
.badge.paid { background: #eefbf7; color: #0f9f86; }
.badge.delivered { background: #ecf2ff; color: #3b6bdb; }
.badge.expired, .badge.cancelled { background: #fff1ee; color: #d15b4a; }
.badge.available { background: #ecfbf6; color: #0f9f86; }
.badge.locked { background: #fff6e8; color: #b7791f; }
.badge.sold { background: #ecf2ff; color: #3b6bdb; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline input, .inline select { width: auto; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.menu-toggle { display: none; border: 0; background: var(--soft); color: var(--primary); border-radius: 10px; padding: 8px 10px; }
#toast { position: fixed; right: 20px; bottom: 20px; background: #1d2636; color: white; padding: 12px 16px; border-radius: 12px; opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: none; max-width: 360px; }
#toast.show { opacity: 1; transform: none; }
.empty { color: var(--muted); padding: 28px 0; text-align: center; }
.key { font-family: Consolas, "Courier New", monospace; font-size: 12px; word-break: break-all; }
.reveal { margin-top: 8px; }
.stock-board { display: flex; flex-direction: column; gap: 10px; }
.stock-row { display: grid; grid-template-columns: 88px 1fr; gap: 8px; align-items: center; }
.stock-len { font-weight: 750; }
.stock-len small, .stock-chip small { color: var(--muted); font-weight: 500; }
.stock-subs { display: flex; gap: 8px; flex-wrap: wrap; }
.stock-chip { border: 1px solid var(--line); background: #fbfcfe; border-radius: 999px; padding: 7px 12px; color: var(--text); }
.stock-chip.active { background: var(--soft); color: var(--primary); border-color: transparent; font-weight: 700; }
.stock-chip b { margin-left: 6px; }
@media (max-width: 1100px) {
  .cards, .grid-2, .split, .auth-page { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
}
.backdrop { position: fixed; inset: 0; z-index: 4; border: 0; background: rgba(29, 38, 54, .38); }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 6; transform: translateX(-105%); transition: .2s; width: min(var(--sidebar), 86vw); }
  .sidebar.open { transform: none; }
  .menu-toggle { display: inline-flex; }
  .content, .header { padding-left: 16px; padding-right: 16px; }
  .header { height: auto; min-height: 60px; flex-wrap: wrap; gap: 8px; padding-top: 10px; padding-bottom: 10px; }
  .header h1 { font-size: 16px; }
  .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 14px; }
  .card strong { font-size: 22px; }
  .section { overflow-x: auto; }
  table { min-width: 640px; }
  .toolbar, .inline, .row-actions { align-items: stretch; }
  .toolbar input, .toolbar select, .inline input, .inline select { width: 100%; min-width: 0; }
  .stock-row { grid-template-columns: 1fr; }
  .auth-card, .content { padding: 16px; }
  input, select, textarea { font-size: 16px; }
  #toast { left: 12px; right: 12px; max-width: none; }
}
