/* 시스템 글꼴만 쓴다 — 외부 글꼴 요청 금지(절대 규칙 1) */
:root {
  --bg: #eef1f5;
  --card: #ffffff;
  --ink: #18212b;
  --muted: #5b6673;
  --line: #c9d1db;
  --brand: #1f4e79;
  --brand-ink: #ffffff;
  --accent: #1d6fd6;
  --accent-soft: #dbe9fb;
  --ok: #1e7a3c;
  --warn: #a35a00;
  --bad: #b3261e;
  --tap: 52px;
  --radius: 12px;
  /* 워드 양식에서 뽑은 색 */
  --navy: #1f4e79;
  --thbg: #dce6f1;
  --tline: #9eabb8;
  --gray: #59626b;
  --red: #c0504d;
  --noticebg: #fce4d6;
  --noticeline: #d99694;
  --noticeink: #803023;
  font-size: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, "Noto Sans KR", "Malgun Gothic", sans-serif;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }

/* 상태줄 — 저장·미전송·서버·영구보관을 항상 보여 준다 */
.statusbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 16px;
  background: var(--brand); color: var(--brand-ink);
}
.brand { font-weight: 700; margin-right: 8px; }
.chip {
  padding: 4px 12px; border-radius: 999px;
  background: rgba(255,255,255,.14); font-size: .9rem; white-space: nowrap;
}
/* 상담 중 손님 눈에 띄지 않게 색 배경 대신 글자색만 바꾼다 */
.chip.warn, .chip.bad { color: #ffd27a; }
.spacer { flex: 1; }
.iconbtn {
  min-height: 44px; padding: 0 16px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,.4); background: transparent; color: inherit;
}
.panel .iconbtn { border-color: var(--line); }
.iconbtn.attn { position: relative; }
.iconbtn.attn::after {
  content: ""; position: absolute; top: 6px; right: 6px;
  width: 9px; height: 9px; border-radius: 50%; background: #ffd27a;
}

.banner {
  padding: 10px 16px; background: #fff3dc; color: var(--warn);
  border: 1px solid #f0d49a; border-radius: 8px; font-weight: 600; white-space: pre-line;
}

main { flex: 1; overflow-y: auto; padding: 16px; background: var(--bg); }

/* ---------- 양식 본문: 워드 양식(표·색·순서)을 그대로 옮긴다 ---------- */
.doc {
  max-width: 1080px; margin: 0 auto; background: var(--card);
  padding: 24px 28px 16px; border-radius: 4px; box-shadow: 0 1px 4px rgba(0,0,0,.12);
}
.doc-head { text-align: center; margin-bottom: 8px; }
.doc-head h1 { margin: 0; color: var(--navy); font-size: 1.7rem; letter-spacing: .02em; }
.doc-sub { margin: 4px 0 0; color: var(--gray); font-size: .9rem; }
.doc h2 { margin: 22px 0 8px; color: var(--navy); font-size: 1.05rem; }
.doc-foot { margin: 18px 0 0; text-align: center; color: var(--gray); font-size: .8rem; }

.tbl { display: grid; border-top: 1px solid var(--tline); border-left: 1px solid var(--tline); }
.tbl > .th, .tbl > .td {
  border-right: 1px solid var(--tline); border-bottom: 1px solid var(--tline);
  padding: 6px 10px; display: flex; align-items: center; min-height: 56px;
}
.tbl > .th { background: var(--thbg); color: var(--navy); font-weight: 700; font-size: .95rem; }
.tbl > .th.c { justify-content: center; }
.tbl + .tbl { border-top: 0; }
.tbl.basic { grid-template-columns: 9em 1fr 9em 1fr; }
.tbl.basic .span3 { grid-column: span 3; }
.tbl.two { grid-template-columns: 11em 1fr; }
.tbl.products { grid-template-columns: 11em auto 1fr; }
.tbl .pname { font-weight: 700; }
.pair { gap: 16px; }
.inline { display: flex; align-items: center; gap: 6px; flex: 1; font-weight: 700; white-space: nowrap; }
.req { color: var(--red); font-size: .75rem; margin-left: 6px; }
/* 표 안 입력칸은 표 칸처럼 보이게 테두리를 옅게 */
.tbl input[type=text], .tbl input[type=tel], .tbl input[type=date], .tbl textarea {
  border-color: #dfe5ec;
}
@media (max-width: 900px) {
  .doc { padding: 16px 14px 12px; }
  .tbl.basic { grid-template-columns: 7.5em 1fr; }
  .tbl.basic .span3 { grid-column: span 1; flex-direction: column; align-items: stretch; gap: 8px; }
  .tbl.two { grid-template-columns: 8.5em 1fr; }
  .tbl.products { grid-template-columns: 8.5em 1fr; }
  .tbl.products > .th.c:nth-child(3) { display: none; }
  .tbl.products > .td:has(textarea) { grid-column: 1 / -1; }
}

input[type=text], input[type=tel], input[type=date], input[type=password], textarea {
  min-height: var(--tap); padding: 8px 12px; border-radius: 8px;
  border: 1.5px solid var(--line); background: #fff; font-weight: 400; width: 100%;
}
textarea { resize: vertical; min-height: 56px; }
input:focus, textarea:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.invalid { border-color: var(--red) !important; outline: 3px solid #f6d5d2 !important; }
h3 small { font-weight: 400; color: var(--muted); }

/* 워드의 □ 칸을 손가락 크기 버튼으로 */
.choices { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.opt { position: relative; }
.opt input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.opt span {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  min-height: 48px; min-width: 76px; padding: 0 14px;
  border-radius: 8px; border: 1.5px solid var(--tline); background: #fff; user-select: none;
}
.opt span::before { content: "□"; color: var(--gray); }
.opt input:checked + span { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 700; }
.opt input:checked + span::before { content: "■"; color: #fff; }
.opt input:focus-visible + span { outline: 3px solid var(--accent-soft); }
.othertext { flex: 1; min-width: 150px; }
.othertext:disabled { background: #f3f5f8; }

.notice-title { margin: 12px 0 4px; color: var(--red); font-weight: 700; }
.notice {
  margin: 0; padding: 12px 14px; background: var(--noticebg);
  border: 1px solid var(--noticeline); color: var(--noticeink); font-weight: 700;
}
.intro { margin: 0 0 8px; }

.consent-q { margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: center; }
.consent-date { text-align: center; margin: 12px 0; }
.signline { display: flex; flex-wrap: wrap; gap: 16px 32px; justify-content: center; align-items: center; }
.signcell { display: flex; align-items: center; gap: 8px; }
.sigpreview {
  width: 280px; height: 96px; display: flex; align-items: center; justify-content: center;
  border: 2px dashed var(--accent); border-radius: 8px; background: #fff; padding: 4px; position: relative;
}
.sigpreview.disabled { border-color: var(--line); background: #f3f5f8; }
.sigpreview img { max-width: 100%; max-height: 100%; }
.sigpreview img:not([hidden]) + .sighint { position: absolute; right: 6px; bottom: 2px; }
.sighint { color: var(--muted); font-size: .85rem; }
.staffname {
  min-width: 180px; min-height: 48px; display: flex; align-items: center; justify-content: center;
  padding: 0 12px; border-bottom: 1.5px solid var(--ink); font-weight: 700;
}
.consent-warn { margin: 10px 0 0; text-align: center; color: var(--warn); font-weight: 600; }
.signer { padding: 12px; }

.sigpad.big { flex: 1; height: auto; min-height: 260px; border-color: var(--accent); }
.row.end { justify-content: flex-end; }
.row.end button { min-width: 140px; }
.pickbtn {
  min-height: var(--tap); padding: 0 12px; border-radius: 10px; text-align: left;
  border: 1.5px solid var(--line); background: #fff; font-weight: 700;
}
.pickbtn.empty { font-weight: 400; color: var(--muted); }
.namegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.namebtn {
  min-height: 60px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; font-size: 1.05rem;
}
.namebtn.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.sigpad {
  width: 100%; height: 150px; display: block; touch-action: none;
  border: 2px dashed var(--line); border-radius: 10px; background: #fff;
}
.sigtools { display: flex; align-items: center; gap: 6px; }
.sigwidths { display: flex; gap: 4px; }
.widthbtn {
  min-height: 40px; padding: 0 12px; border-radius: 8px;
  border: 1.5px solid var(--line); background: #fff; font-size: .85rem;
}
.widthbtn.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }

/* 저장 버튼은 화면 아래에 늘 붙어 있다 */
.savebar {
  display: flex; align-items: center; gap: 16px; justify-content: flex-end;
  padding: 10px 16px; background: var(--card); border-top: 1px solid var(--line);
}
.savehint { color: var(--muted); font-size: .9rem; }
.savebtn {
  min-height: 60px; min-width: 260px; padding: 0 28px; border: 0; border-radius: 12px;
  background: var(--ok); color: #fff; font-size: 1.15rem; font-weight: 700;
}
.savebtn:disabled { opacity: .6; }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 999px;
  font-weight: 600; z-index: 30;
}
.toast.bad { background: var(--bad); }

.overlay {
  position: fixed; inset: 0; z-index: 40; background: rgba(15, 23, 33, .55);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.overlay.lock { background: var(--brand); z-index: 50; }
.overlay[hidden] { display: none; }
.panel {
  background: var(--card); border-radius: 16px; padding: 20px 24px;
  width: min(420px, 100%); max-height: 100%; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
}
.panel.wide { width: min(720px, 100%); }
/* .panel 보다 뒤에 두어야 폭 제한(420px)을 덮는다 */
.panel.signpanel { width: 100%; height: 100%; }
.panelhead { flex-wrap: wrap; gap: 8px; }
.widthbtn { white-space: nowrap; }
.panel h2 { margin: 0; }
.panelhead { display: flex; justify-content: space-between; align-items: center; }
.setgroup { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.setgroup h3 { margin: 4px 0 0; font-size: 1rem; }
.row { display: flex; gap: 8px; }
.row > input { flex: 1; }
.panel button {
  min-height: var(--tap); padding: 0 18px; border-radius: 10px;
  border: 1.5px solid var(--line); background: #fff;
}
.panel button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.panel button.danger { color: var(--bad); border-color: #e3b4b0; }
.muted { color: var(--muted); margin: 0; }
.err { color: var(--bad); margin: 0; font-weight: 600; }
.err.okmsg { color: var(--ok); }
