:root {
  /* 基础色 — 清爽浅色 */
  --bg: #f5f3ff;
  --card: #ffffff;
  --text: #1e1b2e;
  --muted: #6b7280;
  --line: rgba(0,0,0,0.08);

  /* 主色 — 柔和紫色系 */
  --brand: #7c3aed;
  --brand-light: #a78bfa;
  --brand-dark: #6d28d9;
  --ok: #10b981;
  --err: #ef4444;
  --warn: #f59e0b;

  /* 发光色 — 柔和光晕 */
  --glow-brand: rgba(124,58,237,0.15);
  --glow-ok: rgba(16,185,129,0.15);
  --glow-err: rgba(239,68,68,0.15);

  /* 卡片质感 — 干净明亮 */
  --card-glass: rgba(255,255,255,0.85);
  --card-border: rgba(124,58,237,0.12);
  --nav-bg: rgba(255,255,255,0.92);
  --shadow-card: 0 1px 8px rgba(0,0,0,0.06);
  --transition: 0.2s ease;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Microsoft YaHei", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  background: var(--nav-bg);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}

.nav-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.nav-left { display: flex; gap: 10px; align-items: baseline; }
.brand {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.nav-links { display: flex; gap: 6px; flex-wrap: wrap; }
.nav-links a {
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 8px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.nav-links a:hover {
  background: rgba(124,58,237,0.08);
  color: var(--brand);
  text-decoration: none;
}
.nav-links a.active {
  background: rgba(124,58,237,0.1);
  color: var(--brand);
  font-weight: 600;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 18px 14px 36px;
}

.card {
  background: var(--card-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow-card);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.card:hover {
  border-color: rgba(124,58,237,0.2);
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 980px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}
@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr !important; }
}

.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value {
  font-size: 26px;
  font-weight: 800;
  margin-top: 6px;
  color: var(--brand-dark);
}

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1 1 auto; }

.muted { color: var(--muted); }

.flash {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 10px 0;
}
.flash.ok { border-color: rgba(52,211,153,0.5); background: rgba(52,211,153,0.12); }
.flash.error { border-color: rgba(248,113,113,0.5); background: rgba(248,113,113,0.12); }

table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  border-bottom: 1px solid var(--line);
  padding: 8px 6px;
  text-align: left;
  vertical-align: top;
}
th { color: var(--muted); font-weight: 600; font-size: 12px; }
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: rgba(124,58,237,0.04); }
tbody tr:nth-child(even) { background: rgba(124,58,237,0.02); }
tbody tr:nth-child(even):hover { background: rgba(124,58,237,0.04); }

input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--glow-brand);
}
textarea { min-height: 74px; resize: vertical; }

.btn {
  display: inline-block;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
}
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--brand-dark); box-shadow: 0 2px 12px var(--glow-brand); }
.btn.danger { background: rgba(239,68,68,0.08); border-color: rgba(239,68,68,0.3); color: var(--err); }
.btn.danger:hover:not(:disabled) { box-shadow: 0 2px 12px var(--glow-err); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

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

.right { text-align: right; }
.center { text-align: center; }

tr.cancelled { opacity: 0.45; }
tr.cancelled td { text-decoration: line-through; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--line);
}
.badge.ok { border-color: rgba(52,211,153,0.5); color: var(--ok); background: rgba(52,211,153,0.1); }
.badge.warn { border-color: rgba(251,191,36,0.5); color: var(--warn); background: rgba(251,191,36,0.1); }
.badge.err { border-color: rgba(248,113,113,0.5); color: var(--err); background: rgba(248,113,113,0.1); }

/* 汉堡菜单 */
.nav-toggle {
  display: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 4px 10px;
  font-size: 18px;
  cursor: pointer;
}
@media (max-width: 768px) {
  .nav-toggle { display: block; }
  .nav-links {
    display: none;
    width: 100%;
    flex-direction: column;
    gap: 4px;
    padding-top: 8px;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 8px 12px; border-radius: 8px; }
}

/* 手机底部 Tab 栏 */
.bottom-tabs {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 20;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -1px 6px rgba(0,0,0,0.05);
  height: 56px;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-tabs-inner {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 56px;
}
.bottom-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1;
  text-decoration: none;
  color: var(--muted);
  font-size: 10px;
  padding: 4px 0;
  transition: color var(--transition);
}
.bottom-tab svg { width: 22px; height: 22px; }
.bottom-tab.active { color: var(--brand); }
.bottom-tab:hover { text-decoration: none; color: var(--brand); }

@media (max-width: 768px) {
  .bottom-tabs { display: block; }
  body { padding-bottom: 60px; }
  .nav-links, .nav-toggle { display: none !important; }

  /* 按钮触摸友好 */
  .btn, .quick-btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }

  /* 容器减少边距 */
  .container { padding: 12px 10px 70px; }

  /* KPI 数值缩小 */
  .kpi .value { font-size: 20px; }

  /* 卡片减少内边距 */
  .card { padding: 10px; border-radius: 10px; }

  /* 模态框全宽 */
  .modal-content { min-width: unset; width: 95%; }

  /* 配置行垂直堆叠 */
  .config-row { flex-direction: column; align-items: flex-start; gap: 6px; }
  .config-label { min-width: unset; }
  .config-control input[type="text"],
  .config-control select { max-width: 100%; }

  /* 快捷操作按钮全宽 */
  .quick-actions { flex-direction: column; }
  .quick-btn { justify-content: center; width: 100%; }

  /* 标签页紧凑 */
  .tab-link { padding: 8px 12px; font-size: 14px; }

  /* 页面标题行 */
  .page-header { flex-direction: column; align-items: flex-start; }

  /* 操作按钮行换行 */
  .actions { gap: 6px; }

  /* 桌面表格/移动卡片切换 */
  .desktop-table { display: none !important; }
  .mobile-cards { display: block !important; }
  .hide-mobile { display: none !important; }
}

/* 模态框 */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-content {
  min-width: 360px;
  max-width: 480px;
  width: 90%;
}

/* Flatpickr 浅色适配 */
.flatpickr-calendar {
  background: #fff !important;
  border: 1px solid var(--line) !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1) !important;
  border-radius: 12px !important;
}
.flatpickr-months .flatpickr-month,
.flatpickr-current-month .flatpickr-monthDropdown-months {
  background: #fff !important;
  color: var(--text) !important;
}
.flatpickr-current-month input.cur-year { color: var(--text) !important; }
.flatpickr-weekdays { background: #fff !important; }
span.flatpickr-weekday { color: var(--muted) !important; }
.flatpickr-day {
  color: var(--text) !important;
  border-radius: 8px !important;
}
.flatpickr-day:hover { background: rgba(124,58,237,0.1) !important; border-color: transparent !important; }
.flatpickr-day.selected { background: var(--brand) !important; border-color: var(--brand) !important; color: #fff !important; }
.flatpickr-day.today { border-color: var(--brand-light) !important; }
.flatpickr-day.prevMonthDay, .flatpickr-day.nextMonthDay { color: #ccc !important; }
.flatpickr-months .flatpickr-prev-month svg,
.flatpickr-months .flatpickr-next-month svg { fill: var(--muted) !important; }

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

/* Toggle 开关 */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.06);
  border: 1px solid var(--line);
  border-radius: 24px;
  transition: var(--transition);
}
.toggle-slider:before {
  content: "";
  position: absolute;
  height: 18px; width: 18px;
  left: 2px; bottom: 2px;
  background: #ccc;
  border-radius: 50%;
  transition: var(--transition);
}
.toggle-switch input:checked + .toggle-slider {
  background: rgba(124,58,237,0.15);
  border-color: var(--brand);
}
.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(20px);
  background: var(--brand);
}

/* 配置表单 */
.config-section { margin-bottom: 8px; }
.config-section .section-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--brand-dark);
}
.config-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0,0,0,0.04);
}
.config-row:last-child { border-bottom: none; }
.config-label {
  min-width: 120px;
  color: var(--muted);
  font-size: 13px;
}
.config-control { flex: 1; }
.config-control input[type="text"],
.config-control select {
  max-width: 320px;
}

/* 图片预览 */
.img-preview {
  display: inline-block;
  max-width: 120px;
  max-height: 80px;
  border-radius: 6px;
  border: 1px solid var(--line);
  margin-top: 6px;
}
.img-upload-area {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* 标签页 */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--line);
  margin-bottom: 14px;
  overflow-x: auto;
}
.tab-link {
  padding: 10px 18px;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
  text-decoration: none;
}
.tab-link:hover { color: var(--brand); text-decoration: none; }
.tab-link.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 600;
}

/* 手风琴 */
.accordion-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 8px;
  overflow: hidden;
  background: var(--card);
}
.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}
.accordion-header:hover { background: rgba(124,58,237,0.04); }
.accordion-header .acc-title {
  font-weight: 600;
  font-size: 14px;
}
.accordion-header .acc-status {
  font-size: 12px;
  color: var(--muted);
}
.accordion-header .acc-arrow {
  transition: transform 0.2s;
  color: var(--muted);
  font-size: 12px;
}
.accordion-item.open .acc-arrow { transform: rotate(90deg); }
.accordion-body {
  display: none;
  padding: 0 14px 14px;
}
.accordion-item.open .accordion-body { display: block; }

/* 快捷操作按钮 */
.quick-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--brand-dark);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
}
.quick-btn:hover {
  background: rgba(124,58,237,0.06);
  border-color: var(--brand-light);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* 排行榜表格 */
.rank-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}
.rank-1 { background: #fef3c7; color: #b45309; }
.rank-2 { background: #e5e7eb; color: #4b5563; }
.rank-3 { background: #fed7aa; color: #c2410c; }

/* 表格容器（手机端水平滚动） */
.table-wrap { overflow-x: auto; }

/* 页面标题行 */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.page-title {
  font-size: 18px;
  font-weight: 800;
}

/* 状态标签 */
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}
.badge.inactive {
  background: var(--glow-err);
  color: var(--err);
}
tr.row-inactive td {
  opacity: 0.55;
}

/* 桌面端/移动端切换控制 */
.mobile-cards { display: none; }
.desktop-table { display: block; }
.hide-mobile { /* 默认显示 */ }

/* ===== 登录/设置页面 ===== */
.auth-page {
  background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 50%, #ddd6fe 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-container {
  width: 100%;
  max-width: 420px;
  padding: 20px;
}
.auth-card {
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(124,58,237,0.12);
  border-radius: 18px;
  padding: 32px 28px;
  box-shadow: 0 4px 24px rgba(124,58,237,0.1);
}
.auth-brand {
  font-size: 28px;
  font-weight: 800;
  text-align: center;
  margin-bottom: 6px;
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.auth-title {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.auth-subtitle {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 20px;
}
.auth-field {
  margin-bottom: 16px;
}
.auth-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.auth-field input[type="text"],
.auth-field input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 15px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.auth-field input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--glow-brand);
}
.auth-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.password-wrap {
  position: relative;
}
.password-wrap input {
  padding-right: 60px;
}
.pwd-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--brand);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.pwd-toggle:hover {
  background: rgba(124,58,237,0.08);
}
.auth-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
}
.auth-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}
.auth-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition);
  margin-top: 4px;
}
.auth-btn:hover {
  background: var(--brand-dark);
  box-shadow: 0 4px 16px var(--glow-brand);
}
.auth-page .flash {
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 14px;
  font-size: 13px;
}

/* ===== 移动端卡片布局组件 ===== */
.mobile-card {
  background: var(--card-glass);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-card);
  transition: border-color var(--transition);
}
.mobile-card:hover {
  border-color: rgba(124,58,237,0.2);
}
.mobile-card.cancelled {
  opacity: 0.45;
}

/* 卡片头部：主标题 + 状态 */
.mc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.mc-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}
.mc-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* 卡片数据行 */
.mc-body {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  padding: 8px 0;
  border-top: 1px solid rgba(0,0,0,0.05);
}
.mc-row {
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 45%;
}
.mc-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.mc-value {
  font-size: 14px;
  font-weight: 600;
}

/* 卡片底部操作区 */
.mc-footer {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid rgba(0,0,0,0.05);
  margin-top: 4px;
}
.mc-footer .btn {
  flex: 1;
  text-align: center;
  min-height: 36px;
  font-size: 13px;
  padding: 6px 10px;
}

/* 卡片内强调数值 */
.mc-amount {
  font-size: 16px;
  font-weight: 800;
  color: var(--brand-dark);
}
.mc-amount.warn {
  color: var(--warn);
}
.mc-amount.err {
  color: var(--err);
}
