/* =====================================================
   卡片社 全局样式
   设计语言：Ant Design / Semi Design，蓝白简约，支持暗黑模式
   ===================================================== */

:root {
  --primary: #1677ff;
  --primary-hover: #4096ff;
  --primary-active: #0958d9;
  --primary-soft: rgba(22, 119, 255, 0.1);
  --success: #52c41a;
  --warning: #faad14;
  --danger: #ff4d4f;
  --info: #1677ff;

  --bg: #f5f6f9;
  --card-bg: #ffffff;
  --sidebar-bg: #ffffff;
  --topbar-bg: rgba(255, 255, 255, 0.85);
  --text: #1f2329;
  --text-secondary: #86909c;
  --text-light: #c9cdd4;
  --border: #e5e6eb;
  --border-light: #f0f1f5;
  --hover: #f5f6f9;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  --shadow-modal: 0 12px 48px rgba(0, 0, 0, 0.16);
  --radius: 8px;
  --radius-sm: 6px;
  --sidebar-width: 228px;
  --topbar-height: 56px;
  --transition: 0.2s ease;
}

html[data-theme="dark"] {
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-active: #2563eb;
  --primary-soft: rgba(59, 130, 246, 0.18);

  --bg: #0f1015;
  --card-bg: #181a20;
  --sidebar-bg: #181a20;
  --topbar-bg: rgba(24, 26, 32, 0.85);
  --text: #e6e6eb;
  --text-secondary: #a0a4ad;
  --text-light: #6b6f78;
  --border: #2b2e36;
  --border-light: #22242b;
  --hover: #20232b;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-modal: 0 12px 48px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  transition: background var(--transition), color var(--transition);
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; bottom: 0; left: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition), width var(--transition);
}
.sidebar-logo {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-logo img { height: 30px; width: 30px; object-fit: contain; border-radius: 6px; }
.sidebar-logo .logo-name { font-size: 16px; font-weight: 600; white-space: nowrap; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.nav-group-title {
  font-size: 12px; color: var(--text-light); padding: 10px 12px 6px; letter-spacing: 0.5px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  transition: all var(--transition);
  white-space: nowrap;
}
.nav-item svg { flex-shrink: 0; }
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 500; }
.sidebar-footer { padding: 12px 14px; border-top: 1px solid var(--border); flex-shrink: 0; }

.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  transition: margin-left var(--transition);
}

.topbar {
  position: sticky; top: 0; z-index: 90;
  height: var(--topbar-height);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  background: var(--topbar-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-spacer { flex: 1; }
.icon-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}
.icon-btn:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }

.user-box { display: flex; align-items: center; gap: 8px; padding: 4px 10px; border-radius: var(--radius); cursor: pointer; transition: background var(--transition); position: relative; }
.user-box:hover { background: var(--hover); }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 600; overflow: hidden; }
.user-box .nickname { font-size: 14px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content { padding: 20px; flex: 1; }

/* ---------- 组件 ---------- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 15px; font-weight: 600; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 16px; }
.stat-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; display: flex; flex-direction: column; gap: 6px;
}
.stat-card .stat-label { font-size: 13px; color: var(--text-secondary); display: flex; align-items: center; gap: 8px; }
.stat-card .stat-value { font-size: 26px; font-weight: 600; line-height: 1.2; }
.stat-card .stat-extra { font-size: 12px; color: var(--text-light); }
.stat-icon { width: 38px; height: 38px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; color: var(--primary); background: var(--primary-soft); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 16px;
  font-size: 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1.4;
  background: var(--card-bg);
  color: var(--text);
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-primary:active:not(:disabled) { background: var(--primary-active); }
.btn-default { border-color: var(--border); }
.btn-default:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { opacity: 0.85; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { opacity: 0.85; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover:not(:disabled) { opacity: 0.85; }
.btn-outline { border-color: var(--primary); color: var(--primary); background: transparent; }
.btn-outline:hover:not(:disabled) { background: var(--primary-soft); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; }

/* 表单 */
.form-item { margin-bottom: 18px; }
.form-label { display: block; margin-bottom: 6px; font-size: 14px; color: var(--text); font-weight: 500; }
.form-label .req { color: var(--danger); margin-left: 2px; }
.input, .select, .textarea {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  outline: none;
  font-family: inherit;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.input::placeholder, .textarea::placeholder { color: var(--text-light); }
.textarea { resize: vertical; min-height: 80px; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%), linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.form-hint { font-size: 12px; color: var(--text-light); margin-top: 4px; }
.form-error { color: var(--danger); font-size: 13px; margin-top: 4px; }
.inline-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* 表格 */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
.table th { color: var(--text-secondary); font-weight: 500; background: var(--hover); white-space: nowrap; }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--hover); }
.table .cell-img { width: 40px; height: 40px; border-radius: var(--radius-sm); object-fit: cover; border: 1px solid var(--border); }
.table .cell-link { color: var(--primary); }
.table .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ellipsis { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }

/* 徽标 */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 20px; font-size: 12px; line-height: 1.6; font-weight: 500; }
.badge-dot { width: 8px; height: 8px; border-radius: 50%; }
.badge-success { background: rgba(82, 196, 26, 0.12); color: var(--success); }
.badge-success .badge-dot { background: var(--success); }
.badge-danger { background: rgba(255, 77, 79, 0.12); color: var(--danger); }
.badge-danger .badge-dot { background: var(--danger); }
.badge-warning { background: rgba(250, 173, 20, 0.14); color: var(--warning); }
.badge-warning .badge-dot { background: var(--warning); }
.badge-info { background: var(--primary-soft); color: var(--primary); }
.badge-info .badge-dot { background: var(--primary); }
.badge-gray { background: var(--hover); color: var(--text-secondary); }
.badge-gray .badge-dot { background: var(--text-light); }

/* 分页 */
.pagination { display: flex; align-items: center; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.page-btn {
  min-width: 32px; height: 32px; padding: 0 10px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: all var(--transition);
}
.page-btn:hover:not(:disabled):not(.active) { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-info { font-size: 13px; color: var(--text-secondary); margin-left: 4px; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0, 0, 0, 0.5);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; transition: all 0.2s ease;
}
.modal-mask.show { opacity: 1; visibility: visible; }
.modal {
  width: 92%; max-width: 460px;
  max-height: 88vh; overflow-y: auto;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-modal);
  transform: translateY(12px); transition: transform 0.2s ease;
}
.modal-mask.show .modal { transform: translateY(0); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* 二维码弹窗 */
.qr-box { text-align: center; padding: 10px 0; }
.qr-box canvas, .qr-box img { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; background: #fff; }
.qr-tip { font-size: 13px; color: var(--text-secondary); margin-top: 12px; }
.qr-url { font-size: 12px; color: var(--text-light); word-break: break-all; margin-top: 6px; }

/* Toast */
.toast {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%) translateY(-20px);
  z-index: 2000; padding: 10px 20px; border-radius: var(--radius);
  background: var(--card-bg); color: var(--text);
  box-shadow: var(--shadow-modal); border: 1px solid var(--border);
  font-size: 14px; opacity: 0; visibility: hidden; transition: all 0.3s ease;
  display: flex; align-items: center; gap: 8px; max-width: 90%;
}
.toast.show { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }
.toast.success { border-color: var(--success); }
.toast.success svg { color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.error svg { color: var(--danger); }
.toast.warning { border-color: var(--warning); }
.toast.warning svg { color: var(--warning); }

/* 下拉菜单 */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 150px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-modal);
  padding: 6px;
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: all 0.2s ease;
  z-index: 500;
}
.dropdown.open .dropdown-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: 14px; color: var(--text);
  cursor: pointer;
  transition: background var(--transition);
}
.dropdown-item:hover { background: var(--hover); color: var(--primary); }
.dropdown-item.danger:hover { background: rgba(255, 77, 79, 0.1); color: var(--danger); }

/* 空状态 */
.empty { text-align: center; padding: 40px 20px; color: var(--text-light); }
.empty svg { opacity: 0.4; margin-bottom: 10px; }

/* 页签 */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab { padding: 9px 16px; font-size: 14px; color: var(--text-secondary); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all var(--transition); }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

/* 工具 */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.mb-0 { margin-bottom: 0; }
.w-full { width: 100%; }
.text-secondary { color: var(--text-secondary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-primary { color: var(--primary); }
.text-center { text-align: center; }
.font-mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace; }
.hidden { display: none !important; }
.clickable { cursor: pointer; }
.uploader {
  width: 120px; height: 120px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 6px;
  color: var(--text-secondary);
  cursor: pointer; overflow: hidden;
  transition: all var(--transition);
  position: relative; background: var(--hover);
}
.uploader:hover { border-color: var(--primary); color: var(--primary); }
.uploader img { width: 100%; height: 100%; object-fit: cover; }
.uploader input[type="file"] { display: none; }

/* 图表 */
.chart-box { width: 100%; height: 320px; }

/* 支付二维码预览 */
.pay-qr-preview { text-align: center; }
.pay-qr-preview canvas { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; background: #fff; max-width: 240px; }

/* 模拟登录提示条 */
.su-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px;
  background: rgba(250, 173, 20, 0.12);
  color: var(--warning);
  font-size: 13px;
  border-bottom: 1px solid rgba(250, 173, 20, 0.3);
}
.su-banner .su-back { color: var(--primary); font-weight: 500; }
.su-banner .su-back:hover { text-decoration: underline; }

/* 响应式 */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-modal); }
  .main { margin-left: 0; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 12px; }
  .topbar { padding: 0 12px; }
  .user-box .nickname { display: none; }
}
