/* 科室排班 · 企业微信 H5。配色和原型一致：墨绿主色、浅灰底。 */
:root {
  --bg: #F3F5F4; --surface: #FFFFFF; --sunk: #EEF2F1; --line: #DDE4E2; --line-strong: #CBD6D3;
  --fg: #16201E; --fg2: #2E3B38; --muted: #5B6B67;
  --accent: #0E6B61; --accent-hover: #09514A; --accent-soft: #E1F0EE;
  --ok-bg: #E3F4E7; --ok-fg: #145A2A; --warn-bg: #FBF0D9; --warn-fg: #7A4A00; --err-bg: #FDE8E6; --err-fg: #8E1B12;
  --c-surg-bg: #CDEBB5; --c-surg-fg: #2F5D12; --c-lab-bg: #F9D9B5; --c-lab-fg: #7A4209;
  --c-rest-bg: #D6E6F6; --c-rest-fg: #1F4E79; --c-off-fg: #B42318; --c-laser-bg: #E7E0F7; --c-laser-fg: #4A2F86;
  --c-leave-bg: #E4E6E5; --c-leave-fg: #3D4846; --c-nurse-bg: #F8D9E6; --c-nurse-fg: #7A1F4A; --c-night-bg: #22324A;
  --radius: 14px; --shadow: 0 1px 2px rgba(22,32,30,.06);
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 var(--font); -webkit-text-size-adjust: 100%; }
body { font-variant-numeric: tabular-nums; }
a { color: var(--accent); }
button { font: inherit; color: inherit; }
h1 { margin: 0; font-size: 22px; font-weight: 700; text-wrap: balance; }
h2 { margin: 0; font-size: 16px; font-weight: 700; }
[hidden] { display: none !important; }

#view { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(84px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 12px; }
#view.wide { max-width: none; }
.loading, .empty { color: var(--muted); text-align: center; padding: 32px 0; }
.page-head { display: flex; flex-direction: column; gap: 2px; padding: 4px 4px 4px; }
.page-head .sub { font-size: 13px; color: var(--muted); }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.card.tinted { background: var(--accent-soft); box-shadow: none; }
.card.ok { background: var(--ok-bg); box-shadow: none; }
.card.err { background: var(--err-bg); box-shadow: none; }
.card-title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card-title .meta { font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

.btn { height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: var(--fg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--err-fg); border-color: #F1B8B2; }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, .pill:focus-visible, .day:focus-visible, td.c:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btns { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.pill { height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-size: 13px; }
.pill[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }

.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.tag.ok { background: var(--ok-bg); color: var(--ok-fg); }
.tag.warn { background: var(--warn-bg); color: var(--warn-fg); }
.tag.err { background: var(--err-bg); color: var(--err-fg); }
.tag.plain { background: var(--sunk); color: var(--muted); }

.chip { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; height: 26px; padding: 0 8px; border-radius: 6px; font-size: 13px; font-weight: 500; white-space: nowrap; background: var(--surface); border: 1px solid var(--line-strong); }
.chip.empty { border-style: dashed; color: var(--muted); }
.c-surg { background: var(--c-surg-bg); color: var(--c-surg-fg); border-color: transparent; }
.c-lab { background: var(--c-lab-bg); color: var(--c-lab-fg); border-color: transparent; }
.c-rest { background: var(--c-rest-bg); color: var(--c-rest-fg); border-color: transparent; }
.c-comp { background: var(--c-rest-bg); color: var(--c-rest-fg); border-color: var(--c-rest-fg); font-weight: 700; }
.c-off { background: var(--c-rest-bg); color: var(--c-off-fg); border-color: transparent; font-weight: 700; }
.c-laser { background: var(--c-laser-bg); color: var(--c-laser-fg); border-color: transparent; }
.c-leave { background: var(--c-leave-bg); color: var(--c-leave-fg); border-color: transparent; }
.c-nurse { background: var(--c-nurse-bg); color: var(--c-nurse-fg); border-color: transparent; }
.c-meet { background: var(--err-bg); color: var(--c-off-fg); border-color: transparent; }
.c-night { background: var(--c-night-bg); color: #fff; border-color: transparent; }

.list { display: flex; flex-direction: column; }
.list > .item { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--sunk); min-width: 0; }
.list > .item:first-child { border-top: 0; }
.item .nm { width: 64px; flex: none; font-size: 14px; }
.item .d { width: 76px; flex: none; font-size: 14px; color: var(--fg2); }
.item .note { font-size: 12px; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--surface); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.stat b { font-size: 22px; }
.stat span { font-size: 12px; color: var(--muted); }
.stat.err { background: var(--err-bg); color: var(--err-fg); } .stat.err span { color: var(--err-fg); }
.stat.ok { background: var(--ok-bg); color: var(--ok-fg); } .stat.ok span { color: var(--ok-fg); }

.steps { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.step { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); text-align: center; }
.step i { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-style: normal; font-size: 12px; font-weight: 700; background: var(--sunk); }
.step.done i { background: var(--accent); color: #fff; }
.step.cur { color: var(--fg); font-weight: 700; } .step.cur i { background: var(--surface); color: var(--accent); border: 2px solid var(--accent); }

.bar { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 8px; align-items: center; font-size: 13px; }
.track { height: 10px; background: var(--sunk); border-radius: 5px; overflow: hidden; }
.fill { height: 10px; background: var(--accent); border-radius: 5px; }

.daystrip { display: grid; grid-template-columns: 28px repeat(7, minmax(0, 1fr)) 28px; gap: 4px; align-items: center; }
.daystrip button { height: 52px; border-radius: 10px; border: 0; background: var(--surface); cursor: pointer; font-size: 13px; line-height: 1.3; }
.daystrip button[aria-selected="true"] { background: var(--accent); color: #fff; font-weight: 700; }
.daystrip .arrow { background: transparent; border: 0; padding: 0; font-size: 20px; color: var(--muted); min-width: 0; }

.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; text-align: center; }
.cal .wd { font-size: 12px; color: var(--muted); padding-bottom: 4px; }
.day { height: 40px; border-radius: 8px; border: 0; background: transparent; cursor: pointer; font-size: 14px; position: relative; }
.day.we { color: var(--muted); }
.day.has::after { content: ""; position: absolute; left: 50%; bottom: 5px; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--warn-fg); }
.day.sel { background: var(--accent); color: #fff; }
.day.inrange { background: var(--accent-soft); }
.day:disabled { visibility: hidden; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea { height: 42px; border: 1px solid var(--line-strong); border-radius: 10px; padding: 0 12px; font: inherit; font-size: 15px; color: var(--fg); background: var(--surface); min-width: 0; }
.field textarea { height: 72px; padding: 8px 12px; resize: vertical; }

.issues { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.issues li { list-style: none; display: flex; gap: 8px; align-items: flex-start; }
.issues ul { margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding-bottom: env(safe-area-inset-bottom, 0px); z-index: 10; }
.tabbar a { height: 56px; display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--muted); text-decoration: none; }
.tabbar a[aria-current="page"] { color: var(--accent); font-weight: 700; box-shadow: inset 0 3px 0 var(--accent); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--sunk); border-radius: 12px; padding: 3px; gap: 3px; }
.seg a { height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 9px; font-size: 14px; color: var(--muted); text-decoration: none; }
.seg a[aria-current="page"] { background: var(--surface); color: var(--fg); font-weight: 600; box-shadow: var(--shadow); }

.toast { position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: #22302D; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 30; max-width: calc(100% - 32px); }
.sheet { position: fixed; inset: 0; background: rgba(22,32,30,.35); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet > .panel { background: var(--surface); width: 100%; max-width: 560px; border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 12px; max-height: 80vh; overflow: auto; }

/* 整月排班表 */
.scroller { overflow-x: auto; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
table.grid { border-collapse: collapse; font-size: 13px; min-width: 100%; }
.grid th, .grid td { border: 1px solid var(--line); height: 30px; padding: 0 3px; text-align: center; white-space: nowrap; }
.grid th { font-weight: 500; background: var(--sunk); }
.grid .name { position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 64px; font-weight: 500; }
.grid th.name { background: var(--sunk); }
.grid td.c { min-width: 38px; }
.grid td.c.edit { cursor: pointer; }
.grid td.c.edited { box-shadow: inset 0 0 0 2px #E8B931; }
.grid td.c.locked { box-shadow: inset 0 0 0 2px var(--accent); background-image: linear-gradient(225deg, var(--accent) 5px, transparent 5px); }
.grid td.c.changed { outline: 2px dashed #2E9E5B; outline-offset: -4px; }
.lock-bar { display: flex; flex-direction: column; gap: 10px; }
.lock-word { color: var(--accent); font-weight: 500; }
.lock-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.grid tr.line td { font-weight: 500; }
.grid tr.blank td { height: 14px; border-left: 0; border-right: 0; }
.grid tr.gap td { border: 0; height: 12px; background: var(--bg); }
.grid th.bad { color: var(--err-fg); box-shadow: inset 0 -3px 0 var(--err-fg); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--muted); }

@media (min-width: 900px) {
  #view.wide { padding-left: 24px; padding-right: 24px; }
}

/* 规则页：大白话的现行规则 */
.rule-sec { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.rule-sec + .rule-sec { border-top: 1px solid var(--sunk); padding-top: 12px; }
.rule-sec-t { font-size: 12px; color: var(--muted); letter-spacing: .05em; }
.rule { display: flex; gap: 8px; align-items: baseline; font-size: 14px; line-height: 1.6; }
.rule .tag { flex: none; height: 20px; }

/* 排班页：电脑上左边进度和检查、右边整月表；手机上上下排 */
.sched-layout { display: grid; gap: 12px; align-items: start; }
.sched-side, .sched-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
@media (min-width: 1100px) { .sched-layout { grid-template-columns: 360px minmax(0, 1fr); } }
details.card > summary { cursor: pointer; list-style-position: inside; }
