/* 병원에서 쓰는 화면입니다. 차분하고 단정하게, 시선이 문항에만 가도록.
   색은 채도를 낮춰 쓰고, 강조는 위험 표시에만 남겨 둡니다. */

:root {
  --bg: #f6f8f9;
  --card: #ffffff;
  --ink: #2c3339;
  --ink-soft: #4d565e;
  --muted: #7b858e;
  --line: #e3e8ec;
  --line-strong: #cfd7dd;

  --accent: #3f6d8c;          /* 차분한 청회색 */
  --accent-deep: #345b76;
  --accent-soft: #edf3f7;

  --high: #b4453a;
  --high-bg: #fbeeec;
  --mid: #97691f;
  --mid-bg: #fbf4e7;
  --low: #5f6a73;
  --low-bg: #eef1f3;
  --ok: #2f7a55;
  --ok-bg: #ecf5f0;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(24, 39, 51, .04), 0 1px 6px rgba(24, 39, 51, .03);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont,
               "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  font-size: 17px;
  line-height: 1.65;
  letter-spacing: -0.01em;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
h1, h2, h3 { line-height: 1.4; letter-spacing: -0.02em; font-weight: 700; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .95em; }

/* ------------------------------------------------------------ 공통 레이아웃 */

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 20px 120px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 18px;
}
.card h2 { font-size: 1.15rem; margin: 0 0 16px; }
.card h3 { font-size: 1rem; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  /* 반투명·블러는 보기엔 좋지만 저사양 태블릿에서 잔상이 남습니다. 불투명하게. */
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 1.02rem; margin: 0; flex: 1; font-weight: 700; }
.topbar .who { color: var(--muted); font-size: .88rem; }

.muted { color: var(--muted); }
.hidden { display: none !important; }
.err { color: var(--high); margin-top: 10px; min-height: 1.4em; font-size: .95rem; }

/* ------------------------------------------------------------------- 입력류 */

label.field { display: block; margin-bottom: 16px; }
label.field > span {
  display: block;
  font-weight: 600;
  font-size: .95rem;
  color: var(--ink-soft);
  margin-bottom: 7px;
}

input[type="text"], input[type="number"], input[type="password"], input[type="date"] {
  width: 100%;
  padding: 13px 14px;
  font-size: 1.1rem;
  font-family: inherit;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: #aab3ba; }
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn {
  padding: 13px 22px;
  font-size: 1.02rem;
  font-weight: 600;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink-soft);
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover:not(:disabled) { background: #f3f6f8; border-color: var(--muted); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover:not(:disabled) { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover:not(:disabled) { background: #eef1f3; border-color: transparent; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.wide { width: 100%; }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; }

/* ------------------------------------------------------------------ 문진 화면 */

.progress {
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress > div {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width .25s ease;
}
.progress-label {
  font-size: .82rem;
  color: var(--muted);
  margin-bottom: 26px;
  letter-spacing: .02em;
}

.qblock { margin-bottom: 30px; }
.qtext {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 0 8px;
  word-break: keep-all;
  color: var(--ink);
}
.qtext.discreet { font-size: 1.08rem; }
.qnote {
  color: var(--muted);
  font-size: .93rem;
  margin: 0 0 18px;
  white-space: pre-line;
}

.options { display: flex; flex-direction: column; gap: 9px; }
.opt {
  min-height: 66px;
  text-align: left;
  padding: 15px 18px;
  font-size: 1.1rem;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 13px;
  word-break: keep-all;
  transition: border-color .12s, background .12s;
}
.opt:hover { border-color: var(--muted); }
.opt .mark {
  flex: 0 0 24px;
  height: 24px;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: .8rem;
  color: transparent;
  transition: background .12s, border-color .12s;
}
.opt[data-multi="1"] .mark { border-radius: 7px; }
.opt[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}
.opt[aria-pressed="true"] .mark {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.opt .othertext {
  margin-left: auto;
  max-width: 45%;
  padding: 8px 11px;
  font-size: .98rem;
}

.navbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--card);
  border-top: 1px solid var(--line);
  box-shadow: 0 -1px 3px rgba(24, 39, 51, .04);
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  z-index: 20;
}
.navbar .btn { flex: 1; min-height: 56px; font-size: 1.05rem; }
.navbar .btn.primary { flex: 2; }

/* 서명 */
.sigbox {
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: #fff;
  touch-action: none;
}
.sigbox canvas { display: block; width: 100%; height: 220px; touch-action: none; }

/* 스크롤 영역이라 글이 중간에 잘립니다. 아래쪽을 흐리게 해서
   "더 있습니다" 를 알려 주면 잘린 것처럼 보이지 않습니다. */
.consent-scroll { position: relative; }
.consent-scroll::after {
  content: "";
  position: absolute;
  left: 1px; right: 1px; bottom: 1px;
  height: 34px;
  background: linear-gradient(to bottom, rgba(251, 252, 253, 0), #fbfcfd 85%);
  border-radius: 0 0 12px 12px;
  pointer-events: none;
}

.consent-body {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
  background: #fbfcfd;
  max-height: 44vh;
  overflow-y: auto;
  font-size: .95rem;
  line-height: 1.7;
  color: var(--ink-soft);
}
.consent-body h3 {
  font-size: .95rem;
  margin: 20px 0 8px;
  color: var(--ink);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.consent-body h3:first-child { margin-top: 0; }
.consent-body p { margin: 8px 0; }
.consent-body table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 10px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.consent-body td {
  border-bottom: 1px solid var(--line);
  padding: 9px 12px;
  vertical-align: top;
}
.consent-body tr:last-child td { border-bottom: none; }
.consent-body td:first-child {
  width: 32%;
  font-weight: 600;
  background: #f4f7f9;
  color: var(--ink);
}

.donebox { text-align: center; padding: 72px 20px; }
.donebox .big { font-size: 1.9rem; font-weight: 700; margin-bottom: 12px; }

.pending {
  background: var(--mid-bg);
  color: var(--mid);
  border: 1px solid #e8d9b4;
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  margin-bottom: 16px;
  font-weight: 600;
  font-size: .97rem;
}

/* ------------------------------------------------------------------- 목록/표 */

table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td {
  padding: 11px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: .96rem;
}
table.list th {
  color: var(--muted);
  font-weight: 600;
  font-size: .84rem;
  letter-spacing: .02em;
  border-bottom-color: var(--line-strong);
}
table.list tbody tr { cursor: pointer; transition: background .12s; }
table.list tbody tr:hover { background: #f4f7f9; }
table.list tr.selected { background: var(--accent-soft); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .01em;
}
.badge.high { background: var(--high-bg); color: var(--high); }
.badge.mid  { background: var(--mid-bg);  color: var(--mid); }
.badge.done { background: var(--ok-bg);   color: var(--ok); }
.badge.wip  { background: var(--low-bg);  color: var(--low); }

/* ---------------------------------------------------------------- 진료실 리포트 */

.layout { display: grid; grid-template-columns: 340px 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.flagbox {
  border-left: 3px solid;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 8px;
}
.flagbox.high { border-color: var(--high); background: var(--high-bg); }
.flagbox.mid  { border-color: var(--mid);  background: var(--mid-bg); }
.flagbox.low  { border-color: var(--low);  background: var(--low-bg); }
.flagbox b { font-size: 1.02rem; }
.flagbox .why { color: var(--ink-soft); font-size: .9rem; opacity: .85; }

.vitals {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 26px;
  margin: 14px 0 0;
  padding: 14px 16px;
  background: #f7f9fa;
  border-radius: var(--radius-sm);
}
.vitals div { font-size: .93rem; color: var(--muted); }
.vitals b { font-size: 1.12rem; color: var(--ink); margin-left: 3px; }

.rsection { margin-bottom: 24px; }
.rsection h3 {
  font-size: .88rem;
  color: var(--muted);
  letter-spacing: .04em;
  border-bottom: 1px solid var(--line);
  padding-bottom: 7px;
  margin: 0 0 10px;
}
.qa {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 4px 16px;
  padding: 6px 0;
  border-bottom: 1px solid #f1f4f6;
}
.qa:last-child { border-bottom: none; }
.qa .q { color: var(--muted); font-size: .91rem; }
.qa .a { font-weight: 600; color: var(--ink); }
.qa.unanswered .a { color: #b3bbc2; font-weight: 400; }

.sigview {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  max-width: 320px;
  padding: 6px;
}
.sigview img { width: 100%; display: block; }

/* -------------------------------------------------------------------- 인쇄 */

@media print {
  body { background: #fff; font-size: 10.5pt; color: #000; }
  .topbar, .navbar, .noprint, .layout > aside { display: none !important; }
  .layout { display: block; }
  .wrap { max-width: none; padding: 0; }
  .card { border: none; box-shadow: none; padding: 0; margin: 0 0 8pt; }
  .rsection { break-inside: avoid; margin-bottom: 10pt; }
  .qa { padding: 2pt 0; border-bottom: 1px solid #eee; }
  .flagbox { break-inside: avoid; padding: 6pt 8pt; margin-bottom: 4pt; }
  .vitals { background: none; border: 1px solid #ccc; padding: 6pt 8pt; }
  a[href]:after { content: ""; }
}
