*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --text: #1a1d21;
  --text-2: #5b6472;
  --text-3: #8b95a5;
  --border: #e3e6ea;
  --border-2: #ccd3db;
  --primary: #185fa5;
  --primary-soft: #e6f1fb;
  --primary-text: #0c447c;
  --danger: #a32d2d;
  --danger-soft: #fcebeb;
  --warn: #854f0b;
  --warn-soft: #faeeda;
  --ok: #3b6d11;
  --ok-soft: #eaf3de;
  --purple: #534ab7;
  --purple-soft: #eeedfe;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
}

[data-theme="dark"] {
  --bg: #16181c;
  --surface: #1f2227;
  --surface-2: #262a30;
  --text: #e8eaed;
  --text-2: #a8b0bb;
  --text-3: #7b8492;
  --border: #2f343b;
  --border-2: #414850;
  --primary: #85b7eb;
  --primary-soft: #0c447c;
  --primary-text: #b5d4f4;
  --danger: #f09595;
  --danger-soft: #501313;
  --warn: #ef9f27;
  --warn-soft: #412402;
  --ok: #97c459;
  --ok-soft: #173404;
  --purple: #afa9ec;
  --purple-soft: #26215c;
  --shadow: none;
}

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font-family: inherit; font-size: 14px; color: var(--text); }
a { color: var(--primary-text); text-decoration: none; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar { display: none; }

.main { flex: 1; min-width: 0; padding-bottom: 76px; }

.page { max-width: 880px; margin: 0 auto; padding: 16px; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar .title { font-size: 16px; font-weight: 600; flex: 1; }
.topbar .sub { font-size: 12px; color: var(--text-3); font-weight: 400; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; border: 0; background: none; padding: 8px 4px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-3); font-size: 11px; cursor: pointer;
}
.tabbar button.on { color: var(--primary); }
.tabbar .ico { font-size: 19px; line-height: 1; }

@media (min-width: 900px) {
  .tabbar { display: none; }
  .main { padding-bottom: 24px; }
  .sidebar {
    display: flex; flex-direction: column; gap: 2px;
    width: 208px; flex: 0 0 208px;
    background: var(--surface); border-right: 1px solid var(--border);
    padding: 18px 12px; position: sticky; top: 0; height: 100vh;
  }
  .sidebar .brand { font-size: 15px; font-weight: 600; padding: 0 10px 16px; }
  .sidebar .brand span { display: block; font-size: 11px; color: var(--text-3); font-weight: 400; }
  .sidebar button {
    display: flex; align-items: center; gap: 9px; width: 100%;
    border: 0; background: none; text-align: left;
    padding: 9px 10px; border-radius: var(--radius-sm);
    color: var(--text-2); cursor: pointer; font-size: 14px;
  }
  .sidebar button:hover { background: var(--surface-2); }
  .sidebar button.on { background: var(--primary-soft); color: var(--primary-text); font-weight: 500; }
  .sidebar .foot { margin-top: auto; font-size: 12px; color: var(--text-3); padding: 10px; }
  .topbar { border-radius: 0; }
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px;
}
.card.tight { padding: 12px 14px; }
.card-h { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.card-h .t { font-size: 14px; font-weight: 600; flex: 1; }
.card-h .n { font-size: 12px; color: var(--text-3); }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid4 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 640px) { .grid4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.metric { background: var(--surface-2); border-radius: var(--radius-sm); padding: 11px 12px; }
.metric .l { font-size: 12px; color: var(--text-3); }
.metric .v { font-size: 22px; font-weight: 600; line-height: 1.25; margin-top: 2px; }
.metric.warn .v { color: var(--warn); }
.metric.danger .v { color: var(--danger); }
.metric.ok .v { color: var(--ok); }

/* ---------- 表单 ---------- */
label.f { display: block; font-size: 12px; color: var(--text-2); margin: 0 0 5px; }
input[type=text], input[type=password], input[type=date], select, textarea {
  width: 100%; padding: 9px 11px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  outline: none; appearance: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; min-height: 76px; line-height: 1.6; }
select { background-image: none; }
.field { margin-bottom: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-2); background: var(--surface); color: var(--text);
  cursor: pointer; font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.pri { background: var(--primary); border-color: var(--primary); color: #fff; }
[data-theme="dark"] .btn.pri { color: #0c1a2a; }
.btn.pri:hover { filter: brightness(1.08); }
.btn.sm { padding: 5px 11px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); border-color: var(--border-2); }
.btn.full { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  padding: 6px 13px; border-radius: 20px; font-size: 13px;
  border: 1px solid var(--border-2); background: var(--surface); color: var(--text-2);
  cursor: pointer;
}
.seg button.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-text); font-weight: 500; }
.seg button.on[data-v="done"] { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.seg button.on[data-v="blocked"] { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

.chk { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2); cursor: pointer; user-select: none; }
.chk input { width: 15px; height: 15px; accent-color: var(--primary); margin: 0; }

/* ---------- 徽章 ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; padding: 2px 8px; border-radius: 20px;
  background: var(--surface-2); color: var(--text-2); white-space: nowrap;
}
.tag.ongoing { background: var(--primary-soft); color: var(--primary-text); }
.tag.done { background: var(--ok-soft); color: var(--ok); }
.tag.blocked { background: var(--danger-soft); color: var(--danger); }
.tag.planned { background: var(--purple-soft); color: var(--purple); }
.tag.b { background: var(--danger-soft); color: var(--danger); }
.tag.c { background: var(--warn-soft); color: var(--warn); }
.tag.s { background: var(--purple-soft); color: var(--purple); }

/* ---------- 条目 ---------- */
.item {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; margin-bottom: 8px; background: var(--surface);
}
.item .m { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 5px; }
.item .m .who { font-size: 12px; color: var(--text-3); }
.item .c { font-size: 14px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.item .plan { font-size: 12px; color: var(--text-3); margin-top: 5px; }
.item .acts { display: flex; gap: 4px; margin-left: auto; }

.pgroup { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; overflow: hidden; }
.pgroup > .ph {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: var(--surface-2); cursor: pointer;
}
.pgroup > .ph .nm { font-size: 13px; font-weight: 600; flex: 1; }
.pgroup > .pb { padding: 10px 12px; background: var(--surface); }

.empty { text-align: center; color: var(--text-3); font-size: 13px; padding: 26px 10px; }
.hint { font-size: 12px; color: var(--text-3); }
.row { display: flex; align-items: center; gap: 8px; }
.row .sp { flex: 1; }
.divider { height: 1px; background: var(--border); margin: 12px 0; }

/* ---------- 周报编辑 ---------- */
.sec { margin-bottom: 14px; }
.sec .lb { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.sec .lb .cnt { font-size: 11px; color: var(--text-3); font-weight: 400; }
.sec textarea { min-height: 108px; font-size: 13.5px; }

.gw {
  background: #fff; color: #000; border-radius: var(--radius-sm);
  padding: 26px 22px; font-family: "FangSong", "仿宋_GB2312", "STFangsong", serif;
  font-size: 16px; line-height: 1.75;
}
.gw .gw-title { font-family: "FZXiaoBiaoSong-B05S", "方正小标宋简体", "STZhongsong", serif; font-size: 20px; text-align: center; margin: 0 0 18px; }
.gw .gw-h { font-family: "SimHei", "黑体", sans-serif; font-weight: 700; font-size: 16px; margin: 0; text-indent: 2em; }
.gw .gw-p { margin: 0; text-indent: 2em; }
/* 加粗只落在「1.项目名：」和「一是/二是」上，与导出的 Word 保持一致 */
.gw .gw-p b { font-weight: 700; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 372px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px 24px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 19px; font-weight: 600; }
.login-card .s { font-size: 12.5px; color: var(--text-3); margin: 4px 0 22px; }

/* ---------- Toast / 弹层 ---------- */
#toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%);
  z-index: 100; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; align-items: center;
}
#toast .t {
  background: rgba(26, 29, 33, .93); color: #fff;
  padding: 9px 16px; border-radius: 20px; font-size: 13px; max-width: 86vw;
}
[data-theme="dark"] #toast .t { background: rgba(240, 242, 245, .95); color: #16181c; }

.mask {
  position: fixed; inset: 0; z-index: 60; background: rgba(12, 16, 22, .5);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--surface); width: 100%; max-width: 560px;
  border-radius: 16px 16px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow: auto;
}
@media (min-width: 640px) { .mask { align-items: center; } .sheet { border-radius: 16px; max-height: 84vh; } }

.loading { text-align: center; color: var(--text-3); padding: 30px; font-size: 13px; }
.spin { display: inline-block; animation: sp 1s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--text-3); font-weight: 500; font-size: 12px; }
