/* StockTax — 미국주식 양도세 계산기
   모바일 우선(390px), 화이트 + 네이비/블루 */

:root {
  --navy: #0e2a47;
  --navy-2: #173f66;
  --navy-soft: #24486e;
  --blue: #1f6feb;
  --blue-dark: #1558c4;
  --blue-050: #eef4ff;
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #111b2b;
  --ink-2: #33445c;
  --muted: #63758c;
  --line: #e3e9f1;
  --line-2: #eef2f7;
  --good: #0b7a53;
  --good-050: #e9f7f1;
  --warn-ink: #8a4b12;
  --warn-bg: #fff8ee;
  --warn-line: #f6dcb6;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(16, 38, 68, .04), 0 8px 24px -12px rgba(16, 38, 68, .18);
  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard",
          "Noto Sans KR", "Malgun Gothic", "맑은 고딕", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: -0.01em;
  word-break: keep-all;
  overflow-wrap: break-word;
}

a { color: var(--blue-dark); }

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 0 0 10px 0; z-index: 50;
}
.skip:focus { left: 0; }

.wrap { width: 100%; max-width: 780px; margin: 0 auto; padding: 0 18px; }

/* ── 상단 바 ───────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-in { display: flex; align-items: center; justify-content: space-between; height: 58px; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: inherit; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(150deg, var(--navy) 10%, var(--blue) 120%);
  color: #fff; font-size: 12.5px; font-weight: 800; letter-spacing: .04em;
  display: grid; place-items: center;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; font-weight: 800; font-size: 15px; }
.brand-text em { font-style: normal; font-weight: 600; font-size: 11px; color: var(--muted); letter-spacing: 0; }
.topnav { display: flex; gap: 2px; }
.topnav a {
  color: var(--ink-2); text-decoration: none; font-size: 13px; font-weight: 600;
  padding: 8px 10px; border-radius: 9px;
}
.topnav a:hover { background: var(--blue-050); color: var(--blue-dark); }

/* ── 히어로 ───────────────────────────────────────── */
.hero { padding: 20px 0 16px; background: linear-gradient(180deg, #ffffff 0%, var(--bg) 100%); border-bottom: 1px solid var(--line-2); }
.eyebrow {
  display: inline-block; margin: 0 0 10px; padding: 5px 10px;
  background: var(--blue-050); color: var(--blue-dark);
  font-size: 11.5px; font-weight: 700; border-radius: 999px;
}
.hero h1 {
  margin: 0 0 10px; font-size: clamp(25px, 7.4vw, 38px); line-height: 1.22;
  letter-spacing: -0.035em; color: var(--navy);
}
.lede { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.62; }
.lede b { color: var(--navy); }
.deadline {
  display: flex; align-items: center; gap: 8px; margin-top: 12px;
  background: #fff; border: 1px solid var(--warn-line); border-radius: 12px;
  padding: 10px 13px; font-size: 13px; color: var(--warn-ink);
}
.dl-icon { font-size: 15px; }
.dl-text b { color: #7a3f0a; }
.dl-dday {
  display: inline-block; margin-left: 4px; padding: 1px 8px; border-radius: 999px;
  background: #fdeed8; font-weight: 800; font-size: 12px;
}

/* ── 탭 ───────────────────────────────────────────── */
.tabs {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  margin: 14px 0 12px; padding: 4px;
  background: #e8edf5; border-radius: 14px;
  position: sticky; top: 58px; z-index: 20;
}
.tab {
  appearance: none; border: 0; background: transparent;
  font-family: inherit; font-size: 13.5px; font-weight: 700; color: var(--ink-2);
  padding: 11px 4px; border-radius: 11px; cursor: pointer; letter-spacing: -0.02em;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.tab.is-active { background: #fff; color: var(--navy); box-shadow: 0 1px 3px rgba(16, 38, 68, .14); }
.tab:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.panel { display: none; }
.panel.is-active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ── 카드 ─────────────────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-title { margin: 0 0 4px; font-size: 16.5px; letter-spacing: -0.03em; color: var(--navy); }
.card-sub { margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.card-sub b { color: var(--ink-2); }
.card.mini { padding: 16px 18px; }

/* ── 입력 ─────────────────────────────────────────── */
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-wide { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12.5px; font-weight: 700; color: var(--ink-2); display: flex; flex-direction: column; }
.field-label em { font-style: normal; font-weight: 500; font-size: 11px; color: var(--muted); margin-top: 1px; }

.money {
  display: flex; align-items: center; gap: 4px;
  background: #f8fafc; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 0 12px; transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.money:focus-within { border-color: var(--blue); background: #fff; box-shadow: 0 0 0 3px rgba(31, 111, 235, .12); }
.money input {
  flex: 1; min-width: 0; width: 100%; border: 0; background: transparent; outline: none;
  font-family: inherit; font-size: 17px; font-weight: 700; color: var(--navy);
  text-align: right; padding: 13px 0; font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.money input::placeholder { color: #b3bfcd; font-weight: 600; }
.unit { font-size: 12.5px; color: var(--muted); font-weight: 700; padding-left: 2px; }

.hint { margin: 12px 0 0; font-size: 12px; color: var(--muted); line-height: 1.6; }
.hint a { font-weight: 700; }

/* ── 결과 카드 ─────────────────────────────────────── */
.result {
  background: linear-gradient(158deg, var(--navy) 0%, #17395c 55%, #1c4a76 100%);
  border-color: transparent; color: #fff; padding: 20px 18px;
}
.result-label { margin: 0; font-size: 12.5px; font-weight: 700; color: #a9c2df; letter-spacing: .01em; }
.result-value {
  margin: 4px 0 0; display: flex; align-items: baseline; gap: 5px;
  font-size: clamp(34px, 10.4vw, 50px); font-weight: 800; line-height: 1.1;
  letter-spacing: -0.045em; font-variant-numeric: tabular-nums;
  color: #fff; word-break: break-all;
}
.result-unit { font-size: 17px; font-weight: 700; color: #b9cfeb; letter-spacing: 0; }
.result-note { margin: 8px 0 0; font-size: 12.5px; color: #c3d6ec; line-height: 1.55; min-height: 20px; }
.result-note b { color: #fff; }

.kv { margin: 16px 0 0; padding: 0; border-top: 1px solid rgba(255, 255, 255, .14); }
.kv-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid rgba(255, 255, 255, .09); }
.kv-row:last-child { border-bottom: 0; padding-bottom: 0; }
.kv-row dt { margin: 0; font-size: 13px; color: #b7cde7; display: flex; flex-direction: column; }
.kv-row dt em { font-style: normal; font-size: 10.5px; color: #8fabc9; }
.kv-row dd { margin: 0; font-size: 14.5px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; white-space: nowrap; }
.kv-row.strong dt { color: #fff; font-weight: 700; }
.kv-row.strong dd { font-size: 16.5px; }
.kv-row dd.good { color: #6ee7b7; }

.zero-box {
  margin-top: 14px; padding: 13px 14px; border-radius: 12px;
  background: rgba(110, 231, 183, .13); border: 1px solid rgba(110, 231, 183, .32);
}
.zero-title { margin: 0 0 3px; font-size: 13.5px; font-weight: 800; color: #a7f3d0; }
.zero-body { margin: 0; font-size: 12.5px; color: #d3e8dd; line-height: 1.6; }

/* ── 공제 미터 ──────────────────────────────────────── */
.mini-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; }
.mini-label { margin: 0; font-size: 12px; color: var(--muted); font-weight: 700; }
.mini-value { margin: 2px 0 0; font-size: 19px; font-weight: 800; color: var(--navy); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.mini-help { margin: 0; font-size: 11.5px; color: var(--muted); text-align: right; max-width: 52%; line-height: 1.5; }
.meter { margin-top: 12px; height: 8px; border-radius: 999px; background: #e9eef5; overflow: hidden; }
.meter-fill { height: 100%; width: 0%; border-radius: 999px; background: linear-gradient(90deg, var(--blue) 0%, #7aa9f7 100%); transition: width .25s ease; }
.meter-cap { display: flex; justify-content: space-between; margin: 6px 0 0; font-size: 11px; color: var(--muted); }
.meter-cap b { color: var(--ink-2); }

/* ── 버튼 ─────────────────────────────────────────── */
.btn {
  appearance: none; border: 0; font-family: inherit; font-weight: 700; font-size: 14px;
  padding: 13px 16px; border-radius: 12px; cursor: pointer;
  background: var(--navy); color: #fff; transition: transform .06s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn.ghost { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: #cbd6e4; background: #fbfcfe; }
.btn.sm { padding: 8px 12px; font-size: 12.5px; border-radius: 10px; }
.btn.danger { color: #b42318; border-color: #f1d3d0; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.btn-row .btn { flex: 1 1 auto; }

/* ── 손실 종목 행 ──────────────────────────────────── */
.pos-list { display: flex; flex-direction: column; gap: 10px; }
.pos-row {
  border: 1px solid var(--line); border-radius: 13px; padding: 11px;
  background: #fbfcfe;
}
.pos-top { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.pos-name {
  flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 9px; background: #fff;
  font-family: inherit; font-size: 14px; font-weight: 700; color: var(--navy); padding: 9px 10px; outline: none;
}
.pos-name:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(31,111,235,.1); }
.pos-del {
  appearance: none; border: 1px solid var(--line); background: #fff; color: var(--muted);
  width: 36px; height: 36px; border-radius: 9px; font-size: 18px; line-height: 1; cursor: pointer; flex: none;
}
.pos-del:hover { color: #b42318; border-color: #f1d3d0; }
.pos-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pos-cell { display: flex; flex-direction: column; gap: 3px; }
.pos-cell label { font-size: 10.5px; font-weight: 700; color: var(--muted); padding-left: 2px; }
.pos-cell input {
  width: 100%; border: 1px solid var(--line); border-radius: 9px; background: #fff;
  font-family: inherit; font-size: 14.5px; font-weight: 700; color: var(--navy);
  padding: 9px 10px; text-align: right; outline: none; font-variant-numeric: tabular-nums;
}
.pos-cell input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(31,111,235,.1); }
.pos-foot { margin: 8px 0 0; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pos-foot b { color: var(--ink-2); }

/* ── 매도 플랜 ─────────────────────────────────────── */
.plan-table { margin-top: 14px; }
.pt-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  padding: 9px 0; border-top: 1px solid rgba(255, 255, 255, .13); font-size: 13px;
}
.pt-name { color: #fff; font-weight: 700; }
.pt-name span { display: block; font-size: 10.5px; color: #9fbad6; font-weight: 500; }
.pt-val { color: #dbe8f6; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.pt-val b { color: #fff; }

/* ── 안내 박스 ─────────────────────────────────────── */
.notice {
  background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 14px;
  padding: 14px 16px; margin-bottom: 14px;
}
.notice-title { margin: 0 0 5px; font-size: 13.5px; font-weight: 800; color: var(--warn-ink); }
.notice p { margin: 0; font-size: 12.5px; color: #7b4a18; line-height: 1.65; }
.notice b { color: #6b3d0f; }

/* ── 장부 ─────────────────────────────────────────── */
.ledger-list { display: flex; flex-direction: column; gap: 10px; }
.ledger-row { border: 1px solid var(--line); border-radius: 13px; padding: 11px; background: #fbfcfe; }
.led-top { display: flex; gap: 8px; align-items: center; }
.led-name {
  flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 9px; background: #fff;
  font-family: inherit; font-size: 14px; font-weight: 700; color: var(--navy); padding: 9px 10px; outline: none;
}
.led-mode {
  appearance: none; border: 1px solid var(--line); border-radius: 9px; background: #fff;
  font-family: inherit; font-size: 12px; font-weight: 700; color: var(--ink-2); padding: 9px 8px; flex: none;
}
.led-pnl { margin: 8px 0 0; font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.led-pnl.plus { color: var(--good); }
.led-pnl.minus { color: #b42318; }
.empty { padding: 18px 4px; text-align: center; color: var(--muted); font-size: 13px; }

/* ── 가이드 ───────────────────────────────────────── */
.guide, .faq { padding-top: 34px; }
.sec-title { margin: 0 0 8px; font-size: 19px; letter-spacing: -0.03em; color: var(--navy); }
.sec-lede { margin: 0 0 20px; font-size: 13px; color: var(--muted); line-height: 1.7; }
.guide h3 { margin: 26px 0 8px; font-size: 15.5px; letter-spacing: -0.025em; color: var(--navy); }
.guide p { margin: 0 0 10px; font-size: 14px; color: var(--ink-2); line-height: 1.78; }
.guide p b, .guide li b { color: var(--navy); }

.formula { display: flex; flex-direction: column; gap: 8px; margin: 14px 0 4px; }
.formula-step {
  display: flex; gap: 12px; align-items: flex-start;
  background: #fff; border: 1px solid var(--line); border-radius: 13px; padding: 12px 14px;
}
.formula-step > span {
  flex: none; width: 24px; height: 24px; border-radius: 8px; background: var(--blue-050);
  color: var(--blue-dark); font-size: 12px; font-weight: 800; display: grid; place-items: center; margin-top: 1px;
}
.formula-step b { display: block; font-size: 14px; color: var(--navy); letter-spacing: -0.02em; }
.formula-step em { font-style: normal; font-size: 11.5px; color: var(--muted); }

.table { width: 100%; border-collapse: collapse; margin: 12px 0 14px; font-size: 13px; }
.table th, .table td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.table th { background: #f8fafc; font-size: 11.5px; color: var(--muted); font-weight: 700; white-space: nowrap; }
.table td { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.table td b { color: var(--navy); }
.table em { color: var(--muted); font-style: normal; font-size: 11px; }

.steps, .checklist { margin: 10px 0 0; padding-left: 20px; }
.steps li, .checklist li { margin-bottom: 8px; font-size: 13.5px; color: var(--ink-2); line-height: 1.7; }
.steps li::marker { color: var(--blue); font-weight: 700; }

.disclaimer {
  margin-top: 26px; padding: 14px 16px; border-radius: 13px;
  background: #f1f4f9; border: 1px solid var(--line);
}
.disclaimer p { margin: 0; font-size: 11.5px; color: var(--muted); line-height: 1.7; }
.disclaimer b { color: var(--ink-2); }

/* ── FAQ ─────────────────────────────────────────── */
.faq details { background: #fff; border: 1px solid var(--line); border-radius: 13px; margin-bottom: 8px; }
.faq summary {
  cursor: pointer; list-style: none; padding: 14px 16px; font-size: 14px; font-weight: 700;
  color: var(--navy); display: flex; justify-content: space-between; gap: 10px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--muted); font-weight: 700; flex: none; }
.faq details[open] summary::after { content: "−"; }
.faq details p { margin: 0; padding: 0 16px 15px; font-size: 13px; color: var(--ink-2); line-height: 1.75; }
.faq details p b { color: var(--navy); }

/* ── 푸터 ─────────────────────────────────────────── */
.foot { margin-top: 40px; padding: 26px 0 40px; background: #0b2138; color: #a9c0d8; }
.foot-brand { margin: 0 0 8px; font-weight: 800; font-size: 15px; color: #fff; letter-spacing: .01em; }
.foot-links { display: flex; flex-wrap: wrap; gap: 14px; margin: 0 0 12px; }
.foot-links a { color: #cfe0f2; font-size: 12.5px; text-decoration: none; border-bottom: 1px solid rgba(207,224,242,.3); }
.foot-note { margin: 0 0 10px; font-size: 11.5px; line-height: 1.7; color: #8ea7c0; }
.foot-copy { margin: 0; font-size: 11px; color: #6f8aa5; }

/* ── 좁은 화면 ─────────────────────────────────────── */
@media (max-width: 420px) {
  .wrap { padding: 0 15px; }
  .card { padding: 16px; }
  .topnav a { padding: 8px 7px; font-size: 12.5px; }
  .fields { gap: 10px; }
  .money input { font-size: 16px; padding: 12px 0; }
  .tab { font-size: 13px; }
  .mini-help { font-size: 11px; }
  .result-value { font-size: clamp(30px, 9.6vw, 44px); }
}

@media (min-width: 700px) {
  .panel { max-width: 100%; }
  .result { padding: 24px; }
  .pos-grid { grid-template-columns: repeat(4, 1fr); }
  .btn-row .btn { flex: 0 1 auto; }
  .guide, .faq { padding-top: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto; }
}
