:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1b1f24;
  --muted: #5d6673;
  --line: #e3e6eb;
  --accent: #1f6feb;
  --accent-soft: #e8f0fe;
  --good: #137a4b;
  --bad: #c4372f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #171b21;
    --text: #e8eaed;
    --muted: #9aa3ad;
    --line: #2a3038;
    --accent: #5b9cff;
    --accent-soft: #1b2a40;
    --good: #4cc38a;
    --bad: #ff7b72;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  word-break: keep-all;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.wrap.wide { max-width: 1120px; }
.wrap.wide .content, .wrap.wide > .lead, .wrap.wide > .card { max-width: 760px; }

header.site {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
header.site .wrap { max-width: 1120px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 24px; min-height: 56px; padding-top: 8px; padding-bottom: 8px; position: relative; }
header.site .logo { font-weight: 800; font-size: 18px; color: var(--text); white-space: nowrap; }
header.site nav a { color: var(--muted); white-space: nowrap; }
header.site nav a.on { color: var(--accent); font-weight: 700; }
/* PC·태블릿: 메뉴를 펼쳐 두고, 넘치면 다음 줄로 */
header.site .links { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 14px; }
header.site .menu { display: none; }
/* 폰: '전체 계산기' 버튼을 누르면 목록이 열림 */
@media (max-width: 699px) {
  header.site .wrap { justify-content: space-between; }
  header.site .links { display: none; }
  header.site .menu { display: block; }
  .menu summary {
    list-style: none; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--accent);
    padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  }
  .menu summary::-webkit-details-marker { display: none; }
  .menu summary::after { content: " ▾"; }
  .menu[open] summary::after { content: " ▴"; }
  .menu-list {
    position: absolute; left: 16px; right: 16px; top: calc(100% + 4px); z-index: 10;
    display: grid; grid-template-columns: 1fr 1fr; gap: 2px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(16, 24, 40, .14); padding: 8px;
  }
  .menu-list a { padding: 10px 12px; border-radius: 8px; font-size: 15px; }
  .menu-list a:hover, .menu-list a.on { background: var(--accent-soft); text-decoration: none; }
}

main { padding: 24px 0 48px; }
h1 { font-size: 26px; line-height: 1.3; margin: 0 0 6px; letter-spacing: -.02em; }
.lead { color: var(--muted); margin: 0 0 20px; }
h2 { font-size: 20px; margin: 36px 0 10px; letter-spacing: -.01em; }
h3 { font-size: 17px; margin: 22px 0 6px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* 입력 폼 */
.form { display: grid; gap: 14px; }
.field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field .hint { font-size: 13px; color: var(--muted); margin-top: 4px; }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
input { min-width: 0; }
input[type=date] { padding: 0 8px; font-size: 15px; }
.money { position: relative; }
.money input { padding-right: 36px; }
.money::after { content: "원"; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; pointer-events: none; }
.unit-pct::after { content: "%"; }
.unit-month::after { content: "개월"; }
.unit-hour::after { content: "시간"; }
.unit-hour input { padding-right: 52px; }
.related { margin-top: 40px; }
input[type=text], input[type=date], input[type=number], select {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  font: inherit;
  font-size: 17px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); background: var(--surface); }
.unit-month input { padding-right: 52px; }
.korean { font-size: 13px; color: var(--accent); margin-top: 4px; min-height: 1em; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips button, .seg button {
  font: inherit; font-size: 13px; cursor: pointer;
  padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
}
.chips button:hover { border-color: var(--accent); color: var(--accent); }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { font-size: 15px; padding: 9px 14px; border-radius: 10px; }
.seg button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.check { display: flex; align-items: center; gap: 8px; font-size: 15px; cursor: pointer; }
.check input { width: 18px; height: 18px; }

/* 결과 */
.result { margin-top: 16px; }
.big { text-align: center; padding: 8px 0 16px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.big .label { color: var(--muted); font-size: 14px; }
.big .value { font-size: 34px; font-weight: 800; letter-spacing: -.02em; color: var(--accent); line-height: 1.2; }
.big .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
dl.lines { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 7px 12px; font-size: 15px; }
dl.lines dt { color: var(--muted); }
dl.lines dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
dl.lines .total { font-weight: 700; color: var(--text); border-top: 1px solid var(--line); padding-top: 8px; }
.note { font-size: 13px; color: var(--muted); margin-top: 12px; }
.warn { color: var(--bad); }

/* 표 */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--line); }
td { white-space: nowrap; }
.content td { white-space: normal; }
@media (max-width: 480px) {
  th, td { padding: 7px 6px; }
  table { font-size: 13px; }
}
@media (max-width: 360px) {
  .wrap { padding: 0 12px; }
  th, td { padding: 6px 4px; }
  table { font-size: 12px; }
}
/* 실수령액표: 좁은 화면에서는 공제 세부 열을 접어 둠 */
.dcol-toggle { display: none; margin-bottom: 8px; }
.chips-btn {
  font: inherit; font-size: 14px; cursor: pointer; padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
@media (max-width: 899px) {
  .salary-table:not(.all) .dcol { display: none; }
  .dcol-toggle { display: inline-block; }
}
th:first-child, td:first-child { text-align: left; }
thead th { background: var(--bg); position: sticky; top: 0; font-weight: 700; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.hl td { background: var(--accent-soft); }
/* 폰에서 옆으로 밀 때 첫 열(연봉)은 왼쪽에 고정 */
th:first-child, td:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; }
thead th:first-child { background: var(--bg); z-index: 2; }
tbody tr.hl td:first-child { background: var(--accent-soft); }

/* 본문 설명 */
.content { margin-top: 8px; }
.content p, .content li { color: var(--text); }
.content ul, .content ol { padding-left: 22px; }
.content code { background: var(--accent-soft); padding: 1px 6px; border-radius: 6px; font-size: 14px; }
.faq details { border-bottom: 1px solid var(--line); padding: 12px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin: 8px 0 0; color: var(--muted); }

/* 홈 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.grid a.card { display: block; color: var(--text); transition: border-color .15s; }
.grid a.card:hover { border-color: var(--accent); text-decoration: none; }
.grid .t { font-weight: 700; font-size: 17px; }
.grid .d { color: var(--muted); font-size: 14px; margin-top: 4px; }

.ad { margin: 24px 0; min-height: 0; }

footer.site { border-top: 1px solid var(--line); padding: 24px 0 40px; color: var(--muted); font-size: 13px; }
footer.site a { color: var(--muted); margin-right: 14px; }

@media (max-width: 480px) {
  h1 { font-size: 22px; }
  .big .value { font-size: 30px; }
  .card { padding: 16px; }
}
