/* 自律成长陪跑系统 - 温暖克制的家庭配色 */
:root {
  --bg: #f7f4ee;
  --card: #ffffff;
  --ink: #2d2a24;
  --muted: #8d867a;
  --line: #eae3d7;
  --accent: #e08a2e;
  --accent-soft: #fdf0dc;
  --green: #2f9e6e;
  --green-soft: #e6f5ec;
  --red: #cf5b4e;
  --red-soft: #fbe9e6;
  --blue: #4f7ec9;
  --blue-soft: #e9f0fb;
  --shadow: 0 2px 10px rgba(80, 60, 30, 0.06);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 17px; color: var(--accent); white-space: nowrap; }
.tabs { display: flex; gap: 4px; overflow-x: auto; flex: 1; }
.tab {
  text-decoration: none;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 20px;
  white-space: nowrap;
  font-size: 14px;
}
.tab:hover { color: var(--ink); background: var(--accent-soft); }
.tab.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.usermenu { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.role-chip {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
}
.uname { color: var(--muted); font-size: 14px; }

/* ---------- 布局 ---------- */
.container { max-width: 980px; margin: 0 auto; padding: 20px 16px 80px; }
.page-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 8px 0 16px; }
.page-head h2 { margin: 0; font-size: 22px; }
.date-nav { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.week-range { color: var(--muted); font-weight: 600; }
.today-total { margin-left: auto; font-size: 16px; }
.today-total b { font-size: 22px; }
.section-title { margin: 22px 0 10px; font-size: 16px; }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- 卡片 ---------- */
.cards { display: flex; flex-direction: column; gap: 16px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

.cat-title { margin: 0 0 6px; font-size: 15px; font-weight: 700; }
.cat-academic { color: #d97706; }
.cat-growth { color: var(--green); }
.cat-life { color: var(--blue); }

/* ---------- 规则/打卡项 ---------- */
.rule-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  border-top: 1px solid var(--line);
}
.rule-item:first-of-type { border-top: none; }
.rule-info { flex: 1; min-width: 0; }
.rule-name { font-weight: 600; }
.rule-meta { color: var(--muted); font-size: 12.5px; }
.rule-pts { font-weight: 700; width: 64px; text-align: right; }
.rule-actions { display: flex; gap: 6px; }
.pos { color: var(--green); }
.neg { color: var(--red); }

/* ---------- 记录列表 ---------- */
.entry-list { display: flex; flex-direction: column; }
.entry-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 9px 4px;
  border-top: 1px solid var(--line);
}
.entry-item:first-child { border-top: none; }
.cat-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.cat-dot.cat-academic { background: #d97706; }
.cat-dot.cat-growth { background: var(--green); }
.cat-dot.cat-life { background: var(--blue); }
.entry-name { flex: 1; }
.entry-note { color: var(--muted); font-size: 12.5px; }
.entry-pts { font-weight: 700; }

/* ---------- 打卡凭证图 ---------- */
.entry-ev {
  flex: 0 0 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 4px;
}
.ev-thumb { position: relative; display: inline-flex; }
.thumb {
  width: 44px; height: 44px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  cursor: pointer;
  display: block;
}
.ev-del {
  position: absolute; top: -7px; right: -7px;
  width: 18px; height: 18px; line-height: 15px;
  border-radius: 50%; border: none;
  background: var(--red); color: #fff; font-size: 12px;
  cursor: pointer; padding: 0;
}
.ev-del:hover { filter: brightness(1.1); }
.ev-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, .45);
  display: flex; align-items: center; justify-content: center;
}
.ev-panel {
  background: #fff; border-radius: 14px; padding: 18px;
  width: min(92vw, 420px);
  display: flex; flex-direction: column; gap: 12px;
}
.ev-panel h3 { margin: 0; font-size: 16px; }
.ev-preview { display: flex; flex-wrap: wrap; gap: 8px; }
.ev-actions { display: flex; gap: 8px; justify-content: flex-end; }
.ev-bigview { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.ev-bigview img { max-width: min(92vw, 860px); max-height: 78vh; border-radius: 10px; }

/* ---------- 按钮 / 表单 ---------- */
.btn {
  font: inherit;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 7px 14px;
  cursor: pointer;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.btn:hover { filter: brightness(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.warn { background: var(--red-soft); color: var(--red); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.small { padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn.tiny { padding: 2px 8px; font-size: 12px; border-radius: 7px; }
.btn.block { width: 100%; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
label input, label textarea, label select { margin-top: 4px; }
input, textarea, select {
  font: inherit;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; }
.select { width: auto; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row label { flex: 1; min-width: 130px; }
.form-msg { margin: 6px 0 0; font-size: 13px; min-height: 18px; }
.form-msg.error { color: var(--red); }

/* ---------- 统计卡片 ---------- */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-label { color: var(--muted); font-size: 12.5px; }
.stat-val { font-size: 24px; font-weight: 700; margin-top: 2px; }

/* ---------- 打卡日历 ---------- */
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; color: var(--muted); font-size: 12px; padding: 4px 0; }
.cal-cell {
  min-height: 52px;
  border-radius: 9px;
  background: #faf8f3;
  padding: 5px 6px;
  font-size: 12px;
}
.cal-cell.empty { background: transparent; }
.cal-cell.has { background: var(--green-soft); }
.cal-cell.has.neg { background: var(--red-soft); }
.cal-cell.has.zero { background: var(--accent-soft); }
.cal-daynum { font-weight: 600; }
.cal-pts { color: var(--green); font-weight: 600; font-size: 11px; }
.cal-cell.has.neg .cal-pts { color: var(--red); }

/* ---------- 标签 / 其它 ---------- */
.tag { font-size: 11.5px; padding: 2px 8px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); }
.tag.ok { background: var(--green-soft); color: var(--green); }
.tag.off { background: #eee; color: var(--muted); }
.tag.draft { background: var(--accent-soft); color: var(--accent); }
.tag.confirmed { background: var(--blue-soft); color: var(--blue); }
.tag.paid { background: var(--green-soft); color: var(--green); }
.empty { color: var(--muted); text-align: center; padding: 26px 10px; }
.hidden { display: none !important; }
.childpicker { margin-bottom: 14px; }
.feedback-view p { margin: 8px 0 0; }
.settle-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.settle-item:first-of-type { border-top: none; }
.settle-main { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.stage-opt {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; cursor: pointer;
}
.stage-opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.stage-opt input { width: auto; margin-top: 3px; }
.stage-opt b { display: block; color: var(--ink); }
.stage-opt span { color: var(--muted); font-size: 13px; }
.child-line { padding: 6px 0; border-top: 1px dashed var(--line); }
.acc-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.acc-name { min-width: 0; }
.acc-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ---------- 登录页 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: 380px; max-width: 100%;
  background: var(--card); border: 1px solid var(--line); border-radius: 20px;
  padding: 34px 30px; box-shadow: 0 6px 30px rgba(80, 60, 30, 0.08);
  text-align: center;
}
.brand-big { font-size: 46px; }
.login-card h1 { margin: 8px 0 2px; font-size: 24px; }
.login-sub { color: var(--muted); margin: 4px 0 22px; font-size: 14px; }
.init-hint { color: var(--accent); font-weight: 600; margin: 0 0 14px; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: 34px;
  transform: translateX(-50%) translateY(16px);
  background: var(--ink); color: #fff;
  padding: 10px 20px; border-radius: 24px;
  font-size: 14px; opacity: 0; transition: all 0.25s;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
