:root {
  --sidebar-bg: #1e293b;
  --sidebar-active: #10b981;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #fff;
  --header-h: 56px;
  --sidebar-w: 220px;
  --bg: #f0f2f5;
  --card: #fff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --green: #10b981;
  --blue: #3b82f6;
  --red: #ef4444;
  --purple: #8b5cf6;
}

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

body.admin-body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* 登录 */
.admin-login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

.admin-login-card {
  background: #fff;
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.admin-login-card h2 { text-align: center; margin-bottom: 8px; }
.admin-login-card .sub { text-align: center; color: var(--muted); font-size: 0.875rem; margin-bottom: 28px; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 0.875rem; color: var(--muted); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
}
.form-group input:focus { outline: none; border-color: var(--green); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-primary { background: var(--green); color: #fff; width: 100%; }
.btn-primary:hover { opacity: 0.9; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-ghost { background: #f3f4f6; color: var(--text); }
.btn-danger { background: #fee2e2; color: #dc2626; }

/* 布局 */
.admin-shell { display: flex; min-height: 100vh; }

.admin-sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-brand span {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--green);
  line-height: 1.3;
}

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.9rem;
  transition: background 0.2s, color 0.2s;
}

.sidebar-nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.05); }
.sidebar-nav a.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
}

.sidebar-nav a svg, .sidebar-nav a img.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.85;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-footer a {
  color: var(--sidebar-text);
  font-size: 0.85rem;
  text-decoration: none;
}
.sidebar-footer a:hover { color: #fff; }

.admin-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.admin-header {
  height: var(--header-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-left { display: flex; align-items: center; gap: 12px; }

.header-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.header-btn:hover { background: #f3f4f6; color: var(--text); }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--muted);
}
.breadcrumb .dot { width: 6px; height: 6px; background: var(--green); border-radius: 50%; }
.breadcrumb strong { color: var(--text); }

.header-right { display: flex; align-items: center; gap: 8px; }

.user-dropdown {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
}
.user-dropdown:hover { background: #f3f4f6; }

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green), #059669);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
}

.admin-content { flex: 1; padding: 16px 20px 24px; }

.quote-bar {
  background: var(--card);
  padding: 12px 20px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.875rem;
  color: var(--muted);
  border: 1px solid var(--border);
}

/* 流水卡片 */
.flow-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.flow-card {
  background: var(--card);
  border-radius: 8px;
  padding: 20px;
  border: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.flow-card .label { font-size: 0.875rem; color: var(--muted); margin-bottom: 8px; }
.flow-card .value { font-size: 1.75rem; font-weight: 700; color: var(--text); }

.flow-card .icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}
.flow-card.green .icon-wrap { background: #d1fae5; color: var(--green); }
.flow-card.blue .icon-wrap { background: #dbeafe; color: var(--blue); }
.flow-card.red .icon-wrap { background: #fee2e2; color: var(--red); }
.flow-card.purple .icon-wrap { background: #ede9fe; color: var(--purple); }

/* 主网格 */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 280px;
  gap: 16px;
}

.panel-card {
  background: var(--card);
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-head h3 { font-size: 1rem; font-weight: 600; }

.panel-head select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.8rem;
}

.panel-head a { font-size: 0.8rem; color: var(--green); text-decoration: none; }

.panel-body { padding: 20px; }

.order-stats-summary {
  display: flex;
  gap: 32px;
  margin-bottom: 24px;
}

.order-stats-summary .big { font-size: 2rem; font-weight: 700; line-height: 1.2; }
.order-stats-summary .unit { font-size: 0.8rem; color: var(--muted); font-weight: 400; }

.channel-breakdown { list-style: none; }

.channel-breakdown li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid #f3f4f6;
}

.channel-breakdown li:last-child { border-bottom: none; }

.channel-breakdown .left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.channel-breakdown img { width: 32px; height: 32px; }

.channel-breakdown .name { font-weight: 500; font-size: 0.9rem; }
.channel-breakdown .meta { font-size: 0.8rem; color: var(--muted); }

/* 订单表 */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.data-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
}
.data-table td { padding: 12px; border-bottom: 1px solid #f3f4f6; }
.data-table tr:last-child td { border-bottom: none; }

.status-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
}
.status-tag.success { background: #d1fae5; color: #059669; }
.status-tag.success.manual { background: #10b981; color: #fff; }
.status-tag.expired { background: #f3f4f6; color: #6b7280; }
.status-tag.pending { background: #fef3c7; color: #d97706; }

/* 项目汇总 */
.link-list { list-style: none; }

.link-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid #f3f4f6;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}

.link-item:last-child { border-bottom: none; }
.link-item:hover { opacity: 0.85; }

.link-item .link-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.link-item .link-title { font-weight: 500; font-size: 0.9rem; }
.link-item .link-desc { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }

/* 子页面 */
.page-panel { display: none; }
.page-panel.active { display: block; }

.channel-list .channel-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
  background: var(--card);
}

.channel-item img { width: 64px; height: 64px; object-fit: contain; background: #fff; border-radius: 4px; border: 1px solid var(--border); }
.channel-item .meta { flex: 1; }
.channel-item .actions { display: flex; flex-direction: column; gap: 8px; }

.settings-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  max-width: 640px;
  margin-bottom: 16px;
}

.settings-card h2 { font-size: 1.1rem; margin-bottom: 16px; }
.settings-card code { background: #f3f4f6; padding: 2px 6px; border-radius: 4px; font-size: 0.85rem; word-break: break-all; }

.filter-bar { margin-bottom: 16px; }
.filter-bar select { padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; }

.sidebar-footer .version-tag {
  display: block;
  font-size: 0.75rem;
  color: rgba(148, 163, 184, 0.7);
  margin-bottom: 8px;
}

.admin-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 20px 0;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.tab-item {
  padding: 8px 16px;
  border: none;
  background: transparent;
  font-size: 0.875rem;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab-item.active {
  color: var(--green);
  border-bottom-color: var(--green);
  background: #f0fdf4;
  font-weight: 500;
}

.tab-item .tab-close { margin-left: 6px; opacity: 0.5; font-size: 0.75rem; }

/* 订单管理 */
.orders-page { display: flex; flex-direction: column; gap: 12px; }

.orders-filter-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px 16px;
  margin-bottom: 16px;
}

.filter-field label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.filter-field input,
.filter-field select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.875rem;
}

.filter-field-wide { grid-column: span 2; }

.date-range { display: flex; align-items: center; gap: 8px; }
.date-range input { flex: 1; }
.date-range span { color: var(--muted); }

.filter-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}

.filter-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-right: auto;
}

.btn-search {
  background: var(--green);
  color: #fff;
  padding: 8px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.875rem;
}

.btn-search:hover { opacity: 0.92; }

.btn-reset {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.875rem;
}

.btn-danger-outline {
  background: #fff;
  color: #dc2626;
  border: 1px solid #fecaca;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}

.orders-table-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: visible;
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.btn-icon {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  color: var(--muted);
}

.btn-icon:hover { color: var(--green); border-color: var(--green); }

.table-scroll { overflow-x: auto; overflow-y: visible; }

.orders-table td:last-child {
  position: relative;
  overflow: visible;
}

.orders-table .col-check { width: 40px; }
.orders-table .order-link {
  color: #2563eb;
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: none;
}
.orders-table .order-link:hover { text-decoration: underline; }

.pay-platform {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
}

.pay-platform img { width: 20px; height: 20px; }

.action-menu { position: relative; display: inline-block; }

.action-menu .action-trigger {
  color: var(--green);
  cursor: pointer;
  font-size: 0.85rem;
  border: none;
  background: none;
  padding: 4px 8px;
  white-space: nowrap;
}

.action-menu .action-dropdown {
  display: none;
  position: fixed;
  min-width: 132px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
  z-index: 9999;
  padding: 6px 0;
}

.action-menu.open .action-dropdown {
  display: block;
}

.action-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 14px;
  border: none;
  background: none;
  font-size: 0.8rem;
  cursor: pointer;
}

.action-dropdown button:hover { background: #f0fdf4; color: var(--green); }
.action-dropdown button.danger:hover { background: #fef2f2; color: #dc2626; }

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 0;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--muted);
}

.pagination-controls { display: flex; align-items: center; gap: 4px; }

.pagination-controls button {
  min-width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}

.pagination-controls button.active {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.pagination-controls button:disabled { opacity: 0.4; cursor: not-allowed; }

.pagination-size select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* 用户中心 */
.usercenter-grid {
  display: grid;
  grid-template-columns: 280px 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 16px;
}

.uc-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  position: relative;
}

.uc-wide-right { grid-column: 2 / 4; }

.uc-card-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f3f4f6;
}

.uc-sub { font-weight: 400; color: var(--muted); font-size: 0.8rem; }

.uc-profile { position: relative; text-align: center; padding-top: 28px; }

.uc-save-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  border: none;
  background: #10b981;
  color: #fff;
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
}

.uc-save-btn:hover { background: #059669; }

.panel-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-primary-outline {
  background: #fff;
  color: var(--primary, #10b981);
  border: 1px solid var(--primary, #10b981);
}

.btn-primary-outline:hover { background: #ecfdf5; }

#monthIncomeChart {
  width: 100%;
  max-height: 220px;
}

.uc-avatar {
  width: 80px;
  height: 80px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6ee7b7, #10b981);
  color: #fff;
  font-size: 2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.uc-name { font-size: 1.25rem; font-weight: 700; }
.uc-role { font-size: 0.8rem; color: var(--muted); margin: 4px 0 12px; }

.uc-motto {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.6;
  text-align: left;
  padding: 12px;
  background: #f9fafb;
  border-radius: 6px;
}

.uc-section-label { font-size: 0.8rem; color: var(--muted); margin: -8px 0 12px; }

.uc-field { margin-bottom: 14px; }
.uc-field label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 6px; }

.uc-input-wrap {
  display: flex;
  align-items: stretch;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  background: #fafafa;
}

.uc-input-wrap input,
.uc-input-wrap textarea {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 12px;
  font-size: 0.85rem;
  font-family: inherit;
  resize: vertical;
}

.uc-input-wrap input:focus,
.uc-input-wrap textarea:focus { outline: none; background: #fff; }

.uc-copy {
  flex-shrink: 0;
  width: 40px;
  border: none;
  border-left: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 0.9rem;
}

.uc-copy:hover { background: #f0fdf4; }

.uc-btn-sm {
  flex-shrink: 0;
  padding: 0 12px;
  border: none;
  border-left: 1px solid var(--border);
  background: var(--green);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}

.uc-btn-sm:hover { opacity: 0.92; }

.uc-rules { display: flex; flex-direction: column; gap: 12px; }

.uc-rule {
  padding: 12px;
  background: #f9fafb;
  border-radius: 6px;
  font-size: 0.85rem;
  line-height: 1.6;
}

.uc-rule strong { display: block; margin-bottom: 6px; color: var(--text); }
.uc-rule code { background: #e5e7eb; padding: 1px 6px; border-radius: 3px; font-size: 0.8rem; }

.monitor-ch-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border, #f3f4f6);
}
.monitor-ch-row:last-child { border-bottom: none; }
.monitor-ch-info { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.monitor-ch-info span { font-size: 0.875rem; color: var(--muted); }
.monitor-ch-sub { font-size: 0.8rem !important; color: #9ca3af !important; }

@media (max-width: 1200px) {
  .filter-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-field-wide { grid-column: span 2; }
  .usercenter-grid { grid-template-columns: 1fr; }
  .uc-wide-right { grid-column: 1; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .flow-cards { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .admin-sidebar { transform: translateX(-100%); }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .flow-cards { grid-template-columns: 1fr; }
}
