:root {
  --bg: #eef2f5;
  --card: #ffffff;
  --ink: #1f2a37;
  --muted: #69747f;
  --line: #e2e8ef;
  --line-soft: #f0f4f8;
  --primary: #1d7a68;
  --primary-ink: #0f5a4c;
  --primary-soft: #e4f3ef;
  --done: #2f9e6e;
  --done-soft: #e6f6ee;
  --warn: #cf7c1c;
  --warn-soft: #fdf1e0;
  --danger: #cc453e;
  --danger-soft: #fdeceb;
  --gray-soft: #eef1f4;
  --shadow: 0 1px 2px rgba(16, 32, 48, 0.06), 0 8px 24px rgba(16, 32, 48, 0.07);
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
button:disabled { cursor: not-allowed; opacity: .45; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #d8ece6 0%, var(--bg) 55%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 20px;
  padding: 30px 26px 26px;
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 4px; font-size: 21px; letter-spacing: .5px; }
.login-card p.sub { margin: 0 0 24px; color: var(--muted); font-size: 13px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  font-size: 15px;
  background: #fbfcfd;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); background: #fff; }
.btn-primary {
  width: 100%;
  padding: 13px;
  border-radius: 11px;
  background: linear-gradient(180deg, #23876f, #1a6d5c);
  color: #fff;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: 1px;
  box-shadow: 0 6px 16px rgba(29, 122, 104, .28);
}
.btn-primary:active { transform: translateY(1px); }
.err { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 10px; }

/* ---------- 骨架 ---------- */
.app { display: none; }
.app.ready { display: block; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, #1d7a68, #17695a);
  color: #fff;
  padding: 14px 16px 12px;
  box-shadow: 0 2px 10px rgba(16, 60, 50, .18);
}
.topbar .row1 { display: flex; align-items: center; gap: 10px; }
.topbar h1 { font-size: 17px; margin: 0; font-weight: 650; letter-spacing: .4px; }
.topbar .today-chip {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .22);
}
.topbar .spacer { flex: 1; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .16);
}
.user-chip .dot { width: 6px; height: 6px; border-radius: 50%; background: #8be3c8; }
.user-chip.readonly .dot { background: #ffd07a; }

.statbar {
  display: flex;
  gap: 14px;
  margin-top: 10px;
  font-size: 12.5px;
  color: rgba(255, 255, 255, .88);
  flex-wrap: wrap;
}
.statbar b { color: #fff; font-weight: 650; }
.statbar .overdue-link { text-decoration: underline; text-underline-offset: 3px; color: #ffe0a3; }

.toolbar {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  background: var(--bg);
}
.toolbar::-webkit-scrollbar { display: none; }
.tool {
  flex: 0 0 auto;
  padding: 8px 13px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(16, 32, 48, .04);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.tool:active { background: var(--primary-soft); border-color: #bfe0d8; }
.tool.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.tool .badge {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-weight: 600;
}

/* ---------- 表格 ---------- */
.table-card {
  margin: 0 12px 20px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.table-scroll { overflow: auto; max-height: calc(100vh - 150px); }

table.grid { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }
.grid th, .grid td {
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  padding: 0;
  text-align: center;
  font-weight: 400;
  white-space: nowrap;
}

.grid thead th {
  position: sticky;
  top: 0;
  z-index: 6;
  background: #f7fafc;
  color: var(--muted);
  font-size: 12.5px;
  height: 34px;
  font-weight: 600;
  letter-spacing: .3px;
}
.grid thead tr:nth-child(2) th { top: 34px; z-index: 6; background: #f4f8fa; font-weight: 500; }
.grid thead th.proj { border-left: 1px solid var(--line); color: var(--primary-ink); }
.grid thead th.sub { font-size: 11.5px; color: #8b97a3; }

.grid .col-date, .grid .col-week {
  position: sticky;
  z-index: 4;
  background: var(--card);
}
.grid .col-date { left: 0; min-width: 86px; width: 86px; }
.grid .col-week { left: 86px; min-width: 52px; width: 52px; }
.grid thead .col-date, .grid thead .col-week { z-index: 8; background: #f7fafc; }

.grid tbody td.col-date {
  text-align: left;
  padding: 0 8px 0 10px;
  font-variant-numeric: tabular-nums;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: .2px;
  border-right: 1px solid var(--line);
}
.grid tbody td.col-date .m { display: block; font-size: 10.5px; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.grid tbody td.col-week { font-size: 12px; color: var(--muted); }
.grid tbody td.col-week.we { color: #b4703a; }

.grid tbody tr:hover td:not(.col-date):not(.col-week) { background: #fbfdfe; }
.grid tbody tr.today td { background: #f0f9f6; }
.grid tbody tr.today td.col-date { background: #e6f5f0; color: var(--primary-ink); }
.grid tbody tr.today td.col-date::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--primary);
}
.grid tbody td.col-date { position: sticky; }
.grid tbody tr.past td.col-date { color: #8d98a4; }
.grid tbody tr.overdue td.col-date::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--danger);
}
.grid tbody tr.month-start td { border-top: 2px solid #d9e2ea; }

.cell {
  min-width: 56px;
  height: 46px;
  position: relative;
}
.cellbtn {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cellbtn:active { background: var(--primary-soft); }
.cell .filler { font-size: 12px; color: #c3ccd5; }

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 24px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1;
  max-width: 92px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pill.plan { background: var(--primary-soft); color: var(--primary-ink); }
.pill.plan.txt { font-weight: 500; font-size: 12px; }
.pill.done { background: var(--done-soft); color: #1f7a52; }
.pill.late { background: var(--warn-soft); color: var(--warn); }
.pill.cancel { background: var(--gray-soft); color: #7b8794; }
.pill.none { background: var(--danger-soft); color: var(--danger); }

.cell.actual .pill { border: 1px dashed transparent; }
.cell.locked { background: repeating-linear-gradient(45deg, #fafcfd, #fafcfd 6px, #f4f8fa 6px, #f4f8fa 12px); }

.note-cell { min-width: 48px; }
.note-btn { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; gap: 4px; padding: 0 8px; }
.note-btn .ico { font-size: 14px; opacity: .55; }
.note-btn .txt { font-size: 11.5px; color: var(--muted); max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-btn.has .ico { opacity: 1; color: var(--warn); }

/* ---------- 底部弹层 ---------- */
.mask {
  position: fixed;
  inset: 0;
  background: rgba(18, 30, 40, .38);
  z-index: 60;
  display: none;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.mask.show { display: flex; }
.sheet, .modal-card {
  width: 100%;
  max-width: 480px;
  background: var(--card);
  border-radius: 18px 18px 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  animation: slideUp .22s ease-out;
  max-height: 88vh;
  overflow: auto;
}
.modal-card { border-radius: 18px; margin: 0 14px 16px; animation: pop .18s ease-out; }
.mask.center { align-items: center; }
@keyframes slideUp { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes pop { from { transform: scale(.96); opacity: .5; } to { transform: none; opacity: 1; } }

.sheet-head { display: flex; align-items: center; margin-bottom: 14px; }
.sheet-head h3 { margin: 0; font-size: 16px; font-weight: 650; }
.sheet-head .sub { font-size: 12.5px; color: var(--muted); margin-left: 8px; }
.sheet-head .x { margin-left: auto; font-size: 20px; color: var(--muted); padding: 4px 8px; }

.opt-list { display: flex; flex-direction: column; gap: 9px; }
.opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcfd;
  font-size: 14.5px;
}
.opt:active { background: var(--primary-soft); border-color: #bfe0d8; }
.opt.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-ink); font-weight: 600; }
.opt .k { width: 22px; height: 22px; border-radius: 7px; display: flex; align-items: center; justify-content: center; font-size: 12px; background: var(--gray-soft); color: var(--muted); }
.opt.on .k { background: var(--primary); color: #fff; }

.sheet input[type="text"], .sheet textarea, .modal-card input[type="text"], .modal-card input[type="password"] {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  background: #fbfcfd;
}
.sheet textarea { min-height: 84px; resize: vertical; }
.sheet input:focus, .sheet textarea:focus, .modal-card input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); background: #fff; }
.hint { font-size: 12px; color: var(--muted); margin-top: 8px; }
.hint.warn { color: var(--warn); }
.counter { font-size: 11.5px; color: var(--muted); text-align: right; margin-top: 6px; }

.sheet-actions { display: flex; gap: 10px; margin-top: 16px; }
.btn {
  flex: 1;
  padding: 12px;
  border-radius: 11px;
  font-size: 14.5px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: #fff;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.ghost { background: #f7f9fb; }
.btn.danger { color: var(--danger); border-color: #f2d5d3; background: #fff8f7; }

/* ---------- 超期清单 ---------- */
.overdue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 11px;
  background: #fbfcfd;
  border: 1px solid var(--line);
  margin-bottom: 8px;
}
.overdue-item .d { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; width: 92px; }
.overdue-item .p { font-size: 14px; font-weight: 600; flex: 1; }
.empty-tip { text-align: center; color: var(--muted); font-size: 13.5px; padding: 26px 0; }
.empty-tip .big { font-size: 30px; display: block; margin-bottom: 8px; }

/* ---------- 项目配置 ---------- */
.proj-row { display: flex; align-items: center; gap: 10px; padding: 11px 4px; border-bottom: 1px solid var(--line-soft); }
.proj-row .nm { flex: 1; font-size: 14.5px; font-weight: 550; }
.proj-row .tag { font-size: 11.5px; color: var(--muted); background: var(--gray-soft); padding: 2px 8px; border-radius: 999px; }
.proj-row .tag.off { background: var(--danger-soft); color: var(--danger); }
.switch { width: 44px; height: 26px; border-radius: 999px; background: #d5dde5; position: relative; transition: background .18s; flex: 0 0 auto; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.18); }
.switch.on { background: var(--primary); }
.switch.on::after { transform: translateX(18px); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  background: rgba(24, 38, 48, .93);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 99;
  max-width: 86vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 480px) {
  .topbar { padding: 12px 12px 10px; }
  .topbar h1 { font-size: 16px; }
  .toolbar { top: 88px; }
  .table-card { margin: 0 8px 16px; border-radius: 12px; }
  .cell { height: 44px; min-width: 52px; }
}
