/**
 * 全站管理后台布局与数据看板风格（清新、专业）
 * 中文注释：与页面内联样式配合，覆盖 max-width、主色等
 */
:root {
  --admin-bg: #f1f5f9;
  --admin-surface: #ffffff;
  --admin-surface-2: #f8fafc;
  --admin-border: #e2e8f0;
  --admin-text: #0f172a;
  --admin-muted: #64748b;
  --admin-accent: #0d9488;
  --admin-accent-dark: #0f766e;
  --admin-accent-soft: rgba(13, 148, 136, 0.12);
  --admin-sidebar-w: 272px;
  --admin-topbar-h: 56px;
  --admin-radius: 10px;
  --admin-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  --admin-shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.06);
  --admin-font: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body.admin-body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--admin-font);
  background: var(--admin-bg);
  color: var(--admin-text);
  line-height: 1.5;
}

/* 应用骨架：侧栏 + 主区占满宽度 */
.admin-app {
  display: flex;
  min-height: 100vh;
  width: 100%;
  max-width: none;
}

/* 侧栏 */
.admin-sidebar {
  flex: 0 0 var(--admin-sidebar-w);
  width: var(--admin-sidebar-w);
  background: var(--admin-surface);
  border-right: 1px solid var(--admin-border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform 0.25s ease;
}

.admin-sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 100vh;
  padding: 16px 12px 24px;
  overflow-y: auto;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 20px;
  border-bottom: 1px solid var(--admin-border);
  margin-bottom: 12px;
}

.admin-brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--admin-accent) 0%, #0e7490 100%);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: -0.02em;
}

.admin-brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.admin-brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--admin-text);
  line-height: 1.25;
}

.admin-brand-sub {
  font-size: 11px;
  color: var(--admin-muted);
  font-weight: 500;
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-nav-details {
  border-radius: var(--admin-radius);
  overflow: hidden;
}

.admin-nav-details[open] > .admin-nav-summary {
  color: var(--admin-accent-dark);
  background: var(--admin-accent-soft);
}

.admin-nav-summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--admin-muted);
  border-radius: var(--admin-radius);
  user-select: none;
}

.admin-nav-summary::-webkit-details-marker {
  display: none;
}

.admin-nav-summary::after {
  content: "";
  float: right;
  width: 6px;
  height: 6px;
  margin-top: 5px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  opacity: 0.5;
}

.admin-nav-details[open] > .admin-nav-summary::after {
  transform: rotate(-135deg);
  margin-top: 8px;
}

.admin-nav-children {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0 8px 8px;
}

.admin-nav-link {
  display: block;
  padding: 9px 12px 9px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--admin-text);
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.admin-nav-link:hover {
  background: var(--admin-surface-2);
  color: var(--admin-accent-dark);
}

.admin-nav-link.is-active {
  background: var(--admin-accent-soft);
  color: var(--admin-accent-dark);
  border-color: rgba(13, 148, 136, 0.25);
  font-weight: 600;
}

/* 主区域 */
.admin-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--admin-bg);
}

.admin-topbar {
  height: var(--admin-topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px 0 12px;
  background: var(--admin-surface);
  border-bottom: 1px solid var(--admin-border);
  box-shadow: var(--admin-shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.admin-menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  background: var(--admin-surface);
  cursor: pointer;
  color: var(--admin-text);
  font-size: 18px;
  line-height: 1;
}

.admin-menu-toggle:hover {
  background: var(--admin-surface-2);
}

.admin-topbar-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--admin-text);
  letter-spacing: -0.02em;
}

.admin-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-content {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 20px 24px 32px;
}

/* 与旧页面 .container 配合：取消最大宽度、铺满 */
.admin-app .container {
  max-width: none !important;
  width: 100%;
  margin: 0;
  padding-left: 0;
  padding-right: 0;
}

/* 卡片与按钮：统一主色（覆盖旧站紫渐变） */
.admin-app .card {
  border-radius: var(--admin-radius);
  border: 1px solid var(--admin-border);
  box-shadow: var(--admin-shadow-card);
  background: var(--admin-surface);
}

.admin-app .tab-btn.active,
.admin-app .add-btn,
.admin-app .filter-actions button.primary,
.admin-app .page-btn.active {
  background: linear-gradient(135deg, var(--admin-accent) 0%, var(--admin-accent-dark) 100%) !important;
  color: #fff !important;
  border-color: transparent !important;
}

.admin-app .tab-btn:hover:not(.active) {
  background: var(--admin-surface-2);
  color: var(--admin-accent-dark);
}

.admin-app .tabs {
  box-shadow: var(--admin-shadow);
  border: 1px solid var(--admin-border);
  background: var(--admin-surface);
}

.admin-app .filter-actions button:hover,
.admin-app .refresh-btn:hover,
.admin-app .page-btn:hover:not(.active) {
  border-color: var(--admin-accent) !important;
  color: var(--admin-accent-dark) !important;
}

.admin-app .action-btn {
  background: var(--admin-accent) !important;
}

.admin-app .action-btn:hover {
  background: var(--admin-accent-dark) !important;
}

/* 遮罩：移动端侧栏 */
.admin-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.admin-sidebar-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* 工作台首页卡片 */
.admin-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

.admin-dash-card {
  display: block;
  padding: 20px;
  border-radius: var(--admin-radius);
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  box-shadow: var(--admin-shadow-card);
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s, box-shadow 0.15s;
}

.admin-dash-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.admin-dash-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 6px;
  color: var(--admin-text);
}

.admin-dash-card p {
  margin: 0;
  font-size: 13px;
  color: var(--admin-muted);
}

.admin-dash-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--admin-accent-soft);
  color: var(--admin-accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 14px;
}

/* 占位页 */
.admin-placeholder {
  text-align: center;
  padding: 64px 24px;
  background: var(--admin-surface);
  border: 1px dashed var(--admin-border);
  border-radius: var(--admin-radius);
  color: var(--admin-muted);
}

.admin-placeholder h2 {
  margin: 0 0 8px;
  font-size: 18px;
  color: var(--admin-text);
}

/* 移动端 */
@media (max-width: 900px) {
  .admin-menu-toggle {
    display: inline-flex;
  }

  .admin-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: 8px 0 32px rgba(15, 23, 42, 0.12);
  }

  .admin-sidebar.is-open {
    transform: translateX(0);
  }

  .admin-sidebar-backdrop {
    display: block;
  }

  .admin-content {
    padding: 16px 16px 28px;
  }
}

@media (max-width: 480px) {
  :root {
    --admin-sidebar-w: min(288px, 88vw);
  }

  .admin-topbar-title {
    font-size: 15px;
  }
}

/* 弹层、提示条盖住侧栏与顶栏（!important 压过页面内联 z-index） */
.admin-body .modal,
.admin-body [id$="-modal"] {
  z-index: 2200 !important;
}

.admin-body .toast {
  z-index: 2300;
}

/* 今日数据网格与统计卡片（工作台 / 交易统计共用） */
.admin-app .stats-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.admin-app .stat-card {
  padding: 18px 20px;
  border-radius: var(--admin-radius);
  border: 1px solid var(--admin-border);
  box-shadow: var(--admin-shadow-card);
  background: var(--admin-surface);
}

.admin-app .stat-card h3 {
  font-size: 13px;
  color: var(--admin-muted);
  margin: 0 0 10px;
  font-weight: 600;
}

.admin-app .stat-card .value {
  font-size: 22px;
  font-weight: 700;
  color: var(--admin-text);
  letter-spacing: -0.02em;
}

.admin-app .stat-card .trend {
  font-size: 12px;
  margin-top: 6px;
}

.admin-app .stat-card .trend.positive {
  color: #10b981;
}

.admin-app .stat-card .trend.negative {
  color: #ef4444;
}
