:root {
  --bg: #fbf8f3;
  --surface: #ffffff;
  --surface-2: #f6f1ea;
  --line: #e6ddd1;
  --ink: #2b2724;
  --muted: #635a52; /* 대비 4.5:1 이상 */
  --accent: #a9592a;
  --accent-ink: #ffffff;
  --accent-soft: #f6e9de;
  --sel: #3d3530;
  --pending: #fff4d6;
  --pending-line: #e2c27a;
  --warn: #a8552a;
  --warn-soft: #fbece3;
  --ok: #4e7a55;
  --radius: 12px;
  --shadow: none;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: Pretendard, "Pretendard Variable", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.synthetic-banner {
  background: #efe6da;
  color: #5b4a3b;
  font-size: 12px;
  text-align: center;
  padding: 4px 8px;
  letter-spacing: 0.02em;
}
.brand { font-weight: 700; letter-spacing: 0.14em; font-size: 13px; color: var(--accent); }

/* 버튼 */
.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 8px 14px;
  min-height: 40px;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { border-color: #cdbfae; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:disabled { opacity: 0.45; cursor: default; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.small { min-height: 30px; padding: 3px 10px; font-size: 14px; border-radius: 8px; }
.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 14px;
  min-height: 32px;
  line-height: 1.3;
}
.chip.on { background: var(--sel); border-color: var(--sel); color: #fff; }
.chip.pending { background: var(--pending); border-color: var(--pending-line); color: #6b5212; }
.chip.neg.on { background: #5d6b78; border-color: #5d6b78; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ───────── 환자 문진(모바일 우선) ───────── */
body.patient {
  --pt-bg: #faf7f2;
  --pt-surface: #ffffff;
  --pt-fill: #f3ede4;
  --pt-fill-hover: #ede5d9;
  --pt-ink: #2a2623;
  --pt-sub: #62584f;
  --pt-line: #e8dfd3;
  --pt-accent: #b25d27;
  --pt-accent-soft: #f7e8dc;
  --pt-err: #a3441c;
  background: var(--pt-bg);
  color: var(--pt-ink);
  font-size: 16px;
  letter-spacing: -0.005em;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.pt { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.pt-head { position: sticky; top: 0; z-index: 4; display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; height: 52px; padding: 0 8px; background: var(--pt-bg); }
.pt-clinic { text-align: center; font-size: 14px; color: var(--pt-sub); letter-spacing: 0.02em; }
.pt-back { width: 44px; height: 44px; border: 0; background: none; font-size: 28px; line-height: 1; color: var(--pt-ink); border-radius: 50%; }
.pt-back:active { background: var(--pt-fill); }
.pt-count { text-align: right; padding-right: 8px; font-size: 14px; color: var(--pt-sub); font-variant-numeric: tabular-nums; }
.pt-progress { grid-column: 1 / -1; height: 2px; background: var(--pt-line); margin: 0 -8px; align-self: end; }
.pt-progress > i { display: block; height: 100%; background: var(--pt-accent); transition: width 0.25s ease; }
.pt-main { flex: 1; padding: 20px 20px calc(112px + env(safe-area-inset-bottom)); }
.pt-center { display: flex; flex-direction: column; justify-content: center; text-align: center; }
.pt-kicker { margin: 8px 0 10px; font-size: 13px; color: var(--pt-accent); letter-spacing: 0.04em; }
.pt-title { font-size: 21px; line-height: 1.4; font-weight: 600; margin: 4px 0 22px; letter-spacing: -0.02em; }
.pt-title.lg { font-size: 25px; margin-bottom: 10px; }
.pt-lead { color: var(--pt-sub); margin: 0 0 32px; line-height: 1.65; }
.pt-synth { font-size: 13px; color: var(--pt-sub); margin: 24px 0 0; }

/* 질문 */
.pq { margin: 0 0 30px; }
/* 질문 사이를 가는 선으로 나눠 질문과 보기가 섞여 보이지 않게 */
.pq + .pq:not(.tight) { border-top: 1px solid var(--pt-line); padding-top: 26px; }
.pq.tight { margin: -22px 0 30px; }
.pq-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.pq-label { font-size: 18px; font-weight: 700; line-height: 1.45; flex: 1; }
.pq-badge { flex: none; font-size: 13px; font-weight: 500; color: var(--pt-sub); white-space: nowrap; }
.pq-badge.req { color: var(--pt-accent); }
.pq-hint { font-size: 14.5px; color: var(--pt-sub); margin: 0 0 12px; }
.pq-head + .pt-opts, .pq-head + .pt-field, .pq-head + .pt-nrs, .pq-head + .pt-inline, .pq-head + .bm { margin-top: 12px; }
.pq-err { color: var(--pt-err); font-size: 14px; margin: 8px 0 0; }
.pq.has-err .pq-label { color: var(--pt-err); }

.pt-opts { display: grid; grid-template-columns: 1fr; gap: 8px; }
.pt-opts.two { grid-template-columns: 1fr 1fr; }
.pt-opt, .pt-check {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 54px; padding: 12px 14px; border: 1px solid #ebe2d6; border-radius: 12px;
  background: var(--pt-fill); text-align: left; font-size: 16.5px; line-height: 1.35;
  -webkit-tap-highlight-color: transparent; transition: background 0.12s;
}
.pt-opt:active, .pt-check:active { background: var(--pt-fill-hover); }
.pt-opt.on { background: var(--pt-accent-soft); border-color: var(--pt-accent); color: #5a2e12; font-weight: 600; }
.pt-mark { flex: none; width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid #c9bcad; background: var(--pt-surface); position: relative; }
.pt-opt.radio .pt-mark { border-radius: 50%; }
.on > .pt-mark { border-color: var(--pt-accent); background: var(--pt-accent); }
.on > .pt-mark::after { content: ""; position: absolute; left: 6.5px; top: 2.5px; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.pt-check { background: transparent; border-color: transparent; padding: 10px 2px; min-height: 48px; font-weight: 500; }
.pt-check.consent { padding: 14px; background: var(--pt-surface); border: 1px solid var(--pt-line); }
.pt-check.consent.on { border-color: var(--pt-accent); background: var(--pt-accent-soft); }
.pt-details { margin-top: 6px; font-size: 14px; color: var(--pt-sub); }
.pt-details summary { cursor: pointer; padding: 10px 2px; }
.pt-terms { padding: 4px 2px; }
.pt-terms p { margin: 2px 0 6px; line-height: 1.6; }
.pt-draft { font-size: 13px; color: var(--pt-err); }

.pt-field { width: 100%; min-height: 54px; padding: 12px 14px; font-size: 17px; border: 1px solid var(--pt-line); border-radius: 12px; background: var(--pt-surface); }
.pt-field:focus { outline: none; border-color: var(--pt-accent); box-shadow: 0 0 0 3px var(--pt-accent-soft); }
.pt-inline { display: flex; align-items: center; gap: 10px; }
.pt-sub { display: block; font-size: 14.5px; color: var(--pt-sub); margin: 14px 0 6px; }
.pt-opt:focus-visible, .pt-check:focus-visible, .pt-cta:focus-visible, .pt-back:focus-visible, .pt-nrs-b:focus-visible, .bm-chip:focus-visible { outline: 2px solid var(--pt-accent); outline-offset: 2px; }

.pt-nrs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.pt-nrs-b { min-height: 52px; border: 0; border-radius: 12px; background: var(--pt-fill); font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; -webkit-tap-highlight-color: transparent; }
.pt-nrs-b.on { background: var(--pt-accent); color: #fff; }
.pt-nrs-scale { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; color: var(--pt-sub); margin-top: 10px; }
.pt-nrs-scale b { color: var(--pt-accent); font-size: 15px; }

/* 하단 버튼: 안전 영역 고려, 키보드가 열리면 고정 해제 */
.pt-foot { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--pt-bg) 78%, rgba(250, 247, 242, 0)); }
.pt-cta { display: block; width: 100%; max-width: 520px; margin: 0 auto; min-height: 56px; border: 0; border-radius: 14px; background: var(--pt-ink); color: #fff; font-size: 17px; font-weight: 600; letter-spacing: 0.01em; }
.pt-cta:active { background: #45403b; }
.pt-cta:disabled { opacity: 0.55; }
body.kb .pt-foot { position: static; background: none; padding-top: 0; }
body.kb .pt-main { padding-bottom: 16px; }
.pt-alert { background: #fbeee6; color: var(--pt-err); border-radius: 12px; padding: 14px 16px; font-size: 15px; line-height: 1.55; }

/* 완료 */
.pt-done { text-align: center; padding-top: 12vh; }
.pt-done-mark { width: 64px; height: 64px; margin: 0 auto 22px; border-radius: 50%; border: 1.5px solid var(--pt-accent); position: relative; }
.pt-done-mark::after { content: ""; position: absolute; left: 25px; top: 15px; width: 11px; height: 23px; border: solid var(--pt-accent); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.pt-receipt { margin: 0 0 18px; color: var(--pt-sub); }
.pt-receipt b { color: var(--pt-ink); font-size: 22px; margin-left: 4px; font-variant-numeric: tabular-nums; }
.pt-note { font-size: 13px; color: var(--pt-sub); margin: -14px 0 0; }
.pt-kakao { margin: 44px 0 0; padding-top: 22px; border-top: 1px solid var(--pt-line); font-size: 14px; color: var(--pt-sub); }
.pt-kakao p { margin: 0 0 10px; line-height: 1.6; }
.pt-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px; border: 1px solid var(--pt-line); border-radius: 999px; color: var(--pt-ink); text-decoration: none; background: var(--pt-surface); }

/* 불편한 부위 */
.bm-figwrap { display: flex; flex-direction: column; align-items: center; padding: 6px 0 4px; }
.bm-fig { width: min(46vw, 190px); height: auto; display: block; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.bm-body { fill: #ece3d7; }
.bm-spine { fill: none; stroke: #ddd0bf; stroke-width: 1; stroke-linecap: round; }
/* 터치 영역: 평소엔 실루엣만 보이고 흰 가는 선으로 부위 경계만, 선택하면 실루엣 안에서 칠해짐 */
.bm-zone { fill: transparent; stroke: rgba(255, 255, 255, 0.85); stroke-width: 1.4; cursor: pointer; transition: fill 0.12s; }
@media (hover: hover) { .bm-zone:hover { fill: rgba(178, 93, 39, 0.12); } }
.bm-zone.on { fill: #e2a578; }
.bm-zone.primary { fill: var(--pt-accent); }
.bm-side { font-size: 15px; /* 그림 축소(약 0.86배) 후에도 13px 이상 */ fill: var(--pt-sub); }
.bm-cap { font-size: 14px; color: var(--pt-sub); margin: 8px 0 18px; text-align: center; }
.bm .pq-hint { margin-bottom: 8px; }
.bm-group { margin-bottom: 16px; }
.bm-glabel { font-size: 14px; font-weight: 600; color: var(--pt-sub); margin: 0 0 8px; }
.bm-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.bm-btn { flex-direction: column; align-items: flex-start; gap: 6px; min-height: 64px; padding: 10px; font-size: 15px; }
.bm-btn .pt-mark { width: 18px; height: 18px; }
.bm-btn.on > .pt-mark::after { left: 5px; top: 1.5px; width: 4px; height: 9px; }
.bm-name { display: flex; flex-direction: column; line-height: 1.3; word-break: keep-all; }
.bm-name small { font-size: 12px; font-weight: 500; color: var(--pt-accent); }
.bm-primary { margin-top: 24px; }
.bm-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.bm-chip { min-height: 44px; padding: 0 16px; border: 1px solid var(--pt-line); border-radius: 999px; background: var(--pt-surface); font-size: 15px; }
.bm-chip.on { border-color: var(--pt-accent); background: var(--pt-accent); color: #fff; font-weight: 600; }
@media (max-width: 340px) {
  .pt-main { padding-left: 16px; padding-right: 16px; }
  .bm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pt-opts.two { grid-template-columns: 1fr; }
}
@media (min-width: 720px) {
  .pt-main { padding-top: 40px; }
  .pt-title.lg { font-size: 28px; }
}

/* ───────── 직원·의료진 화면 ───────── */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 18px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar { flex-wrap: wrap; row-gap: 6px; }
.topbar > *, .topbar .chip { white-space: nowrap; }
.topbar .title { font-weight: 700; font-size: 15px; }
.topbar .tabs { display: flex; gap: 2px; margin-left: 18px; align-self: stretch; }
/* 메뉴: 활성 항목은 굵은 글씨 + 아래 오렌지 선 */
.topbar .tabs .chip, .topbar .tabs .tab { border: 0; border-radius: 0; background: none; color: var(--muted); font-size: 15px; font-weight: 500; padding: 8px 14px; min-height: 40px; box-shadow: inset 0 -2px 0 transparent; }
.topbar .tabs .chip:hover, .topbar .tabs .tab:hover { color: var(--ink); background: var(--surface-2); }
.topbar .tabs .chip.on, .topbar .tabs .tab.on { color: var(--ink); font-weight: 700; background: none; box-shadow: inset 0 -2px 0 var(--accent); }
.layout { display: grid; grid-template-columns: 250px minmax(0, 1fr) minmax(320px, 420px); gap: 14px; padding: 14px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel > h3, .sec > h3 { margin: 0; font-size: 14px; letter-spacing: 0.02em; }
.list-panel { position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow: auto; }
.list-item { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--surface-2); padding: 10px 12px; }
.list-item:hover { background: var(--surface-2); }
.list-item.on { background: var(--accent-soft); }
.list-item .nm { font-weight: 600; }
.badge { display: inline-block; font-size: 12px; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); margin-left: 4px; vertical-align: 1px; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.ok { background: #e6f0e7; color: var(--ok); }
.editor { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.sec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.sec h3 { margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.sub { display: grid; grid-template-columns: 92px 1fr; gap: 8px; align-items: start; padding: 5px 0; }
.sub > .k { font-size: 14px; color: var(--muted); padding-top: 6px; }
.mini-input { border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; min-height: 32px; font-size: 14px; background: var(--surface); width: 100%; }
.summary { font-size: 14px; white-space: pre-wrap; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; max-height: 260px; overflow: auto; }
.alert { background: var(--warn-soft); border: 1px solid #efc9b4; color: #7a3a19; border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.outputs { position: sticky; top: 70px; display: flex; flex-direction: column; gap: 12px; }
.out { padding: 10px 12px; }
.out .head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.out .head b { font-size: 14px; }
.out textarea { width: 100%; min-height: 120px; resize: vertical; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-family: "Malgun Gothic", "Apple SD Gothic Neo", sans-serif; font-size: 14.5px; line-height: 1.6; background: #fffdf9; }
.out .copy { min-width: 72px; }
.out .copy.done { background: var(--ok); border-color: var(--ok); color: #fff; }
.out .state { font-size: 12px; color: var(--muted); }
.out .state.edited { color: var(--warn); }
.tx-row { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-top: 6px; }
.tx-row.pending { background: var(--pending); border-color: var(--pending-line); }
.tx-row .nm { font-weight: 600; min-width: 92px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* 인계 카드 */
.brief-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; padding: 14px; }
.brief { padding: 14px; }
.brief .who { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.brief .who b { white-space: nowrap; }
.brief .who .muted, .brief .who .badge { white-space: nowrap; }
.brief .who b { font-size: 18px; }
.brief .primary { font-size: 20px; font-weight: 700; color: var(--sel); margin: 6px 0 2px; }
.brief dl { margin: 8px 0 0; display: grid; grid-template-columns: 74px 1fr; gap: 5px 8px; font-size: 15px; }
.brief dt { color: var(--muted); }
.brief dd { margin: 0; }
.brief .caution { color: var(--warn); font-weight: 600; }
.brief .handoff { margin-top: 10px; background: var(--accent-soft); border-radius: 8px; padding: 8px 10px; font-size: 14px; }

.manual-wrap { display: grid; grid-template-columns: 340px 1fr; gap: 14px; padding: 14px; }
.manual-body { white-space: pre-wrap; font-size: 15px; }

.meter { position: fixed; right: 10px; bottom: 10px; z-index: 50; background: rgba(43, 39, 36, 0.86); color: #fff; font-size: 12px; border-radius: 999px; padding: 4px 6px 4px 12px; display: flex; gap: 8px; align-items: center; }
.meter button { background: rgba(255, 255, 255, 0.15); border: 0; color: #fff; border-radius: 999px; font-size: 11px; padding: 2px 8px; }
body.patient .meter { bottom: 96px; }
.toast { position: fixed; left: 50%; top: 16px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 8px 16px; border-radius: 999px; font-size: 14px; z-index: 60; }

.login { max-width: 360px; margin: 10vh auto; padding: 24px; }
.login .field { margin-bottom: 0; width: 100%; }
.login-title { font-size: 20px; margin: 0 0 14px; }
.login-btn { width: 100%; min-height: 48px; margin-top: 4px; }
.lf { margin-bottom: 12px; display: flex; flex-direction: column; gap: 4px; }
.field-err { color: var(--warn); }
.field-err:empty { display: none; }
.owner-line { display: flex; align-items: center; gap: 8px; font-size: 16px; padding: 4px 0; }

/* ADMIN · 계정 관리 */
.acc-wrap { display: flex; flex-direction: column; gap: 14px; max-width: 1180px; }
.acc-wrap h3 { margin: 0 0 10px; font-size: 16px; }
.acc-new, .acc-list, .acc-log, .acc-issued { padding: 16px; }
.acc-new-row { display: grid; grid-template-columns: 1fr 1fr 200px auto; gap: 10px; align-items: end; }
.acc-new-row label { display: flex; flex-direction: column; gap: 4px; }
.acc-new-row .btn { min-height: 42px; }
.acc-issued { border-color: var(--accent); background: var(--warn-soft); }
.acc-temp { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.acc-temp code { font-size: 22px; letter-spacing: 0.06em; background: var(--surface); padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.off td { color: var(--muted); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 14px; }
.nowrap { white-space: nowrap; }
.small-field { min-height: 32px; padding: 3px 8px; font-size: 14px; }
.btn.ghost-warn { color: var(--warn); }
@media (max-width: 900px) { .acc-new-row { grid-template-columns: 1fr; } .acc-list { overflow-x: auto; } }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .list-panel, .outputs { position: static; max-height: none; }
  .manual-wrap { grid-template-columns: 1fr; }
}
@media print {
  .topbar, .meter, .no-print { display: none !important; }
  .qr-card { break-inside: avoid; box-shadow: none; }
}
.tgrp { display: inline-flex; align-items: center; gap: 3px; background: var(--surface-2); border-radius: 999px; padding: 2px 3px 2px 10px; font-size: 13px; }
.tgrp .chip { min-height: 26px; padding: 2px 9px; font-size: 13px; }

/* 접수번호·문진 요약 */
.rno { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 700; margin-right: 6px; }
.rno.lg { font-size: 18px; margin-right: 0; }
dl.sum { display: grid; grid-template-columns: 52px 1fr; gap: 4px 10px; margin: 0; font-size: 14px; }
dl.sum dt { color: var(--muted); }
dl.sum dd { margin: 0; }
.head-sec { border-left: 3px solid var(--accent); }

/* ───────── ADMIN 공통 ───────── */
.admin-body { padding: 20px 24px 40px; max-width: 1360px; width: 100%; }
.notice { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 15px; line-height: 1.6; margin-bottom: 14px; }
.notice.warn { background: var(--warn-soft); border-color: #efc9b4; color: #6e3416; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 7px 14px; min-height: 38px; font-size: 14.5px; color: var(--muted); border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--sel); color: #fff; font-weight: 600; }

/* 문진 QR 카드: 카드 전체 = 미리보기 링크, 버튼은 위에 올라와 따로 동작 */
.qr-tools { margin-bottom: 14px; }
.qr-tools .muted { font-size: 14.5px; max-width: 760px; }
.qr-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (min-width: 1500px) { .qr-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 1000px) { .qr-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .qr-grid { grid-template-columns: 1fr; } }
.qr-card { position: relative; padding: 18px; display: flex; flex-direction: column; gap: 10px; text-align: left; }
.qr-card h3 { margin: 0; font-size: 17px; font-weight: 700; }
.qr-head { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.qr-head .badge { margin: 0; }
.qr-card.active { transition: border-color 0.12s, background 0.12s; }
.qr-card.active:hover { border-color: #cdb9a4; background: #fffdfa; }
.qr-stretch { position: absolute; inset: 0; border-radius: inherit; z-index: 1; }
.qr-stretch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.qr-actions { position: relative; z-index: 2; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.qr-actions .btn { min-height: 38px; font-size: 14.5px; text-decoration: none; display: inline-flex; align-items: center; }
.qr-img { position: relative; align-self: center; }
.qr-img svg { width: 168px; height: 168px; display: block; }
.qr-dev-tag { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-12deg); background: rgba(255, 255, 255, 0.92); color: var(--warn); border: 1.5px solid var(--warn); font-weight: 700; font-size: 13px; padding: 2px 10px; border-radius: 6px; letter-spacing: 0.04em; }
.qr-locked { min-height: 160px; display: grid; place-items: center; text-align: center; border: 1.5px dashed var(--line, #d8cfc4); border-radius: 10px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.qr-card.pending .qr-url { font-style: normal; }
.qr-actions .btn[disabled] { opacity: 0.45; cursor: not-allowed; position: relative; z-index: 2; }
.qr-url { font-size: 13px; color: var(--muted); word-break: break-all; text-align: center; }
.qr-card.planned { background: var(--surface-2); border-style: dashed; color: var(--muted); }
.qr-card.planned h3 { color: var(--muted); font-weight: 600; }
.qr-empty { min-height: 120px; display: grid; place-items: center; text-align: center; font-size: 14px; color: var(--muted); }

/* 문진 통계 */
.st-wrap { display: flex; flex-direction: column; gap: 14px; }
.st-filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.st-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.st-tile { padding: 14px 16px; display: grid; grid-template-columns: 1fr auto; align-items: baseline; row-gap: 2px; }
.st-tile span { grid-column: 1 / -1; font-size: 14.5px; color: var(--muted); }
.st-tile b { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.st-tile small { font-size: 14px; color: var(--muted); }
.st-tile.main b { color: var(--ink); }
.st-h { margin: 10px 0 0; font-size: 17px; gap: 12px; }
.st-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1000px) { .st-grid { grid-template-columns: 1fr; } }
.st-card { padding: 16px 18px; }
.st-card h4 { margin: 0 0 4px; font-size: 16px; font-weight: 700; line-height: 1.4; }
.st-meta { font-size: 14.5px; color: var(--ink); margin-bottom: 12px; }
.st-den { font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.st-bars { display: flex; flex-direction: column; gap: 4px; }
.st-row { display: grid; grid-template-columns: minmax(110px, 38%) 1fr 44px 54px; align-items: center; gap: 10px; padding: 3px 4px; border-radius: 6px; font-size: 14.5px; }
.st-row:hover { background: var(--surface-2); }
.st-lbl { line-height: 1.35; }
.st-track { height: 12px; display: block; }
.st-track i { display: block; height: 100%; background: #b25d27; border-radius: 0 4px 4px 0; }
.st-track i.st-mask { width: 100%; background: repeating-linear-gradient(135deg, #e6ddd1 0 4px, transparent 4px 8px); border-radius: 0; }
.st-n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.st-p { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.st-cols, .st-trend { display: flex; align-items: flex-end; gap: 4px; height: 170px; padding-top: 4px; border-bottom: 1px solid var(--line); }
.st-col { flex: 1; min-width: 0; height: 100%; display: grid; grid-template-rows: 18px 1fr; position: relative; }
.st-col:hover .st-ctrack i { background: #8f4a1f; }
.st-cn { font-size: 12.5px; text-align: center; font-variant-numeric: tabular-nums; color: var(--ink); }
.st-ctrack { display: flex; align-items: flex-end; justify-content: center; }
.st-ctrack i { display: block; width: min(70%, 28px); background: #b25d27; border-radius: 4px 4px 0 0; }
.st-cl { position: absolute; bottom: -22px; left: 0; right: 0; font-size: 12.5px; text-align: center; color: var(--muted); white-space: nowrap; }
.st-cols, .st-trend { margin-bottom: 26px; }
.st-card.wide .st-den { margin-top: 0; }

/* 환자 문진 — 관리자 미리보기 표시 */
.pt-preview-bar { position: sticky; top: 0; z-index: 6; background: #2a2623; color: #fff; font-size: 13px; text-align: center; padding: 6px 10px; letter-spacing: 0.02em; }
body.preview .pt-head { top: 30px; }

@media print {
  body.print-one .qr-card:not(.print-target) { display: none !important; }
  body.print-one .qr-grid { grid-template-columns: 1fr; }
  body.print-one .qr-card.print-target { border: 0; align-items: center; text-align: center; }
  body.print-one .qr-card.print-target svg { width: 300px; height: 300px; }
  .qr-card.planned, .notice { display: none !important; }
  .qr-grid { grid-template-columns: repeat(2, 1fr); }
}

/* 환자 화면 보조 그림 */
.il-start { display: block; width: 100%; max-width: 320px; height: 56px; margin: 4px 0 18px; }
.il-sun { fill: #f1e2d3; }
.il-line { stroke: #d9c8b4; stroke-width: 1; }
.il-line.soft { stroke: #e8ddcf; }
.il-dot { fill: var(--pt-accent); }
.pt-opts.icons .pt-opt.with-icon { flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; min-height: 124px; padding: 12px 8px; position: relative; }
.pt-opt.with-icon .pt-mark { position: absolute; top: 10px; left: 10px; }
.il-collision { width: 80px; height: 70px; }
.il-car rect { fill: #fff; stroke: #8b7c6e; stroke-width: 1.5; }
.il-glass { fill: #e7ddd1; }
.il-arrow { fill: none; stroke: var(--pt-accent); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.il-none { display: grid; place-items: center; width: 58px; height: 58px; font-size: 24px; color: #a4968a; }
.pt-opt.with-icon.on .il-car rect { stroke: var(--pt-accent); }

/* 준비 중 문진: 작은 카드로 따로 모아 사용 중 QR과 구분 */
.qr-sub { margin: 26px 0 10px; font-size: 16px; color: var(--muted); }
.qr-grid.planned .qr-card { padding: 14px 18px; gap: 4px; }
.qr-grid.planned .qr-empty { min-height: 0; display: block; padding: 0; text-align: left; font-size: 14px; }
@media print { .qr-sub, .qr-grid.planned { display: none !important; } }

/* R04: 얼굴 부위 그림·단계 안내·평소 몸 상태 요약 */
.il-face { width: 64px; height: 64px; }
.il-face .il-line { fill: none; stroke: #8b7c6e; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.il-face .il-line.soft { stroke: #b9aa9a; stroke-width: 1.2; }
.il-face .il-line.fill { fill: #efe6db; }
.il-hit { fill: none; stroke: var(--pt-accent); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.il-hit.area { fill: rgba(178, 93, 39, 0.18); stroke-width: 1.6; }
.pt-lead.step-lead { margin: -4px 0 14px; font-size: 15.5px; }
.pt-profile { margin: 20px 0 22px; padding: 16px 18px; background: #fff; border: 1px solid var(--line, #e6dccf); border-radius: 14px; text-align: left; }
.pt-profile h2 { margin: 0 0 10px; font-size: 17px; }
.pt-profile dl { display: grid; grid-template-columns: 64px 1fr; gap: 8px 10px; margin: 0; font-size: 15.5px; }
.pt-profile dt { font-weight: 700; color: var(--pt-sub); }
.pt-profile dd { margin: 0; }
.pt-profile dd.flag { color: var(--pt-text, #2b2520); font-weight: 600; }
.pt-profile p { margin: 12px 0 0; font-size: 14px; color: var(--pt-sub); }

dl.sum.wide { grid-template-columns: minmax(150px, 34%) 1fr; gap: 6px 12px; }
dl.sum.wide dt { font-size: 13.5px; }
.profile-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.profile-grid .pf { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; font-size: 13.5px; display: flex; flex-direction: column; gap: 2px; }
.profile-grid .pf b { font-size: 13px; color: var(--muted); }
.profile-grid .pf.flag { background: var(--accent-soft); }
.profile-grid .pf.flag b { color: var(--accent); }

/* R05: 재진 — 지난 진료 비교 카드 */
.prev-card { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; display: grid; gap: 6px; }
.prev-head { display: flex; align-items: center; gap: 6px; }
.prev-text { margin: 0; font: inherit; font-size: 13.5px; white-space: pre-wrap; color: var(--ink); }
.prev-text.tx { border-top: 1px dashed var(--line); padding-top: 6px; }
.chip.strong { border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* R06: 시행했지만 필수 기록값이 빠진 치료 */
.tx-row.incomplete { border-color: #efc9b4; background: var(--warn-soft); }
.tx-row.flash { outline: 3px solid var(--warn); outline-offset: 2px; transition: outline-color .3s; }

/* R07: 환자 문진 가독성 — 지금 쓰는 문진·질문·설명의 위계를 분명히, 구분선은 가볍게 */
.pt-kicker.step { margin: 0 0 4px; font-size: 13.5px; font-weight: 600; }
.pt-title { font-size: 22px; font-weight: 700; margin-bottom: 24px; }
.pt-lead.step-lead { margin: -12px 0 24px; padding-left: 12px; border-left: 2px solid var(--pt-accent-soft); font-size: 15.5px; line-height: 1.6; }
.pq { margin-bottom: 32px; }
.pq + .pq:not(.tight) { border-top-color: #efe8de; padding-top: 28px; }
.pq-label { font-size: 18px; font-weight: 700; color: var(--pt-ink); letter-spacing: -0.01em; }
.pq-badge { font-size: 12.5px; padding: 2px 8px; border-radius: 999px; line-height: 1.5; }
.pq-badge.req { background: var(--pt-accent-soft); color: #8a4519; font-weight: 600; }
.pq-badge.opt { background: transparent; color: #7d7268; border: 1px solid var(--pt-line); }
.pq-multi { display: inline-block; margin: 2px 0 8px; font-size: 13.5px; font-weight: 600; color: var(--pt-accent); }
.pq-multi + .pq-hint { margin-top: -4px; }
.pq-hint { font-size: 15px; line-height: 1.55; }
.pq-multi + .pt-opts, .pq-hint + .pt-opts { margin-top: 4px; }
.pt-opt { min-height: 54px; }
.pt-meta { list-style: none; margin: -16px 0 28px; padding: 0; display: grid; gap: 6px; font-size: 14.5px; color: var(--pt-sub); }
.pt-meta li { padding-left: 14px; position: relative; }
.pt-meta li::before { content: ""; position: absolute; left: 2px; top: 0.62em; width: 5px; height: 5px; border-radius: 50%; background: var(--pt-accent); opacity: 0.6; }
.pt-details summary { min-height: 44px; display: flex; align-items: center; }
.pt-today { text-align: left; margin: 28px 0 0; padding: 18px 18px 6px; background: var(--pt-surface); border: 1px solid var(--pt-line); border-radius: 14px; }
.pt-today h2 { font-size: 16px; margin: 0 0 8px; }
.pt-today ul { margin: 0; padding-left: 18px; color: var(--pt-ink); line-height: 1.6; font-size: 15px; }
.pt-today li { margin-bottom: 8px; }
.pt-extra { text-align: left; font-size: 14.5px; color: var(--pt-sub); line-height: 1.6; margin: 16px 0 0; }
.pt-done .pt-note { margin-top: 18px; }
/* 교통사고 충돌 방향: 상대 차는 흐리게 */
.il-collision { width: 92px; height: 84px; }
.il-other rect { fill: #efe6db; stroke: #b9aa9a; stroke-width: 1.2; stroke-dasharray: 3 2; }
.pq-badge { font-size: 13px; }
.bm-name small { font-size: 13px; }

/* R08: 단계 표시 그림 · 보기 왼쪽 작은 그림 — 가는 선, 절제된 색 */
.pt-stephead { display: flex; align-items: center; gap: 14px; margin: 4px 0 22px; }
.pt-stephead .pt-kicker { margin: 0 0 2px; }
.pt-stephead .pt-title { margin: 0; }
.il-mark { flex: none; width: 46px; height: 46px; padding: 10px; border-radius: 50%; background: var(--pt-fill); fill: none; stroke: var(--pt-accent); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.il-glyph { flex: none; width: 30px; height: 30px; fill: none; stroke: #8b7c6e; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.il-glyph.blank { display: inline-block; }
.pt-opt.on .il-glyph { stroke: var(--pt-accent); }
.pt-opt.with-glyph { gap: 12px; }

/* R08: 초진 완료(차팅 복사 완료) */
.done-box { display: flex; flex-direction: column; gap: 8px; padding: 12px; }
.done-box .btn.primary { min-height: 44px; font-weight: 600; }
.done-box.ok { border-color: #9cc3a5; background: #f2f8f3; }
.alert.info { background: #f4efe7; border-color: #e0d3c2; }

/* R09: 치료 입력 — 종류 묶음 · 공통 부위 · 상태 3가지(색 + 글자) */
.tx-groups { display: flex; flex-direction: column; gap: 6px; }
.tx-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tx-glabel { width: 84px; flex: none; font-size: 13px; color: var(--muted); }
.chip.st-pending { background: var(--pending); border-color: var(--pending-line); color: #6b5212; }
.chip.st-incomplete.on { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.chip.mini { min-height: 28px; padding: 2px 9px; font-size: 13px; }
.chip.ghost { border-style: dashed; color: var(--muted); }
.zones { display: flex; flex-direction: column; gap: 6px; }
.zone-row { display: flex; flex-wrap: wrap; gap: 6px; }
.zone { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; }
.zone.on { background: var(--surface-2); padding-right: 6px; }
.zone .sides { display: inline-flex; gap: 3px; }
.zone-precise { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tx-list { margin-top: 4px; }
.tx-row.st-pending { background: var(--pending); border-color: var(--pending-line); }
.tx-row.st-incomplete { border-color: #efc9b4; background: var(--warn-soft); }
.tx-row .row { flex-wrap: wrap; gap: 8px; }
.tx-where { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.badge.pend { background: var(--pending); color: #6b5212; border: 1px solid var(--pending-line); }
.linkish { border: 0; background: none; color: var(--accent); font-size: 13px; text-decoration: underline; padding: 4px; cursor: pointer; }
.cups { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 4px; }
.cup { display: inline-flex; align-items: center; gap: 4px; }
.cup > .small { width: 44px; }
.m2-preview { margin: 0; padding: 8px 10px; background: var(--surface-2); border-radius: 8px; font: inherit; font-size: 14px; white-space: pre-wrap; color: var(--ink); }

/* ── R09.2 의료진 화면: 핵심 요약 · 접기 · 부위별 진찰 · 보조 그림 · 현주증상 미리보기 · 좁은 창 배치 ── */
dl.sum.key { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 5px 18px; font-size: 14.5px; }
dl.sum.key .kv { display: grid; grid-template-columns: 100px 1fr; gap: 0 10px; align-items: start; }
dl.sum.key .kv.wide { grid-column: 1 / -1; }
dl.sum.key dt { font-size: 13.5px; padding-top: 1px; }
dl.sum.key dd { line-height: 1.45; word-break: keep-all; overflow-wrap: anywhere; }
dl.sum.key dd.none { color: var(--muted); font-style: italic; }
dl.sum.key dd.flag { color: #7a3a19; font-weight: 600; }
dl.sum.key dd.check { color: var(--muted); }
.flag-tag { display: inline-block; font-size: 11.5px; font-weight: 700; color: var(--warn); border: 1px solid #e7b89c; border-radius: 6px; padding: 0 5px; margin-right: 6px; vertical-align: 1px; }
details.fold { margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 6px; }
details.fold > summary { cursor: pointer; font-size: 13.5px; color: var(--accent); list-style: none; padding: 4px 0; user-select: none; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "▸ "; }
details.fold[open] > summary::before { content: "▾ "; }
.sec > details.fold:first-child { margin-top: 0; border-top: 0; padding-top: 0; }
.sec > details.fold:first-child > summary { color: var(--ink); font-size: 14px; font-weight: 700; }
.fold-h .small { font-weight: 400; }
.full-intake { margin-top: 6px; }
.area-row { display: grid; grid-template-columns: 64px 1fr; gap: 6px; align-items: start; margin-bottom: 4px; }
.area-k { font-size: 12.5px; color: var(--muted); padding-top: 7px; }
.tgrp.test .tname { font-size: 13px; font-weight: 600; }
.tgrp.test .en { font-weight: 400; color: var(--muted); font-size: 12px; }
.face-fig-row { display: flex; align-items: center; gap: 12px; margin: 2px 0 6px; }
.face-fig { width: 112px; height: auto; flex: none; }
.ff-face { fill: #f3ebe1; stroke: #dccbb7; }
.ff-line { fill: none; stroke: #c9b6a0; stroke-width: 2; stroke-linecap: round; }
.ff-mid { stroke: #d9c9b6; stroke-dasharray: 3 4; }
.ff-hit { fill: rgba(169, 89, 42, 0.12); stroke: #c79a7a; stroke-width: 1.2; cursor: pointer; }
.ff-hit.on { fill: var(--accent); stroke: var(--accent); }
.ff-side, .zf-side { font-size: 13px; font-weight: 700; fill: var(--muted); }
.zones-fig { display: flex; gap: 12px; align-items: flex-start; }
.zones-fig > .zones { flex: 1; min-width: 0; }
.zfig-wrap { flex: none; display: flex; flex-direction: column; align-items: center; }
.zfig { width: 84px; height: auto; display: block; }
.zf-body { fill: #ece3d7; }
.zf-zone { fill: transparent; stroke: rgba(255, 255, 255, 0.9); stroke-width: 1.4; cursor: pointer; }
.zf-zone:hover { fill: rgba(169, 89, 42, 0.15); }
.zf-zone.on { fill: #d9915f; }
.zf-cap { font-size: 11.5px; color: var(--muted); margin-top: 2px; text-align: center; max-width: 96px; line-height: 1.3; }
.pi-preview { font-size: 13.5px; line-height: 1.5; background: var(--surface-2); border-radius: 10px; padding: 8px 10px; max-height: 46vh; overflow: auto; }
.pv-g { font-size: 11.5px; font-weight: 700; letter-spacing: 0.03em; color: var(--muted); margin: 8px 0 3px; padding-bottom: 2px; border-bottom: 1px solid var(--line); }
.pv-g:first-child { margin-top: 0; }
.pv-g.pv-obj { color: #3f5f74; }
.pv-g.pv-ref { color: var(--warn); }
.pv-b { display: grid; grid-template-columns: 58px 1fr; gap: 6px; margin: 2px 0; }
.pv-tag { font-weight: 700; font-size: 12.5px; color: var(--ink); }
.pv-b.pv-obj .pv-tag { color: #3f5f74; }
.pv-lines { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 1360px) {
  .layout { grid-template-columns: 210px minmax(0, 1fr) minmax(300px, 360px); gap: 12px; padding: 12px; }
}
/* 좁은 창: 환자 목록은 위로, 진찰(가운데)·차트(오른쪽 고정) 두 칸 유지 */
@media (max-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); }
  .list-panel { grid-column: 1 / -1; position: static; max-height: 180px; }
  .outputs { position: sticky; top: 70px; max-height: calc(100vh - 84px); overflow: auto; }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .outputs { position: static; max-height: none; }
  .sub { grid-template-columns: 1fr; gap: 4px; }
  dl.sum.key, dl.sum.key .kv { grid-template-columns: 1fr; }
  .zones-fig { flex-direction: column; }
}

/* R10 출력 알림 */
.out-note:empty { display: none; }
.out-note { margin-top: 6px; display: grid; gap: 6px; }
.out-warn { border: 1px solid #d9a26a; background: #fff6ec; border-radius: 8px; padding: 8px 10px; font-size: 13px; color: #6b3a12; }
.out-warn.soft { border-color: #e6d3a8; background: #fffbef; color: #5d4a12; }
.out-warn .mono { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.tx-howto { margin: 2px 0 6px; color: #5d4a12; }
.list-item.locked { cursor: default; opacity: .9; background: #faf6ef; }
.access-row { padding: 8px 0; border-bottom: 1px solid var(--line, #eadfce); gap: 8px; flex-wrap: wrap; }
.brief .src-tag { margin-top: 8px; font-size: 12px; color: #7a6a58; }
