/* モダンで美しいライフプランシミュレーター */
:root {
  color-scheme: light dark;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --secondary: #6366f1;
  --accent: #8b5cf6;
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1);
}

.dark {
  --gray-50: #1f2937;
  --gray-100: #374151;
  --gray-200: #4b5563;
  --gray-300: #6b7280;
  --gray-400: #9ca3af;
  --gray-500: #d1d5db;
  --gray-600: #e5e7eb;
  --gray-700: #f3f4f6;
  --gray-800: #f9fafb;
  --gray-900: #ffffff;
}

/* ベース設定 */
body {
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 30%, #cbd5e1 100%);
  background-attachment: fixed;
  min-height: 100vh;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.dark body {
  background: linear-gradient(135deg, #1a202c 0%, #2d3748 50%, #4a5568 100%);
}

/* ヘッダー */
header {
  backdrop-filter: blur(20px);
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid rgba(203, 213, 225, 0.3);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.dark header {
  background: rgba(26, 32, 44, 0.9);
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

/* カード系統 */
.card {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(203, 213, 225, 0.4);
  border-radius: 20px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1), 0 4px 10px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12), 0 8px 16px rgba(0, 0, 0, 0.08);
}

.dark .card {
  background: rgba(45, 55, 72, 0.95);
  border-color: rgba(255, 255, 255, 0.1);
}

/* 入力設定カードの色分け */
.card-basic {
  border-left: 8px solid #3b82f6;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(255, 255, 255, 0.98));
}

.card-income {
  border-left: 8px solid #10b981;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08), rgba(255, 255, 255, 0.98));
}

.card-financial {
  border-left: 8px solid #8b5cf6;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.08), rgba(255, 255, 255, 0.98));
}

.card-children {
  border-left: 8px solid #ec4899;
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.08), rgba(255, 255, 255, 0.98));
}

.card-investment {
  border-left: 8px solid #f59e0b;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(255, 255, 255, 0.98));
}

.card-housing {
  border-left: 8px solid #06b6d4;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.08), rgba(255, 255, 255, 0.98));
}

/* ダークモード用 */
.dark .card-basic {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(45, 55, 72, 0.95));
}

.dark .card-income {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(45, 55, 72, 0.95));
}

.dark .card-financial {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(45, 55, 72, 0.95));
}

.dark .card-children {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.1), rgba(45, 55, 72, 0.95));
}

.dark .card-investment {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(45, 55, 72, 0.95));
}

.dark .card-housing {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.1), rgba(45, 55, 72, 0.95));
}

.card-title {
  font-size: 1.375rem;
  font-weight: 800;
  color: #1f2937;
  padding: 1.5rem 1.5rem 0.5rem;
  margin: 0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.dark .card-title {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
}

.card-body {
  padding: 2.5rem 3rem;
}

/* セクションヘッダー */
.section-header {
  text-align: center;
  margin-bottom: 2rem;
}

.section-title {
  font-size: 2.5rem;
  font-weight: 800;
  color: #1f2937;
  margin-bottom: 0.5rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.dark .section-title {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
}

.section-subtitle {
  color: #4b5563;
  font-size: 1.1rem;
  font-weight: 600;
}

.dark .section-subtitle {
  color: var(--gray-400);
}

/* フォーム要素 */
.form-label {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  color: #374151;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.dark .form-label {
  color: var(--gray-300);
}

.input {
  width: 100%;
  padding: 1rem 1.5rem;
  border: 2px solid #d1d5db;
  border-radius: 12px;
  background: #ffffff;
  color: #1f2937;
  font-size: 1.1rem;
  font-weight: 500;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  min-height: 3.5rem;
  line-height: 1.4;
  max-width: none;
}

.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  transform: translateY(-1px);
}

.dark .input {
  background: #374151;
  border-color: #6b7280;
  color: #f9fafb;
  font-weight: 600;
}

.dark .input:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.3);
  background: #4b5563;
  color: #ffffff;
}

/* ボタン */
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.9);
  color: var(--gray-700);
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 10px;
  border: 2px solid var(--gray-200);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.875rem;
}

.btn-secondary:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: translateY(-1px);
}

.dark .btn-secondary {
  background: rgba(45, 55, 72, 0.9);
  color: var(--gray-300);
  border-color: var(--gray-600);
}

.dark .btn-secondary:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* アイコンボタン */
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid var(--gray-200);
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: scale(1.05);
}

.dark .icon-btn {
  background: rgba(45, 55, 72, 0.9);
  border-color: var(--gray-600);
  color: var(--gray-400);
}

/* グリッドレイアウト */
.input-grid {
  display: grid;
  gap: 2rem;
}

@media (min-width: 768px) {
  .input-grid {
    grid-template-columns: repeat(1, 1fr);
    gap: 2rem;
  }
}

@media (min-width: 1280px) {
  .input-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 2.5rem;
  }
}

/* サブセクション */
.subsection {
  background: rgba(59, 130, 246, 0.05);
  border: 1px solid rgba(59, 130, 246, 0.1);
  border-radius: 16px;
  padding: 1.5rem;
  margin: 1rem 0;
}

.dark .subsection {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.2);
}

.subsection-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: #3b82f6;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dark .subsection-title {
  color: var(--primary);
}

/* テーブル */
.table-enhanced {
  width: 100%;
  font-size: 0.875rem;
  border-collapse: separate;
  border-spacing: 0;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  background: white;
}

.dark .table-enhanced {
  background: var(--gray-800);
}

.table-enhanced thead th {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 1rem 0.75rem;
  text-align: right;
  white-space: nowrap;
  border: none;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* ジャンル別カラーリング - 追従ヘッダー対応 */
.table-enhanced .col-income { 
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(135deg, #10b981, #059669) !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
} /* 緑系 */
.table-enhanced .col-expense { 
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(135deg, #ef4444, #dc2626) !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
} /* 赤系 */
.table-enhanced .col-housing { 
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(135deg, #f59e0b, #d97706) !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
} /* オレンジ系 */
.table-enhanced .col-education { 
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(135deg, #8b5cf6, #7c3aed) !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
} /* 紫系 */
.table-enhanced .col-living { 
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(135deg, #06b6d4, #0891b2) !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
} /* シアン系 */
.table-enhanced .col-medical { 
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(135deg, #ec4899, #db2777) !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
} /* ピンク系 */
.table-enhanced .col-investment { 
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(135deg, #84cc16, #65a30d) !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
} /* ライムグリーン */
.table-enhanced .col-cash { 
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(135deg, #14b8a6, #0f766e) !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
} /* ティール */
.table-enhanced .col-assets { 
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(135deg, #6366f1, #4f46e5) !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
} /* インディゴ */
.table-enhanced .col-savings { 
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(135deg, #22c55e, #16a34a) !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
} /* 成功グリーン */
.table-enhanced .col-principal { 
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(135deg, #f97316, #ea580c) !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
} /* オレンジ */
.table-enhanced .col-interest { 
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(135deg, #dc2626, #b91c1c) !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
} /* 赤 */
.table-enhanced .col-payment { 
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(135deg, #7c2d12, #92400e) !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
} /* ブラウン */
.table-enhanced .col-balance { 
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(135deg, #1e40af, #1d4ed8) !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
} /* ブルー */

.table-enhanced .sticky-col-year {
  text-align: center !important;
  background: linear-gradient(135deg, var(--accent), var(--primary)) !important;
  color: white !important;
  font-weight: 800;
  min-width: 60px;
}

.table-enhanced tbody tr {
  transition: all 0.2s ease;
}

.table-enhanced tbody tr:nth-child(even) {
  background: rgba(59, 130, 246, 0.02);
}

.table-enhanced tbody tr:nth-child(odd) {
  background: white;
}

.dark .table-enhanced tbody tr:nth-child(even) {
  background: rgba(59, 130, 246, 0.05);
}

.dark .table-enhanced tbody tr:nth-child(odd) {
  background: var(--gray-800);
}

.table-enhanced tbody tr:hover {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.1), rgba(139, 92, 246, 0.1)) !important;
  transform: scale(1.01);
}

.table-enhanced tbody td {
  padding: 0.75rem;
  text-align: right;
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 1px solid rgba(59, 130, 246, 0.1);
  color: var(--gray-800);
}

.dark .table-enhanced tbody td {
  color: var(--gray-200);
  border-bottom-color: rgba(59, 130, 246, 0.2);
}

/* チャートコンテナ */
.chart-container {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(10px);
}

.dark .chart-container {
  background: rgba(45, 55, 72, 0.95);
}

/* CSVボタングリッド */
.csv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

/* チェックボックス */
input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 6px;
  border: 2px solid var(--gray-300);
  appearance: none;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  margin-right: 0.5rem;
}

input[type="checkbox"]:checked {
  background: var(--primary);
  border-color: var(--primary);
}

input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-weight: 700;
  font-size: 0.875rem;
}

/* レスポンシブ調整 */
@media (max-width: 768px) {
  .section-title {
    font-size: 2rem;
  }
  
  .card-body {
    padding: 1rem;
  }
  
  .input-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .csv-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* アニメーション */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  animation: fadeIn 0.6s ease-out;
}

/* スクロールバー */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--gray-100);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, var(--primary-hover), var(--accent));
}

.dark ::-webkit-scrollbar-track {
  background: var(--gray-800);
}

/* カラム幅最適化 */
.col-income, .col-expense, .col-assets { min-width: 80px; }
.col-housing, .col-education, .col-living, .col-medical, .col-investment, .col-cash, .col-savings { min-width: 70px; }
.col-principal, .col-interest, .col-payment, .col-balance { min-width: 80px; }

/* ユーティリティ */
.text-gradient {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.glass-effect {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.dark .glass-effect {
  background: rgba(0, 0, 0, 0.2);
  border-color: rgba(255, 255, 255, 0.1);
}

/* ローディング状態 */
.loading {
  opacity: 0.7;
  pointer-events: none;
  position: relative;
  overflow: hidden;
}

.loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.2), transparent);
  animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}