/* ============================================================
   한국 채권 계산기 - Style Sheet
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Pretendard:wght@300;400;500;600;700&display=swap');

/* ── Reset & Base ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary:        #1a56db;
  --primary-light:  #e8effe;
  --primary-dark:   #1140a6;
  --accent:         #0ea5e9;
  --success:        #10b981;
  --success-light:  #d1fae5;
  --warning:        #f59e0b;
  --danger:         #ef4444;
  --text-main:      #0f172a;
  --text-sub:       #475569;
  --text-muted:     #94a3b8;
  --bg-page:        #f0f4fa;
  --bg-card:        #ffffff;
  --bg-input:       #f8fafc;
  --border:         #e2e8f0;
  --border-focus:   #1a56db;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:      0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg:      0 10px 30px rgba(0,0,0,.10), 0 4px 8px rgba(0,0,0,.06);
  --radius-sm:      6px;
  --radius-md:      12px;
  --radius-lg:      18px;
  --font:           'Pretendard', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --transition:     0.18s ease;
}

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--bg-page);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Header ── */
.app-header {
  background: linear-gradient(135deg, #1a56db 0%, #1d4ed8 50%, #1e40af 100%);
  color: #fff;
  padding: 0 1.5rem;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(26,86,219,.4);
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.header-logo i {
  font-size: 1.2rem;
  opacity: .9;
}

.header-badge {
  font-size: .72rem;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.3);
  color: rgba(255,255,255,.9);
  padding: .25rem .7rem;
  border-radius: 20px;
  letter-spacing: .5px;
  font-weight: 500;
}

/* ── Main Layout ── */
.app-main {
  padding: .8rem .75rem 2rem;
}

.calc-container {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: .65rem;
}

/* ── Card ── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .65rem 1.1rem;
  background: linear-gradient(to right, #f8fafc, #f1f5f9);
  border-bottom: 1px solid var(--border);
  font-size: .88rem;
  font-weight: 700;
  color: var(--text-main);
}

.card-header i {
  color: var(--primary);
  font-size: .9rem;
}

.card-body {
  padding: .9rem 1.1rem;
}

/* ── 섹션 번호 배지 ── */
.section-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  font-size: .68rem;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: 0;
}

/* ── Form Grid ── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .55rem .9rem;
}

/* 기본정보 섹션 전용 3열 그리드 */
.basic-grid {
  grid-template-columns: repeat(3, 1fr);
}

/* 이자유형: 3열 전체 차지 (한 줄) */
.basic-full {
  grid-column: 1 / -1;
}

/* 2행 빈 칸 */
.form-group-empty {
  display: block;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: .25rem;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

label {
  font-size: .76rem;
  font-weight: 600;
  color: var(--text-sub);
  letter-spacing: .1px;
}

/* ── Input ── */
.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: .75rem;
  color: var(--text-muted);
  font-size: .85rem;
  pointer-events: none;
}

.form-input {
  width: 100%;
  padding: .38rem .75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  font-family: var(--font);
  font-size: .84rem;
  color: var(--text-main);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  outline: none;
  -moz-appearance: textfield;
}

.form-input::-webkit-inner-spin-button,
.form-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

.input-icon + .form-input {
  padding-left: 2.1rem;
}

.form-input:focus {
  border-color: var(--border-focus);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}

.form-input:hover:not(:focus) {
  border-color: #a0aec0;
}

.suffix-wrap .form-input {
  padding-right: 2.2rem;
}

.input-suffix {
  position: absolute;
  right: .75rem;
  font-size: .8rem;
  color: var(--text-muted);
  font-weight: 500;
  pointer-events: none;
}

/* ── Button Group ── */
.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

/* 이자지급 주기 / 복리계산 주기: 항목이 적으므로 줄바꿈 없이 한 줄 고정 */
#pay-frequency,
#compound-frequency {
  flex-wrap: nowrap;
  gap: .3rem;
}

#pay-frequency .btn-opt,
#compound-frequency .btn-opt {
  flex: 1;
  text-align: center;
  padding-left: .3rem;
  padding-right: .3rem;
  min-width: 0;
}

.btn-opt {
  padding: .28rem .65rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  font-family: var(--font);
  font-size: .76rem;
  font-weight: 500;
  color: var(--text-sub);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-opt:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.btn-opt.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(26,86,219,.3);
}

/* ── Section 3: 산출 정보 ── */
.result-desc {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  background: linear-gradient(to right, #eff6ff, #f0f9ff);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  padding: .5rem .75rem;
  margin-bottom: .75rem;
  font-size: .78rem;
  color: #1e40af;
  line-height: 1.45;
}

.result-desc i {
  color: #3b82f6;
  margin-top: .15rem;
  flex-shrink: 0;
}

.calc-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: center;
}

.calc-item {
  display: flex;
  flex-direction: column;
  gap: .6rem;
}

.calc-label {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .84rem;
  font-weight: 600;
  color: var(--text-sub);
}

.calc-label i {
  color: var(--primary);
}

.calc-hint {
  font-size: .75rem;
  color: var(--text-muted);
  font-weight: 400;
}

.calc-input-row {
  display: flex;
  gap: .6rem;
  align-items: stretch;
}

.flex-1 { flex: 1; }

.calc-input {
  font-size: .88rem;
  font-weight: 500;
  padding: .4rem .75rem !important;
  height: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  letter-spacing: .3px;
  padding-right: .75rem !important;
}

/* 채권가격·수익률 옆 단위 텍스트 */
.calc-unit {
  display: flex;
  align-items: center;
  font-size: .84rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  padding: 0 .1rem;
  flex-shrink: 0;
}

/* 액면가 입력도 우측 정렬 */
#face-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.calc-btn {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: 0 .85rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(26,86,219,.3);
  height: 36px;
}

.calc-btn:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(26,86,219,.4);
  transform: translateY(-1px);
}

.calc-btn:active {
  transform: translateY(0);
}

.calc-btn i {
  font-size: .8rem;
}

.calc-divider {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding-top: 1.6rem;
}

.calc-divider span {
  font-size: .78rem;
  color: var(--text-muted);
  font-weight: 500;
  background: #fff;
  padding: .3rem .5rem;
  border: 1px solid var(--border);
  border-radius: 20px;
}

/* ── 결과 박스 ── */
.result-box {
  border-radius: var(--radius-md);
  overflow: hidden;
}

/* 결과 카드 */
.result-card {
  background: linear-gradient(135deg, #1a56db 0%, #1d4ed8 60%, #1e40af 100%);
  border-radius: var(--radius-md);
  padding: 1.4rem;
  color: #fff;
}

.result-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.2rem;
  padding-bottom: .8rem;
  border-bottom: 1px solid rgba(255,255,255,.2);
}

.result-card-title {
  font-size: .88rem;
  font-weight: 600;
  opacity: .85;
  display: flex;
  align-items: center;
  gap: .4rem;
}

.result-card-date {
  font-size: .75rem;
  opacity: .65;
}

.result-main-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.result-main-item {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: var(--radius-sm);
  padding: 1rem;
  text-align: center;
}

.result-main-item .r-label {
  font-size: .78rem;
  opacity: .75;
  margin-bottom: .35rem;
  font-weight: 500;
}

.result-main-item .r-value {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.result-main-item .r-unit {
  font-size: .78rem;
  opacity: .75;
  margin-left: .2rem;
}

.result-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .6rem;
}

.result-detail-item {
  background: rgba(255,255,255,.08);
  border-radius: var(--radius-sm);
  padding: .65rem .8rem;
  text-align: center;
}

.result-detail-item .rd-label {
  font-size: .72rem;
  opacity: .65;
  margin-bottom: .2rem;
}

.result-detail-item .rd-value {
  font-size: .95rem;
  font-weight: 600;
}

/* Error box */
.result-error {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: 1rem 1.2rem;
  background: #fff5f5;
  border: 1.5px solid #fecaca;
  border-radius: var(--radius-md);
  color: #dc2626;
  font-size: .85rem;
  font-weight: 500;
}

.result-error i {
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* ── Accordion (섹션 2 - 채권시장 제도 옵션) ── */
.accordion-card {}

.accordion-trigger {
  cursor: pointer;
  user-select: none;
  justify-content: space-between !important;
  transition: background var(--transition);
}

.accordion-trigger:hover {
  background: linear-gradient(to right, #f1f5f9, #e8effe);
}

.accordion-title {
  display: flex;
  align-items: center;
  gap: .65rem;
}

.accordion-badge {
  font-size: .7rem;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid #bfdbfe;
  padding: .15rem .55rem;
  border-radius: 20px;
  font-weight: 600;
}

.accordion-icon {
  color: var(--text-muted);
  transition: transform .25s ease;
  font-size: .85rem;
}

.accordion-icon.open {
  transform: rotate(180deg);
}

.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height .35s cubic-bezier(0.4, 0, 0.2, 1);
}

.accordion-body.open {
  max-height: 1000px;
}

/* ── 날짜 입력 (text 타입) ── */
.date-wrap {
  flex-direction: column;
  align-items: stretch;
}

.date-input {
  padding-left: 2.1rem !important;
  font-variant-numeric: tabular-nums;
  letter-spacing: .5px;
}

.date-input.is-invalid {
  border-color: var(--danger) !important;
  background: #fff5f5 !important;
}

.date-input.is-valid {
  border-color: var(--success) !important;
}

.date-error {
  display: block;
  font-size: .72rem;
  color: var(--danger);
  margin-top: .25rem;
  min-height: 1rem;
  font-weight: 500;
}

/* ── 세후수익률 하이라이트 ── */
.result-after-tax {
  background: rgba(16,185,129,.18) !important;
  border: 1px solid rgba(16,185,129,.4) !important;
}

.result-after-tax .rd-label {
  color: #6ee7b7 !important;
  opacity: 1 !important;
  font-weight: 600 !important;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2rem;
}

.result-after-tax .rd-value {
  color: #d1fae5 !important;
  font-size: 1.05rem !important;
}

.at-method-badge {
  font-size: .66rem;
  background: rgba(16,185,129,.35);
  border: 1px solid rgba(16,185,129,.5);
  color: #a7f3d0;
  padding: .1rem .45rem;
  border-radius: 20px;
  font-weight: 500;
  white-space: nowrap;
}

.at-note {
  font-size: .72rem;
  opacity: .7;
  margin-left: .3rem;
}

/* ── 현금흐름표 아코디언 (결과 카드 내부) ── */
.cf-accordion {
  margin-top: 1rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.2);
}

.cf-accordion-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  background: rgba(255,255,255,.1);
  cursor: pointer;
  user-select: none;
  font-size: .85rem;
  font-weight: 600;
  transition: background var(--transition);
  border: none;
  width: 100%;
  color: #fff;
  font-family: var(--font);
}

.cf-accordion-trigger:hover {
  background: rgba(255,255,255,.18);
}

.cf-accordion-trigger .cf-acc-left {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.cf-accordion-trigger .cf-acc-badge {
  font-size: .7rem;
  background: rgba(255,255,255,.2);
  padding: .1rem .5rem;
  border-radius: 20px;
  font-weight: 500;
}

.cf-chevron {
  font-size: .8rem;
  transition: transform .25s ease;
  opacity: .8;
}

.cf-chevron.open { transform: rotate(180deg); }

.cf-accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height .4s cubic-bezier(0.4, 0, 0.2, 1);
}

.cf-accordion-body.open {
  max-height: 600px;
  overflow-y: auto;
}

/* 현금흐름 테이블 */
.cf-table-wrap {
  padding: .6rem .5rem 1rem;
  overflow-x: auto;
}

.cf-basis-label {
  font-size: .74rem;
  color: rgba(255,255,255,.6);
  padding: .3rem .6rem .4rem;
  letter-spacing: .2px;
}

.cf-basis-label strong {
  color: #fde68a;
  font-weight: 600;
}

.cf-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .78rem;
  color: rgba(255,255,255,.9);
}

.cf-table th {
  padding: .45rem .6rem;
  background: rgba(255,255,255,.12);
  font-weight: 600;
  font-size: .72rem;
  opacity: .85;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,.2);
  white-space: nowrap;
}

.cf-table td {
  padding: .4rem .6rem;
  text-align: right;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.cf-table td:first-child,
.cf-table td:nth-child(2) {
  text-align: center;
}

.cf-table tr:last-child td {
  font-weight: 700;
  background: rgba(255,255,255,.1);
  border-top: 1px solid rgba(255,255,255,.25);
}

.cf-table tr:hover td {
  background: rgba(255,255,255,.07);
}

.cf-table .cf-principal { color: #fde68a; font-weight: 600; }
.cf-table .cf-total     { color: #bfdbfe; }
.cf-table .cf-pv        { color: #a7f3d0; }

/* ── 채권명 입력 + 새 채권 버튼 ── */
.bond-name-wrap {
  display: flex;
  gap: .5rem;
  align-items: center;
}

.bond-name-wrap .bond-name-input {
  flex: 1;
}

.new-bond-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .38rem .85rem;
  background: #fff;
  border: 1.5px solid var(--primary);
  color: var(--primary);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
  flex-shrink: 0;
}

.new-bond-btn:hover {
  background: var(--primary);
  color: #fff;
}

.new-bond-btn i {
  font-size: .8rem;
}

/* 모바일에서 텍스트 숨기고 아이콘만 */
@media (max-width: 480px) {
  .new-bond-btn span { display: none; }
  .new-bond-btn { padding: .38rem .6rem; }
}

/* ── 만기보장수익률 UI ── */
.gyr-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem;
}

.gyr-input-wrap {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.gyr-input-wrap .input-wrap {
  width: 130px;
}

.gyr-calc-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .35rem .85rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
  box-shadow: 0 2px 6px rgba(26,86,219,.25);
}

.gyr-calc-btn:hover {
  background: var(--primary-dark);
}

.gyr-result {
  margin-top: .5rem;
  padding: .6rem .9rem;
  background: linear-gradient(to right, #eff6ff, #e8effe);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  color: #1e40af;
  line-height: 1.7;
}

.gyr-result strong {
  color: var(--primary);
  font-size: .95rem;
}

.gyr-result .gyr-formula {
  font-size: .74rem;
  color: var(--text-muted);
  margin-top: .2rem;
}

/* 만기보장수익률로 상환율 자동수정 시 하이라이트 */
@keyframes gyrHighlight {
  0%   { box-shadow: 0 0 0 3px rgba(16,185,129,.5); background: #d1fae5; }
  100% { box-shadow: none; background: var(--bg-input); }
}
.gyr-updated {
  animation: gyrHighlight 1.2s ease-out;
}

/* ── Today 버튼 — input 내장형 ── */
.trade-date-inner {
  /* .date-wrap의 flex-direction:column 을 덮어씀 */
  flex-direction: row !important;
  align-items: stretch !important;
  position: relative;
  padding: 0 !important;
  overflow: hidden;
}

.trade-date-inner .date-input {
  /* 왼쪽 아이콘 + 오른쪽 Today 버튼 공간 */
  padding-right: 3.8rem !important;
  width: 100%;
  border-radius: var(--radius-sm) !important;
}

.today-btn {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .18rem;
  padding: 0 .5rem;
  margin: 0;
  background: var(--primary-light);
  color: var(--primary);
  border: none;
  border-left: 1.5px solid var(--primary);
  border-top: 1.5px solid var(--primary);
  border-right: 1.5px solid var(--primary);
  border-bottom: 1.5px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-family: var(--font);
  font-size: .65rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
  letter-spacing: .2px;
  line-height: 1;
  height: 100%;
  box-sizing: border-box;
}

.today-btn i {
  font-size: .65rem;
}

.today-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary-dark);
}

/* 모바일(480px) Today 텍스트 숨김 처리는 미디어쿼리에서 */

  color: #fff;
  border-color: var(--primary);
}

/* ── 채권명 입력 필드 ── */

.bond-name-group {
  margin-bottom: .45rem;
  padding-bottom: .45rem;
  border-bottom: 1px dashed var(--border);
}

/* 이자유형 — 채권명 바로 아래 독립 행 */
.interest-type-group {
  margin-bottom: .5rem;
  padding-bottom: .5rem;
  border-bottom: 1px dashed var(--border);
}

.interest-type-group label {
  display: block;
  font-size: .76rem;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: .22rem;
}

.interest-type-group .btn-group {
  flex-wrap: nowrap;
}

.bond-name-group label {
  display: flex;
  align-items: center;
  gap: .3rem;
  font-weight: 600;
  font-size: .78rem;
  color: var(--text-sub);
  margin-bottom: .2rem;
}

.bond-name-group label i {
  color: var(--primary);
}

.label-hint {
  font-size: .74rem;
  font-weight: 400;
  color: var(--text-muted);
}

.bond-name-input {
  font-size: .95rem !important;
  font-weight: 600 !important;
  color: var(--text-main) !important;
  letter-spacing: .3px;
}

.bond-name-input::placeholder {
  font-weight: 400;
  color: var(--text-muted);
}

/* ============================================================
   계산 이력 섹션
   ============================================================ */

.history-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history-header-left {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.history-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  height: 1.4rem;
  padding: 0 .4rem;
  border-radius: 20px;
  background: var(--primary);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
}

.history-clear-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .35rem .8rem;
  border: 1px solid var(--danger);
  background: transparent;
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: .78rem;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
}

.history-clear-btn:hover {
  background: var(--danger);
  color: #fff;
}

/* 빈 상태 */
.history-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  padding: 1rem .75rem;
  color: var(--text-muted);
  text-align: center;
}

.history-empty i {
  font-size: 1.4rem;
  opacity: .4;
}

.history-empty p {
  font-size: .78rem;
  line-height: 1.5;
}

/* 이력 목록 */
.history-list {
  display: flex;
  flex-direction: column;
  gap: .7rem;
}

/* 이력 카드 */
.history-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  overflow: hidden;
  transition: box-shadow var(--transition), border-color var(--transition);
}

.history-item:hover {
  box-shadow: var(--shadow-md);
  border-color: #c7d7f7;
}

/* 이력 카드 헤더 */
.hi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .65rem 1rem;
  background: var(--primary-light);
  border-bottom: 1px solid #dde8fb;
  flex-wrap: wrap;
  gap: .4rem;
}

.hi-left {
  display: flex;
  align-items: center;
  gap: .45rem;
  flex-wrap: wrap;
}

.hi-right {
  display: flex;
  align-items: center;
  gap: .4rem;
}

.hi-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  flex-shrink: 0;
}

.hi-name {
  font-weight: 700;
  font-size: .9rem;
  color: var(--text-main);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hi-type-badge,
.hi-mode-badge {
  font-size: .68rem;
  padding: .12rem .5rem;
  border-radius: 20px;
  font-weight: 600;
  white-space: nowrap;
}

.hi-type-badge {
  background: #dbeafe;
  color: #1e40af;
}

.hi-mode-badge {
  background: #fef3c7;
  color: #92400e;
}

.hi-date {
  font-size: .74rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* 불러오기 버튼 */
.hi-load-btn {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .28rem .75rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .76rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: background var(--transition), transform var(--transition);
  white-space: nowrap;
}

.hi-load-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

/* 삭제 버튼 */
.hi-del-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  border: 1px solid #f1c0c0;
  background: transparent;
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: .8rem;
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
}

.hi-del-btn:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

/* 이력 카드 바디 */
.hi-body {
  padding: .8rem 1rem;
}

/* 입력값 요약 행 */
.hi-row {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem .8rem;
  margin-bottom: .7rem;
  padding-bottom: .7rem;
  border-bottom: 1px solid var(--border);
}

.hi-cell {
  display: flex;
  align-items: center;
  gap: .3rem;
  font-size: .78rem;
}

.hi-label {
  color: var(--text-muted);
  font-size: .72rem;
}

.hi-val {
  color: var(--text-sub);
  font-weight: 600;
}

/* 결과값 행 */
.hi-result-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .5rem;
}

@media (max-width: 520px) {
  .hi-result-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

.hi-result-item {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .45rem .6rem;
  display: flex;
  flex-direction: column;
  gap: .15rem;
}

.hi-result-item.primary {
  background: var(--primary-light);
  border-color: #bcd0f7;
}

.hi-rlabel {
  font-size: .68rem;
  color: var(--text-muted);
  font-weight: 500;
}

.hi-rval {
  font-size: .88rem;
  font-weight: 700;
  color: var(--text-main);
}

.hi-result-item.primary .hi-rval {
  color: var(--primary);
}

.hi-rval small {
  font-size: .68rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: .15rem;
}

.hi-aftertax {
  font-weight: 700;
  color: #059669;
}

.hi-aftertax.exempt {
  color: var(--text-muted);
  font-weight: 500;
}

.hi-aftertax small {
  font-size: .68rem;
  font-weight: 400;
}

/* 불러오기 시 하이라이트 flash */
@keyframes highlightFlash {
  0%   { box-shadow: 0 0 0 0 rgba(26, 86, 219, .5); }
  50%  { box-shadow: 0 0 0 8px rgba(26, 86, 219, .15); }
  100% { box-shadow: 0 0 0 0 rgba(26, 86, 219, 0); }
}

.highlight-flash {
  animation: highlightFlash .8s ease;
}

/* ── 튜토리얼 트리거 버튼 (헤더) ── */
.tutorial-trigger {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .3rem .75rem;
  background: rgba(255,255,255,.15);
  color: #fff;
  border: 1.5px solid rgba(255,255,255,.35);
  border-radius: 20px;
  font-family: var(--font);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
  letter-spacing: .2px;
}
.tutorial-trigger:hover {
  background: rgba(255,255,255,.28);
  border-color: rgba(255,255,255,.7);
}
.tutorial-trigger i:first-child { font-size: .85rem; }
.tutorial-chevron {
  font-size: .65rem;
  opacity: .8;
  transition: transform .25s ease;
}
.tutorial-chevron.open { transform: rotate(180deg); }

/* ── 튜토리얼 슬라이드다운 패널 ── */
.tutorial-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height .4s cubic-bezier(.4,0,.2,1);
  background: #f8faff;
  border-bottom: 2px solid var(--border);
}
.tutorial-panel.open {
  max-height: 9999px;
}

.tutorial-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.4rem 1.5rem 1.8rem;
}

/* 패널 헤더 */
.tut-header {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin-bottom: 1.2rem;
  padding-bottom: .75rem;
  border-bottom: 2px solid var(--primary-light);
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--primary-dark);
}
.tut-header i:first-child { color: var(--primary); font-size: 1.1rem; }
.tut-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: .2rem .4rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.tut-close:hover { background: var(--danger); color: #fff; }

/* 섹션 */
.tut-section {
  margin-bottom: 1.4rem;
  padding-bottom: 1.2rem;
  border-bottom: 1px dashed var(--border);
}
.tut-section:last-child { border-bottom: none; margin-bottom: 0; }

.tut-section-title {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .95rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: .65rem;
}
.tut-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  font-size: .75rem;
  font-weight: 700;
  flex-shrink: 0;
}
.tut-section p {
  font-size: .84rem;
  color: var(--text-sub);
  line-height: 1.65;
  margin-bottom: .7rem;
}

/* 4단계 스텝 */
.tut-steps { display: flex; flex-direction: column; gap: .45rem; }
.tut-step {
  display: flex;
  align-items: flex-start;
  gap: .55rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .55rem .8rem;
  font-size: .83rem;
  color: var(--text-sub);
  line-height: 1.55;
}
.tut-step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .1rem .5rem;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

/* 리스트 */
.tut-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.tut-list li {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .6rem .85rem;
  font-size: .83rem;
  color: var(--text-sub);
  line-height: 1.6;
}
.tut-icon {
  color: var(--primary);
  font-size: .85rem;
  margin-top: .15rem;
  flex-shrink: 0;
  width: 1rem;
  text-align: center;
}

/* 양방향 계산 카드 */
.tut-calc-row {
  display: flex;
  align-items: center;
  gap: .8rem;
  margin-top: .5rem;
}
.tut-calc-card {
  flex: 1;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: .85rem 1rem;
  text-align: center;
  font-size: .82rem;
  color: var(--text-sub);
  line-height: 1.55;
}
.tut-calc-card i { font-size: 1.3rem; color: var(--primary); display: block; margin-bottom: .35rem; }
.tut-calc-card strong { display: block; font-size: .88rem; color: var(--text-main); margin-bottom: .3rem; }
.tut-calc-card em { color: var(--primary); font-style: normal; font-weight: 600; }
.tut-calc-arrow { font-size: 1.2rem; color: var(--text-muted); flex-shrink: 0; }

/* 모바일 */
@media (max-width: 680px) {
  .tutorial-trigger span { font-size: .7rem; }
  .tutorial-inner { padding: 1rem 1rem 1.4rem; }
  .tut-calc-row { flex-direction: column; gap: .5rem; }
  .tut-calc-arrow { transform: rotate(90deg); }
}
@media (max-width: 480px) {
  .tutorial-trigger span { display: none; }
  .tutorial-trigger { padding: .28rem .5rem; gap: .25rem; }
}

/* ── Footer ── */
.app-footer {
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: .76rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: .5rem;
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  gap: .4rem;
  align-items: center;
}

.footer-author {
  font-size: .74rem;
  color: var(--text-muted);
}

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

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

/* ── Responsive ── */
@media (max-width: 680px) {
  html { font-size: 14px; }

  /* 기본 2열 그리드는 1열로 */
  .form-grid {
    grid-template-columns: 1fr;
  }

  /* Today 버튼 모바일 중간 사이즈 */
  .today-btn { font-size: .6rem; padding: 0 .38rem; }

  /* 기본정보 섹션: 날짜 3열 유지, 2행 3열 유지 */
  .basic-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  /* 이자유형은 항상 전체 너비 */
  .basic-full {
    grid-column: 1 / -1;
  }

  .calc-grid {
    grid-template-columns: 1fr auto 1fr;
    gap: .5rem;
  }

  /* 좁은 화면에서 calc-label 힌트 숨김 */
  .calc-hint { display: none; }

  /* 계산 버튼: 아이콘만 표시 */
  .calc-btn span { display: none; }
  .calc-btn {
    padding: 0 .65rem;
    gap: 0;
  }

  .calc-divider {
    flex-direction: column;
    padding-top: 0;
  }

  .calc-divider::before,
  .calc-divider::after {
    content: '';
    flex: 0;
    height: 0;
    background: none;
  }

  .result-main-row {
    grid-template-columns: 1fr;
  }

  .result-detail-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .header-badge {
    display: none;
  }

  .app-main { padding: .6rem .6rem 1.5rem; }
  .calc-container { gap: .5rem; }
  .card-body { padding: .75rem .85rem; }
}

/* ── 모바일 컴팩트 (480px 이하) ── */
@media (max-width: 480px) {
  .app-header { height: 44px; }
  .app-header .header-logo { font-size: 1rem; }
  .app-main { padding: .45rem .5rem 1.5rem; }
  .calc-container { gap: .4rem; }
  .card-header { padding: .5rem .85rem; font-size: .82rem; }
  .card-body { padding: .65rem .75rem; }
  .bond-name-group { margin-bottom: .4rem; padding-bottom: .4rem; }
  .form-grid { gap: .4rem .6rem; }
  /* 기본정보: 날짜 3열 유지 */
  .basic-grid { grid-template-columns: repeat(3, 1fr); gap: .35rem .4rem; }
  .basic-full { grid-column: 1 / -1; }
  .form-group { gap: .18rem; }
  label { font-size: .68rem; }
  .form-input { padding: .28rem .45rem; font-size: .76rem; }
  /* 날짜 입력 아이콘 제거 (너무 좁음) */
  .basic-grid .input-icon { display: none; }
  .basic-grid .date-input { padding-left: .45rem !important; }
  /* Today 버튼 내장형: 모바일에서 텍스트 숨김, 아이콘만 */
  .today-btn span { display: none; }
  .today-btn { padding: 0 .3rem; }
  .trade-date-inner .date-input { padding-right: 1.8rem !important; }
  .btn-opt { padding: .2rem .42rem; font-size: .68rem; }
  .result-desc { padding: .38rem .6rem; font-size: .72rem; margin-bottom: .5rem; }
  .calc-input { height: 32px !important; font-size: .78rem; }
  .calc-btn { height: 32px; font-size: .72rem; padding: 0 .5rem; }
  .calc-btn span { display: none; }
  .calc-input-row { gap: .3rem; }
  .calc-unit { font-size: .72rem; }
  .history-empty { padding: .65rem .5rem; }
  .history-empty i { font-size: 1.1rem; }
  .history-empty p { font-size: .72rem; }
}

/* ── Spinner ── */
.spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Number Input Date Fix ── */
input[type="date"] {
  padding: .6rem .85rem;
  font-family: var(--font);
  font-size: .88rem;
}

/* ============================================================
   계산 완료 결과 섹션
   - 산출정보(#section-calc) 바로 아래에 붙어서 표시됨
   ============================================================ */

/* 슬라이드 인 애니메이션 */
@keyframes resultSlideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── 기본 결과 섹션 카드 ── */
.result-section {
  animation: resultSlideIn 0.3s ease;
  border: 1.5px solid rgba(26,86,219,.3) !important;
  box-shadow: 0 6px 24px rgba(26,86,219,.15), 0 2px 6px rgba(0,0,0,.06) !important;
}

/* 결과 섹션 헤더 */
.result-section-header {
  background: linear-gradient(to right, #1a56db, #1e40af) !important;
  border-bottom: none !important;
  justify-content: space-between !important;
  padding: .85rem 1.4rem !important;
}

.result-section-title-wrap {
  display: flex;
  align-items: center;
  gap: .6rem;
}

.result-check-icon {
  color: #6ee7b7 !important;
  font-size: 1.1rem !important;
}

.result-section-header span {
  color: #fff !important;
  font-weight: 700 !important;
  font-size: .95rem;
}

/* 결과 닫기 버튼 */
.result-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  border: 1.5px solid rgba(255,255,255,.4);
  background: rgba(255,255,255,.15);
  color: rgba(255,255,255,.9);
  border-radius: var(--radius-sm);
  font-size: .85rem;
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
}

.result-close-btn:hover {
  background: rgba(255,255,255,.3);
  border-color: rgba(255,255,255,.7);
  color: #fff;
}

/* 결과 섹션 내 바디 패딩 제거 */
.result-body-pad {
  padding: 0 !important;
}

/* 결과 박스 (섹션 내부) */
.result-section .result-box {
  border-radius: 0;
}

.result-section .result-card {
  border-radius: 0 0 calc(var(--radius-lg) - 1px) calc(var(--radius-lg) - 1px);
  padding: 1.4rem;
}

/* 에러 메시지 섹션 내부 */
.result-section .result-error {
  border-radius: 0;
  border: none;
  border-top: 1.5px solid #fecaca;
  margin: 0;
}

/* 산출정보 섹션이 결과와 이어질 때 하단 radius 제거 + 연결선 효과 */
#section-calc.result-visible {
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-bottom-color: rgba(26,86,219,.35) !important;
  border-bottom-width: 1.5px !important;
}

/* 결과 섹션 - 산출정보 바로 아래에 붙어 있을 때 */
#section-result.attached {
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  margin-top: calc(-.65rem - 1px) !important;
  border-top: none !important;
  position: relative;
  z-index: 1;
}

/* attached 상태일 때 결과 카드 하단 radius */
#section-result.attached .result-card {
  border-radius: 0 0 calc(var(--radius-lg) - 2px) calc(var(--radius-lg) - 2px);
}

/* attached 이후 다음 섹션 간격 보정 */
#section-result.attached + * {
  margin-top: .65rem;
}
