:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e3e6ea;
  --border-strong: #c9cfd8;
  --text: #1f2733;
  --text-muted: #6b7482;
  --primary: #2f6fed;
  --primary-hover: #245cd0;
  --primary-soft: #e8f0fe;
  --danger: #d64545;
  --danger-soft: #fdecec;
  --warn: #c98a00;
  --warn-soft: #fff4dd;
  --ok: #1f9d55;
  --ok-soft: #e6f6ec;
  --weekend-bg: #fbf7f0;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 30, 50, 0.08), 0 8px 24px rgba(20, 30, 50, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
a { color: var(--primary); }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: linear-gradient(160deg, #eef3fc 0%, #f6f8fb 60%);
}
.login-card {
  background: var(--surface); padding: 36px 32px; border-radius: 16px;
  width: 100%; max-width: 360px; box-shadow: var(--shadow);
}
.login-card h1 { font-size: 20px; margin: 0 0 6px; text-align: center; }
.login-sub { color: var(--text-muted); text-align: center; margin: 0 0 24px; font-size: 13px; }
.login-card label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 14px; }
.login-card input { margin-top: 5px; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 10px 16px;
}
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; max-width: 100%; }
.nav button {
  border: none; background: transparent; padding: 8px 12px; border-radius: 8px;
  cursor: pointer; font-size: 14px; color: var(--text-muted);
}
.nav button:hover { background: var(--bg); color: var(--text); }
.nav button.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.whoami { color: var(--text-muted); font-size: 13px; }
.today { color: var(--text); font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer; }

.main { padding: 20px 16px 48px; max-width: 1280px; margin: 0 auto; }

/* ---------- 基础控件 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 14px;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }

input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong);
  border-radius: 8px; font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
textarea { resize: vertical; min-height: 60px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px;
}
.card h2 { margin: 0 0 4px; font-size: 16px; }
.card .card-desc { color: var(--text-muted); font-size: 13px; margin: 0 0 14px; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.error-text { color: var(--danger); font-size: 13px; min-height: 18px; margin: 4px 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data th { color: var(--text-muted); font-weight: 600; font-size: 12px; background: #fafbfc; }
table.data tr:hover td { background: #fafbfc; }
.actions { display: flex; gap: 6px; }

/* ---------- 徽标 ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: var(--bg); color: var(--text-muted); }

/* ---------- 日历 ---------- */
.cal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.cal-title { font-size: 17px; font-weight: 700; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); }
.legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }

.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
}
.cal-dow { text-align: center; font-weight: 600; color: var(--text-muted); font-size: 12px; padding: 4px 0; }
.cal-dow.weekend { color: var(--warn); }
.cal-day {
  min-height: 110px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 5px;
  position: relative;
}
.cal-day.out { background: transparent; border-color: transparent; }
.cal-day.weekend { background: var(--weekend-bg); }
.cal-day.today { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.cal-day-head { display: flex; align-items: center; justify-content: space-between; }
.cal-day-num { font-weight: 700; font-size: 13px; }
.cal-day-type { font-size: 10px; color: var(--text-muted); }
.cal-day.weekend .cal-day-type { color: var(--warn); }

/* 患者会话单元格 */
.sess {
  border-radius: 6px; padding: 5px 7px; font-size: 12px; cursor: pointer;
  border-left: 3px solid var(--primary); background: var(--surface);
  border: 1px solid var(--border); border-left: 3px solid var(--primary);
  transition: box-shadow .12s;
}
.sess:hover { box-shadow: 0 0 0 2px var(--primary-soft); }
.sess .sess-top { display: flex; align-items: center; gap: 5px; }
.sess .pname { font-weight: 600; }
.sess .slot { color: var(--text-muted); }
.sess .ops { margin-top: 2px; color: var(--text); }
.sess .ops .tag { display: inline-block; margin-right: 6px; }
.sess .ops .tag b { font-weight: 600; }
.sess.no-primary { border-left-color: var(--danger); background: var(--danger-soft); }
.sess.has-warn { border-left-color: var(--warn); background: var(--warn-soft); }
.sess.has-conflict { border-left-color: var(--danger); background: var(--danger-soft); }
.sess.unclaimed { border-left-color: var(--primary); background: var(--primary-soft); border-style: dashed; }
.sess.mine { border-left-color: var(--ok); background: var(--ok-soft); }
.sess.admin-first { border-left-color: var(--text-muted); background: #fafbfc; }
.sess .pcode { font-weight: 600; cursor: pointer; text-decoration: none; }
.sess .pcode:hover { text-decoration: underline; }
.sess .cap-badge { margin-left: auto; }

/* 患者信息查看 */
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.info-grid label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.info-val { padding: 7px 10px; background: #fafbfc; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; min-height: 18px; word-break: break-all; }
@media (max-width: 640px) { .info-grid { grid-template-columns: 1fr; } }

/* 我的排班 */
.ms-group { margin-bottom: 14px; }
.ms-date { font-weight: 700; padding: 6px 0; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.ms-item { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 7px 4px; border-bottom: 1px dashed var(--border); font-size: 14px; }
.ms-code { font-weight: 600; color: var(--primary); cursor: pointer; }
.ms-code:hover { text-decoration: underline; }
.ms-name { color: var(--text-muted); }
.ms-backup { color: var(--text-muted); font-size: 13px; margin-left: auto; }
.sess .mini-badge { font-size: 10px; margin-left: auto; }

/* 移动端列表视图 */
.day-list { display: flex; flex-direction: column; gap: 10px; }
.day-item { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.day-item.weekend { background: var(--weekend-bg); }
.day-item-head { padding: 9px 12px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); }
.day-item-head .date { font-weight: 700; }
.day-item-body { padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; }

/* ---------- 可用时段 ---------- */
.slot-group { margin-bottom: 18px; }
.slot-group h3 { font-size: 14px; margin: 0 0 8px; }
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.slot-check { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; cursor: pointer; }
.slot-check input { width: auto; }
.slot-check .t { font-weight: 600; font-size: 14px; }
.slot-check .r { color: var(--text-muted); font-size: 12px; }
.slot-check.checked { border-color: var(--primary); background: var(--primary-soft); }
.slot-check.disabled { opacity: .45; cursor: not-allowed; }

/* ---------- 弹层 ---------- */
.modal-root {
  position: fixed; inset: 0; background: rgba(20, 30, 50, 0.45);
  display: flex; align-items: flex-start; justify-content: center; padding: 24px 16px; z-index: 100;
  overflow-y: auto;
}
.modal {
  background: var(--surface); border-radius: 14px; width: 100%; max-width: 560px;
  box-shadow: var(--shadow); padding: 20px 22px; margin: auto;
}
.modal.wide { max-width: 720px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-close { border: none; background: transparent; font-size: 22px; cursor: pointer; color: var(--text-muted); line-height: 1; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.modal .hint { font-size: 12px; color: var(--text-muted); margin: 4px 0; }

/* 校验问题提示 */
.issue-list { margin: 12px 0; padding: 0; list-style: none; }
.issue-list li { font-size: 13px; padding: 7px 10px; border-radius: 6px; margin-bottom: 6px; }
.issue-list li.err { background: var(--danger-soft); color: var(--danger); }
.issue-list li.warn { background: var(--warn-soft); color: var(--warn); }

/* 编辑面板里的主班/候补选择 */
.pick-op { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.pick-op > div { flex: 1; min-width: 140px; }
.pick-op label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.swap-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.empty { text-align: center; color: var(--text-muted); padding: 30px 10px; font-size: 14px; }
.miss { color: var(--text-muted); font-weight: normal; }

/* 操作员自助单选 */
.radio-group { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.radio-opt { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 14px; }
.radio-opt:hover { border-color: var(--primary); }
.radio-opt input { width: auto; }
.ms-ward { color: var(--text-muted); font-size: 13px; }
.ms-done { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.ms-done input { width: auto; }
.ms-note { width: 180px; padding: 5px 8px; font-size: 13px; }
.ms-seq { color: var(--text-muted); font-size: 13px; font-weight: 600; white-space: nowrap; }
.quick-checklist { margin: 10px 0; }
.guide h3 { font-size: 15px; margin: 16px 0 6px; }
.guide ol, .guide ul { margin: 0 0 8px; padding-left: 20px; }
.guide li { margin-bottom: 5px; line-height: 1.6; }
.auto-item { padding: 6px 2px; font-size: 14px; border-bottom: 1px dashed var(--border); }
.qc-item { padding: 6px 2px; border-bottom: 1px dashed var(--border); font-size: 14px; line-height: 1.6; }
.linklike { color: var(--primary); cursor: pointer; font-weight: 600; }
.linklike:hover { text-decoration: underline; }
.swap-banner { background: var(--primary-soft); color: var(--primary); border: 1px dashed var(--primary); padding: 8px 10px; border-radius: 8px; margin-bottom: 10px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* 提示条 */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: #232b38; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .2s; z-index: 200; max-width: 90vw;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.toast.info, .toast.warn { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.warn { background: var(--danger); }

/* ---------- 响应式 ---------- */
@media (max-width: 760px) {
  .main { padding: 12px 10px 40px; }
  .topbar { gap: 8px; padding: 8px 10px; }
  .whoami { display: none; }
  .cal-grid { display: none; }
  .nav { width: 100%; }
}
@media (min-width: 761px) {
  .day-list { display: none; }
}
