:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --border: #e3e7ee;
  --text: #1c2128;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-light: #eaf1ff;
  --danger: #dc2626;
  --success: #16803c;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(20, 30, 60, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding-top: 24px;
  padding-right: clamp(5px, -3px + 2.5vw, 16px);
  padding-bottom: 60px;
  padding-left: clamp(5px, -3px + 2.5vw, 16px);
}

header.site {
  text-align: center;
  padding: 28px 0 8px;
}

header.site h1 {
  font-size: clamp(22px, 5vw, 28px);
  margin: 0 0 6px;
}

header.site p {
  color: var(--muted);
  font-size: clamp(12px, 10.545px + 0.455vw, 14px);
  margin: 0;
}

/* Tabs */
.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 24px 0 20px;
}

.tab-btn {
  padding: 12px 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  font-size: clamp(12px, 10.545px + 0.455vw, 14px);
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--shadow);
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding-top: 22px;
  padding-right: clamp(5px, -7.36px + 3.864vw, 22px);
  padding-bottom: 22px;
  padding-left: clamp(5px, -7.36px + 3.864vw, 22px);
  margin-bottom: 16px;
}

.card h2 {
  font-size: clamp(14.5px, 12.682px + 0.568vw, 17px);
  margin: 0 0 16px;
  text-align: center;
}

.input-suffix {
  position: relative;
}

.input-suffix span {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: clamp(12px, 10.545px + 0.455vw, 14px);
  pointer-events: none;
}

.seg {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.seg button {
  flex: 1;
  padding: 10px;
  border: none;
  background: var(--bg);
  color: var(--muted);
  font-size: clamp(12px, 10.545px + 0.455vw, 14px);
  font-weight: 600;
  cursor: pointer;
}

.seg button.active {
  background: var(--accent);
  color: #fff;
}

.free-unit-seg {
  margin-bottom: 14px;
}


#freeHoursWrap {
  margin-top: -10px;
  height: 400px;
  overflow-y: auto;
}

.sub-title {
  font-size: clamp(13px, 11.545px + 0.455vw, 15px);
  font-weight: 700;
  color: var(--text);
  margin: 8px 0 8px;
}

table.week-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: clamp(11px, 9.545px + 0.455vw, 13px);
  margin-bottom: 6px;
}

table.week-table th {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
}

table.week-table td {
  padding: 5px 4px;
  border-bottom: 1px solid var(--border);
}

table.week-table th:first-child,
table.week-table td:first-child {
  width: 22%;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
}

table.week-table input {
  width: 100%;
  padding: 8px 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: clamp(12px, 10.545px + 0.455vw, 14px);
  text-align: center;
  color: var(--text);
  background: var(--bg);
}

table.week-table input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

.calc-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: clamp(13.5px, 11.682px + 0.568vw, 16px);
  font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
}

.calc-btn:hover {
  background: #1d4fd1;
}

/* Result */
.result {
  display: none;
  margin-top: 18px;
}

.result.show {
  display: block;
}

/* 급여명세서 (스프레드시트형) */
.payslip-sheet-wrap {
  overflow-x: auto;
  margin-bottom: 14px;
}

table.payslip-sheet {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  table-layout: auto;
  border: 1px solid var(--text);
  font-size: clamp(11px, 9.545px + 0.455vw, 13px);
  margin-bottom: 0;
}

table.payslip-sheet th,
table.payslip-sheet td {
  border: 1px solid var(--border);
  padding: 8px 6px;
  overflow-wrap: break-word;
}

table.payslip-sheet th {
  background: #f4f6fb;
  font-weight: 700;
  color: var(--text);
  text-align: left;
  white-space: nowrap;
}

table.payslip-sheet td {
  text-align: right;
  color: var(--text);
  white-space: nowrap;
}

table.payslip-sheet td.item-label {
  text-align: left;
}

table.payslip-sheet .item-sub {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
  margin-top: 2px;
  white-space: normal;
}

table.payslip-sheet .ps-col-head th,
table.input-sheet .ps-col-head th {
  text-align: center;
  font-size: clamp(11px, 9.545px + 0.455vw, 13px);
}

table.payslip-sheet .ps-col-head th.earn-head,
table.input-sheet .ps-col-head th.earn-head {
  background: var(--accent-light);
  color: var(--accent);
}

table.payslip-sheet .ps-col-head th.deduct-head,
table.input-sheet .ps-col-head th.deduct-head {
  background: #fdeaea;
  color: var(--danger);
}

table.payslip-sheet .ps-total-row th,
table.payslip-sheet .ps-total-row td,
table.input-sheet .ps-total-row th,
table.input-sheet .ps-total-row td {
  background: #f4f6fb;
  font-weight: 700;
}

table.payslip-sheet .ps-net-row th,
table.payslip-sheet .ps-net-row td {
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: clamp(14.5px, 12.682px + 0.568vw, 17px);
  text-align: center;
}

table.input-sheet .ps-net-row th {
  font-weight: 800;
  font-size: clamp(14.5px, 12.682px + 0.568vw, 17px);
  text-align: center;
  color: var(--accent);
}

#panel-severance table.payslip-sheet .ps-net-row th,
#panel-severance table.payslip-sheet .ps-net-row td {
  background: transparent;
  color: var(--accent);
}

table.input-sheet .ps-net-row td:first-child {
  border-top: none !important;
  border-left: none !important;
  border-bottom: none !important;
}

.sheet-box:has(.ps-net-row) {
  position: relative;
}

.sheet-box:has(.ps-net-row)::before {
  content: "";
  position: absolute;
  left: -1px;
  bottom: -1px;
  width: 50%;
  height: 2px;
  background: var(--surface);
}

.sheet-box:has(.ps-net-row)::after {
  content: "";
  position: absolute;
  left: -1px;
  bottom: -1px;
  width: 2px;
  height: 42px;
  background: var(--surface);
}

table.input-sheet .ps-net-row td:last-child {
  font-weight: 800;
  font-size: clamp(14.5px, 12.682px + 0.568vw, 17px);
  text-align: right;
  color: var(--accent);
}

/* 입력 폼 (스프레드시트형) */
.input-sheet-wrap {
  overflow-x: auto;
  margin-bottom: 16px;
}

table.input-sheet {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  table-layout: auto;
  border: 1px solid var(--text);
  font-size: clamp(12px, 10.545px + 0.455vw, 14px);
}

table.input-sheet th,
table.input-sheet td {
  border: 1px solid var(--border);
  padding: 10px;
}

table.input-sheet tr.row-compact th,
table.input-sheet tr.row-compact td {
  padding: 4px 10px;
  line-height: 1.25;
}

table.input-sheet th {
  background: #f4f6fb;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  white-space: nowrap;
  width: 20%;
}

table.input-sheet th input.th-input {
  width: 100%;
  border: none;
  background: transparent;
  font: inherit;
  color: inherit;
  text-align: center;
  padding: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

table.input-sheet th input.th-input::placeholder {
  color: var(--muted);
  opacity: 0.5;
  font-weight: 700;
}

table.input-sheet th input.th-input:focus {
  outline: none;
  background: var(--accent-light);
}

table.input-sheet td {
  text-align: right;
}

table.input-sheet.info td {
  text-align: center;
}

table.input-sheet.info input[type="text"],
table.input-sheet.info input[type="date"] {
  text-align: center;
}

table.input-sheet .hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}


table.input-sheet input[type="text"],
table.input-sheet input[type="date"] {
  width: 100%;
  border: none;
  background: transparent;
  padding: 4px 2px;
  font-family: inherit;
  font-size: clamp(12.5px, 11.045px + 0.455vw, 14.5px);
  font-weight: 400;
  color: var(--text);
  text-align: right;
}

table.input-sheet input:focus {
  outline: none;
  background: var(--accent-light);
}

table.input-sheet .input-suffix {
  display: flex;
  align-items: center;
  gap: 4px;
}

table.input-sheet .input-suffix input,
table.input-sheet .input-suffix .input-render {
  flex: 1;
  min-width: 0;
}

table.input-sheet .input-suffix span {
  position: static;
  transform: none;
  color: var(--text);
  font-size: clamp(11px, 9.545px + 0.455vw, 13px);
  white-space: nowrap;
  margin-top: 3px;
}

table.input-sheet .seg {
  height: 34px;
}

/* 통합 명세서(입력+결과 한 화면) 레이아웃 */
.sheet-title-main {
  position: relative;
  padding: 14px 16px;
  font-size: clamp(20.5px, 17.955px + 0.795vw, 24px);
  font-weight: 800;
  color: var(--text);
  text-align: center;
  margin-bottom: 14px;
}

.sheet-print-btn {
  position: absolute;
  top: 50%;
  right: 1px;
  transform: translateY(calc(-50% + 25px));
  border: 1px solid #c3c8d1;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: clamp(11px, 9.545px + 0.455vw, 13px);
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  padding: 7px 10px;
}

.sheet-print-btn:hover {
  background: var(--border);
}

.sheet-box {
  border: 1px solid var(--border);
  border-radius: 0;
  margin-bottom: 14px;
}

.sheet-box-title {
  padding: 10px 14px;
  font-size: clamp(12px, 10.545px + 0.455vw, 14px);
  font-weight: 700;
  text-align: center;
  background: #f4f6fb;
  color: var(--text);
}

.sheet-box-title.earn {
  background: var(--accent-light);
  color: var(--accent);
}

.sheet-box-title.deduct {
  background: #fdeaea;
  color: var(--danger);
}

.sheet-box table.input-sheet {
  border: none;
  min-width: 0;
  table-layout: fixed;
}

.sheet-box .input-sheet-wrap {
  margin-bottom: 0;
}

.sheet-box table.input-sheet tbody:last-of-type tr:last-child th,
.sheet-box table.input-sheet tbody:last-of-type tr:last-child td {
  border-bottom: none;
}

.sheet-box table.input-sheet tbody:first-of-type tr:first-child th,
.sheet-box table.input-sheet tbody:first-of-type tr:first-child td {
  border-top: none;
}

.sheet-box table.input-sheet tr th:first-child,
.sheet-box table.input-sheet tr td:first-child {
  border-left: none;
}

.sheet-box table.input-sheet tr th:last-child,
.sheet-box table.input-sheet tr td:last-child {
  border-right: none;
}

table.input-sheet.split {
  table-layout: fixed;
}

table.input-sheet.split th {
  width: 20%;
}

table.input-sheet.split td {
  width: 30%;
}

table.input-sheet.split th {
  white-space: nowrap;
}


table.input-sheet.split th,
table.input-sheet.split td {
  height: 40px;
  padding-top: 0;
  padding-bottom: 0;
  vertical-align: middle;
}

tr.row-nontax > th:first-child {
  background: #eaf7ee;
}

tr.row-nontax > td:nth-child(2) {
  background: #f4fbf6;
}

td.readonly-val {
  text-align: right;
  font-weight: 600;
}

/* 인적사항/급여항목/공제항목 박스 전체 폰트 14px/600 통일 (통합 명세서 공통, .pay-sheet 범위로 한정) */
/* 제목(.sheet-title-main)과 회사명(plain-center-input)은 이 규칙 밖에 있어 그대로 유지됨 */
.pay-sheet table.input-sheet th,
.pay-sheet table.input-sheet td,
.pay-sheet table.input-sheet input[type="text"],
.pay-sheet table.input-sheet input[type="date"],
.pay-sheet .input-suffix span {
  font-size: clamp(12px, 10.545px + 0.455vw, 14px);
  font-weight: 600;
}

.pay-sheet input.plain-center-input {
  font-size: clamp(18px, 15.818px + 0.682vw, 21px);
  font-weight: 400;
}

.pay-sheet table.input-sheet .ps-net-row th,
.pay-sheet table.input-sheet .ps-net-row td {
  font-size: clamp(13px, 11.545px + 0.455vw, 15px);
  font-weight: 600;
}

table.input-sheet.split td input[type="text"] {
  font-weight: 600;
}

.input-render {
  display: inline-block;
  width: 100%;
  text-align: right;
  font-size: clamp(11px, 9.545px + 0.455vw, 13px);
  color: var(--text);
}

.plain-center-input {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: clamp(18px, 15.818px + 0.682vw, 21px);
  color: var(--text);
  text-align: center;
  padding: 10px;
}

.plain-center-input::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.plain-center-input:focus {
  outline: none;
  background: var(--accent-light);
}

.rate-with-total {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: start;
  margin-bottom: 8px;
}

.insurance-total-note {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-left: 16px;
  border-left: 1px solid var(--border);
  font-size: clamp(11px, 9.545px + 0.455vw, 13px);
  color: var(--muted);
}

.insurance-total-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.insurance-total-row small {
  font-size: 11px;
  margin-left: 2px;
}

.insurance-total-note b {
  font-weight: 700;
  color: var(--text);
}

.warn {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a4a0a;
  font-size: clamp(11px, 9.545px + 0.455vw, 13px);
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 12px;
}

.disclaimer {
  font-size: 12px;
  color: var(--muted);
  opacity: 0.75;
  margin-top: 10px;
  line-height: 1.5;
}

.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding-top: 20px;
  padding-right: clamp(10px, 1.273px + 2.727vw, 22px);
  padding-bottom: 20px;
  padding-left: clamp(10px, 1.273px + 2.727vw, 22px);
  margin-bottom: 16px;
}

.info-card h3 {
  font-size: clamp(13px, 11.545px + 0.455vw, 15px);
  margin: 0 0 8px;
}

.info-card p {
  font-size: clamp(11.5px, 10.045px + 0.455vw, 13.5px);
  color: var(--muted);
  margin: 0 0 8px;
}

.info-card ul {
  margin: 0;
  padding-left: 18px;
  font-size: clamp(11.5px, 10.045px + 0.455vw, 13.5px);
  color: var(--muted);
}

.info-card li {
  margin-bottom: 4px;
}

footer.site {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

footer.site a {
  color: var(--muted);
}

.footer-links a {
  margin: 0 6px;
}

.footer-break {
  display: none;
}

@media (max-width: 460px) {
  .footer-break {
    display: block;
  }
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.modal-overlay.show {
  display: flex;
}

.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(20, 30, 60, 0.25);
  padding: 22px;
  max-width: 320px;
  width: 100%;
  text-align: center;
}

.modal-box p {
  font-size: clamp(12.5px, 11.045px + 0.455vw, 14.5px);
  line-height: 1.6;
  color: var(--text);
  margin: 4px 0 18px;
  white-space: pre-line;
}

.modal-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: clamp(13px, 11.545px + 0.455vw, 15px);
  font-weight: 700;
  cursor: pointer;
}

.modal-btn:hover {
  background: #1d4fd1;
}

@media (max-width: 480px) {
  .tabs {
    gap: 6px;
  }
  .tab-btn {
    font-size: 12.5px;
    padding: 10px 4px;
  }
}

@media (max-width: 480px) {
  .rate-with-total {
    grid-template-columns: 2fr 1fr;
  }
  table.input-sheet.split th {
    white-space: normal;
  }
  table.input-sheet th,
  table.input-sheet td,
  table.payslip-sheet th,
  table.payslip-sheet td {
    padding: 6px 3px;
  }
}

table.input-sheet.fixed-cols {
  table-layout: fixed;
}

@media (max-width: 400px) {
  .card {
    padding-top: 14px;
    padding-bottom: 14px;
  }
}
