:root {
  --brand: #0b5fbe;
  --brand-2: #1a7fd4;
  --brand-soft: #eaf3fd;
  --teal: #0f9488;
  --ink: #1b2434;
  --muted: #6b7789;
  --line: #e2e8f2;
  --bg: #f3f6fb;
  --card: #fff;
  --red: #d92d20;
  --red-soft: #fef3f2;
  --amber: #b54708;
  --amber-soft: #fffaeb;
  --green: #067647;
  --green-soft: #ecfdf3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 14px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  overflow-x: clip; /* 防止宽表/长内容撑出横向溢出导致整页缩放 */
}

a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ============ 顶栏 ============ */
.topbar {
  background: linear-gradient(100deg, #0a4f9e 0%, #0b5fbe 45%, #1180c9 100%);
  color: #fff;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 10px rgba(11, 95, 190, .25);
}
.topbar-inner { max-width: 1440px; margin: 0 auto; display: flex; align-items: center; gap: 18px; height: 60px; }
.logo { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; letter-spacing: .5px; white-space: nowrap; }
.logo .mark {
  width: 30px; height: 30px; border-radius: 8px; background: rgba(255, 255, 255, .18);
  display: grid; place-items: center; font-size: 16px;
}
.logo small { display: block; font-size: 11px; font-weight: 400; opacity: .8; letter-spacing: 0; }
.nav { display: flex; gap: 4px; margin-left: 10px; flex: 1; }
.nav button {
  background: transparent; border: 0; color: rgba(255, 255, 255, .82); padding: 8px 14px;
  border-radius: 8px; font-size: 14px; position: relative;
}
.nav button:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.nav button.on { background: rgba(255, 255, 255, .95); color: var(--brand); font-weight: 600; }
.nav .dot {
  position: absolute; top: 3px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px;
  background: #ff4d4f; color: #fff; border-radius: 9px; font-size: 11px; line-height: 16px; font-weight: 600;
}

.role-switch { display: flex; align-items: center; gap: 8px; }
.role-switch .lbl { font-size: 12px; opacity: .85; }
.role-pills { display: flex; background: rgba(0, 0, 0, .16); border-radius: 8px; padding: 3px; gap: 2px; }
.role-pills button {
  border: 0; background: transparent; color: rgba(255, 255, 255, .85); padding: 5px 12px;
  border-radius: 6px; font-size: 13px;
}
.role-pills button.on { background: #fff; color: var(--brand); font-weight: 600; }

/* ============ 布局 ============ */
.wrap { max-width: 1440px; margin: 0 auto; padding: 18px 20px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 19px; }
.page-head p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }

/* ============ 统计（紧凑、单行、可点击过滤） ============ */
.stats { display: flex; gap: 8px; flex-wrap: nowrap; overflow-x: auto; margin-bottom: 14px; -webkit-overflow-scrolling: touch; }
.stat {
  flex: 1 1 0; min-width: 116px; cursor: pointer; user-select: none;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; box-shadow: var(--shadow); position: relative; overflow: hidden;
  transition: .15s; display: flex; flex-direction: column; justify-content: center;
}
.stat:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(16, 24, 40, .10); border-color: #c9dcf5; }
.stat:active { transform: translateY(0); }
.stat:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.stat b { display: block; font-size: 21px; line-height: 1.15; font-weight: 700; }
.stat span { color: var(--muted); font-size: 12px; }
.stat.on { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(11, 95, 190, .30), var(--shadow); }
.stat.red b { color: var(--red); }
.stat.green b { color: var(--green); }
.stat.blue b { color: var(--brand); }
.stat.amber b { color: var(--amber); }
.stat::after { content: ''; position: absolute; right: -14px; top: -14px; width: 46px; height: 46px; border-radius: 50%; background: var(--brand-soft); opacity: .5; }
.stat.red::after { background: var(--red-soft); }
.stat.green::after { background: var(--green-soft); }
.stat.amber::after { background: var(--amber-soft); }

/* ============ 工具条 ============ */
.toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.toolbar input[type=search], .toolbar select {
  border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; font-size: 13.5px; background: #fff; color: var(--ink);
}
.toolbar input[type=search] { min-width: 230px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: #fff; padding: 6px 12px; border-radius: 20px; font-size: 13px; color: var(--muted);
}
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 500; }
.chip.alert.on { background: var(--red); border-color: var(--red); }
.chip.ct-chip { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; }
.chip.ct-WB.on { background: #d92d20; border-color: #d92d20; }
.chip.ct-FW.on { background: #f79009; border-color: #f79009; }
.chip.ct-ZC.on { background: #12b76a; border-color: #12b76a; }
.spacer { flex: 1; }

/* ============ 按钮 ============ */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 16px; border-radius: 8px; font-size: 13.5px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px; transition: .15s;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #0a54a8; color: #fff; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger:hover { background: #b42318; color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 11px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ============ 卡片列表 ============ */
.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.ccard {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; cursor: pointer; transition: .18s; position: relative;
}
.ccard:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(16, 24, 40, .10); border-color: #c9dcf5; }
.ccard.alert { border-color: #fda29b; }
.ccard.alert::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--red); }
.ccard.closed { opacity: .92; }
.ccard-head { padding: 12px 14px; border-bottom: 1px dashed var(--line); display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.ccard-head-side { display: flex; align-items: flex-start; gap: 6px; flex: 0 0 auto; }
.ccard-del { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); background: #fff; color: #98a2b3; border-radius: 6px; cursor: pointer; padding: 0; flex: 0 0 auto; transition: all .15s; }
.ccard-del:hover { color: #d92d20; border-color: #fda29b; background: #fef3f2; }
.ccard-share { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); background: #fff; color: #98a2b3; border-radius: 6px; cursor: pointer; padding: 0; flex: 0 0 auto; transition: all .15s; }
.ccard-share:hover { color: #0b5fbe; border-color: #bcd8f7; background: #eef4ff; }
.ccard-no { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; color: var(--muted); }
.ccard-name { font-size: 16px; font-weight: 700; margin-top: 2px; }
.ccard-name small { font-weight: 400; color: var(--muted); font-size: 12.5px; margin-left: 6px; }
.ccard-body { padding: 10px 14px 12px; }
.ccard-row { display: flex; gap: 6px; font-size: 13px; color: #46526a; margin-bottom: 4px; }
.ccard-row .k { color: var(--muted); flex: 0 0 62px; }
.ccard-row .v { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ccard-foot { padding: 9px 14px; background: #fafbfd; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; color: var(--muted); }

/* ---------- 长条型紧凑卡片：两行（姓名/性别/年龄 + 病种/居委/发布日期），宽度约原 1/3 ---------- */
.ccard.strip { padding: 0; }
.ccard.strip.has-side .cs-l1, .ccard.strip.has-side .cs-l2 { padding-right: 50px; }
.ccard.strip .cs-side { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; z-index: 2; }
.ccard.strip .cs-side .ccard-del, .ccard.strip .cs-side .ccard-share { width: 20px; height: 20px; }
.ccard.strip .cs-l1 { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; padding: 9px 10px 7px; border-bottom: 1px dashed var(--line); }
.ccard.strip .cs-l2 { display: flex; gap: 8px 16px; flex-wrap: wrap; padding: 7px 10px 9px; font-size: 12.5px; color: #46526a; }
.ccard.strip .cs-f { display: inline-flex; align-items: baseline; gap: 4px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ccard.strip .cs-f i { color: var(--muted); font-style: normal; font-size: 11.5px; flex: 0 0 auto; }
.ccard.strip .cs-f b { font-weight: 600; color: #344054; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ccard.strip .ccard-name { font-size: 15px; }
.ccard.strip .ccard-name small { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 4px; }
.ccard.strip .ccard-no { flex: 0 0 auto; }

/* ============ 病例分类底色皮肤 WB=红 / FW=黄 / ZC=绿 ============ */
:root {
  --wb: #d92d20; --wb-bg: #fef3f2; --wb-hd: #fee4e2; --wb-bd: #fda29b;
  --fw: #dc6803; --fw-bg: #fffaeb; --fw-hd: #fef0c7; --fw-bd: #fec84b;
  --zc: #067647; --zc-bg: #ecfdf3; --zc-hd: #d1fadf; --zc-bd: #6ce9a6;
}
.ccard.skin-WB { background: linear-gradient(180deg, var(--wb-bg) 0%, #fff 76%); border-color: var(--wb-bd); }
.ccard.skin-FW { background: linear-gradient(180deg, var(--fw-bg) 0%, #fff 76%); border-color: var(--fw-bd); }
.ccard.skin-ZC { background: linear-gradient(180deg, var(--zc-bg) 0%, #fff 76%); border-color: var(--zc-bd); }
.ccard.skin-WB .ccard-head { background: var(--wb-hd); border-bottom-color: var(--wb-bd); }
.ccard.skin-FW .ccard-head { background: var(--fw-hd); border-bottom-color: var(--fw-bd); }
.ccard.skin-ZC .ccard-head { background: var(--zc-hd); border-bottom-color: var(--zc-bd); }
.ccard.skin-WB .ccard-foot { background: #fff7f6; border-top-color: #fecdca; }
.ccard.skin-FW .ccard-foot { background: #fffcf2; border-top-color: #fedf89; }
.ccard.skin-ZC .ccard-foot { background: #f4fdf7; border-top-color: #a6f4c5; }
.ccard.skin-WB::after, .ccard.skin-FW::after, .ccard.skin-ZC::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
}
.ccard.skin-WB::after { background: var(--wb); }
.ccard.skin-FW::after { background: #f79009; }
.ccard.skin-ZC::after { background: #12b76a; }
.ccard.skin-WB:hover { border-color: var(--wb); }
.ccard.skin-FW:hover { border-color: #f79009; }
.ccard.skin-ZC:hover { border-color: #12b76a; }

/* 详情页 / 新建页 卡片底色 */
.case-skin.skin-WB { background: linear-gradient(180deg, var(--wb-bg) 0%, #fff 66%); border-color: var(--wb-bd); }
.case-skin.skin-FW { background: linear-gradient(180deg, var(--fw-bg) 0%, #fff 66%); border-color: var(--fw-bd); }
.case-skin.skin-ZC { background: linear-gradient(180deg, var(--zc-bg) 0%, #fff 66%); border-color: var(--zc-bd); }
.case-skin.skin-WB .panel-hd { background: var(--wb-hd); border-bottom-color: var(--wb-bd); }
.case-skin.skin-FW .panel-hd { background: var(--fw-hd); border-bottom-color: var(--fw-bd); }
.case-skin.skin-ZC .panel-hd { background: var(--zc-hd); border-bottom-color: var(--zc-bd); }
.case-skin.step-panel.skin-WB { border-left-color: var(--wb); }
.case-skin.step-panel.skin-FW { border-left-color: #f79009; }
.case-skin.step-panel.skin-ZC { border-left-color: #12b76a; }
.case-skin { transition: background .25s, border-color .25s; }

/* 分类标签 */
.ct-tag {
  display: inline-block; font-family: ui-monospace, Menlo, Consolas, monospace;
  font-weight: 800; font-size: 11px; letter-spacing: .6px; line-height: 1.6;
  padding: 1px 7px; border-radius: 5px; margin-right: 6px; color: #fff; vertical-align: middle;
}
.ct-tag.ct-WB { background: var(--wb); }
.ct-tag.ct-FW { background: #f79009; }
.ct-tag.ct-ZC { background: #12b76a; }
.ct-tag.lg { font-size: 14px; padding: 3px 11px; border-radius: 8px; margin-right: 2px; }

/* 分类单选（带色块） */
.radio-row.ct-row label { padding-left: 26px; position: relative; }
.radio-row.ct-row label::before {
  content: ''; position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  width: 11px; height: 11px; border-radius: 3px;
}
.radio-row.ct-row label.ct-WB::before { background: var(--wb); }
.radio-row.ct-row label.ct-FW::before { background: #f79009; }
.radio-row.ct-row label.ct-ZC::before { background: #12b76a; }
.radio-row.ct-row label em { font-style: normal; color: var(--muted); font-size: 11.5px; margin-left: 5px; }
.radio-row.ct-row label.ct-WB.on { border-color: var(--wb); background: var(--wb-bg); color: var(--wb); }
.radio-row.ct-row label.ct-FW.on { border-color: #f79009; background: var(--fw-bg); color: #b54708; }
.radio-row.ct-row label.ct-ZC.on { border-color: #12b76a; background: var(--zc-bg); color: var(--zc); }
.radio-row.ct-row label.on em { color: inherit; opacity: .75; }
.ct-hint { font-weight: 400; color: var(--muted); font-size: 11.5px; margin-left: 8px; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.b1 { background: var(--brand-soft); color: var(--brand); }
.badge.b2 { background: #f0f4ff; color: #3538cd; }
.badge.b3 { background: #f4f3ff; color: #6941c6; }
.badge.b4 { background: var(--amber-soft); color: var(--amber); }
.badge.done { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.gray { background: #f2f4f7; color: #667085; }

/* 迷你进度 */
.mini-steps { display: flex; gap: 4px; margin-top: 10px; }
.mini-steps i {
  flex: 1; height: 5px; border-radius: 3px; background: #e6ebf3; display: block;
}
.mini-steps i.ok { background: var(--teal); }
.mini-steps i.cur { background: var(--brand); }
.mini-steps i.bad { background: var(--red); }

/* ============ 处理卡详情 ============ */
.detail { display: grid; grid-template-columns: 1fr; gap: 14px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-hd { padding: 13px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.panel-hd h3 { margin: 0; font-size: 15.5px; }
.panel-bd { padding: 16px 18px; }

.case-hero { background: linear-gradient(180deg, #fff 0%, #fbfdff 100%); }
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; padding: 16px 18px 8px; }
.hero-title { font-size: 21px; font-weight: 700; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hero-sub { color: var(--muted); font-size: 13px; margin-top: 4px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* 步骤条 */
.stepbar { display: flex; padding: 6px 18px 18px; gap: 0; overflow-x: auto; }
.stepbar .st { flex: 1; min-width: 150px; position: relative; padding-top: 26px; text-align: center; }
.stepbar .st::before {
  content: ''; position: absolute; top: 12px; left: 0; right: 0; height: 3px; background: #e6ebf3;
}
.stepbar .st:first-child::before { left: 50%; }
.stepbar .st:last-child::before { right: 50%; }
.stepbar .st.ok::before, .stepbar .st.cur::before { background: linear-gradient(90deg, var(--teal), var(--teal)); }
.stepbar .st .num {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 3px solid #e6ebf3;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--muted); z-index: 2;
}
.stepbar .st.ok .num { background: var(--teal); border-color: var(--teal); color: #fff; }
.stepbar .st.cur .num { background: #fff; border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 4px rgba(11, 95, 190, .14); }
.stepbar .st.bad .num { background: var(--red); border-color: var(--red); color: #fff; }
.stepbar .st .tt { font-size: 13.5px; font-weight: 600; }
.stepbar .st .dd { font-size: 12px; color: var(--muted); }
.stepbar .st.cur .tt { color: var(--brand); }
.stepbar .st.bad .tt { color: var(--red); }

/* 环节区块 */
.step-panel { border-left: 4px solid transparent; }
.step-panel.active { border-left-color: var(--brand); }
.step-panel.done { border-left-color: var(--teal); }
.step-panel.locked { border-left-color: #dfe5ee; background: #fcfdfe; }
.step-panel.warn { border-left-color: var(--red); }
.step-no {
  width: 24px; height: 24px; border-radius: 6px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: 12.5px; font-weight: 700; flex: none;
}
.step-panel.done .step-no { background: var(--teal); }
.step-panel.locked .step-no { background: #b7c1d1; }
.step-panel.warn .step-no { background: var(--red); }
.dept-tag { background: #eef2f7; color: #475467; border-radius: 5px; padding: 2px 8px; font-size: 12px; font-weight: 600; }
.dept-tag.shewei { background: #e7f0fb; color: #0b5fbe; }
.dept-tag.juwei { background: #e8f7f2; color: #0f766e; }
.dept-tag.xiaodu { background: #f4edfd; color: #7839ee; }

.locked-tip, .role-tip {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 8px;
  background: #f7f9fc; color: var(--muted); font-size: 13px; border: 1px dashed var(--line);
}
.role-tip { background: var(--brand-soft); border-color: #bcd8f7; color: #0a4f9e; }
.role-tip .btn { margin-left: auto; }

/* 只读摘要 */
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px 20px; }
.kv .item { border-bottom: 1px dotted #e8edf5; padding-bottom: 6px; }
.kv .item.full { grid-column: 1 / -1; }
.kv .k { color: var(--muted); font-size: 12px; display: block; }
.kv .v { font-size: 13.5px; word-break: break-all; }
.kv .v.em { font-weight: 600; }
.kv .v.red { color: var(--red); font-weight: 700; }
.kv .v.green { color: var(--green); font-weight: 600; }

/* 表单 */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.fld { display: flex; flex-direction: column; gap: 5px; }
.fld.full { grid-column: 1 / -1; }
.fld > span.lb { font-size: 12.5px; color: #475467; font-weight: 500; }
.fld > span.lb i { color: var(--red); font-style: normal; margin-left: 2px; }
.fld input, .fld select, .fld textarea {
  border: 1px solid #d5dce7; border-radius: 7px; padding: 8px 10px; font-size: 13.5px;
  font-family: inherit; background: #fff; color: var(--ink); width: 100%;
}
.fld input:focus, .fld select:focus, .fld textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(11, 95, 190, .12);
}
.fld textarea { resize: vertical; min-height: 62px; }
.radio-row { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-row label {
  border: 1px solid #d5dce7; border-radius: 7px; padding: 7px 13px; font-size: 13.5px; cursor: pointer; background: #fff;
  display: inline-flex; align-items: center; gap: 6px; user-select: none;
}
.radio-row label:hover { border-color: var(--brand); }
.radio-row input { display: none; }
.radio-row label.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.radio-row label.on.no { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.form-actions { display: flex; gap: 10px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); flex-wrap: wrap; align-items: center; }

/* 智能识别录入 */
.paste-panel {
  background: linear-gradient(180deg, #eff7ff 0%, #fbfdff 100%);
  border: 1px dashed #9cc4ee; border-radius: 10px; padding: 14px 16px; margin-bottom: 18px;
}
.paste-panel .pp-hd { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; }
.paste-panel .pp-ico { font-size: 20px; line-height: 1.2; }
.paste-panel .pp-hd b { font-size: 14.5px; color: #0a4f9e; }
.paste-panel .pp-hd small { display: block; color: #547296; font-size: 12.5px; margin-top: 2px; }
.paste-panel textarea {
  width: 100%; border: 1px solid #bdd6f2; border-radius: 8px; padding: 10px 12px;
  font-size: 13.5px; font-family: inherit; line-height: 1.7; background: #fff; color: var(--ink); resize: vertical;
}
.paste-panel textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(11, 95, 190, .12); }
.paste-panel .pp-actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.paste-panel .pp-tip { color: #6b7789; font-size: 12px; }
.paste-panel .pp-tip.ok { color: var(--green); font-weight: 600; }
.paste-panel .pp-tip.err { color: var(--red); font-weight: 600; }

@keyframes fillFlash {
  0% { background: #fff3c4; box-shadow: 0 0 0 3px rgba(240, 180, 41, .25); }
  100% { background: #fff; box-shadow: none; }
}
.fld.just-filled input, .fld.just-filled select, .fld.just-filled textarea { animation: fillFlash 1.8s ease-out; border-color: #f0b429; }
.fld.just-filled > span.lb::after { content: ' ✓ 已识别'; color: var(--teal); font-size: 11px; font-weight: 600; }
.m-row.just-filled td { animation: fillFlash 1.8s ease-out; }

/* 原文留档卡片 */
.raw-card {
  position: relative; background: #fbfcfe; border: 1px solid var(--line); border-left: 4px solid var(--brand);
  border-radius: 8px; padding: 12px 14px;
}
.raw-head { display: flex; gap: 8px; justify-content: flex-end; margin-bottom: 8px; }
.raw-card .raw-text { white-space: pre-wrap; word-break: break-word; font-size: 13.5px; line-height: 1.85; color: #2b3648; max-height: 5.2em; overflow: hidden; position: relative; transition: max-height .2s ease; }
.raw-card.open .raw-text { max-height: 60vh; overflow: auto; }
.raw-card .raw-text::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2.2em; background: linear-gradient(180deg, rgba(251,252,254,0), #fbfcfe); pointer-events: none; }
.raw-card.open .raw-text::after { display: none; }
.raw-card .raw-copy, .raw-card .raw-toggle { position: static; }

/* 同住人表 */
.mtable { width: 100%; border-collapse: collapse; margin-top: 6px; }
.mtable th, .mtable td { border: 1px solid var(--line); padding: 6px 8px; font-size: 13px; text-align: left; }
.mtable th { background: #f7f9fc; color: #475467; font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.mtable td input, .mtable td select { border: 1px solid #dde3ec; border-radius: 6px; padding: 5px 7px; font-size: 13px; width: 100%; font-family: inherit; }
.mtable tr.no-blood { background: var(--red-soft); }
.mtable .nm { font-weight: 600; }
.sec-title { font-size: 13.5px; font-weight: 700; margin: 18px 0 4px; display: flex; align-items: center; gap: 8px; }
.sec-title::before { content: ''; width: 3px; height: 14px; background: var(--brand); border-radius: 2px; }
.sec-title small { font-weight: 400; color: var(--muted); font-size: 12px; }

/* 预警横幅 */
.alert-banner {
  background: linear-gradient(92deg, #fff1f0 0%, #fff6f5 100%); border: 1px solid #fda29b;
  border-left: 5px solid var(--red); border-radius: var(--radius); padding: 14px 18px;
  display: flex; gap: 14px; align-items: flex-start;
}
.alert-banner .ico { font-size: 22px; line-height: 1; animation: pulse 1.6s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .55; transform: scale(.92); } }
.alert-banner h4 { margin: 0 0 4px; color: var(--red); font-size: 15px; }
.alert-banner p { margin: 0; font-size: 13px; color: #7a271a; }
.alert-banner .who { font-weight: 700; }

/* 时间线 */
.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding-bottom: 14px; }
.tl-item::before {
  content: ''; position: absolute; left: -18px; top: 6px; width: 9px; height: 9px; border-radius: 50%;
  background: #fff; border: 2px solid var(--brand);
}
.tl-item.sys::before { border-color: var(--red); background: var(--red); }
.tl-item .t { font-size: 12px; color: var(--muted); font-family: ui-monospace, Menlo, monospace; }
.tl-item .c { font-size: 13.5px; }
.tl-item .c b { color: var(--ink); }

.mob-item { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; background: #fcfdff; }
.mob-item .hd { display: flex; gap: 10px; align-items: center; font-size: 13px; margin-bottom: 4px; flex-wrap: wrap; }
.mob-item .hd b { font-size: 13.5px; }

/* ============ 台账 ============ */
.ledger-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.ledger-scroll { overflow: auto; max-height: calc(100vh - 300px); }
table.ledger { border-collapse: separate; border-spacing: 0; font-size: 12.5px; white-space: nowrap; }
table.ledger th, table.ledger td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 7px 10px; text-align: left; }
table.ledger thead th {
  position: sticky; top: 0; z-index: 3; background: #f1f5fb; color: #344054; font-weight: 600;
  border-bottom: 2px solid #d8e2f0;
}
table.ledger tbody tr:hover td { background: #f8fbff; }
table.ledger tbody tr.alert td { background: var(--red-soft); }
table.ledger tbody tr.alert:hover td { background: #fee9e7; }
table.ledger td.sticky, table.ledger th.sticky {
  position: sticky; left: 0; z-index: 2; background: #fff; font-family: ui-monospace, Menlo, monospace; font-weight: 600;
}
table.ledger thead th.sticky { z-index: 4; background: #f1f5fb; }
table.ledger tbody tr.alert td.sticky { background: #fee4e2; }
table.ledger td.wrap-cell { white-space: normal; min-width: 220px; }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 8px; opacity: .5; }

/* toast */
#toast {
  position: fixed; top: 76px; left: 50%; transform: translateX(-50%) translateY(-16px);
  background: #1b2434; color: #fff; padding: 10px 20px; border-radius: 8px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 999; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--red); }
#toast.ok { background: #067647; }

.modal-mask {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .45); z-index: 200;
  display: grid; place-items: center; padding: 20px;
}
.modal { background: #fff; border-radius: 12px; width: min(520px, 100%); box-shadow: 0 20px 40px rgba(0, 0, 0, .2); overflow: hidden; }
.modal h3 { margin: 0; padding: 15px 18px; border-bottom: 1px solid var(--line); font-size: 16px; }
.modal .mbd { padding: 16px 18px; }
.modal .mft { padding: 12px 18px; background: #fafbfd; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
/* 分享填写链接弹窗 */
.share-row { padding: 12px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 10px; background: #fafbfd; }
.share-row .sr-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.share-row .sr-desc { color: #6b7789; font-size: 12.5px; }
.share-row .sr-link { display: flex; margin-bottom: 8px; }
.share-row .sr-input { flex: 1; width: 100%; font-size: 12px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: #46526a; }
/* 分享视角横幅 */
.share-banner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin-bottom: 12px; background: linear-gradient(92deg, #eef4ff, #f7faff); border: 1px solid #c7d7fe; border-left: 4px solid #0b5fbe; border-radius: 10px; font-size: 13.5px; color: #1d3a73; }
.share-banner b { color: #0b3f8f; }
.share-banner .btn { margin-left: auto; }

/* ============ 移动端适配 ============ */
@media (max-width: 900px) {
  .wrap { padding: 12px 12px 56px; }
  .stats { gap: 8px; }
  .stat { padding: 8px 10px; min-width: 104px; }
  .stat b { font-size: 19px; }
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

  /* 顶栏：logo 与身份药丸同行自适应，导航独占一行并可横向滚动 */
  .topbar { padding: 4px 12px; }
  .topbar-inner { height: auto; flex-wrap: wrap; align-items: center; gap: 6px; padding: 4px 0; }
  .logo { flex: 1 1 auto; min-width: 0; font-size: 15px; }
  .logo small { display: none; }
  .role-switch { order: 2; flex: 0 0 auto; max-width: 100%; }
  .role-switch .lbl { display: none; }
  .role-pills { padding: 2px; gap: 2px; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .role-pills button { padding: 5px 10px; font-size: 12.5px; flex: 0 0 auto; }
  .nav { order: 3; flex: 0 0 100%; min-width: 100%; width: 100%; margin-left: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .nav button { white-space: nowrap; }

  .toolbar { gap: 8px; }
  .toolbar input[type=search], .toolbar select { flex: 1 1 100%; min-width: 0; }
  .toolbar .chips { width: 100%; }
  .toolbar .spacer { display: none; }
  .panel-hd { padding: 11px 13px; }
  .panel-bd { padding: 13px 14px; }
  .hero-top { padding: 12px 14px 6px; }
  .stepbar { padding: 6px 14px 16px; }
  .ccard-row .v { white-space: normal; }
}

@media (max-width: 600px) {
  body { font-size: 13.5px; }
  .card-grid { grid-template-columns: 1fr; }
  .page-head { display: block; }
  .page-head .btn.primary { width: 100%; margin-top: 10px; justify-content: center; }
  .page-head h2 { font-size: 17px; }
  .stats { gap: 6px; }
  .ccard-head { padding: 11px 12px; }
  .ccard-body { padding: 9px 12px 11px; }
  .ccard-row { font-size: 12.5px; }
  .ccard-row .k { flex-basis: 56px; }
  .hero-title { font-size: 18px; }
  .hero-sub { font-size: 12px; }
  .hero-actions .btn { flex: 1 1 auto; justify-content: center; }
  .alert-banner { flex-wrap: wrap; }
  .alert-banner .btn { width: 100%; }
  .role-tip { flex-wrap: wrap; }
  .role-tip .btn { margin-left: 0; width: 100%; }
  .share-banner { flex-wrap: wrap; }
  .share-banner .btn { margin-left: 0; width: 100%; }
  .modal .mbd { padding: 14px; }
  .ledger-scroll { max-height: calc(100vh - 250px); -webkit-overflow-scrolling: touch; }
  .share-row .sr-link { flex-wrap: wrap; }
  .share-row .sr-input { width: 100%; }
}

@media (max-width: 480px) {
  /* 极窄屏：顶栏纵向堆叠，导航与身份药丸居中并可滚动 */
  .topbar-inner { flex-direction: column; align-items: stretch; gap: 6px; }
  .logo { justify-content: center; font-size: 14px; }
  .role-switch { justify-content: center; order: 2; }
  .role-pills { justify-content: center; }
  .nav { justify-content: flex-start; }
  .stat b { font-size: 20px; }
  .stats { gap: 6px; }
  .ccard-name { font-size: 15px; }
  .sec-title { font-size: 13px; }
  .form-actions .btn { flex: 1 1 auto; justify-content: center; }
}

@media print {
  .topbar, .toolbar, .hero-actions, .form-actions, .no-print { display: none !important; }
  body { background: #fff; }
  .panel { box-shadow: none; border: 1px solid #ccc; page-break-inside: avoid; }
  .ledger-scroll { max-height: none; overflow: visible; }
  /* 病例分类底色需要跟着打印出来 */
  .ccard, .case-skin, .case-skin .panel-hd, .ct-tag, .ccard-head, .ccard-foot {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
}
