:root {
  --bg: #f2f4f8;
  --card: #ffffff;
  --text: #1c2330;
  --muted: #6b7686;
  --line: #e3e7ee;
  --primary: #2f6fed;
  --danger: #d9483b;
  --ok: #1d9e6f;
  --warn: #c07f16;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
}

#app { max-width: 560px; margin: 0 auto; padding: 16px 14px 48px; }

h1 { font-size: 22px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 10px; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); font-size: 13px; min-height: 16px; margin: 6px 0 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 8px;
}
.topbar .actions { display: flex; gap: 8px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; margin-bottom: 12px;
}

.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 8px; padding: 7px 14px; font-size: 14px; cursor: pointer;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.danger { background: #fff; border-color: var(--danger); color: var(--danger); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

input, textarea {
  width: 100%; padding: 8px 10px; font-size: 15px; font-family: inherit;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text);
}
textarea { min-height: 64px; resize: vertical; }
label.field { display: block; margin: 10px 0 0; font-size: 13px; color: var(--muted); }
label.field input { margin-top: 4px; }

/* 日期+时间双控件：datetime-local 的弹出 UI 在各端不一致（macOS 端只有日历），拆开选 */
.dt-row { display: flex; gap: 8px; margin-top: 4px; }
.dt-row input { margin-top: 0; }
.dt-row input[type="date"] { flex: 1.3; min-width: 0; }
.dt-row input[type="time"] { flex: 1; min-width: 0; }

.chip {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; white-space: nowrap;
}
.chip-planned { background: #e8eefc; color: #2f5fc4; }
.chip-submitted { background: #fdf3df; color: var(--warn); }
.chip-approved { background: #e0f5ec; color: var(--ok); }
.chip-returned { background: #fde9e7; color: var(--danger); }
.chip-overdue { background: var(--danger); color: #fff; margin-left: 6px; }

.task-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.task-title { font-size: 16px; font-weight: 600; }
.task-time { color: var(--muted); font-size: 13px; margin-top: 4px; }
.task-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

.note { font-size: 14px; margin: 8px 0 0; white-space: pre-wrap; }
.feedback-line {
  margin-top: 8px; padding: 8px 10px; border-radius: 8px;
  background: #f6f8fb; font-size: 13px; color: var(--text);
}

.photos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.photos img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; cursor: pointer; }

details.history { margin-top: 8px; font-size: 13px; color: var(--muted); }
details.history summary { cursor: pointer; }

.datebar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.datebar input[type="date"] { flex: 1; }

.overlay {
  position: fixed; inset: 0; background: rgba(20, 26, 36, 0.45);
  display: flex; align-items: flex-end; justify-content: center; z-index: 10;
}
.modal {
  background: #fff; border-radius: 16px 16px 0 0; width: 100%; max-width: 560px;
  padding: 16px; max-height: 88vh; overflow: auto;
}
.modal .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.preview { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.preview .thumb { position: relative; width: 72px; height: 72px; }
.preview .thumb img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; }
.thumb-del { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px;
  border-radius: 50%; border: none; background: var(--danger); color: #fff;
  font-size: 11px; line-height: 1; cursor: pointer; padding: 0; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #243044; color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 14px; z-index: 20; max-width: 90vw;
}
.toast.err { background: var(--danger); }

/* ===== 分组区（需要关注 / 已完成 / 统计 / 周条） ===== */
.sec-head { display: flex; align-items: center; gap: 8px; margin: 20px 0 10px;
  font-size: 15px; font-weight: 600; }
.sec-head .count { background: var(--danger); color: #fff; border-radius: 999px;
  font-size: 12px; padding: 1px 8px; }
.sec-head .count.warn { background: var(--warn); }
.sec-head .count.ok { background: var(--ok); }
.card.overdue { border-color: #f0b6b0; background: #fff7f6; }
.card.overdue .task-title { color: var(--danger); }
.badge-note { font-size: 12px; color: var(--danger); margin-top: 6px; }

.stat-row { display: flex; gap: 8px; margin-bottom: 14px; }
.stat { flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 6px; text-align: center; font-size: 13px; color: var(--muted); }
.stat b { display: block; font-size: 20px; color: var(--text); margin-bottom: 2px; }
.stat.warn b { color: var(--warn); }
.stat.danger b { color: var(--danger); }

.week { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.week-caption { font-size: 12px; color: var(--muted); margin: 0 0 6px; }
.day-cell { flex: 1 0 52px; max-width: 84px; border-radius: 10px; padding: 8px 2px;
  text-align: center; cursor: pointer; }
.day-cell .d { font-size: 12px; font-weight: 600; }
.day-cell .frac { font-size: 11px; margin-top: 2px; color: var(--muted); }
.day-cell.g { background: #e0f5ec; }
.day-cell.y { background: #fdf3df; }
.day-cell.r { background: #fde9e7; }
.day-cell.f { background: #e8eefc; }
.day-cell.n { background: #eceff4; }
.day-cell.today-cell { outline: 2px solid var(--primary); outline-offset: -2px; }
