:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1b1f24;
  --muted: #5b6573;
  --line: #e3e7ec;
  --primary: #5b3cc4;
  --primary-dark: #48309e;
  --accent-bg: #f1edfc;
  --warn-bg: #fff6e5;
  --warn-text: #8a5a00;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  font-size: 16px;
  line-height: 1.7;
  word-break: keep-all;
}

a { color: var(--primary); }

.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }

/* 상단 메뉴 */
header.site {
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
header.site .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 12px;
  padding-bottom: 12px;
}
.logo { font-weight: 800; font-size: 18px; color: var(--text); text-decoration: none; }
.logo span { color: var(--primary); }
nav.menu { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 14px; }
nav.menu a { color: var(--muted); text-decoration: none; }
nav.menu a:hover { color: var(--primary); }

main { padding: 24px 0 40px; }

h1 { font-size: 26px; line-height: 1.35; margin: 8px 0 8px; }
h2 { font-size: 20px; margin: 32px 0 10px; }
h3 { font-size: 17px; margin: 22px 0 6px; }
.lead { color: var(--muted); margin: 0 0 20px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
}

/* 계산기 입력 */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.field .hint { display: block; font-size: 13px; color: var(--muted); margin-top: 4px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .row { grid-template-columns: 1fr; } }

input[type="date"], input[type="text"], select {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent; }

.tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tabs button {
  flex: 1;
  padding: 10px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
}
.tabs button.active { background: var(--accent-bg); color: var(--primary); border-color: var(--primary); }
.field label + label { margin-top: 6px; }
details.more { margin: 4px 0 16px; }
details.more summary { cursor: pointer; color: var(--primary); font-weight: 600; font-size: 15px; }
details.more .inner { padding-top: 14px; }

button.calc {
  width: 100%;
  padding: 15px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
}
button.calc:hover { background: var(--primary-dark); }

.error { color: #c62828; font-size: 14px; margin-top: 10px; min-height: 1em; }

/* 결과 */
#result { display: none; }
#result.show { display: block; }
.big {
  background: var(--accent-bg);
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  margin-bottom: 16px;
}
.big .label { color: var(--muted); font-size: 14px; }
.big .amount { font-size: 32px; font-weight: 800; color: var(--primary); }
.big .sub { font-size: 14px; color: var(--muted); }

table.detail { width: 100%; border-collapse: collapse; font-size: 15px; }
table.detail th, table.detail td { padding: 9px 4px; border-bottom: 1px solid var(--line); text-align: left; }
table.detail td { text-align: right; font-weight: 600; }
table.detail td small, table.detail th small { display: block; color: var(--muted); font-weight: 400; font-size: 13px; }

.notice {
  background: var(--warn-bg);
  color: var(--warn-text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
  margin-top: 14px;
}

.formula {
  background: var(--accent-bg);
  border-radius: 10px;
  padding: 14px;
  font-weight: 600;
  text-align: center;
}

/* 글 목록 */
.guides { display: grid; gap: 10px; padding: 0; list-style: none; margin: 0; }
.guides a {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
}
.guides a:hover { border-color: var(--primary); }
.guides small { display: block; color: var(--muted); font-weight: 400; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 10px 0; }
.table-scroll table.data { margin: 0; min-width: 520px; }
@media (max-width: 520px) { table.data { font-size: 14px; } }
table.data { width: 100%; border-collapse: collapse; font-size: 15px; margin: 10px 0; background: var(--card); }
table.data th, table.data td { border: 1px solid var(--line); padding: 8px; text-align: left; }
table.data th { background: var(--accent-bg); }

.faq dt { font-weight: 700; margin-top: 14px; }
.faq dd { margin: 4px 0 0; color: var(--muted); }

.updated { color: var(--muted); font-size: 13px; }

footer.site {
  border-top: 1px solid var(--line);
  background: var(--card);
  font-size: 13px;
  color: var(--muted);
  padding: 20px 0;
}
footer.site a { color: var(--muted); margin-right: 12px; }

/* 양식(문서) 미리보기와 인쇄 */
textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: inherit;
  resize: vertical;
}
.doc-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 14px; }
.doc-actions button {
  padding: 12px 16px; font-size: 15px; font-weight: 700; font-family: inherit;
  border-radius: 10px; cursor: pointer; border: 1px solid var(--primary);
  background: var(--primary); color: #fff;
}
.doc-actions button.ghost { background: var(--card); color: var(--primary); }
.doc {
  background: #fff; color: #000; border: 1px solid var(--line); border-radius: 6px;
  padding: 40px 36px; margin: 0 0 20px; font-size: 15px; line-height: 1.9;
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}
.doc h2.doc-title { text-align: center; font-size: 26px; letter-spacing: 12px; margin: 0 0 28px; }
.doc table.doc-table { width: 100%; border-collapse: collapse; margin: 0 0 22px; }
.doc table.doc-table th, .doc table.doc-table td { border: 1px solid #333; padding: 8px 10px; text-align: left; vertical-align: top; }
.doc table.doc-table th { width: 26%; background: #f3f3f3; font-weight: 600; }
.doc .doc-body { white-space: pre-wrap; margin: 0 0 26px; }
.doc .doc-date { text-align: center; margin: 26px 0; }
.doc .doc-sign { text-align: right; margin: 0 0 6px; }
.doc .doc-to { margin-top: 30px; font-weight: 700; font-size: 17px; }
.doc .blank { color: #999; }
@media (max-width: 520px) { .doc { padding: 24px 16px; font-size: 14px; } .doc h2.doc-title { font-size: 22px; letter-spacing: 6px; } }
@media print {
  @page { size: A4; margin: 18mm; }
  body { background: #fff; }
  header.site, footer.site, .no-print, ins.adsbygoogle { display: none !important; }
  main.wrap { padding: 0; max-width: none; }
  .doc { border: 0; padding: 0; margin: 0; font-size: 14pt; }
  .doc .blank { color: #000; }
  body.printing-doc main > *:not(.doc) { display: none !important; }
}
/* 품목 표 (견적서·거래명세서) */
.item-row { display: grid; grid-template-columns: 2fr 1fr 0.7fr 1.2fr auto; gap: 6px; margin-bottom: 8px; align-items: center; }
.item-row input { padding: 10px; font-size: 15px; }
.item-row button { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 8px 10px; cursor: pointer; color: var(--muted); font-family: inherit; }
.item-head { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
@media (max-width: 520px) {
  .item-row { grid-template-columns: 1fr 1fr; padding: 10px; border: 1px solid var(--line); border-radius: 10px; }
  .item-row input:first-child { grid-column: 1 / -1; }
  .item-head { display: none; }
}
.doc table.doc-items { width: 100%; border-collapse: collapse; margin: 0 0 18px; font-size: 0.92em; }
.doc table.doc-items th, .doc table.doc-items td { border: 1px solid #333; padding: 6px 8px; }
.doc table.doc-items th { background: #f3f3f3; font-weight: 600; text-align: center; }
.doc table.doc-items td.num { text-align: right; white-space: nowrap; }
.doc table.doc-items tfoot td { font-weight: 700; }
.doc .doc-total { font-size: 1.1em; font-weight: 700; border-top: 2px solid #333; border-bottom: 2px solid #333; padding: 8px 0; margin: 0 0 14px; }
.doc .doc-head { display: grid; grid-template-columns: 1fr 1.3fr; gap: 16px; align-items: start; margin-bottom: 18px; }
.doc .doc-head .to { font-size: 1.15em; font-weight: 700; padding-top: 6px; }
.doc .doc-head table.doc-table { margin: 0; font-size: 0.92em; }
@media (max-width: 520px) { .doc .doc-head { grid-template-columns: 1fr; } }@media (max-width: 520px) {
  .doc table.doc-items { font-size: 0.82em; table-layout: fixed; }
  .doc table.doc-items th, .doc table.doc-items td { padding: 4px 3px; overflow-wrap: anywhere; }
  .doc table.doc-items td.num { white-space: normal; }
  .doc table.doc-items th:nth-child(1) { width: 2.2em; }
  .doc table.doc-items th:nth-child(3) { width: 3.2em; }
  .doc table.doc-items th:nth-child(4), .doc table.doc-items th:nth-child(5) { width: 24%; }
}