/* ============================================================
   抖爆销售管理系统 V2 — 公共样式
   适配：手机 / 平板 / 桌面 / 大屏
   ============================================================ */

:root {
  --card:      #181c34;
  --bg:        #0a0d1f;
  --bg2:       #111428;
  --bg3:       #181c34;
  --border:    rgba(255,255,255,0.08);
  --border2:   rgba(102,126,234,0.25);
  --primary:   #667eea;
  --primary2:  #764ba2;
  --green:     #38ef7d;
  --green2:    #11998e;
  --red:       #ff6b6b;
  --orange:    #ff9f43;
  --gold:      #ffd700;
  --text:      #e8eaf6;
  --text2:     #8892b0;
  --text3:     #4a5568;
  --sidebar-w: 240px;
  --topbar-h:  60px;
  --radius:    12px;
  --radius-lg: 18px;
  --shadow:    0 4px 24px rgba(0,0,0,0.35);
}

*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}

/* ── 滚动条 ── */
::-webkit-scrollbar { width:6px; height:6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius:3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }

/* ════════════════════════════════
   LAYOUT
════════════════════════════════ */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 200;
  transition: transform 0.28s cubic-bezier(.4,0,.2,1);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-logo {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo .logo-title {
  font-size: 15px;
  font-weight: 800;
  background: linear-gradient(135deg, #fff 0%, #a3b5f5 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.3;
}

.sidebar-logo .logo-ver {
  font-size: 11px;
  color: var(--text2);
  margin-top: 3px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
}

.nav-section {
  margin-bottom: 4px;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text3);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 10px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text2);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 2px;
  white-space: nowrap;
}

.nav-item .icon {
  font-size: 16px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(102,126,234,0.2), rgba(118,75,162,0.15));
  color: #a3b5f5;
  border: 1px solid rgba(102,126,234,0.2);
}

.sidebar-footer {
  padding: 14px 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.user-info-mini {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11px;
  color: var(--text2);
}

.btn-logout {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.2s;
}

.btn-logout:hover { color: var(--red); }

/* ── Topbar ── */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--topbar-h);
  background: rgba(10,13,31,0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
}

.topbar-title {
  flex: 1;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Hamburger (mobile) */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.2s;
  flex-shrink: 0;
}

.menu-toggle:hover { background: rgba(255,255,255,0.08); }

/* Sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 199;
  backdrop-filter: blur(2px);
}

/* ── Main content ── */
.main {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  flex: 1;
  min-width: 0;
  padding: 24px;
}

/* ════════════════════════════════
   COMPONENTS
════════════════════════════════ */

/* ── Card ── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 10px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Stat Cards ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  overflow: hidden;
  transition: transform 0.25s, box-shadow 0.25s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.stat-card.blue::after  { background: linear-gradient(90deg, var(--primary), var(--primary2)); }
.stat-card.green::after { background: linear-gradient(90deg, var(--green2), var(--green)); }
.stat-card.red::after   { background: linear-gradient(90deg, #f093fb, var(--red)); }
.stat-card.gold::after  { background: linear-gradient(90deg, #f5af19, #f12711); }

.stat-icon {
  font-size: 2rem;
  flex-shrink: 0;
  line-height: 1;
}

.stat-body { flex: 1; min-width: 0; }

.stat-label {
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 4px;
  white-space: nowrap;
}

.stat-value {
  font-size: 1.7rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.stat-card.blue  .stat-value { color: #a3b5f5; }
.stat-card.green .stat-value { color: var(--green); }
.stat-card.red   .stat-value { color: #fc8d9f; }
.stat-card.gold  .stat-value { color: var(--gold); }

.stat-sub {
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
  white-space: nowrap;
  line-height: 1;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  color: #fff;
  box-shadow: 0 3px 12px rgba(102,126,234,0.3);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(102,126,234,0.5);
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(135deg, var(--green2), var(--green));
  color: #fff;
}

.btn-danger {
  background: rgba(231,76,60,0.15);
  color: var(--red);
  border: 1px solid rgba(231,76,60,0.3);
}

.btn-danger:hover { background: rgba(231,76,60,0.25); }

.btn-ghost {
  background: rgba(255,255,255,0.07);
  color: var(--text2);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: rgba(255,255,255,0.12);
  color: var(--text);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* ── Form ── */
.form-group { margin-bottom: 18px; }

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #a3b5f5;
  letter-spacing: 0.5px;
  margin-bottom: 7px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  background: rgba(255,255,255,0.05);
  border: 1.5px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text3); }

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  background: rgba(102,126,234,0.07);
}

.form-group select option { background: #1a1c35; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ── Table ── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  background: rgba(255,255,255,0.04);
  padding: 13px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text2);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.025); }

/* ── Badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-green  { background: rgba(56,239,125,0.12); color: var(--green); border: 1px solid rgba(56,239,125,0.25); }
.badge-blue   { background: rgba(102,126,234,0.12); color: #a3b5f5;    border: 1px solid rgba(102,126,234,0.25); }
.badge-red    { background: rgba(255,107,107,0.12); color: var(--red);  border: 1px solid rgba(255,107,107,0.25); }
.badge-orange { background: rgba(255,159,67,0.12);  color: var(--orange); border: 1px solid rgba(255,159,67,0.25); }
.badge-gray   { background: rgba(255,255,255,0.07); color: var(--text2); border: 1px solid var(--border); }
.badge-gold   { background: rgba(255,215,0,0.12);   color: var(--gold); border: 1px solid rgba(255,215,0,0.25); }

/* ── Modal ── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.open { display: flex; animation: fadeIn 0.18s ease; }

@keyframes fadeIn { from{opacity:0} to{opacity:1} }

.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: slideUp 0.22s ease;
  position: relative;
}

.modal-box.wide { max-width: 700px; }

@keyframes slideUp {
  from { transform: translateY(20px); opacity:0; }
  to   { transform: translateY(0);    opacity:1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.modal-header h3 { font-size: 16px; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 20px;
  cursor: pointer;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  transition: all 0.2s;
}

.modal-close:hover { background: rgba(255,255,255,0.08); color: #fff; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

/* ── Toolbar ── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.toolbar-search {
  flex: 1;
  min-width: 180px;
  padding: 9px 14px;
  background: rgba(255,255,255,0.05);
  border: 1.5px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.toolbar-search:focus { border-color: var(--primary); }
.toolbar-search::placeholder { color: var(--text3); }

.toolbar-select {
  padding: 9px 14px;
  background: rgba(255,255,255,0.05);
  border: 1.5px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

.toolbar-select option { background: #1a1c35; }

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.page-btn {
  padding: 7px 14px;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text2);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.page-btn:hover:not(:disabled) { background: rgba(255,255,255,0.12); color: var(--text); }
.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.page-info {
  font-size: 12px;
  color: var(--text2);
  padding: 0 6px;
}

/* ── Empty / Loading states ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text2);
}

.empty-state .empty-icon { font-size: 3rem; margin-bottom: 14px; }
.empty-state p { font-size: 15px; color: var(--text2); }
.empty-state small { color: var(--text3); font-size: 13px; }

.loading-row td {
  text-align: center;
  padding: 50px;
  color: var(--text2);
}

.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ── */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: toastIn 0.25s ease;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 320px;
}

.toast-success { background: #1a3a28; border: 1px solid rgba(56,239,125,0.3); color: var(--green); }
.toast-error   { background: #3a1a1a; border: 1px solid rgba(255,107,107,0.3); color: var(--red); }
.toast-info    { background: #1a2040; border: 1px solid rgba(102,126,234,0.3); color: #a3b5f5; }

@keyframes toastIn {
  from { transform: translateX(24px); opacity:0; }
  to   { transform: translateX(0);    opacity:1; }
}

/* ── Misc ── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

.text-muted { color: var(--text2); }
.text-sm    { font-size: 12px; }
.fw-600     { font-weight: 600; }
.fw-700     { font-weight: 700; }
.text-right { text-align: right; }
.text-center{ text-align: center; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mb-16  { margin-bottom: 16px; }
.mb-24  { margin-bottom: 24px; }

/* ── Rank badges ── */
.rank-1 { background: linear-gradient(135deg, #ffd700, #ffaa00); color:#000; width:26px; height:26px; border-radius:50%; display:inline-flex; align-items:center; justify-content:center; font-weight:800; font-size:12px; }
.rank-2 { background: linear-gradient(135deg, #c0c0c0, #a0a0a0); color:#000; width:26px; height:26px; border-radius:50%; display:inline-flex; align-items:center; justify-content:center; font-weight:800; font-size:12px; }
.rank-3 { background: linear-gradient(135deg, #cd7f32, #a0522d); color:#fff; width:26px; height:26px; border-radius:50%; display:inline-flex; align-items:center; justify-content:center; font-weight:800; font-size:12px; }
.rank-n { background: rgba(255,255,255,0.08); color: var(--text2); width:26px; height:26px; border-radius:50%; display:inline-flex; align-items:center; justify-content:center; font-weight:700; font-size:12px; }

/* ════════════════════════════════
   RESPONSIVE
════════════════════════════════ */
@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  }

  .sidebar-overlay.open { display: block; }

  .topbar { left: 0; padding: 0 16px; }

  .menu-toggle { display: flex; }

  .main {
    margin-left: 0;
    padding: 16px;
  }

  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .stat-value { font-size: 1.4rem; }

  .form-row { grid-template-columns: 1fr; }

  .modal-box { padding: 22px 18px; }

  .card { padding: 16px 18px; }

  .toolbar { gap: 8px; }
  .toolbar-search { min-width: 140px; }

  table { font-size: 12.5px; }
  thead th, tbody td { padding: 11px 10px; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card  { padding: 14px 16px; gap: 10px; }
  .stat-icon  { font-size: 1.5rem; }
  .stat-value { font-size: 1.25rem; }
  .main { padding: 12px; }
  .card { padding: 14px 16px; }
}
