/* 견적서·거래명세서 작성기 — 앱 UI. site.css(사이트 크롬) 위에 얹는다. */
:root {
  --ink: #111827;
  --muted: #5b6472;
  --line: #d6ddec;
  --brand: #1d4ed8;
  --brand-dark: #163a9e;
  --bg: #f4f7ff;
  --card: #ffffff;
  --danger: #b91c1c;
  --ok: #166534;
}
* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); }
main { max-width: 1120px; }
h1, h2, h3 { color: var(--ink); }
a { color: var(--brand); }
.small, .muted { color: var(--muted); font-size: .875rem; }
.lead { font-size: 1.02rem; color: #374151; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 14px; }
.badge { background: #e8efff; color: var(--brand-dark); border-radius: 999px; padding: 3px 10px; font-size: .8rem; font-weight: 600; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 16px; border-radius: 10px;
  border: 1px solid #c3cee3; background: #fff; color: var(--ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); color: #fff; }
.btn.danger { border-color: #f0b4b4; background: #fff5f5; color: var(--danger); }
.btn.mini { min-height: 36px; padding: 4px 10px; font-size: .85rem; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; margin: 14px 0;
}
.card h2 { margin-top: 0; font-size: 1.08rem; }
.cards3 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.cards3 .card { margin: 0; }
.cards3 h3 { margin-top: 0; }
.layout { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.side { min-width: 0; }
@media (min-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1.05fr) minmax(380px, .95fr); }
  .side .card.sticky { position: sticky; top: 12px; }
}
.grid2 { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.fld { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; min-width: 0; }
.fld label { font-weight: 600; font-size: .9rem; }
.fld .req { color: var(--danger); }
.card input, .card select, .card textarea, .toolbar input, .toolbar select {
  width: 100%; min-height: 44px; padding: 8px 10px;
  border: 1px solid #c3cee3; border-radius: 8px; background: #fff;
  font: inherit; color: var(--ink);
}
.card textarea { min-height: 80px; resize: vertical; }
.card input:focus-visible, .card select:focus-visible, .card textarea:focus-visible,
.toolbar input:focus-visible, .toolbar select:focus-visible, .btn:focus-visible {
  outline: 3px solid #f59e0b; outline-offset: 2px;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip {
  min-height: 44px; padding: 8px 16px; border-radius: 999px;
  border: 1px solid #c3cee3; background: #fff; color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer;
}
.chip[aria-pressed="true"], .chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.notice { background: #fff8e1; border: 1px solid #f2d98a; border-radius: 8px; padding: 8px 12px; font-size: .9rem; }
.tool-err { color: var(--danger); min-height: 1.2em; margin: 8px 0; font-weight: 600; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin: 12px 0; }
.toolbar .grow { flex: 1 1 220px; }
.toolbar .fld { margin: 0; }
.logo-preview { max-width: 160px; max-height: 80px; margin-top: 6px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; background: #fff; }

/* 품목 행 */
.item-row {
  display: grid; gap: 8px; padding: 10px 0; border-bottom: 1px dashed var(--line);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
}
.item-row input { min-height: 42px; }
.item-row .it-name, .item-row .it-spec { grid-column: span 2; }
.item-row .it-line { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.item-row .it-del { min-height: 36px; padding: 4px 10px; border-radius: 8px; border: 1px solid #f0b4b4; background: #fff5f5; color: var(--danger); font: inherit; cursor: pointer; }
.item-row .it-err { grid-column: 1 / -1; margin: 0; color: var(--danger); font-size: .82rem; }
@media (min-width: 760px) {
  .item-row {
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) 76px 110px minmax(0, 1fr) 100px auto;
  }
  .item-row .it-name, .item-row .it-spec { grid-column: auto; }
}
.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.totals-bar { border-top: 2px solid var(--ink); margin-top: 10px; padding-top: 8px; }
.totals-bar p { display: flex; justify-content: space-between; margin: 4px 0; font-size: .95rem; }
.totals-bar strong { font-variant-numeric: tabular-nums; }
.totals-bar .grand { font-size: 1.15rem; border-top: 1px solid var(--line); padding-top: 6px; }
.totals-bar .grand strong { color: var(--brand-dark); }

/* 문서(종이) */
.paper {
  background: #fff; color: #111;
  border: 1px solid var(--line); border-radius: 12px;
  padding: 18px; max-width: 100%;
  font-size: 13px; line-height: 1.55;
  box-shadow: 0 2px 8px rgba(17, 24, 39, .06);
}
.paper-preview { max-height: 460px; overflow: auto; border-radius: 8px; }
.paper-preview .paper { padding: 12px; font-size: 10.5px; border-radius: 8px; }
.doc { max-width: 100%; }
.doc-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; border-bottom: 2px solid #111; padding-bottom: 10px; margin-bottom: 12px; }
.doc-title-wrap { display: flex; align-items: center; gap: 10px; }
.doc-logo { max-height: 54px; max-width: 140px; object-fit: contain; }
.doc-title { font-size: 26px; letter-spacing: .12em; margin: 0; color: #111; }
.doc-meta p { margin: 2px 0; font-size: 11.5px; }
.doc-meta .k, .doc-note .k { color: #555; margin-right: 6px; }
.doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.doc-parties section { border: 1px solid #bbb; border-radius: 6px; padding: 8px 10px; }
.doc-parties h2 { font-size: 11.5px; margin: 0 0 4px; color: #555; letter-spacing: .06em; }
.doc-parties p { margin: 1px 0; font-size: 11.5px; }
.doc-parties .muted { color: #777; }
.doc-table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 11.5px; }
.doc-table th, .doc-table td { border: 1px solid #999; padding: 4px 6px; text-align: left; vertical-align: top; }
.doc-table thead th { background: #eef2f8; text-align: center; font-weight: 700; }
.doc-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.doc-table .name { min-width: 90px; }
.doc-totals { margin-left: auto; width: min(340px, 100%); border-collapse: collapse; font-size: 12px; }
.doc-totals th, .doc-totals td { border: 1px solid #999; padding: 4px 8px; }
.doc-totals th { background: #f4f6fa; text-align: left; width: 45%; }
.doc-totals td { text-align: right; font-variant-numeric: tabular-nums; }
.doc-totals .grand th, .doc-totals .grand td { background: #e8efff; font-size: 13px; }
.doc-note { margin: 8px 0 0; font-size: 11.5px; }
.doc-notices { margin: 10px 0 0; padding-left: 16px; color: #555; font-size: 10.5px; }
.doc-notices li { margin: 1px 0; }
.watermark { margin: 8px 0 0; text-align: right; color: #9aa3af; font-size: 9.5px; letter-spacing: .02em; }
.tpl-simple .doc-parties { grid-template-columns: 1fr; }
.tpl-simple .doc-table th:nth-child(3), .tpl-simple .doc-table td:nth-child(3),
.tpl-simple .doc-table th:nth-child(7), .tpl-simple .doc-table td:nth-child(7) { display: none; }
.tpl-detail .doc-table { font-size: 12px; }
.tpl-detail .doc-table th, .tpl-detail .doc-table td { padding: 5px 7px; }

/* 저장 목록 */
.doc-list { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 8px; }
.doc-row { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.doc-row-main { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; }
.doc-no { font-weight: 700; font-variant-numeric: tabular-nums; }
.doc-row-sub { color: #374151; font-size: .9rem; margin: 4px 0 8px; }
.doc-row-sub .money { font-weight: 700; }
.doc-row-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.doc-row-actions select { min-height: 36px; padding: 2px 6px; border: 1px solid #c3cee3; border-radius: 8px; font: inherit; font-size: .85rem; background: #fff; }
.steps { padding-left: 20px; }
.steps li { margin: 8px 0; }
.linklist { padding-left: 18px; }
.linklist li { margin: 6px 0; }

/* 인쇄 — nav·버튼·미리보기 외 모든 것을 숨기고 A4 1장 */
@media print {
  @page { size: A4; margin: 12mm; }
  html, body { background: #fff !important; }
  nav.chrome, footer.chrome, .no-print, .ad-slot, .toolbar,
  main > h1, main > .updated, main > .aeo, main > .sources, main > .related,
  main > .faq, main > h2, main > p, main > ul, main > ol, main > .cards3 { display: none !important; }
  main { max-width: none; margin: 0; padding: 0; }
  #doc-paper {
    display: block !important; width: auto; min-height: 0; margin: 0; padding: 0;
    border: 0; border-radius: 0; box-shadow: none; font-size: 11.5pt; line-height: 1.5;
  }
  .paper { border: 0; box-shadow: none; padding: 0; }
  .doc-table tr, .doc-totals tr, .doc-notices li { break-inside: avoid; }
  .doc-notices { color: #444; }
  .watermark { color: #999; }
  a { color: inherit; text-decoration: none; }
}
@media (max-width: 420px) {
  .card { padding: 12px; }
  .doc-title { font-size: 20px; }
  .doc-parties { grid-template-columns: 1fr; }
  .paper { padding: 12px; font-size: 12px; }
}
