/* 预约挂号系统 — 全局样式（简洁医疗风） */
* { margin: 0; padding: 0; box-sizing: border-box; }
.hidden { display: none !important; }
:root {
  --primary: #1a73c4;
  --primary-dark: #125a9e;
  --primary-light: #e8f2fb;
  --success: #2e9e5b;
  --warning: #d98a16;
  --danger: #d64545;
  --text: #2b3a4a;
  --text-light: #6b7c8d;
  --border: #dde5ee;
  --bg: #f4f7fa;
  --card: #ffffff;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(30, 60, 90, .07);
}
html { font-size: 15px; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit;
  font-size: .95rem;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  transition: border-color .15s;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,115,196,.12); }
textarea { resize: vertical; min-height: 80px; }

.btn {
  display: inline-block;
  padding: 9px 22px;
  border: none;
  border-radius: 6px;
  font-size: .95rem;
  background: var(--primary);
  color: #fff;
  transition: background .15s, transform .1s;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn:disabled { background: #a9c4dd; cursor: not-allowed; }
.btn-outline { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-sm { padding: 5px 12px; font-size: .85rem; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b53535; }
.btn-success { background: var(--success); }
.btn-success:hover { background: #237a45; }
.btn-ghost { background: transparent; color: var(--text-light); }
.btn-ghost:hover { background: #eef2f6; color: var(--text); }

/* 状态标签 */
.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: .8rem;
  white-space: nowrap;
}
/* 排班时段小标签（上午/下午/全天）：三种时段分别用蓝 / 橙 / 紫，避免与状态色（绿/红）混淆 */
.period-tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: .76rem;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
  white-space: nowrap;
}
.period-am   { background: #e7f0fb; color: #2b6cb0; }
.period-pm   { background: #fff1e0; color: #b96a12; }
.period-full { background: #efe8fa; color: #6b46a3; }
/* 排班页：医院改为单选下拉，隐藏全站多选切换器；一天一行的医生标签 */
#page-schedule .ctx-hos-wrap { display: none; }
.sch-doc-tag {
  display: inline-block; padding: 2px 9px; margin: 2px 5px 2px 0;
  background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 6px;
  font-size: .82rem; color: var(--text); white-space: nowrap; line-height: 1.5;
}
.sch-doc-tag .sd-hos { color: var(--text-light); font-size: .74rem; margin-left: 4px; }
.sch-cell-none { color: #b6c0cb; }
/* 按天编辑弹窗：每位医生一行（医生 / 时段 / 号源 / 删除）——统一网格、禁止选项文字换行 */
.day-edit-row {
  display: grid; grid-template-columns: minmax(170px, 1.6fr) minmax(184px, 1fr) 76px 32px;
  gap: 10px; align-items: center; padding: 10px 12px; margin-bottom: 8px;
  background: #f8fafc; border: 1px solid #e8eef4; border-radius: 8px;
}
.day-edit-row:last-child { margin-bottom: 0; }
.day-edit-row.is-removed { opacity: .45; background: #f1f4f7; }
.day-edit-row select, .day-edit-row input { width: 100%; height: 38px; }
.day-edit-row .de-del { width: 32px; height: 38px; padding: 0; font-size: .9rem; }
.day-edit-period { display: flex; gap: 6px; flex-wrap: nowrap; }
.day-edit-period label {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  flex: 1 1 0; min-width: 0; height: 38px; padding: 0 6px;
  border: 1px solid var(--border); border-radius: 6px; background: #fff;
  font-size: .84rem; line-height: 1; color: var(--text-light);
  cursor: pointer; user-select: none; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.day-edit-period label:hover { border-color: var(--primary); color: var(--primary); }
.day-edit-period label:has(input:checked) {
  background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600;
}
.day-edit-period input[type="radio"] { width: 13px; height: 13px; margin: 0; accent-color: var(--primary); flex: 0 0 auto; }
.day-edit-period label:has(input:checked) input[type="radio"] { accent-color: #fff; }
.tag-pending   { background: #fdf3e0; color: var(--warning); }
.tag-confirmed { background: var(--primary-light); color: var(--primary); }
.tag-arrived   { background: #e3f5ea; color: var(--success); }
.tag-finished  { background: #eceff3; color: var(--text-light); }
.tag-cancelled { background: #fbeaea; color: var(--danger); }
.tag-no_show   { background: #f0e8f8; color: #7a4fb8; }
/* 展示层状态分组（2026-11-18 修订）：待回访=黄色（从未回访）、待跟进=橙色（有回访仍需再回访）、
 * 已回访=绿色（有回访无需再回访）、已失效=灰色 */
.tag-pending-follow { background: #fdf0e0; color: #e07b24; }
.tag-followed  { background: #e3f5ea; color: var(--success); }
.tag-invalid   { background: #eceff3; color: var(--text-light); }
/* 通用启用/停用状态（2026-11-25 改）：正常/启用=绿色，停诊/停用=红色。
 * 专门用新类，不再复用 tag-arrived——后者被「已到诊整行红色」规则覆盖成红色，导致正常状态误显红色。 */
.tag-normal { background: #e3f5ea; color: var(--success); font-weight: 600; }
.tag-stop   { background: #fdecec; color: var(--danger); font-weight: 600; }

/* 提示条 */
.notice { padding: 10px 14px; border-radius: 6px; margin: 12px 0; font-size: .9rem; }
.notice-error { background: #fbeaea; color: var(--danger); border: 1px solid #f2c9c9; }
.notice-ok { background: #e3f5ea; color: var(--success); border: 1px solid #bde5cc; }
.notice-info { background: var(--primary-light); color: var(--primary); border: 1px solid #c8ddf2; }

.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -3px; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 空状态 */
.empty { text-align: center; color: var(--text-light); padding: 40px 0; font-size: .92rem; }

/* 表格 */
table.data-table { width: 100%; border-collapse: collapse; background: #fff; }
table.data-table th, table.data-table td {
  padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: .9rem;
}
/* 表头默认与内容一致左对齐（排班/组织/日志/角色/用户等页面）；仅预约管理页保留居中 */
table.data-table th { background: #f8fafc; color: var(--text-light); font-weight: 600; white-space: nowrap; text-align: left; vertical-align: middle; }
#page-appointments table.data-table th { text-align: center; }
table.data-table tr:hover td { background: #f6fafd; }

/* 表格单元格副行（合并列的第二行信息） */
.cell-sub { display: block; font-size: .76rem; color: var(--text-light); margin-top: 2px; font-weight: normal; }

/* 预约管理表格：医生名与操作列不换行 */
.data-table td .nowrap { white-space: nowrap; }
.data-table td:last-child { white-space: nowrap; }
/* 预约列表：压缩操作列内边距与按钮尺寸，避免新增"编辑"按钮后被挤出可视区 */
#page-appointments table.data-table th, #page-appointments table.data-table td { padding: 7px 8px; }
#page-appointments table.data-table td:last-child { padding: 7px 3px; }
#page-appointments table.data-table td:last-child .btn { padding: 2px 5px; font-size: .76rem; }

/* ===== 表格统一美化（预约/排班/日志/角色/用户等所有 data-table） ===== */
/* 1) 列间竖直分隔线：每列右侧一条细线，最后一列不画，保持右缘干净 */
table.data-table th, table.data-table td { border-right: 1px solid #eef1f5; }
table.data-table th:last-child, table.data-table td:last-child { border-right: none; }
/* 2) 操作列居中仅限预约管理页（用户口径 2026-11-18：排班/组织/日志/角色等页面表头与内容统一左对齐） */
#page-appointments table.data-table th:last-child, #page-appointments table.data-table td:last-child { text-align: center; }
/* 3) 短列居中工具类：仅预约管理页生效（性别/年龄/状态等窄列）；其他页面保持左对齐 */
#page-appointments table.data-table th.td-c, #page-appointments table.data-table td.td-c { text-align: center; }

/* 表头排序：可排序列显示 ⇅ 提示，当前排序列高亮 ▲/▼（操作列不加 data-sort，不参与排序） */
table.data-table th[data-sort] { cursor: pointer; user-select: none; }
table.data-table th[data-sort] .th-sort { margin-left: 4px; font-size: .68rem; color: #b7c0cb; font-weight: 400; }
table.data-table th[data-sort]:hover .th-sort { color: var(--text-light); }
table.data-table th.sorted-asc .th-sort, table.data-table th.sorted-desc .th-sort { color: #4a8fc9; font-weight: 700; }

/* ===== 预约管理表格列宽治理（2026-11-18）：约束易被拉宽的列 =====
 * 背景：表格 width:100% 撑满面板后，nowrap/max-width 锁死的列不吃多余宽度，
 * 全部堆进无约束列 → 内容一小格、列内大片空白。给这些列加上限后空白收敛。
 * 注：列号对应当前表头顺序（1预约号…18操作），调整列顺序时需同步检查本段。 */
/* 预约表列宽上限：医院列已移除（医院改为页面级全局上下文展示），其后索引整体 -1 */
#page-appointments table.data-table th:nth-child(6),
#page-appointments table.data-table td:nth-child(6) { max-width: 110px; }   /* 科室 */
#page-appointments table.data-table th:nth-child(9),
#page-appointments table.data-table td:nth-child(9) { max-width: 150px; }   /* 预约到诊时间 */
#page-appointments table.data-table th:nth-child(10),
#page-appointments table.data-table td:nth-child(10) { max-width: 90px; }   /* 地区 */
#page-appointments table.data-table th:nth-child(11),
#page-appointments table.data-table td:nth-child(11) { max-width: 140px; }  /* 来源渠道 */
#page-appointments table.data-table th:nth-child(12),
#page-appointments table.data-table td:nth-child(12) { max-width: 100px; }  /* 客服 */
#page-appointments table.data-table th:nth-child(13),
#page-appointments table.data-table td:nth-child(13) { max-width: 110px; }  /* 预约方式 */
#page-appointments table.data-table th:nth-child(15),
#page-appointments table.data-table td:nth-child(15) { max-width: 95px; }   /* 回访记录 */
#page-appointments table.data-table th:nth-child(16),
#page-appointments table.data-table td:nth-child(16) { max-width: 175px; }  /* 添加时间 */

/* ===== 全局医院上下文（页面标题旁：- 医院名 + 多选切换器，全站共享一个状态） =====
 * margin-right:auto 吸收剩余空间：标题与医院条紧贴居左，.right 汇总/区间信息仍靠右。
 * 标题医院名：字体、字号、字重与左侧栏菜单 .side-menu a 一致（继承字体 / .92rem / 常规字重）；
 * 颜色取同色系的弱化中性色 var(--text-light) 以适配白色内容区——侧栏是深色底浅字（#b9c7d4），
 * 该色值直接放到白底会无法辨认，故按「同一视觉层级」做等价适配。 */
.ctx-hos-wrap { display: inline-flex; align-items: center; gap: 10px; margin-left: 12px; margin-right: auto; font-weight: 400; }
.ctx-hos-wrap .ctx-hos-name { font-family: inherit; font-size: inherit; font-weight: inherit; color: inherit; white-space: nowrap; }

/* 医院多选选择器：整体仍是一个「选项框」，展开后为复选列表；框内医院名称统一蓝色 */
.hos-picker { position: relative; display: inline-flex; align-items: center; }
.hos-picker-btn { padding: 6px 12px; font-size: .88rem; line-height: 1.4; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--text); white-space: nowrap; transition: border-color .15s; }
.hos-picker-btn:hover { border-color: var(--primary); }
.hos-picker-panel { position: absolute; top: calc(100% + 5px); left: 0; z-index: 70; min-width: 200px; max-height: 264px; overflow-y: auto; padding: 6px; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 20px rgba(15,30,45,.16); }
.hos-picker-panel[hidden] { display: none; }
.hos-opt { display: flex; align-items: center; gap: 7px; padding: 6px 9px; border-radius: 6px; font-size: .9rem; color: var(--primary); cursor: pointer; white-space: nowrap; }
.hos-opt:hover { background: var(--primary-light); }
.hos-opt input { margin: 0; flex: 0 0 auto; }
.hos-opt-all { border-bottom: 1px solid var(--border); border-radius: 0; margin-bottom: 4px; padding-bottom: 9px; font-weight: 600; }
.home-hero .hos-picker-btn { padding: 8px 12px; font-size: .88rem; }
/* 表单 / 筛选区里的多选医院组：与其他表单控件统一边框、字号、悬停/选中反馈 */
.hos-multi { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 0; }
.hos-multi label { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: .88rem; line-height: 1.4; color: var(--text); background: #fff; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, color .15s; }
.hos-multi label:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.hos-multi label:has(input:checked), .hos-multi label.checked { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.hos-multi input { margin: 0; flex: 0 0 auto; }
.hos-filter-bar { display: inline-flex; align-items: center; gap: 8px; }
.hos-filter-label { font-size: .86rem; color: var(--text-light); white-space: nowrap; }
.hos-filter-tip { font-size: .78rem; color: var(--text-light); white-space: nowrap; }

/* ===== 到院状态醒目反馈（已到诊/已完成 = 全部信息红色，参照参考系统） ===== */
.tag-arrived { background: #fdecec; color: #d43a3a; font-weight: 700; }
/* 列表整行：到院完成后该行所有字段字体置红 */
.data-table tr.row-arrived td { color: #d43a3a; }
.data-table tr.row-arrived .pt-name { font-weight: 700; }
.data-table tr.row-arrived td .cell-sub { color: #e08f8f; }
.data-table tr.row-arrived td .tag { /* 状态标签保持原有配色，仅文字随红 */ }
.data-table tr.row-arrived td.pt-time b { color: #d43a3a; }

/* 详情抽屉：到院/完成后全部信息字体置红（按钮、输入框、分区标题除外） */
#drawer.arrived-all { color: #d43a3a; }
#drawer.arrived-all .k { color: var(--text-light); }
#drawer.arrived-all .drawer-sec { color: var(--text-light); }
#drawer.arrived-all .arr-hint { color: var(--text-light); }
#drawer.arrived-all button { color: inherit; }
/* 分段控件例外：未选中项正常深色文字，选中项白字（避免红底红字不可见） */
#drawer.arrived-all .seg-btn { color: var(--text); }
#drawer.arrived-all .seg-btn.active { color: #fff; }
#drawer.arrived-all .btn { color: #fff; }
#drawer.arrived-all .btn-ghost { color: var(--text-light); }
#drawer.arrived-all input { color: var(--text); }
#drawer.arrived-all .followup-item .meta { color: var(--text-light); }

/* ===== 详情抽屉：分区 + 单字段行 ===== */
.drawer-sec { margin: 18px 0 8px; font-size: .8rem; font-weight: 700; color: var(--text-light); letter-spacing: .06em; }
.drawer-sec:first-of-type { margin-top: 6px; }

/* 到院状态操作条（固定高度，两种状态栏高一致，切换状态时不变化） */
.arr-bar { display: flex; align-items: center; gap: 14px; padding: 12px 14px; height: 58px; box-sizing: border-box; margin-bottom: 6px;
  background: #f7f9fb; border: 1px solid var(--border); border-radius: 10px; }
.arr-bar.on { background: #fdf0f0; border-color: #f2c9c9; }
.arr-bar .arr-label { font-size: .86rem; font-weight: 700; white-space: nowrap; }
.arr-bar.on .arr-label { color: #d43a3a; }
.arr-bar .arr-hint { font-size: .78rem; color: var(--text-light); margin-left: auto; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 分段单选控件（未到院 / 已到院 二选一）；不收缩、不换行，避免挤压时文字竖排导致栏高变化 */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; flex: none; }
.seg-btn { border: none; background: #fff; padding: 7px 18px; font-size: .86rem; cursor: pointer; color: var(--text); white-space: nowrap; }
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn.active { background: var(--primary); color: #fff; font-weight: 700; }
.seg-btn.seg-red.active { background: #d43a3a; }
.seg-btn:disabled { opacity: .45; cursor: not-allowed; }

/* 轻提示 toast */
#toast { position: fixed; top: 22px; left: 50%; transform: translateX(-50%) translateY(-8px); z-index: 999;
  background: rgba(34, 40, 49, .92); color: #fff; padding: 10px 22px; border-radius: 8px; font-size: .88rem;
  opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease; }
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.toast-err { background: rgba(196, 43, 43, .94); }

/* ===== 组织管理·字典表（病种/平台/引擎/地区）列宽与排版治理（2026-11-25） =====
 * 背景：去掉名称下方的「适用医院」副行后行高压缩，名称列在整行宽度里被拉出大片空白；
 * 处理：colgroup 百分比定宽 + 长文本省略号（悬停看全文），时间列不换行，操作列按钮收紧。 */
table.org-dict-table { table-layout: fixed; }
table.org-dict-table th, table.org-dict-table td { overflow: hidden; text-overflow: ellipsis; }
table.org-dict-table td { white-space: nowrap; }
table.org-dict-table td.org-name { font-weight: 500; }
table.org-dict-table td.org-hos { color: var(--text-light); }
table.org-dict-table td.org-time { color: var(--text-light); font-variant-numeric: tabular-nums; font-size: .86rem; }
table.org-dict-table td:last-child { padding-right: 8px; }
table.org-dict-table td:last-child .btn { padding: 3px 7px; font-size: .82rem; }
table.org-dict-table th { padding-top: 11px; padding-bottom: 11px; }

/* 组织管理·医生/科室等列表：姓名·职称·所属科室·所属医院不换行，简介自动换行吃掉剩余宽度 */
table.data-table td.nowrap { white-space: nowrap; }

/* 字典表最小宽度：窗口过窄时改为横向滚动，而不是把序号/复选框压到文字截断 */
#org-table-wrap table.org-dict-table { min-width: 920px; }
