:root {
  --primary: #1677ff;
  --primary-dark: #0958d9;
  --success: #52c41a;
  --warning: #faad14;
  --danger: #ff4d4f;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f2329;
  --muted: #8a9099;
  --border: #e5e6eb;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}

/* 顶栏 */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 24px; background: var(--card); border-bottom: 1px solid var(--border);
}
.brand { font-size: 18px; font-weight: 700; color: var(--primary); }
.top-actions { display: flex; align-items: center; gap: 14px; }
.stat-pill { background: #eef3ff; color: var(--primary); padding: 4px 10px; border-radius: 12px; font-size: 12px; }
.link { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 13px; }
.link.danger { color: var(--danger); }

/* 联调状态条 */
.status-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 16px; margin-bottom: 20px; font-size: 13px; color: var(--text);
}
.status-bar .sep { color: var(--border); }
.status-bar .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.green { background: var(--success); }
.dot.red { background: var(--danger); }
.dot.gray { background: #c9cdd4; }
.badge { padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.badge.warn { background: #fffbe6; color: var(--warning); }

/* 弹层 */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-box { background: #fff; border-radius: 10px; padding: 24px; width: 480px; max-width: 92vw; position: relative; max-height: 86vh; overflow: auto; }
.modal-box h3 { margin: 0 0 12px; }
.modal-close { position: absolute; top: 12px; right: 16px; background: none; border: none; font-size: 22px; color: var(--muted); cursor: pointer; }
#modal-content { white-space: pre-wrap; word-break: break-all; background: #f7f8fa; padding: 12px; border-radius: 6px; font-size: 13px; max-height: 60vh; overflow: auto; }

/* 容器与卡片 */
.container { max-width: 960px; margin: 24px auto; padding: 0 16px; }
.card { background: var(--card); border-radius: 10px; padding: 24px; margin-bottom: 20px; box-shadow: 0 1px 4px rgba(0,0,0,.04); }
.card h2 { margin: 0 0 16px; font-size: 17px; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 0 0 16px; }
.msg { color: var(--danger); font-size: 13px; min-height: 18px; margin: 10px 0 0; }

/* 表单 */
.form-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.form-row label { width: 90px; color: var(--muted); flex-shrink: 0; }
input[type=month], input[type=text], input[type=password] {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; flex: 1; max-width: 360px;
}
button {
  background: var(--primary); color: #fff; border: none; padding: 9px 22px; border-radius: 6px;
  font-size: 14px; cursor: pointer; transition: background .15s;
}
button:hover { background: var(--primary-dark); }
button:disabled { background: #c9cdd4; cursor: not-allowed; }
button.secondary { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
button.secondary:hover { background: #eef3ff; }

/* 统计条 */
.stats-bar { display: flex; gap: 12px; margin-bottom: 16px; }
.stats-bar .item { flex: 1; padding: 14px; border-radius: 8px; text-align: center; font-weight: 600; }
.item.success { background: #f0fbe9; color: var(--success); }
.item.warning { background: #fffbe6; color: var(--warning); }
.item.danger { background: #fff1f0; color: var(--danger); }
.item .num { font-size: 24px; display: block; }

/* 工具栏与 Tab */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin: 8px 0 14px; flex-wrap: wrap; gap: 10px; }
.tabs { display: flex; gap: 6px; }
.tab { background: #f2f3f5; color: var(--text); border: none; padding: 7px 14px; border-radius: 6px; font-size: 13px; }
.tab.active { background: var(--primary); color: #fff; }
.switch { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }

/* 表格 */
.tab-panel table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tab-panel th, .tab-panel td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
.tab-panel th { color: var(--muted); font-weight: 600; background: #fafafa; }
.tab-panel tr:hover { background: #f7f9ff; }
.amount-hidden { color: var(--muted); font-style: italic; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 12px; }
.tag.dedup { background: #fff1f0; color: var(--danger); }

/* 二次确认 */
.confirm-box { margin-top: 20px; padding: 16px; background: #fafbff; border: 1px solid var(--border); border-radius: 8px; }
.confirm-box label { display: block; margin-bottom: 12px; }
.confirm-box .form-row { margin-top: 8px; }

/* 进度与结果 */
.progress-wrap { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.progress-bar { flex: 1; height: 10px; background: #eef0f3; border-radius: 6px; overflow: hidden; position: relative; }
.progress-bar::after { content: ''; position: absolute; left: 0; top: 0; height: 100%; width: var(--p, 0%); background: var(--primary); transition: width .3s; }
.result-summary { display: flex; gap: 16px; margin-bottom: 14px; font-size: 14px; }
.result-summary b { font-size: 18px; }
.result-table table { width: 100%; border-collapse: collapse; font-size: 13px; }
.result-table th, .result-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.fail td { color: var(--danger); }

/* 弹层 */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-box { background: #fff; border-radius: 10px; padding: 24px; max-width: 480px; width: 90%; max-height: 80vh; overflow: auto; position: relative; }
.modal-close { position: absolute; top: 10px; right: 14px; background: none; border: none; font-size: 22px; color: var(--muted); cursor: pointer; }
.modal-box pre { white-space: pre-wrap; word-break: break-all; font-size: 13px; line-height: 1.7; margin: 0; }

/* 登录页 */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: #fff; padding: 40px; border-radius: 12px; width: 340px; text-align: center; box-shadow: 0 4px 20px rgba(0,0,0,.08); }
.login-card h1 { margin: 0 0 6px; color: var(--primary); }
.subtitle { color: var(--muted); margin: 0 0 24px; font-size: 13px; }
.login-card label { display: block; text-align: left; color: var(--muted); margin-bottom: 6px; font-size: 13px; }
.login-card input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 14px; }
.login-card button { width: 100%; }
.hint { color: var(--muted); font-size: 12px; margin-top: 18px; line-height: 1.6; }

/* ═══════════════ OA 卡片预览（模拟钉钉工作通知卡片外观） ═══════════════ */
.oa-card {
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,.08);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}
.oa-head {
  background: linear-gradient(135deg, #2E9BFF 0%, #1677ff 50%, #0958d9 100%);
  color: #fff;
  padding: 28px 24px 22px;
  text-align: center;
}
.oa-head-period {
  font-size: 13px;
  opacity: .85;
  margin-bottom: 6px;
  letter-spacing: 1px;
}
.oa-head-greeting {
  font-size: 15px;
  margin-bottom: 12px;
  opacity: .95;
}
.oa-head-amount {
  font-size: 36px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -1px;
}
.oa-head-unit {
  font-size: 14px;
  opacity: .8;
  margin-top: 2px;
}
.oa-body {
  background: #fff;
  padding: 4px 0;
}
.oa-section-title {
  padding: 12px 20px 4px;
  font-size: 12px;
  color: var(--muted);
  background: #fafbfc;
  border-bottom: 1px solid #f0f1f3;
}
.oa-field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 20px;
  border-bottom: 1px solid #f5f6f7;
  font-size: 14px;
}
.oa-field:last-child { border-bottom: none; }
.oa-key {
  color: var(--text);
  flex-shrink: 0;
  margin-right: 16px;
}
.oa-val {
  color: #1f2329;
  font-weight: 500;
  text-align: right;
  word-break: break-all;
}
.oa-val.oa-deduction {
  color: var(--danger);
}

/* 弹层内卡片预览：去掉默认背景和 pre 样式 */
#modal-content { white-space: normal; background: transparent; padding: 0; }
#modal-content .oa-card { box-shadow: 0 2px 16px rgba(0,0,0,.12); }

/* ════════════════ 预览：手机视图 / 网格视图 ════════════════ */
.preview-toolbar { display: flex; justify-content: space-between; align-items: center; margin: 8px 0 14px; flex-wrap: wrap; gap: 10px; }
.view-toggle { display: flex; gap: 6px; }
.sci-title { font-size: 12px; color: var(--muted); margin-bottom: 6px; }

/* 手机外壳：模仿手机屏幕，整体效果接近手机查看 */
.phone-frame {
  width: 390px; max-width: 100%; margin: 0 auto;
  background: #eef0f3; border: 12px solid #15181d; border-radius: 42px;
  box-shadow: 0 14px 50px rgba(0,0,0,.20); overflow: hidden; position: relative;
}
.phone-notch {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  width: 130px; height: 24px; background: #15181d; border-radius: 0 0 16px 16px; z-index: 5;
}
.phone-statusbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 22px 4px; background: #15181d; color: #fff; font-size: 12px; letter-spacing: .5px;
}
.phone-statusbar .sb-time { font-weight: 600; }
.phone-statusbar .sb-icons span { margin-left: 6px; opacity: .9; }
.phone-appbar {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px; background: #fff; border-bottom: 1px solid var(--border);
  font-size: 15px; font-weight: 600; color: #1f2329; position: sticky; top: 0; z-index: 3;
}
.phone-appbar .ab-count { font-size: 12px; font-weight: 400; color: var(--muted); }
.phone-screen {
  height: 640px; overflow-y: auto; padding: 12px; background: #eef0f3; scroll-behavior: smooth;
}
.phone-screen::-webkit-scrollbar { width: 6px; }
.phone-screen::-webkit-scrollbar-thumb { background: #c9cdd4; border-radius: 3px; }
.phone-list { display: flex; flex-direction: column; gap: 12px; }
.phone-list .sheet-card-item { margin: 0; }
.phone-home { height: 4px; width: 120px; background: #15181d; border-radius: 3px; margin: 8px auto 6px; }

/* 网格视图（行列 R×C）：多张卡片以自适应网格排列 */
.cards-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px;
}
.cards-grid .sheet-card-item { margin: 0; }
