* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Microsoft YaHei", system-ui, sans-serif; background: #f3f5f8; color: #2b3440; font-size: 14px; }
a { color: #2f6fed; text-decoration: none; }

/* 登录页 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg,#1e3a6e,#2f6fed); }
.login-card { width: 360px; background: #fff; border-radius: 10px; padding: 36px 32px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card p.sub { color: #8a94a0; margin-bottom: 24px; font-size: 12px; }

/* 通用 */
input, select, textarea { width: 100%; padding: 9px 10px; border: 1px solid #d4dae2; border-radius: 6px; font-size: 14px; font-family: inherit; background:#fff; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #2f6fed; }
label { display: block; margin: 14px 0 6px; font-weight: 600; font-size: 13px; }
button { cursor: pointer; border: none; border-radius: 6px; padding: 9px 16px; font-size: 14px; font-family: inherit; background: #e8ecf2; color: #2b3440; }
button.primary { background: #2f6fed; color: #fff; }
button.danger { background: #fdecec; color: #c62828; }
button.block { width: 100%; margin-top: 20px; padding: 11px; }
.msg { margin-top: 14px; color: #c62828; font-size: 13px; min-height: 18px; }

/* 后台布局 */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 210px; background: #1e2735; color: #c6cfda; flex-shrink: 0; display: flex; flex-direction: column; }
.logo { padding: 20px 18px; font-size: 16px; font-weight: 700; color: #fff; border-bottom: 1px solid #2c3949; }
.nav { flex: 1; padding: 10px 0; }
.nav a { display: block; padding: 11px 20px; color: #c6cfda; font-size: 14px; }
.nav a.active, .nav a:hover { background: #2c3949; color: #fff; }
.nav a.soon { color: #66717e; }
.side-user { padding: 14px 20px; border-top: 1px solid #2c3949; font-size: 13px; }
.side-user .btns { margin-top: 10px; display: flex; gap: 8px; }
.side-user button { padding: 5px 10px; font-size: 12px; }
.main { flex: 1; padding: 24px 28px; min-width: 0; }
.page-title { font-size: 18px; font-weight: 700; margin-bottom: 18px; }

/* 卡片表格 */
.card { background: #fff; border-radius: 8px; padding: 18px 20px; box-shadow: 0 1px 4px rgba(20,40,80,.06); margin-bottom: 18px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #eef1f5; font-size: 13px; }
th { color: #8a94a0; font-weight: 600; background: #fafbfc; }
.tag { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 12px; }
.tag.admin { background: #e8f0fe; color: #1a56c4; }
.tag.staff { background: #eef6ee; color: #2e7d32; }
.tag.st-green { background: #eef6ee; color: #2e7d32; }
.tag.st-blue { background: #e8f0fe; color: #1a56c4; }
.tag.st-red { background: #fdecec; color: #c62828; }
.tag.st-gray { background: #f1f2f4; color: #7a828c; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(15,25,45,.45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: #fff; border-radius: 10px; padding: 24px 26px; width: 400px; max-width: 92vw; max-height: 92vh; overflow-y: auto; }
.modal.wide { width: 860px; }
.big-ta { height: 110px; margin-top: 10px; font-family: inherit; resize: vertical; }
.imp-table { margin-top: 14px; font-size: 12px; }
.imp-table th, .imp-table td { padding: 5px 6px; }
.imp-table input, .imp-table select { padding: 4px 6px; font-size: 12px; width: 100%; }
.imp-table tr.row-bad { background: #fff8f0; }
.imp-table tr.row-bad td { color: #b26a00; }
.modal h3 { margin-bottom: 6px; }
.modal .btns { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.hidden { display: none !important; }
.muted { color: #8a94a0; }

/* 表格滚动容器（JS 自动包裹，见 app.js wrapTables） */
.t-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.t-wrap > table { width: auto; min-width: 100%; }

/* ===== 模块4：项目/合同看板增强 ===== */
.row-overdue { background: #fdf3f3; }
.row-overdue:hover { background: #fbeaea; }
.stat-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.stat-card { flex: 1; min-width: 150px; margin-bottom: 0; cursor: pointer; transition: box-shadow .15s; }
.stat-card:hover { box-shadow: 0 3px 10px rgba(20,40,80,.12); }
.stat-n { font-size: 26px; font-weight: 700; color: #1f2d3d; margin: 4px 0; }
.stage-line { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.stage-btn { border: 1px solid #d6dbe2; background: #f5f7fa; color: #56606b; border-radius: 8px; padding: 5px 12px; font-size: 13px; cursor: pointer; min-height: 34px; }
.stage-btn:hover { border-color: #409eff; color: #409eff; }
.stage-cur { display: inline-block; padding: 4px 14px; border-radius: 8px; font-weight: 600; font-size: 13px; }
.pct-bar { height: 6px; border-radius: 3px; background: #eef1f5; overflow: hidden; margin-top: 4px; }
.pct-bar > i { display: block; height: 100%; background: #67c23a; border-radius: 3px; }

/* 桌面/移动二选一的提示文字 */
.only-m { display: none; }
@media (max-width: 820px) {
  .only-pc { display: none; }
  .only-m { display: inline; }
}

/* ===== 移动端适配（手机/平板竖屏，断点 820px） =====
   顶栏+侧边抽屉 / 弹窗底部面板 / 表单触控放大 / 表格横滚 */
.mobile-bar { display: none; }
.scrim { position: fixed; inset: 0; background: rgba(10,18,35,.45); z-index: 65; }

@media (max-width: 820px) {
  /* 顶栏 + 抽屉式侧边栏 */
  .mobile-bar { display: flex; position: fixed; top: 0; left: 0; right: 0; height: 48px; z-index: 60;
    background: #1e2735; color: #fff; align-items: center; padding: 0 8px; gap: 8px; }
  .mobile-bar .mb-title { flex: 1; font-size: 15px; font-weight: 700; }
  .mobile-bar button { background: transparent; color: #fff; font-size: 20px; padding: 6px 12px; min-height: 40px; }
  .mobile-bar button#mb-logout { font-size: 14px; }
  .layout { display: block; padding-top: 48px; }
  .sidebar { position: fixed; top: 48px; left: 0; bottom: 0; width: 240px; z-index: 70;
    transform: translateX(-100%); transition: transform .22s ease; overflow-y: auto; }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 14px 10px 60px; }
  .page-title { font-size: 17px; margin-bottom: 12px; }

  /* 登录页 */
  .login-card { width: min(360px, 94vw); padding: 30px 22px; }

  /* 触控目标 & 防 iOS 聚焦自动缩放（16px 以下会被 zoom） */
  input, select, textarea { font-size: 16px; padding: 11px 10px; }
  button { min-height: 40px; font-size: 15px; }
  th, td { padding: 8px 10px; }

  /* 弹窗改为底部滑出面板，内部可滚动 */
  .modal-mask { align-items: flex-end; }
  .modal, .modal.wide { width: 100vw; max-width: 100vw; border-radius: 14px 14px 0 0;
    max-height: 88vh; overflow-y: auto; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
  .modal .btns { position: sticky; bottom: -18px; background: #fff; padding: 12px 0 0; margin-top: 16px; }
  .modal .btns button { flex: 1; }

  /* 所有内联 flex 工具栏/搜索行允许换行，控件弹性收缩 */
  .toolbar { flex-wrap: wrap; gap: 8px; }
  [style*="flex"] { flex-wrap: wrap; }
  [style*="flex"] > input, [style*="flex"] > select { flex: 1 1 150px; min-width: 0; max-width: none !important; }
  [style*="flex"] > button { flex: 0 0 auto; }
  .imp-table input, .imp-table select { padding: 6px; font-size: 14px; }

  /* 卡片与表格密度 */
  .card { padding: 12px 12px; margin-bottom: 12px; border-radius: 6px; }

  /* 首页统计卡：两列排布 */
  .stat-card { min-width: calc(50% - 7px); padding: 12px 14px; }
  .stat-n { font-size: 22px; }
}

/* 页脚 ICP 备案号 */
.site-footer { text-align: center; padding: 10px 0 16px; font-size: 12px; color: #9aa0a6; }
.site-footer a { color: #9aa0a6; text-decoration: none; }
.site-footer a:hover { color: #4a90d9; text-decoration: underline; }
