/* ===== pages.css · 页面专属样式 ===== */

/* ---- 口令门 ---- */
#gate { position: fixed; inset: 0; background: var(--bg); z-index: 100; display: flex; align-items: center; justify-content: center; }
.gate-card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 36px 34px; width: min(92vw, 380px); text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.12); }
.gate-card .lock { font-size: 2.6rem; margin-bottom: 10px; }
.gate-card p { font-size: .92rem; color: var(--text2); margin-bottom: 18px; }
.gate-card input { width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); color: var(--text); font-size: 1.05rem; text-align: center; letter-spacing: 3px; }
.gate-card .btn { margin-top: 16px; }
.gate-err { color: var(--red); font-size: .8rem; margin-top: 10px; min-height: 1.2em; }

/* ---- 环境到期提醒横幅 ---- */
#envBanner { display: none; border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; font-size: .88rem; line-height: 1.7; align-items: center; gap: 10px; }
#envBanner.warn { display: flex; background: #fff7e6; border: 1px solid #faad14; color: #ad6800; }
#envBanner.danger { display: flex; background: #fff1f0; border: 1px solid #ff4d4f; color: #cf1322; font-weight: 600; }
#envBanner .btn-renew { margin-left: auto; flex-shrink: 0; padding: 6px 14px; border: 1px solid currentColor; border-radius: 8px; background: transparent; color: inherit; font-size: .8rem; cursor: pointer; font-weight: 600; }

/* ---- 图表区 ---- */
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 1100px) { .charts { grid-template-columns: 1fr; } }
.chart-box { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.chart-box h3 { font-size: .92rem; margin-bottom: 12px; color: var(--text2); font-weight: 600; }
.chart-holder { position: relative; height: 320px; }

/* ---- 月度作业 grid 布局（旧版，保留兼容） ---- */
.layout { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }
#result { display: none; }

/* ---- 页面工具栏（列表页通用） ---- */
.page-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.toolbar-right { display: flex; gap: 10px; align-items: center; }

/* ---- 规则说明折叠区 ---- */
details.rules { margin-top: 16px; }
details.rules summary { cursor: pointer; font-size: .85rem; color: var(--text2); padding: 6px 0; }
details.rules .body { font-size: .8rem; color: var(--text2); line-height: 1.8; padding: 10px 14px; background: var(--bg); border-radius: 8px; }

/* ---- 规则表单（页面内） ---- */
.rules-banner { margin-top: 14px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); font-size: .84rem; font-weight: 600; cursor: pointer; user-select: none; }
.rules-banner:hover { border-color: var(--primary); color: var(--primary); }
.rules-tip-bar { background: rgba(37,99,235,.06); border: 1px solid rgba(37,99,235,.2); border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-size: .82rem; color: var(--text2); line-height: 1.6; }
.time-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.time-grid label { font-size: .78rem; }
.time-grid input[type="time"] { width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text); }
.rule-note { font-size: .75rem; color: var(--text2); background: var(--bg); border-radius: 8px; padding: 10px 12px; line-height: 1.8; margin-top: 12px; }
.rtabs { display: flex; gap: 6px; margin: 12px 0 16px; }
.rtab { flex: 1; text-align: center; padding: 8px; border-radius: 8px; border: 1px solid var(--border); font-size: .85rem; cursor: pointer; color: var(--text2); }
.rtab.active { background: var(--primary); color: #fff; font-weight: 600; border-color: var(--primary); }

/* ---- 日历网格 ---- */
.cal-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-cell { border: 1px solid var(--border); border-radius: 8px; padding: 7px 4px; text-align: center; font-size: .82rem; cursor: pointer; user-select: none; position: relative; line-height: 1.5; }
.cal-cell:hover { border-color: var(--primary); }
.cal-cell .cw { font-size: .62rem; color: var(--text2); }
.cal-cell.blank { border: none; cursor: default; }
.cal-cell.blank:hover { border-color: transparent; }
.cal-cell.d-holiday3 { background: var(--red); color: #fff; font-weight: 700; }
.cal-cell.d-holiday2 { background: #f59e0b; color: #fff; font-weight: 700; }
.cal-cell.d-makeup { background: var(--green); color: #fff; font-weight: 700; }
.cal-cell.d-rest { background: #64748b; color: #fff; font-weight: 700; }
.cal-cell.is-rest { opacity: .55; }
.cal-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .75rem; color: var(--text2); margin: 10px 0 4px; }
.cal-legend b { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; }
.cal-dirty { color: var(--red); font-size: .75rem; margin-left: auto; }

/* ---- 页脚 ---- */
footer { text-align: center; font-size: .75rem; color: var(--text2); }

/* ===== 月度详情页：固定顶部 + 表格内部独立滚动（#/attendance/monthly/detail） =====
   仅对月度详情页生效，不影响其他页面。
   原理：锁定 app-shell 为视口高度 → main-area 固定不整体滚动 →
   app-content 满高 flex 列 → page-monthly-detail 顶部信息区自然布局 +
   Tab 内容区 flex:1 独立滚动。min-height:0 是 flex 子项内部可滚动的关键。 */

/* 1. 锁定应用壳为视口高度，阻止内容撑开产生整页滚动条 */
#app-shell:has(.page-monthly-detail) {
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

/* 2. main-area 固定高度、不整体滚动（envBanner/breadcrumb/footer 自然布局，app-content 占剩余空间） */
#app-shell:has(.page-monthly-detail) #main-area {
  overflow: hidden;
  min-height: 0;
}

/* 3. app-content 成为可收缩的 flex 列容器 */
#app-shell:has(.page-monthly-detail) #app-content {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

/* 4. 页面根容器：满高 flex 列，顶部信息区（detail-header/stats/tabs）自然排列，Tab 区占据剩余 */
.page-monthly-detail {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

/* 5. 三个 Tab card：占满剩余空间，内部独立垂直滚动 */
.page-monthly-detail .card[id^="tab-"] {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 6. 表格容器：独立滚动（Tab2 内联 max-height 已移除，统一由 flex 自适应） */
.page-monthly-detail .tbl-wrap {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
}

/* 7. 表头冻结：滚动时 thead 固定在表格顶部（th 的 sticky top:0 已在 components.css 定义，此处补 z-index 与不透明背景兜底） */
.page-monthly-detail .tbl-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg);
}

/* 8. 合计行冻结：滚动时 tfoot 合计行常驻表格底部（兜底不透明背景，避免透出底层行） */
.page-monthly-detail .tbl-wrap tfoot td {
  position: sticky;
  bottom: 0;
  z-index: 1;
  background: var(--bg);
}

/* 9. 表格列宽固定方案：按字段内容+字段数统一设计列宽（colgroup 注入） */
.page-monthly-detail table.oa-fixed { table-layout: fixed; }
/* 打卡记录：7 列窄表，打卡记录列最宽（单行展示，尽量不换行） */
.page-monthly-detail table.punch-tbl { width: 100%; max-width: 1000px; }
/* 月度汇总：15 列宽报表，数值密集，窄屏横向滚动 */
.page-monthly-detail table.sum-tbl { width: 100%; min-width: 1098px; }
/* 人员明细：9 列，打卡记录列最宽，明细 Tab 与抽屉共用 */
.page-monthly-detail table.det-tbl { width: 100%; max-width: 920px; }

/* 9. 图表 Tab：charts 区超出容器时内部滚动，不撑出页面 */
.page-monthly-detail #tab-chart .charts {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  grid-template-columns: 1fr; /* 改动5：移除出勤率图表后，单个图表占满整行 */
}
/* 窗口过矮时压缩图表高度，避免图表区出现双重滚动 */
@media (max-height: 700px) {
  .page-monthly-detail .chart-holder { height: 260px; }
}
