@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;600;700;800&family=Inter:wght@400;500;600;700;800&display=swap');

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

:root {
  --bg: #0d0f1a;
  --bg2: #12152a;
  --card: rgba(255,255,255,0.04);
  --card-border: rgba(255,255,255,0.08);
  --card-hover: rgba(255,255,255,0.07);
  --primary: #7c3aed;
  --primary2: #4f46e5;
  --glow: rgba(124,58,237,0.3);
  --gold: #f59e0b;
  --gold-light: #fbbf24;
  --success: #10b981;
  --danger: #ef4444;
  --text: #f1f5f9;
  --text-sub: #94a3b8;
  --text-muted: #475569;
  --radius: 16px;
  --radius-sm: 10px;
}

body {
  font-family: 'Noto Sans KR', 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── HEADER ── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13,15,26,0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--card-border);
  padding: 0 24px;
}

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

.logo {
  font-size: 18px;
  font-weight: 800;
  text-decoration: none;
  background: linear-gradient(135deg, #a78bfa, #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.3px;
}

nav a {
  color: var(--text-sub);
  text-decoration: none;
  margin-left: 28px;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s;
}

nav a:hover { color: var(--text); }

/* ── HERO ── */
.hero {
  position: relative;
  overflow: hidden;
  padding: 80px 24px 72px;
  text-align: center;
}

.hero::before {
  content: '';
  position: absolute;
  top: -40%;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 500px;
  background: radial-gradient(ellipse, rgba(124,58,237,0.25) 0%, rgba(79,70,229,0.1) 50%, transparent 70%);
  pointer-events: none;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(124,58,237,0.15);
  border: 1px solid rgba(124,58,237,0.3);
  color: #a78bfa;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 100px;
  margin-bottom: 20px;
  letter-spacing: 0.5px;
}

.hero h1 {
  font-size: 48px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -1px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #ffffff 0%, #c4b5fd 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: 17px;
  color: var(--text-sub);
  max-width: 460px;
  margin: 0 auto;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-top: 40px;
}

.stat {
  text-align: center;
}

.stat .num {
  font-size: 22px;
  font-weight: 800;
  color: var(--gold-light);
}

.stat .desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── CONTAINER ── */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

/* ── CARD ── */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 20px;
  transition: border-color 0.3s;
}

.card:hover {
  border-color: rgba(124,58,237,0.2);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.card-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.card-header h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

/* ── TRANSACTION ROW ── */
.tx-list { display: flex; flex-direction: column; gap: 10px; }

/* transaction-row 정의는 mode-tabs 섹션으로 통합됨 */

.tx-num {
  position: absolute;
  top: -10px;
  left: 18px;
  background: var(--primary);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 100px;
}

label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

input[type="number"],
input[type="text"] {
  width: 100%;
  padding: 11px 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  transition: border-color 0.2s, background 0.2s;
}

input::placeholder { color: var(--text-muted); }

input:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(124,58,237,0.08);
}

/* ── BUTTONS ── */
.btn-remove {
  width: 44px;
  height: 44px;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.2);
  color: #ef4444;
  border-radius: 8px;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-remove:hover {
  background: rgba(239,68,68,0.2);
  border-color: #ef4444;
}

.btn-add {
  width: 100%;
  padding: 13px;
  margin-top: 12px;
  margin-bottom: 20px;
  background: transparent;
  border: 1px dashed rgba(124,58,237,0.4);
  border-radius: var(--radius-sm);
  color: #a78bfa;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-add:hover {
  background: rgba(124,58,237,0.08);
  border-color: var(--primary);
}

.btn-calc {
  width: 100%;
  padding: 18px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary2) 100%);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: -0.2px;
  transition: all 0.2s;
  box-shadow: 0 4px 24px var(--glow);
  position: relative;
  overflow: hidden;
}

.btn-calc::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}

.btn-calc:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px var(--glow);
}

.btn-calc:hover::after { opacity: 1; }

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

/* ── RESULT ── */
.result-box { display: none; }
.result-box.visible { display: block; animation: fadeUp 0.4s ease; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.result-item {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: center;
  transition: all 0.3s;
}

.result-item.highlight {
  background: rgba(124,58,237,0.1);
  border-color: rgba(124,58,237,0.3);
  box-shadow: 0 0 24px rgba(124,58,237,0.15);
}

.result-item .r-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.result-item .r-value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  font-family: 'Inter', sans-serif;
}

.r-value.green { color: var(--success); }
.r-value.red   { color: var(--danger); }
.r-value.purple { color: #a78bfa; }

/* ── BREAKDOWN ── */
.breakdown {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 14px;
}

.breakdown-row:last-child {
  border-bottom: none;
  background: rgba(124,58,237,0.08);
  font-weight: 700;
  font-size: 16px;
  color: #a78bfa;
}

.breakdown-row .bd-name { color: var(--text-sub); }

.result-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 14px 18px;
  background: rgba(124,58,237,0.08);
  border: 1px solid rgba(124,58,237,0.2);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: #c4b5fd;
}

/* ── INFO CARDS ── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.info-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 20px;
  transition: all 0.2s;
}

.info-card:hover {
  border-color: rgba(124,58,237,0.25);
  background: rgba(124,58,237,0.05);
}

.info-card-icon {
  font-size: 24px;
  margin-bottom: 10px;
}

.info-card h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.info-card p, .info-card li {
  font-size: 13px;
  color: var(--text-sub);
  line-height: 1.7;
}

.info-card ul { padding-left: 16px; }

.badge {
  display: inline-block;
  background: rgba(124,58,237,0.15);
  border: 1px solid rgba(124,58,237,0.3);
  color: #a78bfa;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 100px;
  margin-bottom: 10px;
  letter-spacing: 0.3px;
}

/* ── CTA BANNER ── */
.cta-banner {
  background: linear-gradient(135deg, rgba(124,58,237,0.2) 0%, rgba(79,70,229,0.15) 100%);
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: var(--radius);
  padding: 36px;
  text-align: center;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}

.cta-banner::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(124,58,237,0.15), transparent 70%);
}

.cta-banner h2 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 8px;
}

.cta-banner p {
  color: var(--text-sub);
  margin-bottom: 20px;
  font-size: 15px;
}

.btn-cta {
  display: inline-block;
  padding: 14px 32px;
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  color: white;
  font-weight: 700;
  font-size: 15px;
  border-radius: 10px;
  text-decoration: none;
  transition: all 0.2s;
  box-shadow: 0 4px 20px var(--glow);
}

.btn-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px var(--glow);
}

/* ── FOOTER ── */
footer {
  border-top: 1px solid var(--card-border);
  padding: 32px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

footer a {
  color: var(--text-muted);
  text-decoration: none;
  margin: 0 12px;
  transition: color 0.2s;
}

footer a:hover { color: var(--text-sub); }

/* ── MODE TABS ── */
.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 20px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 6px;
}

.mode-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-tab:hover { color: var(--text-sub); background: rgba(255,255,255,0.04); }

.mode-tab.active {
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  color: white;
  box-shadow: 0 2px 12px var(--glow);
}

.mode-tab-desc {
  font-size: 11px;
  font-weight: 400;
  opacity: 0.75;
}

/* ── TRANSACTION ROW: 모드별 컬럼 ── */
.transaction-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 44px;
  gap: 10px;
  align-items: start;
  padding: 20px 18px 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s;
  position: relative;
}

.transaction-row:hover { border-color: rgba(124,58,237,0.25); }

/* 간편 모드: memo + pnl + remove */
.transaction-row.simple-mode {
  grid-template-columns: 1fr 1fr 44px;
}

/* 컬럼 show/hide */
.detail-col { display: block; }
.simple-col { display: none; }
.simple-mode .detail-col { display: none; }
.simple-mode .simple-col { display: block; }

/* ── SECTION LABEL ── */
.section-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 20px 0 10px;
}

/* ── LABEL HINT ── */
.label-hint {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 4px;
  text-transform: none;
  letter-spacing: 0;
}

/* ── AMOUNT HINT ── */
.amount-hint {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #a78bfa;
  margin-top: 5px;
  min-height: 15px;
  opacity: 0;
  transition: opacity 0.2s;
}

/* ── P&L PER ROW ── */
.tx-pnl {
  grid-column: 1 / -1;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  display: none;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  margin-top: 4px;
  transition: all 0.2s;
}

.tx-pnl.gain, .tx-pnl.loss { display: flex; }

.tx-pnl.gain {
  background: rgba(16,185,129,0.08);
  color: var(--success);
  border: 1px solid rgba(16,185,129,0.18);
}

.tx-pnl.loss {
  background: rgba(239,68,68,0.08);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,0.18);
}

.pnl-pct {
  font-size: 12px;
  opacity: 0.75;
}

/* ── TRANSACTION BREAKDOWN (결과) ── */
.bd-tx-list {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 4px;
}

.bd-tx-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 14px;
}

.bd-tx-memo {
  color: var(--text-sub);
  font-weight: 500;
}

.bd-tx-pnl { font-weight: 700; font-family: 'Inter', sans-serif; }
.bd-tx-pnl.gain { color: var(--success); }
.bd-tx-pnl.loss { color: var(--danger); }

.bd-tx-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 700;
  background: rgba(255,255,255,0.03);
}

.bd-tx-total .gain { color: var(--success); }
.bd-tx-total .loss { color: var(--danger); }

/* ── DEDUCTION PROGRESS BAR ── */
.deduction-bar-wrap {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin-bottom: 4px;
}

.deduction-bar-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 10px;
  color: var(--text-sub);
}

.deduction-limit { color: var(--text-muted); font-size: 12px; }

.deduction-bar-track {
  height: 8px;
  background: rgba(255,255,255,0.08);
  border-radius: 100px;
  overflow: hidden;
}

.deduction-bar-fill {
  height: 100%;
  border-radius: 100px;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
  transition: width 0.8s cubic-bezier(0.34,1.56,0.64,1);
}

.deduction-bar-fill.over {
  background: linear-gradient(90deg, var(--danger), #f97316);
}

.deduction-extra {
  font-size: 13px;
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  font-weight: 500;
}

.deduction-extra.success {
  background: rgba(16,185,129,0.1);
  color: var(--success);
  border: 1px solid rgba(16,185,129,0.2);
}

.deduction-extra.warn {
  background: rgba(239,68,68,0.08);
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,0.18);
}

.deduction-extra.info {
  background: rgba(255,255,255,0.03);
  color: var(--text-muted);
  border: 1px solid var(--card-border);
}

/* ── RUNNING TOTAL ── */
.running-total {
  display: none;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  margin-top: 4px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-sub);
}

.running-label {
  display: flex;
  align-items: center;
  gap: 6px;
}

#running-total-value {
  font-weight: 800;
  font-size: 17px;
  font-family: 'Inter', sans-serif;
  transition: color 0.3s;
}

/* ── ERROR MESSAGE ── */
.calc-error {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: var(--radius-sm);
  color: #fca5a5;
  font-size: 14px;
  margin-bottom: 12px;
  animation: fadeUp 0.2s ease;
}

/* ── RESPONSIVE ── */
@media (max-width: 640px) {
  .hero h1 { font-size: 32px; }
  .hero-stats { gap: 24px; }
  .mode-tab-desc { display: none; }
  .transaction-row,
  .transaction-row.simple-mode {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .memo-col { grid-column: span 2; }
  .simple-col { grid-column: span 2; }
  .transaction-row .btn-remove { justify-self: end; margin-top: 8px; }
  .tx-pnl { grid-column: span 2; }
  .result-summary { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr; }
  .card { padding: 20px; }
}
