/* ============ 变量与重置 ============ */
:root {
  --primary: #2563eb;
  --primary-light: #3b82f6;
  --primary-dark: #1d4ed8;
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --cyan: #06b6d4;
  --success: #10b981;
  --success-50: #ecfdf5;
  --warning: #f59e0b;
  --warning-50: #fffbeb;
  --danger: #ef4444;
  --danger-50: #fef2f2;
  --bg: #f1f5f9;
  --bg-soft: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.08);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --gradient-primary: linear-gradient(135deg, #2563eb 0%, #06b6d4 100%);
  --gradient-card: linear-gradient(135deg, rgba(37, 99, 235, 0.05) 0%, rgba(6, 182, 212, 0.05) 100%);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; outline: none; }
ul, ol { list-style: none; }

/* ============ 通用按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all .18s ease;
  white-space: nowrap;
}
.btn-primary {
  background: var(--gradient-primary); color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35); }
.btn-default {
  background: #fff; color: var(--text-secondary); border: 1px solid var(--border);
}
.btn-default:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid var(--border); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-ghost { padding: 6px 10px; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--primary); background: var(--primary-50); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 14px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ============ 表单 ============ */
.form-row { margin-bottom: 16px; }
.form-row label {
  display: block; margin-bottom: 6px;
  font-size: 13px; color: var(--text-secondary); font-weight: 500;
}
.form-row label .req { color: var(--danger); margin-left: 2px; }
.input, .select {
  width: 100%; padding: 10px 12px;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text);
  transition: all .18s ease;
}
.input:focus, .select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.input::placeholder { color: var(--text-muted); }

/* ============ 标签 ============ */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 4px;
  font-size: 12px; font-weight: 500;
}
.tag-success { background: var(--success-50); color: var(--success); }
.tag-warning { background: var(--warning-50); color: var(--warning); }
.tag-danger { background: var(--danger-50); color: var(--danger); }
.tag-info { background: var(--primary-50); color: var(--primary); }
.tag-default { background: var(--bg); color: var(--text-secondary); }
.tag .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ============ 卡片 ============ */
.card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); border: 1px solid var(--border-light);
}
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.table th {
  text-align: left; padding: 12px 16px; font-weight: 500;
  color: var(--text-secondary); background: var(--bg-soft);
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}
.table td {
  padding: 14px 16px; border-bottom: 1px solid var(--border-light);
  color: var(--text); vertical-align: middle;
}
.table tr:hover td { background: var(--bg-soft); }
.table .actions { display: flex; gap: 4px; }

/* ============ 模态框 ============ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.modal-mask.show { opacity: 1; pointer-events: auto; }
.modal {
  background: #fff; border-radius: var(--radius-lg);
  width: 480px; max-width: 90vw; max-height: 90vh;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px); transition: transform .2s ease;
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-mask.show .modal { transform: translateY(0); }
.modal-header {
  padding: 18px 24px; border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  width: 28px; height: 28px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 22px 24px; overflow-y: auto; }
.modal-footer {
  padding: 14px 24px; border-top: 1px solid var(--border-light);
  display: flex; justify-content: flex-end; gap: 10px;
  background: var(--bg-soft);
}

/* ============ 通知 ============ */
.toast-container {
  position: fixed; top: 24px; right: 24px; z-index: 2000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: #fff; padding: 12px 18px; border-radius: var(--radius);
  box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px;
  font-size: 13px; min-width: 240px;
  border-left: 3px solid var(--primary);
  animation: toast-in .25s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warning); }
.toast .ico {
  width: 18px; height: 18px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.toast.success .ico { color: var(--success); }
.toast.error .ico { color: var(--danger); }
.toast.warn .ico { color: var(--warning); }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ============ 登录页 ============ */
.login-page {
  min-height: 100vh; display: flex;
  background: #f1f5f9;
  position: relative; overflow: hidden;
}
.login-page::before {
  content: ''; position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 12% 20%, rgba(37, 99, 235, 0.10) 0, transparent 35%),
    radial-gradient(circle at 88% 80%, rgba(6, 182, 212, 0.10) 0, transparent 35%),
    linear-gradient(to right, rgba(15, 23, 42, 0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(15, 23, 42, 0.04) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 56px 56px, 56px 56px;
  pointer-events: none;
}
.login-left {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  padding: 60px 80px; position: relative; z-index: 1;
}
.login-brand {
  display: flex; align-items: center; gap: 12px; margin-bottom: 40px;
}
.brand-mark {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--gradient-primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 20px;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
  position: relative; overflow: hidden;
}
.brand-mark::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent 30%, rgba(255,255,255,.3) 50%, transparent 70%);
}
.brand-name { font-size: 18px; font-weight: 600; color: var(--text); }
.brand-name .sub { display: block; font-size: 12px; color: var(--text-muted); font-weight: 400; margin-top: 2px; }
.login-headline {
  font-size: 38px; font-weight: 700; line-height: 1.25; margin-bottom: 18px;
  background: linear-gradient(135deg, #0f172a 0%, #2563eb 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.login-sub { font-size: 15px; color: var(--text-secondary); margin-bottom: 36px; max-width: 480px; line-height: 1.7; }
.login-features { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; max-width: 520px; }
.feat-item {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  background: rgba(255,255,255,.7); border: 1px solid var(--border-light);
  border-radius: var(--radius); backdrop-filter: blur(8px);
}
.feat-ico {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--primary-50); color: var(--primary);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.feat-text { font-size: 13px; }
.feat-text strong { display: block; color: var(--text); font-weight: 600; margin-bottom: 2px; }
.feat-text span { color: var(--text-muted); font-size: 12px; }

.login-right {
  width: 460px; display: flex; align-items: center; justify-content: center;
  padding: 40px; position: relative; z-index: 1;
}
.login-card {
  width: 100%; max-width: 380px; background: #fff;
  border-radius: var(--radius-lg); padding: 40px 36px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-light);
}
.login-title { font-size: 22px; font-weight: 600; margin-bottom: 6px; }
.login-tip { font-size: 13px; color: var(--text-muted); margin-bottom: 28px; }
.tab-row {
  display: flex; gap: 4px; padding: 4px;
  background: var(--bg); border-radius: 8px; margin-bottom: 22px;
}
.tab-row button {
  flex: 1; padding: 8px 12px; border-radius: 6px;
  font-size: 13px; color: var(--text-secondary); transition: all .18s;
}
.tab-row button.active { background: #fff; color: var(--primary); box-shadow: var(--shadow-sm); font-weight: 500; }
.input-group { position: relative; margin-bottom: 14px; }
.input-group .input { padding-left: 38px; height: 42px; }
.input-group .input-ico {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); pointer-events: none;
}
.input-group .input-ico svg,
.feat-ico svg,
.nav-ico svg,
.stat-ico svg,
.topbar-icon svg,
.toast .ico svg,
.search-input .ico svg {
  width: 100%;
  height: 100%;
  display: block;
}
.login-btn {
  width: 100%; height: 44px; margin-top: 8px;
  background: var(--gradient-primary); color: #fff; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
  transition: all .2s;
}
.login-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(37, 99, 235, 0.4); }
.login-hint {
  margin-top: 18px; padding: 12px; background: var(--primary-50);
  border-radius: var(--radius-sm); font-size: 12px; color: var(--primary-dark);
  line-height: 1.6;
}
.login-hint code {
  background: #fff; padding: 1px 6px; border-radius: 4px;
  font-family: "SF Mono", Consolas, monospace; font-size: 12px;
  color: var(--primary);
}

/* ============ 后台布局 ============ */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: #fff;
  border-right: 1px solid var(--border-light);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  padding: 20px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border-light);
}
.sidebar-brand .brand-mark { width: 36px; height: 36px; font-size: 16px; border-radius: 9px; }
.sidebar-brand .brand-text { font-size: 14px; font-weight: 600; }
.sidebar-brand .brand-text .sub { display: block; font-size: 11px; color: var(--text-muted); font-weight: 400; margin-top: 1px; }
.sidebar-nav {
  flex: 1; padding: 12px; overflow-y: auto;
}
.nav-group { margin-bottom: 16px; }
.nav-group-title {
  padding: 6px 12px; font-size: 11px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-secondary); cursor: pointer;
  transition: all .15s; margin-bottom: 2px;
  position: relative;
}
.nav-item:hover { background: var(--bg-soft); color: var(--text); }
.nav-item.active {
  background: var(--primary-50); color: var(--primary); font-weight: 500;
}
.nav-item.active::before {
  content: ''; position: absolute; left: -12px; top: 50%;
  transform: translateY(-50%); width: 3px; height: 18px;
  background: var(--primary); border-radius: 0 3px 3px 0;
}
.nav-item .nav-ico { width: 18px; height: 18px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 60px; background: #fff;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; position: sticky; top: 0; z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.crumb { font-size: 14px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.crumb .sep { color: var(--text-muted); }
.crumb .current { color: var(--text); font-weight: 500; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-icon {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); cursor: pointer; position: relative;
  transition: all .15s;
}
.topbar-icon:hover { background: var(--bg-soft); color: var(--primary); }
.badge-dot {
  position: absolute; top: 8px; right: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger); border: 2px solid #fff;
}
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 12px 4px 4px; border-radius: 22px;
  background: var(--bg-soft); cursor: pointer;
  border: 1px solid transparent; transition: all .15s;
}
.user-chip:hover { border-color: var(--border); }
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--gradient-primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
}
.user-name { font-size: 13px; }
.user-name .role { display: block; font-size: 11px; color: var(--text-muted); }

.content { padding: 24px; flex: 1; overflow: auto; }

/* ============ 概览统计卡 ============ */
.stat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px;
}
.stat-card {
  background: #fff; padding: 20px; border-radius: var(--radius);
  border: 1px solid var(--border-light);
  position: relative; overflow: hidden;
  transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card::after {
  content: ''; position: absolute; right: -20px; bottom: -20px;
  width: 100px; height: 100px; border-radius: 50%;
  background: var(--gradient-card); pointer-events: none;
}
.stat-label { font-size: 13px; color: var(--text-muted); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.stat-label .stat-ico {
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--primary-50); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.stat-card.success .stat-ico { background: var(--success-50); color: var(--success); }
.stat-card.warning .stat-ico { background: var(--warning-50); color: var(--warning); }
.stat-card.danger .stat-ico { background: var(--danger-50); color: var(--danger); }
.stat-value {
  font-size: 28px; font-weight: 700;
  font-feature-settings: "tnum"; line-height: 1.2;
  background: linear-gradient(180deg, var(--text) 0%, #334155 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.stat-meta { margin-top: 8px; font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }
.trend-up { color: var(--success); }
.trend-down { color: var(--danger); }

/* ============ 工具条 ============ */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.toolbar-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search-input {
  position: relative; width: 240px;
}
.search-input input {
  width: 100%; padding: 8px 12px 8px 34px; height: 34px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; font-size: 13px;
}
.search-input input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.search-input .ico {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
}

/* ============ 分页 ============ */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-top: 1px solid var(--border-light);
  font-size: 13px; color: var(--text-secondary);
}
.pagination-controls { display: flex; gap: 4px; }
.page-btn {
  min-width: 30px; height: 30px; padding: 0 10px;
  border-radius: 6px; background: #fff;
  border: 1px solid var(--border);
  font-size: 12px; color: var(--text-secondary);
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ============ 图表区 ============ */
.chart-row {
  display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px;
}
.chart-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
.chart-container { width: 100%; height: 280px; }
.chart-container.small { height: 220px; }

/* ============ 活动时间线 ============ */
.timeline { padding: 4px 0; }
.timeline-item {
  display: flex; gap: 12px; padding: 10px 0;
  position: relative;
}
.timeline-item:not(:last-child)::before {
  content: ''; position: absolute; left: 7px; top: 22px; bottom: -10px;
  width: 1px; background: var(--border);
}
.timeline-dot {
  width: 14px; height: 14px; border-radius: 50%; background: #fff;
  border: 2px solid var(--primary); flex-shrink: 0; margin-top: 4px;
  position: relative; z-index: 1;
}
.timeline-item.success .timeline-dot { border-color: var(--success); }
.timeline-item.warning .timeline-dot { border-color: var(--warning); }
.timeline-content { flex: 1; }
.timeline-title { font-size: 13px; color: var(--text); margin-bottom: 2px; }
.timeline-meta { font-size: 12px; color: var(--text-muted); }

/* ============ 空状态 ============ */
.empty {
  padding: 60px 20px; text-align: center; color: var(--text-muted);
}
.empty-ico {
  width: 56px; height: 56px; margin: 0 auto 14px;
  background: var(--bg); border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
}
.empty-text { font-size: 13px; margin-bottom: 16px; }

/* ============ 工具类 ============ */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-gap-8 { display: flex; gap: 8px; }
.flex-col { display: flex; flex-direction: column; }
.gap-12 { gap: 12px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-0 { margin-bottom: 0; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-right { text-align: right; }
.hidden { display: none !important; }

/* ============ 响应式 ============ */
@media (max-width: 1280px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-row { grid-template-columns: 1fr; }
  .chart-row.cols-3 { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .login-left { display: none; }
  .login-right { width: 100%; }
  .sidebar { width: 64px; }
  .sidebar-brand .brand-text, .nav-item span, .nav-group-title { display: none; }
}
