:root {
  --primary: #6366f1;
  --primary-2: #a855f7;
  --grad: linear-gradient(135deg, #6366f1, #a855f7);
  --bg: #f4f5fa;
  --card: #ffffff;
  --border: #e8eaf2;
  --text: #1f2333;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --danger: #ef4444;
  --radius: 16px;
  --shadow: 0 2px 12px rgba(30, 35, 80, .06);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
button { font-family: inherit; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card.empty { text-align: center; color: var(--text-3); }

/* ---------- 登录 ---------- */
.auth-wrap {
  min-height: 100vh;
  background: var(--grad);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.auth-card { width: 100%; max-width: 380px; padding: 36px; text-align: center; }
.logo {
  width: 64px; height: 64px; margin: 0 auto 12px;
  background: var(--grad); border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; box-shadow: 0 8px 24px rgba(99, 102, 241, .35);
}
.auth-card h1 { font-size: 24px; margin-bottom: 4px; }
.subtitle { color: var(--text-3); font-size: 14px; margin-bottom: 24px; }
.tabs { display: flex; background: #f0f1f7; border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.tabs .tab {
  flex: 1; padding: 9px; border: none; border-radius: 8px;
  background: transparent; cursor: pointer; font-size: 14px; color: var(--text-2);
}
.tabs .tab.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
#authForm input {
  width: 100%; padding: 12px 14px; margin-bottom: 12px;
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 15px; outline: none; transition: border .2s;
}
#authForm input:focus { border-color: var(--primary); }
#authForm button[type="submit"] {
  width: 100%; padding: 13px; border: none; border-radius: 10px;
  background: var(--grad); color: #fff; font-size: 15px;
  cursor: pointer; transition: opacity .2s;
}
#authForm button[type="submit"]:hover { opacity: .9; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 8px; }

/* ---------- 顶栏 ---------- */
.topbar {
  background: #fff; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 14px 20px;
  display: flex; justify-content: space-between; align-items: center;
}
.brand { font-size: 18px; font-weight: 700; }
.user-box { display: flex; align-items: center; gap: 10px; }
.welcome { color: var(--text-2); font-size: 14px; }

.icon-btn {
  border: 1px solid var(--border); background: #fff;
  border-radius: 10px; padding: 7px 11px; cursor: pointer;
  color: var(--text-2); font-size: 14px; transition: all .15s;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-outline {
  border: 1px solid var(--border); background: #fff;
  border-radius: 10px; padding: 7px 16px; cursor: pointer;
  color: var(--text-2); font-size: 14px;
}
.btn-outline:hover { color: var(--danger); border-color: var(--danger); }
.btn-outline-dark {
  border: 1px solid var(--border); background: #f6f7fb;
  border-radius: 10px; padding: 9px 18px; cursor: pointer;
  color: var(--text); font-size: 14px; white-space: nowrap;
}
.btn-outline-dark:hover { background: #eceef5; }
.btn-primary {
  border: none; background: var(--grad); color: #fff;
  border-radius: 10px; padding: 11px 20px; cursor: pointer;
  font-size: 14px; white-space: nowrap; transition: opacity .15s;
}
.btn-primary:hover { opacity: .9; }

/* ---------- 布局 ---------- */
.layout {
  max-width: 1080px; margin: 24px auto; padding: 0 20px;
  display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px;
  align-items: start;
}
@media (max-width: 820px) { .layout { grid-template-columns: 1fr; } }

/* ---------- 统计 ---------- */
.stats-card { display: flex; padding: 18px 10px; }
.stat { flex: 1; text-align: center; }
.stat + .stat { border-left: 1px solid var(--border); }
.stat-num {
  font-size: 26px; font-weight: 800;
  background: var(--grad); -webkit-background-clip: text;
  background-clip: text; -webkit-text-fill-color: transparent;
}
.stat-label { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ---------- 表单 ---------- */
.add-row { display: flex; gap: 10px; align-items: center; }
.add-row input[type="text"], .add-row input[type="email"] {
  flex: 1; padding: 11px 14px;
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; outline: none; transition: border .2s;
}
.add-row input:focus { border-color: var(--primary); }
.add-row.sub { margin-top: 12px; font-size: 13px; color: var(--text-2); }
.mini-label { display: flex; align-items: center; gap: 6px; }
.mini-label input[type="time"] {
  border: 1px solid var(--border); border-radius: 8px; padding: 5px 8px;
  font-size: 13px; color: var(--text-2);
}
.mini-label input[type="color"] {
  width: 34px; height: 28px; border: none; border-radius: 6px;
  cursor: pointer; background: none;
}
.hint { margin-left: auto; color: var(--text-3); font-size: 12px; }

/* ---------- 目标卡片 ---------- */
.goal-card { cursor: pointer; transition: box-shadow .2s, border-color .2s; }
.goal-card:hover { border-color: #c7cbf5; }
.goal-card.selected { border-color: var(--primary); box-shadow: 0 4px 20px rgba(99, 102, 241, .15); }
.goal-head { display: flex; align-items: center; gap: 10px; }
.goal-head strong { flex: 1; font-size: 16px; }
.dot { width: 13px; height: 13px; border-radius: 50%; flex-shrink: 0; }
.goal-meta { font-size: 13px; color: var(--text-2); margin: 10px 0 14px; }
.check-btn {
  width: 100%; padding: 12px; border: none; border-radius: 10px;
  background: var(--grad); color: #fff; font-size: 15px;
  cursor: pointer; transition: opacity .15s;
}
.check-btn:disabled { background: #e5e7eb; color: var(--text-3); cursor: not-allowed; }
.check-btn:not(:disabled):hover { opacity: .9; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  display: flex; align-items: center; gap: 6px;
  background: #eef0ff; color: var(--primary);
  border-radius: 999px; padding: 5px 12px; font-size: 12px;
  max-width: 100%;
}
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button {
  border: none; background: none; color: var(--primary);
  cursor: pointer; font-size: 13px; padding: 0;
}

/* ---------- 日历 ---------- */
.nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.nav h3 { font-size: 15px; }
.grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 6px; text-align: center;
}
.weekday { font-size: 12px; color: var(--text-3); padding: 4px 0; }
.day {
  padding: 10px 0; border-radius: 10px; font-size: 14px;
  color: var(--text-2); background: #f6f7fb;
}
.day.has-media { position: relative; }
.day.has-media::after {
  content: ""; position: absolute; top: 5px; right: 5px;
  width: 6px; height: 6px; border-radius: 50%; background: #f59e0b;
}
.day.checked {
  background: var(--grad); color: #fff; font-weight: 600;
  cursor: pointer; transition: transform .15s;
}
.day.checked:hover { transform: scale(1.06); }
.day.today { box-shadow: inset 0 0 0 2px var(--primary-2); }
.no-goal { grid-column: 1 / -1; text-align: center; color: var(--text-3); padding: 24px 0; }
.cal-tip { margin-top: 14px; font-size: 12px; color: var(--text-3); text-align: center; }

/* ---------- 弹窗 ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(20, 22, 40, .55); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: #fff; border-radius: 20px; padding: 24px;
  width: 100%; max-width: 720px; max-height: 85vh;
  overflow-y: auto; box-shadow: 0 24px 80px rgba(0,0,0,.3);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-head h3 { font-size: 17px; }
.gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.media-item {
  position: relative; border-radius: 12px; overflow: hidden;
  background: #f0f1f7; border: 1px solid var(--border);
}
.media-item img, .media-item video {
  width: 100%; height: 160px; object-fit: cover; display: block;
}
.media-del {
  position: absolute; top: 8px; right: 8px;
  border: none; border-radius: 8px; padding: 5px 8px;
  background: rgba(0,0,0,.5); color: #fff; cursor: pointer; font-size: 13px;
}
.media-del:hover { background: var(--danger); }
.empty-tip { text-align: center; color: var(--text-3); padding: 30px 0; }

/* ---------- 卡片标题 ---------- */
.card-title { font-size: 15px; margin-bottom: 16px; }
.card-sub { font-size: 13px; color: var(--text-3); font-weight: 400; }

/* ---------- 热力图 ---------- */
.heat-wrap {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 13px);
  grid-auto-columns: 13px;
  gap: 3px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.h-cell {
  width: 13px; height: 13px; border-radius: 3px; display: block;
}
.h0 { background: #eef0f6; }
.h1 { background: #a5b4fc; }
.h2 { background: #4f46e5; }
.h-cell.future { background: transparent; }
.heat-legend {
  display: flex; align-items: center; gap: 4px;
  margin-top: 12px; font-size: 12px; color: var(--text-3);
}
.heat-legend .h-cell { display: inline-block; }

/* ---------- 月度报表 ---------- */
.report-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0;
}
.report-row + .report-row { border-top: 1px solid var(--border); }
.r-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.r-name {
  width: 110px; font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.r-bar {
  flex: 1; height: 8px; background: #eef0f6;
  border-radius: 4px; overflow: hidden;
}
.r-bar i {
  display: block; height: 100%;
  background: var(--grad); border-radius: 4px;
  transition: width .4s;
}
.r-num { font-size: 12px; color: var(--text-2); white-space: nowrap; }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: #d3d6e4; border-radius: 4px; }
