/* 铭筑阁 Web 管理台 — 移动端优先（基准 375px），桌面自适应。零 CDN。 */
:root {
  --blue: #1f4e79;
  --bg: #f2f4f7;
  --card: #ffffff;
  --text: #1c2733;
  --muted: #8a94a0;
  --red: #d9363e;
  --yellow: #c98a00;
  --green: #1e9e5a;
  --grey: #9aa3ad;
  --line: #e4e8ee;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 15px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  padding-bottom: 62px; /* 底部导航高度 */
}
a { color: var(--blue); text-decoration: none; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--blue); color: #fff;
  padding: 10px 14px; display: flex; align-items: center; gap: 10px;
}
.topbar .brand { font-size: 1.15rem; font-weight: 700; letter-spacing: 2px; white-space: nowrap; }
.topbar .topbar-center {
  flex: 1; text-align: center; font-size: .85rem; opacity: .9;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar .topbar-right { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.topbar .whoami { font-size: .8rem; opacity: .85; }
.topbar .logout-form { display: inline; margin: 0; }
.topbar .logout-btn {
  background: none; border: none; padding: 0; margin: 0;
  color: inherit; font: inherit; font-size: .8rem; opacity: .85;
  text-decoration: underline; cursor: pointer;
}

/* 页面容器 */
.page { max-width: 760px; margin: 0 auto; padding: 10px 10px 20px; }
.pgtitle { font-size: 1.1rem; display: flex; align-items: center; gap: 8px; margin: 14px 2px 8px; }
.pgtitle .spacer, .tabs-sub .spacer { flex: 1; }

/* 卡片 */
.card {
  background: var(--card); border-radius: 10px; padding: 12px 14px;
  margin: 10px 0; box-shadow: 0 1px 3px rgba(16, 34, 61, .06);
}
.card h2 { margin: 2px 0 8px; font-size: 1.05rem; }
.card h3 { margin: 2px 0 10px; font-size: .95rem; color: var(--blue); }

/* 键值对 */
.kv > div { display: flex; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: .92rem; }
.kv > div:last-child { border-bottom: 0; }
.kv i { color: var(--muted); font-style: normal; min-width: 5.5em; }
.kv b { font-weight: 600; word-break: break-all; }

/* 提示/空态/闪烁消息 */
.hint { color: var(--muted); font-size: .82rem; margin: 8px 0 0; }
.empty { color: var(--muted); text-align: center; padding: 18px 0; }
.muted { color: var(--muted); font-size: .85em; }
.warn { color: var(--red); }
.flash-wrap { max-width: 760px; margin: 8px auto 0; padding: 0 10px; }
.flash { padding: 9px 12px; border-radius: 8px; font-size: .9rem; margin-bottom: 6px; }
.flash.ok { background: #e6f6ee; color: #14713f; }
.flash.err { background: #fdeaea; color: var(--red); }

/* 今日 pill / 待办 */
.row2 { display: flex; gap: 8px; }
.pill { flex: 1; text-align: center; padding: 9px 4px; border-radius: 8px; font-size: .88rem; font-weight: 600; }
.pill.green { background: #e6f6ee; color: #14713f; }
.pill.red { background: #fdeaea; color: var(--red); }
.todos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.todo { background: var(--bg); border-radius: 10px; padding: 10px 4px; text-align: center; color: var(--text); }
.todo b { display: block; font-size: 1.5rem; line-height: 1.2; }
.todo span { font-size: .74rem; color: var(--muted); }
.todo.hot b { color: var(--red); }
.todo.warm b { color: var(--yellow); }

/* 最近动态 */
.recent { list-style: none; margin: 0; padding: 0; font-size: .9rem; }
.recent li { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.recent li:last-child { border-bottom: 0; }

/* 摘要条 */
.summary-strip { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.summary-strip > div { background: var(--bg); border-radius: 8px; padding: 7px 10px; font-size: .82rem; }
.summary-strip b { display: block; font-size: .95rem; }

/* 子 tab / 月份导航 */
.tabs-sub { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 10px 2px; }
.tabs-sub a { padding: 6px 12px; border-radius: 18px; background: var(--card); color: var(--muted); font-size: .88rem; white-space: nowrap; }
.tabs-sub a.on { background: var(--blue); color: #fff; }
.month-nav { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin: 8px 2px; font-size: .92rem; }
.month-nav b { font-size: 1rem; }

/* 月历 */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-d {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 1; border-radius: 8px; font-size: .85rem;
  background: var(--bg); color: var(--muted);
}
.cal-d.has { background: var(--blue); color: #fff; font-weight: 700; }
.cal-d.none { background: #eceff3; color: #b6bdc7; text-decoration: line-through; }
.cal-d.future { background: transparent; border: 1px dashed var(--line); color: #c8cedb; }
.cal-d.blank { background: transparent; }

/* 日志列表 */
.diary-list { list-style: none; margin: 0; padding: 0; }
.diary-item { display: flex; align-items: center; gap: 8px; padding: 9px 2px; border-bottom: 1px dashed var(--line); color: var(--text); flex-wrap: wrap; }
.diary-item:last-child { border-bottom: 0; }
.diary-item .date { font-weight: 700; min-width: 6em; }
.diary-item .loc { flex: 1; min-width: 8em; font-size: .9rem; }
.diary-item .num { color: var(--muted); font-size: .85rem; }
.red-text th, .red-text td, .diary-item .red { color: var(--red); }
table.fields { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.fields th { text-align: left; color: var(--muted); font-weight: 400; width: 7em; padding: 6px 8px 6px 0; vertical-align: top; white-space: nowrap; }
table.fields td { padding: 6px 0; border-bottom: 1px dashed var(--line); word-break: break-all; }
table.fields tr:last-child td { border-bottom: 0; }

/* 标签 / 徽章 */
.tag { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: .72rem; }
.tag.red { background: #fdeaea; color: var(--red); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: .74rem; font-weight: 600; }
.badge.red { background: #fdeaea; color: var(--red); }
.badge.yellow { background: #fdf5e0; color: var(--yellow); }
.badge.green { background: #e6f6ee; color: #14713f; }
.badge.grey { background: #eef1f4; color: var(--grey); }

/* 照片网格 */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.photo-grid.big { grid-template-columns: repeat(3, 1fr); }
.ph { margin: 0; position: relative; }
.ph img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; background: #e8ebef; }
.ph figcaption { font-size: .7rem; color: var(--muted); padding: 2px 1px 4px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ph .date { color: var(--text); }
.ph-broken { width: 100%; aspect-ratio: 1; border-radius: 8px; background: repeating-linear-gradient(45deg, #f0f2f5, #f0f2f5 8px, #e7eaef 8px, #e7eaef 16px); display: flex; align-items: center; justify-content: center; color: var(--grey); font-size: .7rem; text-align: center; padding: 4px; }

/* 筛选表单 */
.filter { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: .85rem; }
.filter label { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.filter .grow { flex: 1; min-width: 150px; }
.filter input[type="search"], .filter select {
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: .85rem; background: #fff;
}

/* 按钮 */
.btn {
  display: inline-block; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--blue); color: #fff; padding: 9px 16px; font-size: .9rem;
  white-space: nowrap;
}
.btn.small { padding: 6px 12px; font-size: .82rem; }
.btn.tiny { padding: 3px 9px; font-size: .75rem; }
.btn.ok { background: var(--green); }
.btn.danger { background: var(--red); }
.btn:active { opacity: .85; }

/* 分页 */
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 14px 0; color: var(--muted); }

/* 合同卡片 */
.contract-item { display: block; padding: 10px 2px; border-bottom: 1px dashed var(--line); color: var(--text); }
.contract-item:last-child { border-bottom: 0; }
.ci-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ci-body { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .85rem; margin: 5px 0; }
.bar { height: 7px; background: #e9edf2; border-radius: 4px; overflow: hidden; }
.bar-in { height: 100%; background: linear-gradient(90deg, var(--blue), #3f7fbf); }
.ci-foot { font-size: .78rem; margin-top: 3px; }

/* 表格（横向滚动容器保护 375px） */
.table-wrap { overflow-x: auto; }
table.tbl { border-collapse: collapse; width: 100%; font-size: .84rem; min-width: 480px; }
table.tbl th, table.tbl td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.tbl th { color: var(--muted); font-weight: 500; background: #f7f9fb; }
table.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl td.wrap { white-space: normal; min-width: 10em; }

/* 审核台 */
.rv-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 8px 0; }
.rv-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.rv-body { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: .88rem; margin: 7px 0; }
.rv-body .wrap { white-space: normal; width: 100%; color: var(--muted); }
.rv-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.rv-actions form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.rv-actions input[type="text"], .rv-actions input[type="number"], .rv-actions input[type="date"],
.rv-actions select {
  flex: 1; min-width: 130px; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; font-size: .88rem;
}
.rv-actions button { white-space: nowrap; }
.match-form select[name="contract_id"] { flex: 2; }
.audit-list { list-style: none; margin: 0; padding: 0; font-size: .85rem; }
.audit-list li { display: flex; flex-wrap: wrap; gap: 4px 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.audit-list li:last-child { border-bottom: 0; }

/* 五方主体折叠 */
details.entity { border-bottom: 1px dashed var(--line); padding: 8px 0; font-size: .9rem; }
details.entity summary { cursor: pointer; }
details.entity .kv { margin-top: 8px; }

/* 导出表单 */
.export-form { display: flex; gap: 10px; align-items: center; margin: 8px 0; font-size: .9rem; flex-wrap: wrap; }
.export-form select, .export-form input[type="date"] {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: .88rem;
}

/* 底部导航 */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding: 4px 0 calc(4px + env(safe-area-inset-bottom));
}
.tabbar a {
  flex: 1; text-align: center; color: var(--muted);
  font-size: 1.15rem; padding: 4px 0; text-decoration: none;
}
.tabbar a span { display: block; font-size: .68rem; margin-top: 1px; }
.tabbar a.active { color: var(--blue); font-weight: 700; }

/* 桌面自适应 */
@media (min-width: 640px) {
  .photo-grid.big { grid-template-columns: repeat(6, 1fr); }
  .todos { grid-template-columns: repeat(4, 1fr); }
  .rv-actions { flex-direction: row; flex-wrap: wrap; }
  .rv-actions form { flex: 1; min-width: 260px; }
}

/* 照片灯箱 */
#lightbox {
  display: none; position: fixed; inset: 0; z-index: 90;
  background: rgba(10, 18, 28, .92);
  flex-direction: column; align-items: center; justify-content: center;
  padding: 16px; gap: 10px;
}
#lightbox.show { display: flex; }
#lightbox img { max-width: 100%; max-height: 72vh; border-radius: 8px; }
#lightbox .lb-meta { color: #cfd8e3; font-size: .82rem; text-align: center; max-width: 640px; line-height: 1.6; }
#lightbox .lb-close {
  position: absolute; top: 10px; right: 14px; border: 0; border-radius: 50%;
  width: 38px; height: 38px; font-size: 1.4rem; color: #fff; background: rgba(255,255,255,.15);
  cursor: pointer;
}

/* ── 日志状态生命周期（specs/zijin design §4.2，迁移006）────────── */
.tag.yellow { background: #fef7e0; color: #b06000; }
.tag.green { background: #e6f4ea; color: #137333; }
.tag.gray { background: #f1f3f4; color: #5f6368; }
.btn.warn { background: #b06000; }
.cal-d { position: relative; }
.cal-d .dot { position: absolute; right: 4px; bottom: 3px; width: 7px; height: 7px;
  border-radius: 50%; display: inline-block; }
.dot.yellow { background: #f5b800; }
.dot.green { background: #137333; }
.cal-d.approved { background: var(--green); }
.cal-d.none:hover { background: #dbe4f0; color: #1f4e79; text-decoration: none; }
.detail-actions { display: inline-flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-left: auto; }
.review-bar { display: flex; gap: 14px; align-items: center; justify-content: space-between;
  font-size: .88rem; color: #5f6368; }
.review-bar form { margin: 0; }
.month-nav { display: flex; align-items: center; gap: 12px; }
