:root {
  --bg-page: #f6f7f9;
  --bg-surface: #ffffff;
  --bg-subtle: #f9fafb;
  --bg-hover: #f2f4f7;

  --border-default: #e5e8eb;
  --border-strong: #d1d6db;
  --border-focus: #1b64da;

  --text-primary: #191f28;
  --text-secondary: #4e5968;
  --text-tertiary: #8b95a1;

  --accent-blue: #1b64da;
  --accent-blue-soft: #eef4ff;
  --accent-red: #d92d20;
  --accent-red-soft: #fef3f2;
  --accent-green: #067647;
  --accent-green-soft: #ecfdf3;
  --accent-amber: #b54708;
  --accent-amber-soft: #fffaeb;

  --radius-md: 8px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', sans-serif;
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* Top Global Navigation */
.topbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
}

.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  background: var(--text-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: -0.04em;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-divider {
  color: var(--border-strong);
  font-weight: 300;
}

.brand-sub {
  font-size: 13.5px;
  color: var(--text-secondary);
  font-weight: 500;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.deadline-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 4px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  font-size: 12.5px;
  color: var(--text-secondary);
}

.deadline-chip strong {
  color: var(--accent-blue);
  font-weight: 700;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* Editorial Page Header */
.page-header {
  margin-bottom: 24px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
}

.page-header h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.page-header p {
  font-size: 14.5px;
  color: var(--text-secondary);
}

.header-meta-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 12.5px;
  color: var(--text-tertiary);
}

/* AdSense Slot (Clean, unobtrusive placeholder) */
.ad-slot {
  width: 100%;
  min-height: 90px;
  background: var(--bg-surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  font-size: 12px;
  margin: 20px 0 24px;
  padding: 12px;
  text-align: center;
}

/* Underline Tabs */
.tabs {
  display: flex;
  gap: 28px;
  border-bottom: 1px solid var(--border-default);
  margin-bottom: 24px;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 12px 2px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-tertiary);
  cursor: pointer;
  font-family: inherit;
  margin-bottom: -1px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--text-primary);
  border-bottom-color: var(--text-primary);
}

/* Main 2-Column Layout */
.workspace {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
  align-items: start;
}

.workspace > * {
  min-width: 0;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 24px;
  min-width: 0;
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease, border-color 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:hover {
  background: var(--bg-hover);
}

.btn-primary {
  background: var(--text-primary);
  border-color: var(--text-primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: #333d4b;
  border-color: #333d4b;
}

.btn-accent {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: #ffffff;
}

.btn-accent:hover {
  background: #1554ba;
  border-color: #1554ba;
}

/* Settings Strip */
.settings-bar {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1.1fr;
  gap: 14px;
  padding: 16px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.input, select {
  height: 36px;
  width: 100%;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input.num {
  text-align: right;
}

.input:focus, select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(27, 100, 218, 0.12);
}

/* Financial Ledger Table */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.ledger-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

.ledger-table th {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  padding: 10px 10px;
  border-bottom: 1px solid var(--border-default);
  text-align: right;
  white-space: nowrap;
}

.ledger-table th:first-child {
  text-align: left;
  padding-left: 14px;
}

.ledger-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border-default);
  vertical-align: middle;
}

.ledger-table tr:last-child td {
  border-bottom: none;
}

.ledger-table td:first-child {
  padding-left: 14px;
}

.ledger-table .input {
  height: 34px;
  font-size: 13px;
  padding: 0 8px;
}

.cell-result {
  text-align: right;
  white-space: nowrap;
  padding-right: 6px;
}

.res-amount {
  font-size: 13.5px;
  font-weight: 700;
  display: block;
}

.res-roi {
  font-size: 11.5px;
  color: var(--text-tertiary);
}

.txt-gain { color: var(--accent-red); } /* 한국 주식시장 표준: 수익 빨강 / 손실 파랑 대신 세무 계산기 표준으로 수익 녹색/빨강 중 선택 -> 세무/회계는 수익 +녹색, 손실 -파랑 or 빨강. 명확하게 +초록/#067647, -빨강/#d92d20 적용 */
.val-pos { color: var(--accent-green); }
.val-neg { color: var(--accent-red); }
.val-blue { color: var(--accent-blue); }

.btn-icon {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  border-radius: 4px;
  cursor: pointer;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: var(--accent-red-soft);
  color: var(--accent-red);
}

/* Callout Notes */
.note-box {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
}

.note-box strong {
  color: var(--text-primary);
}

.note-box.warn {
  background: var(--accent-red-soft);
  border-color: #fecdca;
  color: #912018;
}

.note-box.warn strong { color: #7a271a; }

.note-box.info {
  background: var(--accent-blue-soft);
  border-color: #c7dcff;
  color: #1849a9;
}

.note-box.info strong { color: #103783; }

/* Sticky Right Summary Card (Tax Receipt Style) */
.summary-card {
  position: sticky;
  top: 76px;
  border-top: 3px solid var(--text-primary);
}

.summary-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.summary-head h2 {
  font-size: 15px;
  font-weight: 700;
}

.tax-total-box {
  padding: 18px 16px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
}

.tax-total-label {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.tax-total-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.tax-total-value.has-tax {
  color: var(--accent-blue);
}

.tax-total-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
}

.statement-list {
  display: flex;
  flex-direction: column;
  margin-bottom: 18px;
}

.statement-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 13.5px;
  border-bottom: 1px solid #f0f2f5;
}

.statement-row:last-child { border-bottom: none; }
.statement-row .k { color: var(--text-secondary); }
.statement-row .v { font-weight: 600; color: var(--text-primary); }

.statement-row.subtotal {
  border-top: 1px solid var(--border-default);
  border-bottom: 1px solid var(--border-default);
  margin: 4px 0;
  padding: 10px 0;
}

.statement-row.subtotal .k {
  color: var(--text-primary);
  font-weight: 700;
}

.statement-row.subtotal .v {
  font-weight: 700;
}

.ratio-wrap {
  margin-bottom: 18px;
}

.ratio-head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.ratio-bar {
  height: 8px;
  background: #e5e8eb;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
}

.ratio-net { background: var(--text-primary); transition: width 0.25s ease; }
.ratio-tax { background: var(--accent-blue); transition: width 0.25s ease; }

.ratio-legend {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-tertiary);
  margin-top: 6px;
}

.summary-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Tab 2 & 3 Simulator Panels */
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.sim-block {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-bottom: 18px;
  background: var(--bg-surface);
}

.sim-block-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 14px;
}

.slider-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 16px 0 8px;
}

.slider-top .lbl {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.slider-top .val {
  font-size: 20px;
  font-weight: 800;
  color: var(--accent-red);
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border-default);
  outline: none;
  margin: 8px 0 10px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 2px solid var(--accent-blue);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  cursor: pointer;
}

.slider-scale {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-tertiary);
  margin-bottom: 18px;
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-subtle);
}

.kpi-cell {
  padding: 14px 16px;
  border-right: 1px solid var(--border-default);
}

.kpi-cell:last-child { border-right: none; }

.kpi-cell.saved {
  background: var(--accent-blue-soft);
}

.kpi-cell .k {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.kpi-cell .v {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.kpi-cell.saved .v {
  color: var(--accent-blue);
}

.compare-bars {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cbar-row {
  display: grid;
  grid-template-columns: 95px 1fr 95px;
  align-items: center;
  gap: 12px;
  font-size: 12.5px;
}

.cbar-track {
  height: 10px;
  background: #edf0f4;
  border-radius: 4px;
  overflow: hidden;
}

.cbar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.25s ease;
}

.cbar-fill.before { background: #9aa5b1; }
.cbar-fill.after { background: var(--accent-blue); }

/* Segmented Control */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin: 8px 0 16px;
  gap: 4px;
}

.seg-btn {
  padding: 9px 12px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}

.seg-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* SEO & Editorial Guide Section */
.guide-section {
  margin-top: 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.guide-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 28px;
}

.guide-card h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-default);
}

.guide-card h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 20px 0 8px;
}

.guide-card p, .guide-card li {
  font-size: 14.5px;
  color: var(--text-secondary);
  line-height: 1.75;
}

.guide-card ul {
  padding-left: 18px;
  margin: 8px 0 12px;
}

.formula-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  border-left: 3px solid var(--text-primary);
  padding: 12px 16px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 10px 0 14px;
}

.ref-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 13.5px;
}

.ref-table th, .ref-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-default);
  text-align: left;
  vertical-align: top;
}

.ref-table th {
  width: 24%;
  color: var(--text-primary);
  font-weight: 600;
  background: var(--bg-subtle);
}

.ref-table td {
  color: var(--text-secondary);
}

.faq-item {
  border-bottom: 1px solid var(--border-default);
}

.faq-item:last-child { border-bottom: none; }

.faq-q {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 15px 0;
  color: var(--text-primary);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: inherit;
}

.faq-q .icon {
  color: var(--text-tertiary);
  font-weight: 400;
  font-size: 18px;
  margin-left: 12px;
}

.faq-a {
  display: none;
  padding: 0 0 16px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.75;
}

.faq-item.open .faq-a { display: block; }
.faq-item.open .faq-q { color: var(--accent-blue); }

footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border-default);
  color: var(--text-tertiary);
  font-size: 12.5px;
  line-height: 1.7;
}

.footer-links {
  display: flex;
  gap: 16px;
  margin-top: 10px;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
}

.footer-links a:hover { text-decoration: underline; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--text-primary);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.gift-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

@media (max-width: 960px) {
  .workspace { grid-template-columns: 1fr; }
  .summary-card { position: static; }
  .settings-bar { grid-template-columns: 1fr; }
  .kpi-strip { grid-template-columns: 1fr; }
  .kpi-cell { border-right: none; border-bottom: 1px solid var(--border-default); }
  .kpi-cell:last-child { border-bottom: none; }
  .topbar-meta { display: none; }
}

@media (max-width: 640px) {
  .topbar-inner { padding: 0 16px; }
  .brand-divider, .brand-sub { display: none; }
  .container { padding: 20px 16px 60px; }
  .page-header h1 { font-size: 22px; }
  .tabs {
    gap: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn { font-size: 14px; white-space: nowrap; flex-shrink: 0; }
  .card { padding: 18px 16px; }
  .guide-card { padding: 20px 16px; }
  .gift-grid { grid-template-columns: 1fr; }
  .cbar-row { grid-template-columns: 74px 1fr 74px; gap: 8px; font-size: 12px; }
  .ref-table th { width: 32%; }
}

@media print {
  .topbar, .ad-slot, .tabs, .btn-group, .summary-actions, .guide-section { display: none !important; }
  body { background: #fff; }
  .workspace { grid-template-columns: 1fr; }
  .card { border: 1px solid #ccc; }
}

/* 계산기 바로가기 (모든 페이지 공통) */
.calc-nav { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 20px; }
.calc-nav a { padding: 6px 12px; border: 1px solid var(--border-default); border-radius: 999px; font-size: 13px; color: inherit; text-decoration: none; background: var(--bg-surface, #fff); }
.calc-nav a:hover { background: var(--bg-hover, #f2f4f6); }
.calc-nav a[aria-current="page"] { background: var(--text-primary, #111); color: var(--bg-surface, #fff); border-color: transparent; }
.page-meta { font-size: 13px; color: var(--text-tertiary); margin: 24px 0 0; line-height: 1.7; }
.page-meta a { color: var(--text-secondary); }
