/* 기본 리셋 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #4f46e5;
  --primary-hover: #4338ca;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --border-color: #e5e7eb;
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  -webkit-font-smoothing: antialiased;
  background-color: #f5f5f5;
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  background-color: var(--bg-primary);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: fadeIn 0.5s ease-out;
}

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

/* 헤더 */
header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 3rem 2rem;
  text-align: center;
}

header h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 1rem;
  opacity: 0.9;
  font-weight: 500;
}

/* 표 섹션 */
.table-section {
  padding: 2rem;
}

.table-info {
  background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
  padding: 1.5rem;
  border-radius: 16px;
  margin-bottom: 2rem;
  border-left: 4px solid var(--primary-color);
}

.table-info h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.table-info ul {
  list-style: none;
  padding-left: 0;
}

.table-info li {
  font-size: 0.9rem;
  color: var(--text-secondary);
  padding: 0.4rem 0;
  padding-left: 1.5rem;
  position: relative;
}

.table-info li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--primary-color);
  font-weight: bold;
}

/* 세율 구간 범례 */
.tax-bracket-legend {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 2px solid rgba(79, 70, 229, 0.2);
}

.tax-bracket-legend h4 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.legend-items {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.legend-color {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 2px solid rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.legend-color.bracket-1 {
  background-color: #f0fdf4;
}

.legend-color.bracket-2 {
  background-color: #ecfeff;
}

.legend-color.bracket-3 {
  background-color: #fef3c7;
}

.legend-color.bracket-4 {
  background-color: #fed7aa;
}

.legend-color.bracket-5 {
  background-color: #fecaca;
}

.legend-color.bracket-6 {
  background-color: #fef08a;
}

.legend-color.bracket-7 {
  background-color: #fca5a5;
}

.legend-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* 표 래퍼 */
.table-wrapper {
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  overflow: visible;
}

/* 표 스타일 */
.salary-table {
  width: 100%;
  border-collapse: collapse;
  background-color: white;
  font-size: 0.9rem;
  overflow: visible;
}

.salary-table thead {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  position: sticky;
  top: 0;
  z-index: 100;
}

.salary-table th {
  padding: 1.25rem 1rem;
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.salary-table tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: all 0.2s;
}

.salary-table tbody tr.data-row:hover {
  background-color: #f1f5f9 !important;
  transform: scale(1.01);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.salary-table tbody tr.expanded {
  background-color: #e0e7ff !important;
  border-bottom: none;
}

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

/* 확장 아이콘 */
.expand-icon {
  display: inline-block;
  margin-right: 0.5rem;
  font-size: 0.7rem;
  transition: transform 0.3s;
  color: var(--primary-color);
}

/* 상세 행 스타일 */
.detail-row {
  background-color: #f8fafc !important;
  border-bottom: 2px solid var(--primary-color) !important;
}

.detail-row:hover {
  background-color: #f8fafc !important;
  transform: none !important;
  box-shadow: none !important;
}

.detail-content {
  padding: 2rem;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.detail-section {
  margin-bottom: 2rem;
  padding: 1.5rem;
  background-color: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.detail-section:last-of-type {
  margin-bottom: 1.5rem;
}

.detail-section h4 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--primary-color);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.detail-item {
  display: grid;
  grid-template-columns: 1.5fr 2fr 1fr;
  gap: 1rem;
  align-items: center;
  padding: 0.75rem;
  background-color: var(--bg-secondary);
  border-radius: 8px;
  font-size: 0.85rem;
}

.detail-label {
  font-weight: 600;
  color: var(--text-primary);
}

.detail-calc {
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-family: 'Courier New', monospace;
}

.detail-value {
  font-weight: 700;
  color: var(--primary-color);
  text-align: right;
}

.cap-notice {
  color: #f59e0b;
  font-size: 0.75rem;
  font-weight: 600;
}

.detail-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}

.summary-box {
  padding: 1.25rem;
  background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
  border-radius: 12px;
  text-align: center;
}

.summary-box.highlight {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.summary-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  opacity: 0.9;
}

.summary-box.highlight .summary-label {
  color: white;
}

.summary-value {
  display: block;
  font-size: 1.25rem;
  font-weight: 800;
}

.summary-box.highlight .summary-value {
  color: white;
}

/* 세율 구간별 배경색 */
.salary-table tbody tr.bracket-1 {
  background-color: #f0fdf4; /* 연한 초록 - 6% */
}

.salary-table tbody tr.bracket-2 {
  background-color: #ecfeff; /* 연한 청록 - 15% */
}

.salary-table tbody tr.bracket-3 {
  background-color: #fef3c7; /* 연한 노랑 - 24% */
}

.salary-table tbody tr.bracket-4 {
  background-color: #fed7aa; /* 연한 주황 - 35% */
}

.salary-table tbody tr.bracket-5 {
  background-color: #fecaca; /* 연한 빨강 - 38% */
}

.salary-table tbody tr.bracket-6 {
  background-color: #fef08a; /* 연한 노랑 - 40% (30% 연하게) */
}

.salary-table tbody tr.bracket-7 {
  background-color: #fca5a5; /* 연한 빨강 - 45% (30% 연하게) */
}

/* 세율 구간 변경 경계선 */
.salary-table tbody tr.tax-bracket-change {
  border-top: 3px solid #4f46e5;
  position: relative;
}

.salary-table tbody tr.tax-bracket-change td:first-child::before {
  content: attr(data-bracket-text);
  position: absolute;
  left: 0.5rem;
  top: -1.5rem;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
  z-index: 5;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.salary-table td {
  padding: 0.75rem 0.5rem;
  text-align: center;
  color: var(--text-primary);
  position: relative;
}

.salary-table td:first-child {
  font-weight: 700;
  color: var(--primary-color);
  white-space: nowrap;
  text-align: left;
  padding-left: 1rem;
}

.salary-table td:nth-child(2),
.salary-table td:nth-child(3) {
  font-weight: 600;
  white-space: nowrap;
  font-size: 0.85rem;
}

.salary-table td:nth-child(4) {
  font-weight: 700;
  color: #10b981;
}

.salary-table td:nth-child(5) {
  color: var(--text-secondary);
  white-space: nowrap;
  font-size: 0.85rem;
}

/* 푸터 */
footer {
  padding: 2rem;
  background-color: var(--bg-secondary);
  text-align: center;
  border-top: 1px solid var(--border-color);
}

footer p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0.25rem 0;
}

/* 태블릿 */
@media (min-width: 768px) {
  header {
    padding: 3.5rem 2.5rem;
  }

  header h1 {
    font-size: 2.25rem;
  }

  .subtitle {
    font-size: 1.1rem;
  }

  .table-section {
    padding: 2.5rem;
  }

  .salary-table {
    font-size: 1rem;
  }

  .salary-table th {
    padding: 1.5rem 1rem;
    font-size: 1rem;
  }

  .salary-table td {
    padding: 1rem 0.75rem;
  }

  .salary-table td:nth-child(2),
  .salary-table td:nth-child(3),
  .salary-table td:nth-child(5) {
    font-size: 0.95rem;
  }

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

  .detail-item {
    font-size: 0.9rem;
  }

  .detail-calc {
    font-size: 0.85rem;
  }
}

/* 데스크톱 */
@media (min-width: 1024px) {
  .detail-content {
    padding: 2.5rem;
  }

  .detail-section {
    padding: 2rem;
  }

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

  .detail-item {
    padding: 1rem;
    font-size: 0.95rem;
  }

  .summary-value {
    font-size: 1.5rem;
  }
}

/* 데스크톱 */
@media (min-width: 1024px) {
  header h1 {
    font-size: 2.5rem;
  }

  .table-section {
    padding: 3rem;
  }

  .table-info {
    padding: 2rem;
  }
}

/* 접근성 */
*:focus-visible {
  outline: 3px solid var(--primary-color);
  outline-offset: 2px;
}
