/* ==========================================
   1. Base Rule (全体共通の基本設定)
   ========================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Noto Sans JP', sans-serif;
  background-color: #F8FAFC;
  color: #0F172A;
}

.hidden {
  display: none !important;
}

/* ==========================================
   2. Common Header & Navigation (共通ヘッダーとナビ)
   ========================================== */
.common-header {
  display: flex;
  padding: 16px 24px;
  background-color: #0F172A;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-logo {
  height: 48px;
  width: auto;
  background-color: rgba(255, 255, 255, 0.95);
  padding: 6px;
  border-radius: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  object-fit: contain;
}

.header-title-area {
  display: flex;
  flex-direction: column;
}

.header-main-title {
  margin: 0;
  color: #FFFFFF;
  font-weight: 900;
  font-size: 1.25rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1.2;
}

.header-sub-title {
  margin: 6px 0 0 0;
  color: #34D399; 
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.2em;
}

.header-actions {
  display: flex;
  gap: 12px;
}

/* 各種ボタンの設定 */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: #FFFFFF;
  cursor: pointer;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
}

.btn-pdf { background-color: #EF4444; }
.btn-csv { background-color: #F59E0B; }
.btn-import { background-color: #3B82F6; }

/* 🌟 Tombol "Hapus Data" — merah lebih gelap dari .btn-pdf supaya tetap
   beda jelas, menandakan aksi destruktif/menghapus data tersimpan. */
.btn-clear {
  background-color: #DC2626;
  color: #FFFFFF;
}

.btn-clear:hover {
  background-color: #B91C1C;
}

.btn:hover, 
.btn:active {
  opacity: 0.85;
  transform: translateY(-1px);
}

/* ステップナビゲーション */
.step-nav {
  width: 100%;
  height: 50px;
  background-color: #FFFFFF;
  border-bottom: 1px solid #E2E8F0;
  padding: 12px;
  overflow-x: auto;
}

.nav-list {
  display: flex;
  list-style: none;
  gap: 8px;
  justify-content: center;
  padding: 0;
  margin: 0;
}

.nav-link {
  display: inline-block;
  text-decoration: none;
  color: #94A3B8; 
  background-color: #F1F5F9; 
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: bold;
  transition: all 0.2s ease;
}

.nav-link:hover {
  color: #0F172A;
  background-color: #E2E8F0;
}

/* ==========================================
   3. Content Header (各ページのタイトルエリア)
   ========================================== */
.tab-header {
  background-color: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.tab-header h2 {
  color: #0F172A;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.tab-header p {
  color: #475569;
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 8px;
}

.tab-header p:last-child {
  margin-bottom: 0;
}

/* ==========================================
   4. Common Layout & Footer (共通レイアウトとフッター)
   ========================================== */
.main-container {
  max-width: 1100px;
  margin: 40px auto;
  padding: 0 20px;
}

.sheet-section {
  background-color: #FFFFFF;
  border-radius: 30px;
  padding: 40px 30px;
  border: 1px solid #E2E8F0;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

footer {
  text-align: center;
  padding: 20px;
  border-top: 1px solid #E2E8F0;
  background-color: #FFFFFF;
}

footer p {
  color: #94A3B8;
  font-size: 14px;
}

/* ==========================================
   5. Form Elements & Input Optimization (通常入力・テキストエリアの統合)
   ========================================== */
.finance-block,
.profile-block {
  background-color: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 20px;
}

.input-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
}

.input-group label {
  color: #334155;
  font-size: 0.875rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-group label i { color: #10B981; }
.profile-block label i    { color: #3B82F6; }
.saving-block h3 i           { color: #06B6D4; }
.income-block h3 i           { color: #10B981; }
.expense-block h3 i          { color: #EF4444; }
.remittance-block h3 i       { color: #8B5CF6; }
.desire-block h3 i           { color: #EC4899; }
.period-block h3 i           { color: #6366F1; }
.result-block h3 i           { color: #F59E0B; }

/* ★すべてのインプット欄・カレンダー・複数行テキスト（textarea）のスタイルを共通統合 */
.input-group input[type="text"],
.input-group input[type="number"],
.input-group input[type="url"],
.input-group input[type="date"],
.input-group-half input,
.invest-table input,
.input-group textarea {
  width: 100%;
  padding: 12px 16px;
  font-size: 0.95rem;
  color: #0F172A;
  background-color: #F8FAFC;
  border: 1px solid #CBD5E1;
  border-radius: 10px;
  outline: none;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.input-group textarea {
  resize: vertical;
  font-family: inherit;
}

/* ★フォーカス時の共通アニメーション */
.input-group input:focus,
.invest-table input:focus,
.input-group textarea:focus {
  background-color: #FFFFFF;
  border-color: #3B82F6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* ★プレースホルダーの共通指定 */
.input-group input::placeholder,
.invest-table input::placeholder,
.input-group textarea::placeholder {
  color: #94A3B8;
}

.row-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.single-row {
  width: 100%;
  max-width: 400px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.item-name { flex: 3; }
.item-amount { flex: 2; }

/* ★行追加ボタンの設定 */
.button-row {
  margin-top: 12px;
  width: 100%;
  display: flex;
  justify-content: flex-start; 
}

.btn-add {
  background-color: #475569;
  color: #FFFFFF;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background-color 0.2s ease;
}

.btn-add:hover {
  background-color: #334155;
}

/* ==========================================
   6. Responsive (スマホ用設定)
   ========================================== */
@media (max-width: 768px) {
  /* ① ヘッダーを縦並びにして要素の衝突を防ぐ */
  .common-header {
    padding: 12px 16px !important;
    height: auto !important;
  }

  .header-top {
    flex-direction: column !important;
    align-items: center !important;
    gap: 12px !important;
  }

  .header-left {
    flex-direction: column !important;
    gap: 8px !important;
    text-align: center !important;
    width: 100% !important;
  }

  .header-logo {
    height: 40px !important;
  }

  .header-main-title {
    font-size: 1.1rem !important;
  }

  .header-sub-title {
    margin-top: 4px !important;
  }

  /* ② 右上の3つのボタン群をロゴの下へ綺麗に横並び配置 */
  .header-actions {
    width: 100% !important;
    display: flex !important;
    flex-direction: row !important;
    justify-content: center !important;
    gap: 8px !important;
  }
  
  .btn {
    flex: 1 !important;
    min-width: 0 !important;
    padding: 8px 4px !important;
    font-size: 0.7rem !important;
    text-align: center !important;
    border-radius: 0.5rem !important;
  }

  /* ③ 1〜10のステップナビを絶対に隠さず、指で左右スライド（横スクロール）可能にする */
  .step-nav {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    padding: 8px 12px !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    -webkit-overflow-scrolling: touch !important;
    background-color: #FFFFFF !important;
  }

  .nav-list {
    display: flex !important;
    flex-direction: row !important;
    justify-content: flex-start !important;
    gap: 6px !important;
    width: max-content !important;
  }

  .nav-list li {
    flex-shrink: 0 !important; 
  }

  .nav-link {
    padding: 6px 14px !important;
    font-size: 0.75rem !important;
  }

  /* その他全体レイアウトのスマホ調整 */
  .tab-header { padding: 16px !important; }
  .tab-header h2 { font-size: 1.25rem !important; }
  .main-container { margin: 20px auto !important; padding: 0 12px !important; }
  .sheet-section { padding: 24px 16px !important; border-radius: 16px !important; }
  
  /* 左右の無駄な巨大余白を半分に削って、文字が見える領域を最大化！ */
  .input-group input[type="text"],
  .input-group input[type="number"],
  .input-group input[type="url"],
  .input-group input[type="date"],
  .input-group textarea,
  .item-name,
  .item-amount,
  .month-input {
    padding: 6px 8px !important; 
    font-size: 0.85rem !important; 
    height: 32px !important;
  }

  /* マトリクス表内の「Rp」の文字やコピーアイコンの位置調整 */
  .input-group span,
  div[style*="position: relative"] span {
    font-size: 0.75rem !important;
    left: 4px !important;
  }

  /* インラインの追加・ゴミ箱ボタンの余白・サイズをシャープにカット */
  .btn-add-inline,
  .btn-table-action,
  .btn-table-action.btn-delete-row {
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    padding: 0 !important;
    margin: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .btn-add-inline i,
  .btn-table-action i {
    font-size: 0.8rem !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  
  /* ==========================================
     ⚡ 【Tahap 1 用】スマホ画面用の横幅黄金比率
     ========================================== */
  .row-inputs {
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
  }
  .row-inputs > div:first-child {
    flex: 1 !important;
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
  }
  .item-name {
    width: 100% !important;
    flex: 1 !important;
  }
  .row-inputs > div:nth-child(2) {
    width: 100px !important;
    flex-shrink: 0 !important;
  }
  .row-inputs > div:nth-child(2) input {
    padding-left: 24px !important;
  }
  .dynamic-row .btn-table-action {
    flex-shrink: 0 !important;
  }
}
/* ==========================================
   7. Action Buttons & Icons (操作系ボタンと装飾アイコン)
   ========================================== */
.dynamic-row {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px !important;
  width: 100% !important;
}

.spacer-width,
.btn-table-action {
  width: 38px !important;
  min-width: 38px !important;
  flex-shrink: 0 !important;
}

.btn-table-action,
.btn-table-action i {
  background: none !important;
  border: none !important;
  color: #EF4444 !important; 
  cursor: pointer !important;
  font-size: 1.1rem !important; 
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.risk-section h3 i { color: #EF4444; }
.success-section h3 i { color: #10B981; }
.superstar-section h3 i { color: #F59E0B; }

.field-desc {
  font-size: 0.85rem;
  color: #64748B;
  margin-bottom: 12px;
  line-height: 1.5;
}

.btn-table-action.btn-delete-row {
  background: none;
  border: none;
  color: #94A3B8;
  padding: 6px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-table-action.btn-delete-row:hover,
.btn-table-action.btn-delete-row:active {
  color: #EF4444;
  background-color: #FEE2E2;
}

/* ==========================================
   8. Active Navigation State (ボタン現在地の自動発光)
   ========================================== */
.step-box.active-step,
.step-sub-box.active-step {
  background-color: #0F172A !important;
  color: #FFFFFF !important;
  border-color: #0F172A !important;
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.2);
  transform: scale(1.02);
}

.step-box.active-step span { color: #94A3B8 !important; }
.step-sub-box.active-step i { color: #34D399 !important; }

/* ==========================================
   9. 📊 Calendar Page Excel Button (画面直置きエクセルボタン用スタイル)
   ========================================== */
.calendar-actions-row {
  margin-bottom: 16px;
  display: flex;
  justify-content: flex-end;
}

.btn-excel-direct {
  background-color: #107C41; /* Excel公式のグリーン */
  color: #FFFFFF;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 6px -1px rgba(16, 124, 65, 0.2);
  transition: all 0.2s ease;
}

.btn-excel-direct:hover {
  background-color: #0E6535;
  transform: translateY(-1px);
  box-shadow: 0 10px 15px -3px rgba(16, 124, 65, 0.3);
}

/* ==========================================
   10. 📑 Professional Print Optimization (A4提出用PDFの最適化)
   ========================================== */
@media print {
  /* ① 提出書類に不要な操作用UI・ボタン・WEBパーツをすべて完全消去 */
  #header-container, .common-header, .step-nav, #footer-container, footer,
  .header-actions, .btn-add, .btn-table-action, .button-row, .spacer-width,
  .calendar-actions-row, .btn-excel-direct {
    display: none !important;
  }

  @page {
    size: A4 portrait;
    margin: 20mm 15mm 20mm 15mm;
  }

  body {
    background-color: #FFFFFF !important;
    color: #000000 !important;
    font-size: 11pt;
    line-height: 1.5;
  }

  .main-container {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* ② 入力枠をシャープな「提出書類用の綺麗な枠線」に固定 */
  .sheet-section, .finance-block, .profile-block {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin-bottom: 24px !important;
    background: transparent !important;
  }

  .input-group input,
  .invest-table input,
  .input-group textarea {
    background-color: #FFFFFF !important;
    border: 1px solid #475569 !important;
    border-radius: 4px !important;
    color: #000000 !important;
    padding: 8px 12px !important;
    font-size: 11pt !important;
    box-shadow: none !important;
  }

  /* ③ 用紙の切れ目での「枠線の真っ二つちぎれエラー」を完璧に防ぐ */
  .finance-block, .profile-block, .input-group, .dynamic-row, tr {
    page-break-inside: avoid !important;
  }

  h1, h2, h3 { page-break-after: avoid !important; }

  /* ④ テーブル構造をカッチリした黒い罫線へ落とし込む */
  table {
    width: 100% !important;
    border-collapse: collapse !important;
  }

  table th, table td {
    border: 1px solid #000000 !important;
    padding: 6px 10px !important;
    font-size: 10pt !important;
  }

  table th {
    background-color: #F1F5F9 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}