/* roster-tables.css —— 强化 / 续管 / 随访三张登记表的统一皮肤（中文注释） */
/* 中文说明：颜色全部取自系统医疗色板，不新增品牌色；0 值只做视觉弱化，不隐藏。 */

:root {
  --rt-primary: var(--color-primary, #28544d);
  --rt-primary-soft: #eaf2f0;
  --rt-success-soft: #eaf6f0;
  --rt-page-bg: var(--color-page-bg, #f5f7f7);
  --rt-surface: var(--color-surface, #ffffff);
  --rt-line: var(--color-border, #e6ecea);
  --rt-sep: #bfcfcb;
  /* 中文说明：线条粗细层级：1px = 表内行与行之间，2px = 表格与表格之间 / 表头下方 / 合计行上方 */
  --rt-hairline: 1px;
  --rt-block-line: 2px;
  --rt-block-line-color: #b4c6c1;
  --rt-text-main: var(--color-text-main, #111827);
  --rt-text-secondary: var(--color-text-secondary, #374151);
  --rt-text-zero: #9ca3af;
  --rt-stripe: #eef4f2;
  --rt-hover: #e6efec;
}

/* 中文说明：三张表之间的间距收小，靠 2px 粗线做“表格与表格”的边界（行内仍是 1px 细线） */
.rt-stack { display: grid; gap: 12px; }
.rt-stack > .rt-card + .rt-card { border-top: var(--rt-block-line) solid var(--rt-block-line-color); }
.rpt-roster-tables { margin-bottom: 18px; }

/* 中文说明：区块头（科室页专用）：标题 + 两个轻量按钮，不抢表格注意力 */
.rt-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 10px;
}

.rt-block-title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--color-text-main, #111827);
}

.rt-block-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.rt-block-tip { font-size: 12px; color: var(--color-text-secondary, #374151); }

.rt-block-btn {
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid var(--color-border, #e6ecea);
  background: var(--color-surface, #ffffff);
  color: var(--rt-primary);
  font-size: 12px;
  cursor: pointer;
}

.rt-block-btn:hover { border-color: var(--rt-primary); background: var(--rt-primary-soft); }

.rt-card {
  background: var(--rt-surface);
  border: 1px solid var(--rt-line);
  border-radius: 12px;
  padding: 14px 16px 12px;
}

.rt-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.rt-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--rt-text-main);
  letter-spacing: 0.2px;
}

.rt-head-aside { display: flex; align-items: center; gap: 10px; }

.rt-unit { font-size: 12px; color: var(--rt-text-secondary); }

.rt-note {
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--rt-text-secondary);
}

/* 中文说明：只有表格自己横向滚动，页面不被撑破 */
.rt-scroll {
  overflow-x: auto;
  border: 1px solid var(--rt-line);
  border-radius: 10px;
}

.rt-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--rt-surface);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* 中文说明：组内不画竖线，只在分组边界用左边线分隔，避免 25 列网格糊成一片 */
.rt-table th,
.rt-table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--rt-line);
  text-align: center;
  white-space: nowrap;
}

.rt-table thead th {
  background: var(--rt-page-bg);
  color: var(--rt-text-secondary);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  position: sticky;
  top: 0;
  z-index: 1;
}

/* 中文说明：表头最下沿用 2px 线，和表体里的 1px 行线形成粗细层级 */
.rt-table thead tr:last-child th { border-bottom: var(--rt-block-line) solid var(--rt-block-line-color); }

/* 中文说明：第一层分组表头与第二层列名同色，列与列只靠竖线区分，不铺底色（避免页面花） */
.rt-table .rt-head-group {
  background: var(--rt-page-bg);
  color: var(--rt-text-main);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 6px;
  border-bottom: 1px solid var(--rt-line);
}

.rt-table .rt-head-group:not(:first-child) { border-left: 1px solid var(--rt-line); }

/* 中文说明：分组分隔线：每个分组的第一列左侧画一条竖线，把八组数据明确分开（表头与表体一致） */
.rt-table .rt-sep { border-left: 1px solid var(--rt-sep); }
.rt-table thead .rt-sep { border-left: 1px solid var(--rt-sep); }

/* 中文说明：行底色是唯一的底色区分手段：偶数行浅绿、鼠标悬停加深，列一律不上色 */
.rt-table tbody tr:nth-child(even) { background: var(--rt-stripe); }
.rt-table tbody tr:hover { background: var(--rt-hover); }

/* 中文说明：首列（人员 / 组别）粘住，横向滚动时仍然知道这是哪一行 */
.rt-table .rt-group,
.rt-table .rt-head-first {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 84px;
  text-align: left;
  padding-left: 12px;
  font-weight: 500;
  color: var(--rt-text-main);
  background: inherit;
  box-shadow: 1px 0 0 var(--rt-line);
}

.rt-table thead .rt-head-first,
.rt-table thead th:first-child { z-index: 3; }

.rt-table .rt-num { color: var(--rt-text-main); }
.rt-table .rt-num.is-zero { color: var(--rt-text-zero); }
.rt-table .rt-num.is-strong { font-weight: 600; }

/* 中文说明：合计行用医疗绿淡底 + 顶部两像素绿线，永远在表底可见；即使它是偶数行也要压过斑马纹 */
.rt-table tbody tr.rt-total { background: var(--rt-success-soft); }
.rt-table .rt-total td {
  font-weight: 600;
  color: var(--rt-text-main);
  border-top: 2px solid var(--rt-primary);
  border-bottom: none;
}
.rt-table .rt-total .rt-group { color: var(--rt-text-main); background: inherit; }

.rt-table tbody tr:last-child td { border-bottom: none; }

/* 中文说明：续管表只有 6 列，不需要横向滚动，列宽均匀一些更好看 */
.rt-table-continue { table-layout: auto; }
.rt-table-continue th:not(:first-child),
.rt-table-continue td:not(:first-child) { min-width: 96px; }

/* 中文说明：随访表是横向一张表，数字列等宽，避免数字位数变化时抖动 */
.rt-table-follow th,
.rt-table-follow td { min-width: 84px; }

/* 中文说明：窄屏降低密度，但不改变列数与顺序 */
@media (max-width: 720px) {
  .rt-card { padding: 12px 10px 10px; }
  .rt-title { font-size: 15px; }
  .rt-table { font-size: 12px; }
  .rt-table th,
  .rt-table td { padding: 6px 4px; }
  .rt-table .rt-group,
  .rt-table .rt-head-first { min-width: 68px; padding-left: 8px; }
}

/* 中文说明：打印 A4 横向；表头跨页重复，去掉底色保证黑白也读得清 */
@media print {
  .rt-stack { gap: 10px; }
  .rt-card { border: 1px solid #999; border-radius: 0; break-inside: avoid; }
  .rt-scroll { overflow: visible; border: none; }
  .rt-table { font-size: 10px; }
  .rt-table thead th,
  .rt-table .rt-head-group { background: #fff !important; color: #000; }
  /* 中文说明：打印时行底色全部去掉，只留黑线，黑白打印也读得清 */
  .rt-table tbody tr,
  .rt-table tbody tr:nth-child(even),
  .rt-table tbody tr.rt-total { background: #fff !important; }
  .rt-table .rt-total td { border-top: 1.5px solid #000; }
  .rt-table td,
  .rt-table th { border-bottom: 1px solid #bbb; }
  .rt-table .rt-num.is-zero { color: #444; }
}
