/* 온라인 견적서 */
:root {
  --bg: #eef0f3;
  --card: #fff;
  --ink: #1d2530;
  --sub: #5b6573;
  --mute: #8a94a3;
  --line: #d6dbe2;
  --navy: #1f3a5c;
  --navy-d: #16283f;
  --red: #b42318;
  /* 견적서 */
  --d-line: #8d929a;
  --d-head: #ece7d6;
  --d-head2: #f6f3ea;
  --tabs-h: 62px;
  --top-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  word-break: keep-all;
  overflow-wrap: break-word;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
p, .txt, .hint, .warn { text-wrap: pretty; }
h1, h2, .card-h, .fld > span { text-wrap: balance; }

/* ---------- 앱 틀 ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  height: var(--top-h);
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.top-title { flex: 1; font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.top-btn {
  height: 36px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 10px;
  background: #fff; font-size: 14px; font-weight: 600; color: var(--sub);
}
.top-btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }

.side { display: none; }

.main {
  padding: 16px 16px calc(var(--tabs-h) + var(--safe-b) + 24px);
  max-width: 880px;
  margin: 0 auto;
}

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex;
  height: calc(var(--tabs-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: #fff;
  border-top: 1px solid var(--line);
}
.tabs .nav-btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 0; background: none;
  font-size: 12px; font-weight: 600; color: var(--mute);
}
.nav-btn svg {
  width: 22px; height: 22px;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.tabs .nav-btn.on { color: var(--navy); }
body.typing .tabs { display: none; }

.view-bar { display: none; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + var(--safe-b) + 16px); z-index: 40;
  transform: translate(-50%, 12px);
  max-width: calc(100% - 32px);
  padding: 11px 18px;
  border-radius: 12px;
  background: rgba(22, 40, 63, .94); color: #fff;
  font-size: 14px; text-align: center;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* PC: 왼쪽 메뉴 */
@media (min-width: 960px) {
  body:not(.viewer) .top, body:not(.viewer) .tabs { display: none; }
  body:not(.viewer) .side {
    display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 20;
    width: 220px;
    padding: 20px 14px;
    background: var(--navy-d); color: #fff;
  }
  body:not(.viewer) .main { margin-left: 220px; max-width: none; padding: 32px 40px 48px; }
  body:not(.viewer) .main > .panel { max-width: 860px; margin: 0 auto; }
  .brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; font-size: 19px; font-weight: 800; }
  .brand img { border-radius: 7px; }
  .side-menu { display: flex; flex-direction: column; gap: 4px; }
  .side .nav-btn {
    display: flex; align-items: center; gap: 12px;
    height: 46px; padding: 0 12px;
    border: 0; border-radius: 10px;
    background: none; color: rgba(255, 255, 255, .72);
    font-size: 15px; font-weight: 600; text-align: left;
  }
  .side .nav-btn:hover { background: rgba(255, 255, 255, .07); color: #fff; }
  .side .nav-btn.on { background: rgba(255, 255, 255, .14); color: #fff; }
  .side-new {
    margin-top: auto;
    height: 44px;
    border: 1px solid rgba(255, 255, 255, .25); border-radius: 10px;
    background: none; color: #fff; font-size: 14px; font-weight: 600;
  }
  .side-new:hover { background: rgba(255, 255, 255, .07); }
  .toast { bottom: 28px; }
  body:not(.viewer) .toast { margin-left: 110px; }
}

/* ---------- 작성 화면 ---------- */
.card {
  background: var(--card);
  border-radius: 16px;
  padding: 20px 18px;
  margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
}
.card-h { font-size: 17px; font-weight: 700; margin-bottom: 14px; }
.card-h small { font-size: 13px; font-weight: 500; color: var(--mute); margin-left: 6px; }

.grid2 { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
@media (min-width: 560px) { .grid2 { grid-template-columns: 1fr 1fr; } }

.fld { display: block; margin-bottom: 14px; }
.fld > span { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 600; color: var(--sub); }
.fld em { font-style: normal; font-weight: 400; color: var(--mute); margin-left: 4px; font-size: 13px; }
.fld input, .fld textarea {
  display: block; width: 100%;
  padding: 11px 13px;
  border: 1px solid #cdd3db; border-radius: 10px;
  background: #fff;
  font-size: 16px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.fld input { height: 48px; }
.fld textarea { resize: vertical; line-height: 1.6; }
.fld input:focus, .fld textarea:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(31, 58, 92, .14); }
.fld input::placeholder, .fld textarea::placeholder { color: #a7afba; }
.fld input[type="date"] { appearance: none; -webkit-appearance: none; min-width: 0; }

.hint { font-size: 13px; color: var(--mute); }
.txt { font-size: 15px; color: var(--sub); margin-bottom: 16px; }
.warn {
  margin-bottom: 14px; padding: 11px 13px;
  border-radius: 10px; background: #fff6e5; color: #8a5300;
  font-size: 14px;
}
.link-btn {
  border: 0; background: none; padding: 0;
  color: var(--navy); font-size: inherit; font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px;
}

/* 항목 */
.items { list-style: none; margin: 0; padding: 0; }
.item {
  padding: 14px 14px 6px;
  margin-bottom: 12px;
  border: 1px solid #e1e5ea; border-radius: 12px;
  background: #fafbfc;
}
.item-h { display: flex; align-items: center; justify-content: space-between; min-height: 32px; margin-bottom: 10px; }
.item-no { font-size: 15px; font-weight: 700; color: var(--navy); }
.item-del {
  height: 32px; padding: 0 12px;
  border: 1px solid #e6c8c5; border-radius: 8px;
  background: #fff; color: var(--red); font-size: 13px; font-weight: 600;
}
.item .fld { margin-bottom: 10px; }
.i-amt { text-align: right; font-variant-numeric: tabular-nums; }
.item-calc { min-height: 0; font-size: 13px; color: var(--sub); text-align: right; font-variant-numeric: tabular-nums; }
.item-calc:empty { display: none; }
@media (min-width: 560px) { .item-calc { padding-left: calc(50% + 7px); text-align: right; } }
.item-more {
  display: inline-flex; align-items: center; gap: 6px;
  height: 40px; padding: 0 2px;
  border: 0; background: none;
  color: var(--navy); font-size: 14px; font-weight: 600;
}
.item-more::after {
  content: ""; width: 7px; height: 7px;
  border: solid currentColor; border-width: 0 2px 2px 0;
  transform: translateY(-2px) rotate(45deg);
  transition: transform .15s;
}
.item-more[aria-expanded="true"]::after { transform: translateY(1px) rotate(-135deg); }
.item-detail { margin-top: 2px; }
.item-detail textarea { font-size: 16px; line-height: 1.6; }

.btn-add {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; height: 50px;
  border: 1.5px dashed #a9b6c6; border-radius: 12px;
  background: #fff; color: var(--navy);
  font-size: 16px; font-weight: 700;
}
.btn-add span { font-size: 20px; line-height: 1; }
.btn-add:hover { background: #f5f8fb; }

.sum {
  margin: 16px 0 0; padding: 14px 16px;
  border-radius: 12px; background: #f3f5f8;
}
.sum div { display: flex; justify-content: space-between; align-items: baseline; padding: 3px 0; }
.sum dt { font-size: 15px; color: var(--sub); }
.sum dd { margin: 0; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sum .sum-total { margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.sum .sum-total dt { font-size: 16px; font-weight: 700; color: var(--ink); }
.sum .sum-total dd { font-size: 20px; font-weight: 800; color: var(--navy); }

/* 보내는 곳 접기 */
.fold > summary { list-style: none; cursor: pointer; display: flex; align-items: center; margin-bottom: 0; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after {
  content: ""; flex: none; width: 8px; height: 8px; margin: 0 4px 0 10px;
  border: solid var(--sub); border-width: 0 2px 2px 0;
  transform: translateY(-2px) rotate(45deg);
}
.fold[open] > summary { margin-bottom: 14px; }
.fold[open] > summary::after { transform: translateY(2px) rotate(-135deg); }
.fold-sum {
  flex: 1; min-width: 0;
  text-align: right; font-size: 14px; font-weight: 500; color: var(--mute);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fold[open] .fold-sum { visibility: hidden; }

/* 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 50px; padding: 0 18px;
  border: 1px solid transparent; border-radius: 12px;
  font-size: 16px; font-weight: 700; text-decoration: none; text-align: center;
}
.btn.primary { background: var(--navy); color: #fff; }
.btn.primary:hover { background: #18304d; }
.btn.ghost { background: #fff; border-color: #c6cdd6; color: var(--navy); }
.btn.ghost:hover { background: #f5f8fb; }
.btn.wide { width: 100%; }
.next-row { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; margin-top: 6px; }

.link-out { margin-top: 16px; }
.link-out textarea {
  display: block; width: 100%;
  padding: 11px 13px;
  border: 1px solid #cdd3db; border-radius: 10px;
  background: #f6f8fa;
  font-size: 13px; color: var(--sub); line-height: 1.5;
  word-break: break-all; resize: none;
}
.link-acts { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 10px 0 10px; }
@media (min-width: 560px) { .link-acts { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); } }

/* ---------- 미리보기 / 받는 분 화면 ---------- */
.view-note { font-size: 14px; color: var(--sub); margin: 0 2px 10px; }
.paper {
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 8px 24px rgba(16, 24, 40, .06);
  padding: 44px 44px 48px;
}
.link-foot {
  margin: 18px auto 0; max-width: 560px;
  font-size: 13px; color: var(--mute); text-align: center;
  text-wrap: balance;
}
.link-foot .link-btn { display: inline-block; margin-top: 6px; color: var(--sub); font-weight: 500; }

body.viewer .main { max-width: 900px; }
body.viewer .tabs { display: none; }
@media (max-width: 959px) {
  body.viewer .view-bar {
    display: block;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    padding: 10px 16px calc(10px + var(--safe-b));
    background: #fff; border-top: 1px solid var(--line);
  }
  body.viewer .top-btn.primary { display: none; }
  body.viewer.broken .view-bar { display: none; }
}
@media (min-width: 960px) {
  body.viewer .top { padding: 0 max(24px, calc(50% - 434px)); }
  body.viewer .main { padding: 32px 24px 56px; }
  body.viewer .toast { bottom: 28px; }
}
.broken-msg { padding: 40px 8px; text-align: center; color: var(--sub); line-height: 1.8; }
.broken-msg b { color: var(--ink); font-size: 17px; }

/* ---------- 견적서 문서 ---------- */
.doc { color: #1a1a1a; font-size: 13px; line-height: 1.45; word-break: keep-all; }
.doc table { width: 100%; border-collapse: collapse; }
.doc th, .doc td { border: 1px solid var(--d-line); padding: 6px 8px; vertical-align: middle; }
.doc th { background: var(--d-head); font-weight: 600; }

.doc-title {
  margin-bottom: 22px; padding: 12px 0;
  background: var(--d-head);
  border-top: 2px solid #4a4a4a; border-bottom: 2px solid #4a4a4a;
  text-align: center;
  font-size: 26px; font-weight: 800; letter-spacing: .14em;
  text-wrap: balance;
}

.parties { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.party { table-layout: fixed; }
.party th { width: 76px; font-size: 12.5px; text-align: center; white-space: nowrap; }
.party th.side-l { width: 30px; padding: 6px 0; background: var(--d-head); }
.party th.side-l span {
  display: inline-block;
  writing-mode: vertical-rl; text-orientation: upright;
  letter-spacing: .35em; font-weight: 700;
}
.party td { height: 31px; text-align: center; overflow-wrap: anywhere; }
.party td.strong { font-weight: 700; }
.party td.mail { word-break: break-all; }
.seal { color: #8a8f96; margin-left: 2px; }

.lead { margin-bottom: 8px; font-size: 13px; }
.grand {
  display: flex; align-items: stretch;
  margin-bottom: 14px;
  border: 1.5px solid #4a4a4a;
}
.grand-l {
  flex: none; display: flex; align-items: center; justify-content: center;
  width: 106px; padding: 9px 6px;
  background: var(--d-head); border-right: 1px solid var(--d-line);
  font-weight: 700;
}
.grand-v { flex: 1; padding: 9px 14px; font-size: 14px; }
.grand-v b { font-size: 15px; }
.grand-n { color: #444; font-variant-numeric: tabular-nums; white-space: nowrap; }

.lines { table-layout: fixed; }
.lines col.w-no { width: 40px; }
.lines col.w-name { width: 104px; }
.lines col.w-amt { width: 96px; }
.lines col.w-vat { width: 84px; }
.lines thead th { padding: 8px 4px; font-size: 12.5px; text-align: center; white-space: nowrap; }
.lines tbody td { padding: 10px 8px; }
.lines .c-no { text-align: center; }
.lines .c-name { text-align: center; font-weight: 700; }
.lines .c-amt { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lines .c-sum { font-weight: 700; }
.lines .detail { font-size: 11.5px; line-height: 1.6; color: #333; white-space: pre-wrap; text-wrap: pretty; }
.lines tr.empty td { padding: 22px; text-align: center; color: #888; }
.lines tfoot th { text-align: center; font-size: 13px; background: var(--d-head2); }
.lines tfoot td { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.lines tfoot tr.total th, .lines tfoot tr.total td { background: var(--d-head); font-weight: 800; font-size: 14px; }
.lines tfoot tr.total td { color: var(--red); }

.extra { margin: 14px 0 0; border: 1px solid var(--d-line); }
.extra div { display: flex; }
.extra div + div { border-top: 1px solid var(--d-line); }
.extra dt {
  flex: none; width: 106px; padding: 8px 6px;
  background: var(--d-head); border-right: 1px solid var(--d-line);
  text-align: center; font-weight: 600;
}
.extra dd { flex: 1; margin: 0; padding: 8px 12px; overflow-wrap: anywhere; }
.extra dd.pre { white-space: pre-wrap; }

/* 견적서: 화면이 좁을 때 (인쇄에는 적용 안 함) */
@media screen and (max-width: 720px) {
  .paper { padding: 26px 18px 28px; border-radius: 14px; }
  .doc-title { font-size: 21px; letter-spacing: .08em; margin-bottom: 18px; }
  .parties { grid-template-columns: 1fr; gap: 12px; }
}
@media screen and (max-width: 600px) {
  .paper { padding: 22px 14px 24px; }
  .party th { width: 68px; font-size: 12px; padding: 6px 4px; }
  .party th.side-l { width: 28px; }
  .grand { flex-direction: column; }
  .grand-l { width: auto; justify-content: flex-start; padding: 7px 12px; border-right: 0; border-bottom: 1px solid var(--d-line); }
  .grand-v { padding: 9px 12px; }

  /* 항목 표 → 카드 */
  .lines, .lines tbody, .lines tfoot, .lines tr, .lines td, .lines th { display: block; width: auto; }
  .lines colgroup, .lines thead { display: none; }
  .lines tbody tr {
    display: grid; grid-template-columns: auto 1fr;
    border: 1px solid var(--d-line); margin-bottom: 10px;
  }
  .lines tbody td { border: 0; padding: 0; grid-column: 1 / -1; }
  .lines tbody td.c-no, .lines tbody td.c-name {
    grid-column: auto;
    padding: 8px 0 8px 12px;
    background: var(--d-head); font-weight: 700; text-align: left;
  }
  .lines tbody td.c-no::after { content: "."; }
  .lines tbody td.c-name { padding: 8px 12px 8px 4px; }
  .lines tbody td.c-detail { padding: 10px 12px; border-top: 1px solid var(--d-line); border-bottom: 1px solid #e3e0d6; }
  .lines tbody td.c-detail:empty { display: none; }
  .lines tbody td.c-amt {
    display: flex; justify-content: space-between;
    padding: 5px 12px;
  }
  .lines tbody td.c-name + .c-detail:empty + .c-amt { border-top: 1px solid var(--d-line); padding-top: 9px; }
  .lines tbody td.c-detail + .c-amt { padding-top: 9px; }
  .lines tbody td.c-sum { padding-bottom: 9px; }
  .lines tbody td.c-amt::before { content: attr(data-l); font-weight: 400; color: #555; }
  .lines tbody tr.empty td { padding: 18px; }
  .lines tfoot { border: 1px solid var(--d-line); }
  .lines tfoot tr { display: flex; justify-content: space-between; align-items: baseline; }
  .lines tfoot tr + tr { border-top: 1px solid var(--d-line); }
  .lines tfoot th, .lines tfoot td { border: 0; background: transparent; padding: 8px 12px; }
  .lines tfoot tr.total { background: var(--d-head); }
  .lines tfoot tr.total th, .lines tfoot tr.total td { background: transparent; }

  .extra div { flex-direction: column; }
  .extra dt { width: auto; text-align: left; padding: 6px 12px; border-right: 0; border-bottom: 1px solid var(--d-line); }
  .extra dd { padding: 8px 12px; }
}
@media screen and (max-width: 359px) {
  .main { padding-left: 12px; padding-right: 12px; }
  .paper { padding: 18px 10px 20px; }
  .doc-title { font-size: 19px; letter-spacing: .04em; }
  .party th { width: 60px; }
}

/* ---------- 문서 공통 추가: 견적번호·보내는 곳 ---------- */
.doc-no { margin: -12px 0 12px; text-align: right; font-size: 12px; color: #555; }
.sign { margin-top: 28px; text-align: center; }
.sign-date { font-size: 13px; margin-bottom: 8px; }
.sign-name { display: flex; justify-content: center; align-items: center; gap: 10px; font-size: 15px; }
.sign-l { font-size: 12px; color: #666; font-weight: 400; }
.sign-name .seal-big {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; margin-left: 2px;
  border: 1.5px solid #b9bdc3; border-radius: 50%;
  color: #8a8f96; font-size: 12px;
}

/* 받는 분 화면: 보낸 회사 */
.from {
  margin: 0 0 12px; padding: 13px 16px;
  border-radius: 12px; background: #e9f0f8; color: var(--navy);
  font-size: 15px; text-align: center; text-wrap: balance;
}
.from b { font-weight: 800; }

/* ---------- 작성: 종이 위에서 바로 적기 ---------- */
.edit-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 12px;
}
.edit-hint { font-size: 14px; color: var(--sub); text-wrap: pretty; }
.hint-sw { padding: 1px 6px; border-radius: 4px; background: #e6eef8; box-shadow: inset 0 0 0 1px #c9d8ea; color: var(--navy); font-weight: 600; }
.edit-acts { display: flex; gap: 8px; flex: none; }
.btn.sm { height: 40px; padding: 0 16px; font-size: 14px; border-radius: 10px; }
.phone-only { display: none; }
.edit-foot { margin: 14px 2px 0; font-size: 13px; color: var(--mute); text-wrap: pretty; }
.edit-foot .link-btn { color: var(--sub); font-weight: 500; }

.doc-edit .ed {
  display: block; width: 100%;
  margin: 0; padding: 4px 6px;
  border: 0; border-radius: 4px;
  background: #e6eef8;
  box-shadow: inset 0 0 0 1px #c9d8ea;
  color: inherit; font: inherit; text-align: inherit; letter-spacing: inherit;
  outline: none;
  transition: background .12s, box-shadow .12s;
}
.doc-edit .ed:hover { background: #dbe7f5; }
.doc-edit .ed:focus { background: #fff; box-shadow: 0 0 0 2px #2f6fb5; }
.doc-edit .ed::placeholder { color: #8da0b6; font-weight: 400; letter-spacing: 0; }
.doc-edit textarea.ed { resize: none; overflow: hidden; line-height: inherit; }
.doc-edit input[type="date"].ed { min-height: 27px; }

.doc-edit .doc-title { padding: 8px 14px; }
.doc-edit .doc-title .ed { padding: 4px 8px; text-align: center; font-weight: 800; background: rgba(255, 255, 255, .6); }
.doc-edit .doc-no { display: flex; justify-content: flex-end; }
.doc-edit .doc-no label { display: inline-flex; align-items: center; gap: 6px; }
.doc-edit .doc-no .ed { width: 130px; font-size: 12px; }
.doc-edit .party td { padding: 3px 4px; }
.doc-edit .party td.strong .ed { font-weight: 700; }
.ceo-in { display: flex; align-items: center; gap: 4px; }
.ceo-in .ed { flex: 1; min-width: 0; }
.ceo-in .seal { flex: none; font-size: 12px; }

.doc-edit .lines tbody#lineRows td { padding: 6px; vertical-align: top; }
.doc-edit .lines .c-no { vertical-align: top; padding-top: 10px !important; }
.doc-edit .lines .c-name .ed { text-align: center; font-weight: 700; }
.doc-edit .ed-detail { font-size: 11.5px; line-height: 1.6; text-align: left; min-height: 46px; }
.doc-edit .ed-amt { text-align: right; font-variant-numeric: tabular-nums; }
.doc-edit .lines .c-vat, .doc-edit .lines .c-sum { padding-top: 10px !important; }
.doc-edit .no { display: block; font-weight: 600; }
.row-tools { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 8px; }
.row-tools button {
  width: 26px; height: 26px; padding: 0;
  border: 1px solid #d3d8df; border-radius: 6px;
  background: #fff; color: #6b7280; font-size: 14px; line-height: 1;
}
.row-tools .row-star:hover { color: #b7791f; border-color: #e5c07b; }
.row-tools .row-del:hover { color: var(--red); border-color: #e6c8c5; }
.open-detail { display: none; }

.doc-edit .add-row td { padding: 8px; border-style: dashed; background: #fafbfc; }
.add-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 14px; margin-right: 6px;
  border: 1.5px dashed #9fb3cb; border-radius: 8px;
  background: #fff; color: var(--navy); font-size: 14px; font-weight: 700;
}
.add-btn span { font-size: 18px; line-height: 1; }
.add-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.add-btn.sub { border-style: solid; border-color: #d3d8df; color: var(--sub); font-weight: 600; }
.add-btn:hover { background: #f3f7fb; }

.doc-edit .extra dd { padding: 4px 6px; }
.doc-edit .sign-name .ed { width: 300px; max-width: 100%; text-align: center; font-weight: 700; }

/* 자주 쓰는 항목 */
.presets { list-style: none; margin: 0; padding: 0; }
.preset { padding: 14px 0; border-top: 1px solid var(--line); }
.preset:first-child { border-top: 0; padding-top: 4px; }
.preset-t { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.preset-t b { font-size: 16px; }
.preset-t span { flex: none; font-size: 15px; font-weight: 600; color: var(--navy); font-variant-numeric: tabular-nums; }
.preset-x {
  margin-top: 6px; font-size: 13px; color: var(--sub); white-space: pre-wrap;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.preset-acts { display: flex; gap: 8px; margin-top: 10px; }
.preset-acts .btn { min-width: 76px; }
.empty-note { padding: 18px 0 6px; text-align: center; color: var(--mute); font-size: 14px; }

@media (max-width: 959px) {
  .edit-bar { display: block; }
  .edit-acts { display: none; }
  .phone-only { display: grid; }
  .next-row.phone-only { grid-template-columns: 1fr 1.6fr; gap: 10px; margin-top: 14px; }
}

/* 폰: 종이도 카드 모양으로, 입력 글씨는 16px (아이폰 확대 방지) */
@media screen and (max-width: 600px) {
  .doc-edit .ed, .doc-edit .ed-detail, .doc-edit .doc-no .ed { font-size: 16px; }
  .doc-edit .doc-title .ed { font-size: 20px; }
  .doc-edit .doc-no { margin-top: -8px; }
  .doc-edit .lines tbody#lineRows tr { position: relative; }
  .doc-edit .lines tbody#lineRows td.c-no { padding: 12px 0 8px 12px !important; }
  .doc-edit .lines tbody#lineRows td.c-name { padding: 6px 76px 6px 4px; }
  .doc-edit .lines .c-name .ed { text-align: left; }
  .doc-edit .no { display: inline; }
  .row-tools { position: absolute; top: 7px; right: 8px; flex-direction: row; margin: 0; }
  .row-tools button { width: 32px; height: 32px; font-size: 16px; }
  .doc-edit .lines tbody#lineRows td.c-detail { padding: 10px 12px; }
  .doc-edit .c-detail.closed .ed-detail { display: none; }
  .doc-edit .c-detail.closed .open-detail {
    display: block; padding: 2px 0; border: 0; background: none;
    color: var(--navy); font-size: 14px; font-weight: 600;
  }
  .doc-edit .lines tbody#lineRows td.c-amt { align-items: center; padding: 6px 12px !important; }
  .doc-edit .lines tbody#lineRows td.c-in::before { flex: none; margin-right: 12px; }
  .doc-edit .lines tbody#lineRows td.c-in .ed { max-width: 62%; margin-left: auto; }
  .doc-edit .lines tbody#lineRows td.c-vat:empty, .doc-edit .lines tbody#lineRows td.c-sum:empty { display: none; }
  .doc-edit .add-row { display: block; margin-bottom: 10px; }
  .doc-edit .add-row td { display: flex; flex-wrap: wrap; gap: 8px; border: 0; padding: 0; background: none; }
  .add-btn { flex: 1 1 100%; justify-content: center; height: 46px; margin: 0; font-size: 15px; }
  .doc-edit .extra dd { padding: 6px 8px; }
  .sign-name { flex-wrap: wrap; }
  .doc-edit .sign-name .ed { flex: 1; width: auto; text-align: center; }
  .doc-edit .sign-l { flex: 1 1 100%; }
  .doc-edit .sign-name { gap: 6px 8px; }
}

/* 최근 견적·앱 설치 */
.recents { list-style: none; margin: 0; padding: 0; }
.recent { padding: 14px 0; border-top: 1px solid var(--line); }
.recent:first-child { border-top: 0; padding-top: 4px; }
.recent-m { margin-top: 4px; font-size: 13px; color: var(--mute); }
.preset-acts { flex-wrap: nowrap; }
.recent .preset-acts .btn { flex: 1 1 0; min-width: 0; padding: 0 8px; }
.install {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px; padding: 10px 10px 10px 16px;
  border-radius: 12px; background: #fff; box-shadow: 0 1px 2px rgba(16, 24, 40, .06);
  font-size: 14px; color: var(--sub);
}
.install p { flex: 1; min-width: 0; }
.install b { color: var(--ink); }
.install-x { flex: none; width: 34px; height: 34px; border: 0; background: none; color: var(--mute); font-size: 20px; }
.side-install {
  margin-top: auto; margin-bottom: 8px;
  height: 44px;
  border: 0; border-radius: 10px;
  background: rgba(255, 255, 255, .12); color: #fff; font-size: 14px; font-weight: 600;
}
.side-install:not([hidden]) + .side-new { margin-top: 0; }

/* 상호 칸 아래 최근 거래처 */
.sug-wrap { position: relative; }
.sug {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30;
  min-width: 240px; max-width: calc(100vw - 48px);
  margin: 0; padding: 4px; list-style: none;
  border: 1px solid #c9d3df; border-radius: 10px; background: #fff;
  box-shadow: 0 8px 24px rgba(16, 24, 40, .14);
  text-align: left;
}
.sug-h { padding: 6px 10px 4px; font-size: 12px; color: var(--mute); }
.sug button {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  width: 100%; padding: 9px 10px;
  border: 0; border-radius: 8px; background: none;
  font-size: 14px; font-weight: 600; text-align: left;
}
.sug button:hover { background: #eef4fb; }
.sug small { flex: none; font-size: 12px; font-weight: 400; color: var(--mute); }
.doc-edit textarea.ed.one { white-space: pre-wrap; word-break: keep-all; overflow-wrap: anywhere; }

/* 만든 곳·사용 문의 */
.made { margin: 14px auto 0; max-width: 560px; font-size: 13px; color: var(--mute); text-align: center; text-wrap: balance; }
.made a, .side-made a { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
p.made.phone-only { display: none; }
@media (max-width: 959px) { p.made.phone-only { display: block; margin-top: 18px; } }
.side-made { margin: 14px 4px 0; font-size: 12px; line-height: 1.6; color: rgba(255, 255, 255, .55); }
.top-back { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; margin-left: -8px; color: var(--ink); }
.top-back svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.contact-page .main { max-width: 640px; padding-bottom: 40px; }
.feat { margin: 0 0 16px; padding-left: 20px; color: var(--ink); font-size: 15px; line-height: 1.75; }
.contact-acts { display: grid; grid-template-columns: 1fr; gap: 8px; margin-bottom: 10px; }
@media (min-width: 560px) { .contact-acts { grid-template-columns: 1fr 1fr; } }
.co { margin: 0; }
.co div { display: grid; grid-template-columns: 112px 1fr; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 15px; }
.co div:first-child { border-top: 0; padding-top: 0; }
.co dt { color: var(--sub); }
.co dd { margin: 0; overflow-wrap: anywhere; }
.co a { color: var(--navy); }

/* 도장: '(인)' 위에 겹쳐 찍는다 */
.seal { position: relative; display: inline-block; }
.seal-img {
  position: absolute; left: 50%; top: 50%;
  width: 40px; height: 40px; object-fit: contain;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.seal-big .seal-img { width: 58px; height: 58px; }
.sign-name .seal-big.has-img { border-color: transparent; }

/* 작성: 보내는 곳·도장 선택 (인쇄 안 됨) */
.doc-edit .sign.off { opacity: .35; }
.doc-edit .sign.off .ed { pointer-events: none; }
.doc-opts {
  margin-top: 22px; padding-top: 16px;
  border-top: 1px dashed var(--line);
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px;
}
.opt { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; font-size: 15px; font-weight: 600; cursor: pointer; }
.opt input { width: 20px; height: 20px; margin: 0; accent-color: var(--navy); }
.opt-seal { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.seal-thumb:empty { display: none; }
.seal-thumb { display: inline-flex; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 8px; align-items: center; justify-content: center; background: #fff; }
.seal-thumb img { max-width: 34px; max-height: 34px; }
.opt-hint { flex: 1 1 100%; font-size: 13px; color: var(--mute); text-wrap: pretty; }

/* 사용 문의 폼 */
.ask .fld textarea { min-height: 120px; }
.honey { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.agree { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 16px; font-size: 14px; cursor: pointer; }
.agree input { flex: none; width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--navy); }
.agree small { display: block; margin-top: 4px; font-size: 12.5px; color: var(--mute); text-wrap: pretty; }
.ask-msg { min-height: 22px; margin-top: 10px; font-size: 14px; color: var(--navy); text-align: center; text-wrap: balance; }
.ask button[disabled] { opacity: .6; }

/* 받는 분 화면 아래: 사용 문의 (인쇄 안 됨) */
.promo {
  display: flex; align-items: center; gap: 14px;
  max-width: 640px; margin: 18px auto 0; padding: 16px 18px;
  border-radius: 14px; background: #fff; box-shadow: 0 1px 2px rgba(16, 24, 40, .06);
}
.promo p { flex: 1; min-width: 0; font-size: 15px; text-wrap: pretty; }
.promo p span { display: block; margin-top: 2px; font-size: 13px; color: var(--mute); }
.promo .btn { flex: none; }
@media (max-width: 420px) {
  .promo { flex-direction: column; align-items: stretch; text-align: center; }
  .promo .btn { height: 46px; }
}
@media (max-width: 600px) {
  .opt-seal > .opt { flex: 1 1 100%; }
}

/* 작성 중 미리보기 */
.view-acts {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px;
}
.view-acts-t { flex: 1; min-width: 0; font-size: 14px; color: var(--sub); text-align: center; }
.next-row.phone-only.three { grid-template-columns: 1fr 1fr; }
.next-row.phone-only.three .js-link { grid-column: 1 / -1; }
@media (max-width: 600px) {
  .view-acts { flex-wrap: wrap; }
  .view-acts-t { order: -1; flex: 1 1 100%; text-align: left; margin: 0 2px 2px; }
  .view-acts .btn { flex: 1 1 0; padding: 0 8px; }
}

.link-kind { margin: 2px 0 8px; color: var(--navy); font-weight: 600; }

/* ---------- 인쇄 (A4) ---------- */
@page { size: A4; margin: 12mm 11mm; }
@media print {
  html, body { background: #fff !important; }
  body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .side, .top, .tabs, .view-bar, .toast, .from, .link-foot, .made, .promo, .view-acts, #p-edit, #p-send, #p-presets, #p-recent { display: none !important; }
  #p-view, #p-view[hidden] { display: block !important; }
  .main, body.viewer .main, body:not(.viewer) .main { margin: 0 !important; padding: 0 !important; max-width: none !important; }
  .main > .panel { max-width: none !important; }
  .paper { padding: 0; box-shadow: none; border-radius: 0; }
  .doc { font-size: 12.5px; }
  .doc-title { margin-bottom: 18px; }
  .lines tr, .extra, .grand, .parties, .sign { break-inside: avoid; }
  .lines tfoot { display: table-row-group; } /* 페이지마다 합계가 반복되지 않게 */
}
