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

:root {
  --primary: #3182F6;
  --primary-hover: #1B64DA;
  --primary-light: #E8F3FF;
  --secondary: #4E5968;
  --success: #00C4B8;
  --danger: #FF736A;
  --bg: #2A2A2A;
  --surface: #FFFFFF;
  --text-primary: #191F28;
  --text-secondary: #4E5968;
  --text-tertiary: #8B95A1;
  --border: #E5E8EB;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --ambient-glow: rgba(255, 200, 100, 0.6);
}

body {
  font-family: 'Noto Sans KR', 'Apple SD Gothic Neo', 'Pretendard', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-secondary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding: 24px 0 60px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 48px;
  padding-top: 20px;
}

.header h1 {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -1px;
  color: #FFFFFF;
  margin-bottom: 12px;
  line-height: 1.2;
}

.subtitle {
  font-size: 16px;
  color: #B0B8C1;
  font-weight: 400;
}

/* Main Layout */
.main-content {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  transition: all 0.3s ease;
}

/* 계산 전: 입력 섹션 가운데 정렬 */
.main-content.centered {
  display: flex;
  justify-content: center;
}

.main-content.centered .input-section {
  max-width: 700px;
  width: 100%;
}

.main-content.centered .result-section {
  display: none;
}

/* 계산 후: 2열 레이아웃 */
@media (min-width: 1024px) {
  .main-content.with-results {
    grid-template-columns: 550px 1fr;
    gap: 32px;
  }
}

/* Sections */
.input-section,
.result-section {
  background: var(--surface);
  padding: 32px;
  border-radius: var(--radius-xl);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04),
              0 8px 16px rgba(0, 0, 0, 0.06),
              0 8px 20px -2px rgba(255, 200, 100, 0.25),
              0 10px 24px -2px rgba(255, 195, 95, 0.22),
              0 12px 28px -3px rgba(255, 190, 90, 0.19),
              0 14px 32px -3px rgba(255, 185, 85, 0.16),
              0 16px 36px -4px rgba(255, 180, 80, 0.13),
              0 18px 40px -4px rgba(255, 175, 75, 0.10),
              0 20px 44px -5px rgba(255, 170, 70, 0.08),
              0 24px 52px -6px rgba(255, 165, 65, 0.06),
              0 28px 60px -8px rgba(255, 160, 60, 0.04),
              inset 0 1px 0 rgba(255, 255, 255, 0.9);
  border: 2px solid #E5E8EB;
  position: relative;
}

/* Result Header with Export Buttons */
.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.input-section h2,
.result-section h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 0;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.input-section h2 {
  margin-bottom: 24px;
}

/* Export Buttons */
.export-buttons {
  display: flex;
  gap: 8px;
}

.btn-export {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  background: white;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

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

.btn-export svg {
  flex-shrink: 0;
}

.btn-export-image:hover {
  background: #E8F5E9;
  border-color: #4CAF50;
  color: #2E7D32;
}

.btn-export-pdf:hover {
  background: #FFEBEE;
  border-color: #F44336;
  color: #C62828;
}

/* Form Groups */
.form-group {
  margin-bottom: 24px;
}

.form-group-inline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.inline-input {
  display: flex;
  flex-direction: column;
}

.form-group label {
  display: block;
  margin-bottom: 10px;
  font-weight: 600;
  color: var(--text-primary);
}

.label-text {
  font-size: 15px;
}

.required-badge {
  display: inline-block;
  padding: 2px 6px;
  margin-left: 6px;
  background: #FEE2E2;
  color: #DC2626;
  font-size: 10px;
  font-weight: 600;
  border-radius: 4px;
  letter-spacing: 0.3px;
}

.label-hint {
  font-size: 13px;
  color: var(--text-tertiary);
  font-weight: 400;
  margin-left: 4px;
}

.form-group input[type="number"],
.form-group input[type="text"],
.form-group select {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 16px;
  font-family: inherit;
  color: var(--text-primary);
  transition: all 0.2s ease;
  background: var(--surface);
}

.form-group input[type="number"]::placeholder,
.form-group input[type="text"]::placeholder {
  color: #B0B8C1;
}

.form-group input[type="number"]:hover,
.form-group input[type="text"]:hover,
.form-group select:hover {
  border-color: #B0B8C1;
}

.form-group input[type="number"]:focus,
.form-group input[type="text"]:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(49, 130, 246, 0.1);
}

.form-group input[type="text"]:read-only {
  background: var(--primary-light);
  cursor: not-allowed;
  font-weight: 700;
  color: var(--primary);
  border-color: var(--primary-light);
}

/* Input with Unit */
.input-with-unit {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-unit input {
  width: 100%;
  padding-right: 60px;
}

.input-with-unit input[type="number"]::-webkit-inner-spin-button,
.input-with-unit input[type="number"]::-webkit-outer-spin-button {
  margin-left: 20px;
}

.input-unit {
  position: absolute;
  right: 50px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  pointer-events: none;
}

/* Sub Inputs Grid */
.sub-input-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 12px;
}

/* 태블릿 이상: 2열 */
@media (min-width: 640px) {
  .sub-input-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 데스크톱: 4열 */
@media (min-width: 1024px) {
  .sub-input-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Sub Inputs */
.sub-input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}

.sub-input-grid .sub-input-group {
  margin-top: 0;
}

.form-group > .sub-input-group {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}

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

.sub-input-grid .sub-label {
  font-size: 12px;
  white-space: nowrap;
}

/* Label with Checkbox */
.label-with-checkbox {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* Inline Checkbox (작은 체크박스) */
/* 체크박스 섹션 (취득세 대출 포함) */
.checkbox-section {
  margin-bottom: 12px;
  padding: 14px 18px;
  background: #F9FAFB;
  border-radius: 8px;
  border: 1.5px solid #E5E8EB;
  transition: all 0.2s ease;
}

.checkbox-section:hover {
  background: #F3F4F6;
  border-color: var(--primary);
}

.inline-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

.inline-checkbox:hover {
  color: var(--primary);
}

.inline-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
  flex-shrink: 0;
  margin: 0;
}

.inline-checkbox span {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  user-select: none;
}

.sub-input-group input {
  height: 48px;
  padding: 0 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 15px;
  transition: all 0.2s ease;
  background: var(--surface);
  color: var(--text-primary);
}

.sub-input-group input:hover {
  border-color: #B0B8C1;
}

.sub-input-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(49, 130, 246, 0.1);
}

.sub-input-group input:read-only {
  background: var(--primary-light);
  cursor: not-allowed;
  font-weight: 700;
  color: var(--primary);
  border-color: var(--primary-light);
}

.total-group {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 2px solid var(--border);
}

.total-group .sub-label {
  font-weight: 700;
  color: var(--text-primary);
}

/* Checkbox */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 16px;
  background: #F9FAFB;
  border: 1.5px solid #D1D6DB;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.checkbox-label:hover {
  background: #F2F4F6;
  border-color: #B0B8C1;
}

.checkbox-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--primary);
  flex-shrink: 0;
  margin: 0;
  vertical-align: middle;
  position: relative;
  top: 0;
}

.checkbox-label span {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

/* Hint Text */
.hint-text {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 8px;
  line-height: 1.5;
}

/* Buttons */
.btn-calculate {
  width: 100%;
  height: 56px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 8px 20px rgba(49, 130, 246, 0.3);
  font-family: inherit;
  letter-spacing: -0.3px;
  margin-top: 8px;
}

.btn-calculate:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(49, 130, 246, 0.35);
}

.btn-calculate:active {
  transform: translateY(0);
  box-shadow: 0 4px 12px rgba(49, 130, 246, 0.25);
}

.btn-calculate.loading {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-secondary {
  width: 100%;
  height: 52px;
  background: var(--bg);
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 20px;
}

.btn-secondary:hover {
  background: #F2F4F6;
  border-color: #D1D6DB;
}

/* Result Cards */
.result-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 32px;
}

@media (min-width: 768px) {
  .result-cards {
    grid-template-columns: repeat(3, 1fr);
  }
}

.result-card {
  background: var(--surface);
  padding: 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1.5px solid var(--border);
  transition: all 0.3s ease;
}

.result-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: #D1D6DB;
}

.result-card.primary {
  background: linear-gradient(135deg, var(--primary) 0%, #1B64DA 100%);
  color: white;
  grid-column: span 1;
  box-shadow: 0 12px 32px rgba(49, 130, 246, 0.3);
  border: none;
}

@media (min-width: 768px) {
  .result-card.primary {
    grid-column: span 3;
  }
}

.result-card.primary:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 40px rgba(49, 130, 246, 0.35);
}

.card-label {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.result-card.primary .card-label {
  color: rgba(255, 255, 255, 0.8);
}

.card-value {
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 8px;
  font-family: 'Poppins', 'Noto Sans KR', sans-serif;
  letter-spacing: -1px;
  color: var(--text-primary);
  line-height: 1.1;
  word-break: keep-all;
}

.result-card.primary .card-value {
  color: white;
  font-size: 30px;
}

.card-detail {
  font-size: 13px;
  color: var(--text-tertiary);
  white-space: pre-line;
  line-height: 1.6;
}

.result-card.primary .card-detail {
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
}

.result-card.highlight {
  background: linear-gradient(135deg, #10B981 0%, #059669 100%);
  color: white;
  grid-column: span 1;
  box-shadow: 0 12px 32px rgba(16, 185, 129, 0.3);
  border: none;
}

@media (min-width: 768px) {
  .result-card.highlight {
    grid-column: span 3;
  }
}

.result-card.highlight:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 40px rgba(16, 185, 129, 0.35);
}

.result-card.highlight .card-label {
  color: rgba(255, 255, 255, 0.9);
  font-size: 15px;
}

.result-card.highlight .card-detail {
  color: rgba(255, 255, 255, 0.95);
  font-size: 14px;
  font-weight: 500;
}

/* Detail Sections */
.detail-section,
.structure-section {
  margin-top: 24px;
  padding: 24px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.detail-section h3,
.structure-section h3 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.detail-table {
  display: grid;
  gap: 10px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 16px;
  background: #F9FAFB;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  transition: background 0.2s ease;
}

.detail-row:hover {
  background: #F2F4F6;
}

.detail-label {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
}

.detail-value {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 15px;
}

/* Structure Visual */
.structure-visual {
  padding: 20px;
  background: #F9FAFB;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.structure-items {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

.structure-item {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.structure-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.structure-sep {
  color: var(--text-tertiary);
  font-weight: 800;
  font-size: 20px;
}

.item-label {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.item-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

/* Info Box */
.info-box {
  margin-top: 24px;
  padding: 20px;
  background: linear-gradient(135deg, #FFF7ED 0%, #FFF1DC 100%);
  border: 1.5px solid #FFEDD5;
  border-radius: var(--radius-lg);
}

.info-box h4 {
  margin-bottom: 12px;
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 700;
}

.info-content p {
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.info-content p:last-child {
  margin-bottom: 0;
}

/* Comparison Section */
.comparison-section {
  margin-top: 24px;
  padding: 24px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.comparison-section h3 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.comparison-table table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.comparison-table th,
.comparison-table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.comparison-table thead th {
  background: var(--bg);
  font-weight: 700;
  color: var(--text-primary);
}

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

.comparison-table tbody tr:hover {
  background: var(--bg);
}

/* Footer */
.footer {
  margin-top: 60px;
  text-align: center;
  color: var(--text-tertiary);
  padding: 20px 0;
}

.footer p {
  font-size: 14px;
  margin-bottom: 8px;
}

.disclaimer {
  font-size: 13px;
  opacity: 0.8;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

.modal-content {
  background: var(--surface);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 500px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-icon {
  font-size: 28px;
  line-height: 1;
}

.modal-header h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.modal-body {
  padding: 24px 28px;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.7;
  white-space: pre-line;
  max-height: 60vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 28px 24px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.modal-btn {
  padding: 12px 28px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.modal-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(49, 130, 246, 0.3);
}

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

/* Responsive */
@media (max-width: 640px) {
  body {
    padding: 16px 0 40px;
  }

  .modal-content {
    width: 95%;
    max-width: none;
    margin: 16px;
  }

  .modal-header {
    padding: 20px 20px 16px;
  }

  .modal-body {
    padding: 20px;
    font-size: 14px;
  }

  .modal-footer {
    padding: 12px 20px 20px;
  }

  .header {
    margin-bottom: 32px;
  }

  .header h1 {
    font-size: 32px;
  }

  .subtitle {
    font-size: 14px;
  }

  .input-section,
  .result-section {
    padding: 24px;
    border-radius: var(--radius-lg);
  }

  .sub-input-group {
    grid-template-columns: 120px 1fr;
  }

  .structure-items {
    flex-direction: column;
    align-items: stretch;
  }

  .structure-sep {
    transform: rotate(90deg);
    margin: 8px 0;
  }
}
