/* ============================================================
   青澈去水印 · Web 管理后台样式
   配色与小程序保持一致，Token 定义见 :root（对应小程序 styles/tokens.wxss）
   主色青碧 #14A9B8 / #0C8492，强调珊瑚橙 #FF7A45，会员香槟金 #FFB020
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ---- 品牌 · 青碧 ---- */
  --brand-50:  #EAF8F9;
  --brand-100: #D2F0F1;
  --brand-200: #A6E2E5;
  --brand-400: #2FD3DD;
  --brand-500: #14A9B8;
  --brand-600: #0C8492;
  --brand-700: #0A6B77;

  /* ---- 功能强调 · 珊瑚橙 ---- */
  --accent-50:  #FFF1E8;
  --accent-500: #FF7A45;
  --accent-600: #F2652F;

  /* ---- 会员 · 香槟金 ---- */
  --gold-50:   #FFF6DE;
  --gold-100:  #FFE9A8;
  --gold-400:  #FFC53D;
  --gold-500:  #FFB020;
  --gold-600:  #E89600;

  /* ---- 语义 ---- */
  --success-50:  #E7F7EF;
  --success-500: #22C55E;
  --success-700: #157F41;
  --danger-50:   #FDE8E9;
  --danger-500:  #E5484D;
  --danger-700:  #B3252A;

  /* ---- 中性 · 青调冷灰 ---- */
  --gray-50:  #F3F6F7;
  --gray-100: #EAF0F1;
  --gray-200: #E4EBEC;
  --gray-400: #8A9BA1;
  --gray-500: #46595F;
  --gray-900: #16242A;
  --white:    #FFFFFF;

  /* ---- 语义别名（沿用原变量名，缩小改动面）---- */
  --primary: var(--brand-500);
  --primary-dark: var(--brand-600);
  --primary-light: var(--brand-100);
  --orange: var(--accent-500);
  --orange-light: var(--accent-50);
  --green: var(--success-500);
  --green-light: var(--success-50);
  --purple: var(--gold-500);
  --cyan: var(--brand-400);
  --gold: var(--gold-400);
  --bg: var(--gray-50);
  --text: var(--gray-900);
  --text-secondary: var(--gray-500);
  --text-muted: var(--gray-400);
  --border: var(--gray-200);
  --shadow: rgba(12, 32, 36, 0.05);
  --mask: rgba(12, 32, 36, 0.55);

  /* ---- 渐变 ---- */
  --grad-brand: linear-gradient(135deg, #2FD3DD 0%, #0C8492 100%);
  --grad-brand-deep: linear-gradient(135deg, #0C8492 0%, #0A6B77 100%);
  --grad-gold: linear-gradient(135deg, #FFC53D 0%, #FFB020 100%);

  /* ---- 圆角 ---- */
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
}

html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }

/* Toast */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-20px);
  background: var(--text); color: var(--white); padding: 10px 24px; border-radius: var(--radius);
  font-size: 14px; z-index: 10000; opacity: 0; transition: all 0.3s ease; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Login */
.login-mode #app { display: flex; align-items: center; justify-content: center; width: 100%; height: 100vh; background: linear-gradient(135deg, #2FD3DD 0%, #0C8492 55%, #0A6B77 100%); }
.login-mode .layout { display: none; }
.login-container { width: 100%; max-width: 440px; margin: auto; padding: 20px; }
.login-card { background: var(--white); border-radius: var(--radius-xl); padding: 48px 40px; box-shadow: 0 12px 48px rgba(12,32,36,0.22); }
.login-logo { text-align: center; margin-bottom: 36px; }
.login-logo-icon { font-size: 56px; margin-bottom: 16px; }
.login-logo h1 { font-size: 22px; font-weight: 700; color: var(--text); margin-bottom: 6px; letter-spacing: 1px; }
.login-subtitle { font-size: 14px; color: var(--text-secondary); }
.login-form { display: flex; flex-direction: column; gap: 20px; }
.login-error { color: var(--danger-500); font-size: 13px; text-align: left; min-height: 20px; line-height: 1.6; white-space: pre-wrap; word-break: break-all; }
.btn-block { width: 100%; }
.login-mode .login-card { border: 1px solid rgba(255,255,255,0.1); }
/* 记住账号密码：复选框横向布局，与表单纵向布局区分 */
.form-remember { flex-direction: row; align-items: center; gap: 8px; }
.remember-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); cursor: pointer; user-select: none; }
.remember-label input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; margin: 0; accent-color: var(--primary-dark); }

/* Layout */
.layout { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 240px; background: var(--white); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-header { padding: 24px 20px 16px; border-bottom: 1px solid var(--border); }
.sidebar-header h2 { font-size: 18px; font-weight: 700; color: var(--primary-dark); margin: 0; }
.sidebar-subtitle { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item { display: flex; align-items: center; padding: 12px 20px; color: var(--text-secondary); text-decoration: none; font-size: 14px; transition: all 0.2s; border-left: 3px solid transparent; }
.nav-item:hover { background: var(--brand-50); color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary-dark); border-left-color: var(--primary); font-weight: 600; }
.nav-icon { margin-right: 10px; font-size: 16px; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.sidebar-user { font-size: 13px; color: var(--text-secondary); }
.btn-logout { background: none; border: 1px solid var(--border); color: var(--text-secondary); padding: 6px 12px; border-radius: var(--radius); cursor: pointer; font-size: 12px; transition: all 0.2s; }
.btn-logout:hover { border-color: var(--danger-500); color: var(--danger-500); }

/* Main */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.content-header { padding: 24px 32px 16px; background: var(--white); border-bottom: 1px solid var(--border); }
.page-title { font-size: 20px; font-weight: 700; color: var(--text); margin: 0; }
.content-body { flex: 1; padding: 24px 32px; overflow-y: auto; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 8px 20px; border-radius: var(--radius); font-size: 14px; font-weight: 500; border: 1px solid transparent; cursor: pointer; transition: all 0.2s; text-decoration: none; gap: 6px; white-space: nowrap; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
/* 主按钮用 #0C8492 打底，白字对比度 4.4:1（#14A9B8 上放白字不达标） */
.btn-primary { background: var(--primary-dark); color: var(--white); border-color: var(--primary-dark); }
.btn-primary:hover:not(:disabled) { background: var(--brand-700); border-color: var(--brand-700); }
.btn-outline { background: var(--white); color: var(--text-secondary); border-color: var(--border); }
.btn-outline:hover:not(:disabled) { border-color: var(--primary-dark); color: var(--primary-dark); }
.btn-outline-danger { background: var(--white); color: var(--danger-500); border-color: var(--border); }
.btn-outline-danger:hover:not(:disabled) { border-color: var(--danger-500); color: var(--white); background: var(--danger-500); }
.btn-sm { padding: 4px 12px; font-size: 12px; }

/* Forms */
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--text); }
.form-input { height: 40px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; background: var(--bg); color: var(--text); outline: none; transition: border-color 0.2s; }
.form-input:focus { border-color: var(--primary); }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%238A9BA1'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--white); border-radius: var(--radius-lg); padding: 20px; box-shadow: 0 2px 8px var(--shadow); position: relative; overflow: hidden; }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; width: 4px; height: 100%; }
.stat-blue::before { background: var(--primary); }
.stat-orange::before { background: var(--orange); }
.stat-green::before { background: var(--green); }
.stat-purple::before { background: var(--purple); }
.stat-cyan::before { background: var(--cyan); }
.stat-icon { font-size: 28px; margin-bottom: 8px; }
.stat-info { display: flex; flex-direction: column; gap: 2px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--text-secondary); }
.stat-trend { font-size: 12px; color: var(--text-muted); margin-top: 8px; }

/* Dashboard section */
.dashboard-section { margin-top: 8px; }
.section-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 12px; }
.quick-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.quick-action-card { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 20px 16px; background: var(--white); border-radius: var(--radius-lg); box-shadow: 0 2px 8px var(--shadow); text-decoration: none; transition: all 0.2s; cursor: pointer; }
.quick-action-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(12,32,36,0.10); }
.qa-icon { font-size: 32px; }
.qa-text { font-size: 13px; color: var(--text-secondary); font-weight: 500; }

/* Toolbar */
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.search-box { display: flex; gap: 8px; align-items: center; }
.search-box .form-input { width: 240px; }
.filter-group { display: flex; gap: 8px; align-items: center; }
.filter-group .form-select { width: 140px; }
.toolbar-info { font-size: 13px; color: var(--text-muted); }

/* Table */
.table-wrapper { background: var(--white); border-radius: var(--radius-lg); box-shadow: 0 2px 8px var(--shadow); overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { background: var(--bg); padding: 12px 16px; text-align: left; font-size: 12px; font-weight: 600; color: var(--text-secondary); white-space: nowrap; border-bottom: 1px solid var(--border); }
.data-table th.th-sortable { cursor: pointer; user-select: none; }
.data-table th.th-sortable:hover { color: var(--primary-dark); }
.data-table td { padding: 12px 16px; font-size: 13px; border-bottom: 1px solid var(--border); color: var(--text); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--gray-50); }
.text-center { text-align: center; color: var(--text-muted); padding: 32px 0; }
.text-mono { font-family: 'SFMono-Regular', Consolas, monospace; font-size: 12px; }
.text-sm { font-size: 12px; color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 500; }
.badge-green { background: var(--green-light); color: var(--success-700); }
.badge-red { background: var(--danger-50); color: var(--danger-700); }
.badge-orange { background: var(--orange-light); color: var(--accent-600); }
.badge-blue { background: var(--primary-light); color: var(--brand-700); }
.badge-gray { background: var(--gray-100); color: var(--gray-500); }

/* User avatar in table */
.user-avatar { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--primary-light); color: var(--primary-dark); font-size: 12px; font-weight: 600; margin-right: 8px; vertical-align: middle; }

/* Pagination */
.pagination { margin-top: 16px; display: flex; justify-content: center; }
.pagination-inner { display: flex; gap: 4px; align-items: center; }
.page-ellipsis { padding: 4px 8px; color: var(--text-muted); font-size: 12px; user-select: none; }

/* Modal */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--mask); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal { background: var(--white); border-radius: var(--radius-xl); width: 90%; max-width: 480px; max-height: 80vh; overflow-y: auto; box-shadow: 0 8px 32px rgba(12,32,36,0.18); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 0; }
.modal-header h4 { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 24px; color: var(--text-muted); cursor: pointer; padding: 0; line-height: 1; }
.modal-body { padding: 16px 24px 8px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 24px 20px; }

/* Loading & Error States */
.loading, .error-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; margin-bottom: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-state p { color: var(--text-muted); font-size: 14px; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-header h2, .sidebar-subtitle, .sidebar-user, .nav-item span:not(.nav-icon) { display: none; }
  .sidebar-nav { padding: 8px 0; }
  .nav-item { justify-content: center; padding: 12px; border-left-width: 2px; }
  .nav-icon { margin-right: 0; font-size: 20px; }
  .content-header, .content-body { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .quick-actions { grid-template-columns: repeat(2, 1fr); }
}
