/* ── Kaito 全局样式 — 参考 kaito_redesign.html ── */

@import url("fonts.css");

/* 变量 */
:root {
  --primary: #6366f1;
  --primary-light: #818cf8;
  --secondary: #f59e0b;
  --accent: #10b981;
  --bg-sidebar: #0f172a;
  --bg-main: #f8fafc;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --card-bg: #ffffff;
  --sidebar-active: rgba(99, 102, 241, 0.2);
  --sidebar-hover: rgba(255, 255, 255, 0.05);
  --radius-lg: 16px;
  --radius-md: 12px;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-hover: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --border: #e2e8f0;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
}

/* 重置 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', 'Noto Sans SC', -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
}

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

/* ── 登录页 ── */
.login-page {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
}

.login-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-hover);
  width: 420px;
  max-width: 90vw;
  padding: 40px 36px;
}

.login-card h1 {
  text-align: center;
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary-light), #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}

.login-card .subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 28px;
}

.login-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}

.login-tabs button {
  flex: 1;
  padding: 10px;
  border: none;
  background: none;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.login-tabs button.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* ── 表单 ── */
.form-group { margin-bottom: 18px; }

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border 0.2s;
  font-family: inherit;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-group input:disabled {
  background: var(--bg-main);
  color: var(--text-muted);
}

/* ── 按钮 ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: #4f46e5; }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
}
.btn-outline:hover { background: var(--bg-main); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #dc2626; }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-disabled { background: var(--border); color: var(--text-muted); cursor: not-allowed; }

/* ── 主应用布局 ── */
.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* 侧栏 */
.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  color: white;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 10;
}

.sidebar .logo-section {
  padding: 0 12px 40px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar .logo-section .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--primary-light), #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar .logo-section .logo i { width: 24px; height: 24px; }

.sidebar .logo-section .logo-sub {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.sidebar-menu {
  list-style: none;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-menu li { margin: 0; }

.sidebar-menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: #94a3b8;
  text-decoration: none;
  transition: all 0.2s ease;
  font-weight: 500;
  font-size: 15px;
}

.sidebar-menu a:hover {
  background: var(--sidebar-hover);
  color: white;
}

.sidebar-menu a.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.sidebar-menu a i { width: 20px; height: 20px; }

.sidebar-menu .divider {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin: 8px 12px;
}

.sidebar-menu .logout-item { margin-top: auto; padding-top: 20px; }
.sidebar-menu .logout-item a { color: #f87171; }
.sidebar-menu .logout-item a:hover { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }

/* 主内容 */
.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 32px 48px;
}

/* 页面 header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 40px;
}

.page-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-main);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card-bg);
  padding: 6px 16px 6px 6px;
  border-radius: 100px;
  box-shadow: var(--shadow);
}

.avatar {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), #c084fc);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
}

/* ── Section 标题 ── */
.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 24px;
  color: var(--text-main);
}

.section-title i { color: var(--secondary); }

/* ── 卡片网格 ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
  margin-bottom: 48px;
}

/* ── 卡片 ── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid #f1f5f9;
  position: relative;
  overflow: hidden;
  animation: fadeIn 0.5s ease-out forwards;
}

.card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-hover);
  border-color: var(--primary-light);
}

.card:nth-child(2) { animation-delay: 0.1s; }
.card:nth-child(3) { animation-delay: 0.2s; }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.card-title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-main);
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.tag {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.tag-food { background: #fef3c7; color: #92400e; }
.tag-car { background: #e0f2fe; color: #075985; }
.tag-default { background: #f1f5f9; color: #475569; }
.tag-hot { background: #fee2e2; color: #991b1b; }

.card-desc {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.6;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 16px;
  border-top: 1px solid #f1f5f9;
}

.reward {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 18px;
  color: var(--secondary);
}

.stats {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── 进度条 ── */
.progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.progress-container {
  flex: 1;
  height: 8px;
  background: #f1f5f9;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 4px;
  transition: width 1s ease-in-out;
}

.progress-label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 500;
  flex-shrink: 0;
}

/* ── 状态标签 ── */
.status-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.status-active { background: #dcfce7; color: #166534; }
.status-upcoming { background: #dbeafe; color: #1e40af; }
.status-ended { background: #f1f5f9; color: #64748b; }

/* ── 筛选栏 ── */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-bar .filter-btn {
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--card-bg);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-bar .filter-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ── 表格 ── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  padding: 10px 12px;
  background: var(--bg-main);
  color: var(--text-muted);
  font-weight: 500;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

tr:hover td { background: rgba(99, 102, 241, 0.04); }

/* ── Modal 弹窗 ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-content {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 640px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-hover);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 16px; }

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  line-height: 1;
}

.modal-close:hover { color: var(--text-main); }

.modal-body { padding: 20px 24px; }

/* ── Treemap 容器 ── */
#treemap-container {
  width: 100%;
  height: 500px;
  background: var(--card-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
}

/* ── 收益汇总卡片 ── */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
}

.stat-card .stat-number {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── 活动概览卡片 ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-value { font-weight: 700; }
.stat-label { font-weight: 600; color: var(--text-muted); }

/* ── 空状态 ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px;
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 2px dashed #e2e8f0;
  color: var(--text-muted);
}

.empty-state i { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }

/* ── 加载 / 错误 ── */
.loading { text-align: center; padding: 40px; color: var(--text-muted); }
.loading::after { content: "加载中..."; }

.error-message {
  text-align: center;
  padding: 20px;
  color: var(--danger);
  background: #fef2f2;
  border-radius: var(--radius-md);
}

/* ── 动画 ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── 面包屑 ── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 6px;
}

/* ── 任务简报 ── */
.task-brief {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 24px 32px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid #f1f5f9;
  gap: 20px;
}

.brief-info h2 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 4px;
}

.brief-info p {
  color: var(--text-muted);
  font-size: 14px;
  max-width: 600px;
}

.brief-actions {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
}

/* ── 排行榜容器 ── */
.matrix-container {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid #f1f5f9;
  padding: 32px;
}

.matrix-header {
  display: flex;
  align-items: center;
  margin-bottom: 24px;
}

.matrix-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 700;
}

.matrix-title i { color: var(--secondary); }

/* ── Modal v2（增强弹窗） ── */
.modal-overlay.modal-v2 {
  backdrop-filter: blur(4px);
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal-overlay.modal-v2.active {
  display: flex;
  opacity: 1;
}

.modal-v2 .modal-v2-content {
  background: var(--card-bg);
  width: 90%;
  max-width: 600px;
  border-radius: 24px;
  padding: 40px;
  position: relative;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  max-height: 85vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.modal-v2.active .modal-v2-content {
  transform: translateY(0);
}

.modal-v2 .close-modal {
  position: absolute;
  top: 24px;
  right: 24px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  transition: color 0.2s;
}

.modal-v2 .close-modal:hover { color: var(--text-main); }

.modal-v2 .modal-header {
  padding: 0;
  border: none;
  margin-bottom: 24px;
}

.modal-v2 .modal-header h3 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 8px;
}

.modal-v2 .modal-header p {
  color: var(--text-muted);
  font-size: 15px;
}

.modal-v2 .modal-body {
  padding: 0;
}

/* ── 详情弹窗信息行 ── */
.info-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.info-item {
  background: #f8fafc;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
}

.info-item span {
  color: var(--text-muted);
  display: block;
  font-size: 12px;
  margin-bottom: 2px;
}

.info-item strong {
  color: var(--text-main);
  font-weight: 700;
}

/* ── 标签蓝色变体 ── */
.tag-blue { background: #e0f2fe; color: #0369a1; }
