/* =========================
   reset / base
========================= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: #121212;
  color: #e0e0e0;
  /* スマホでの横揺れ防止 */
  overflow-x: hidden;
}

/* =========================
   header
========================= */
.header {
  height: 56px;
  background-color: #1e1e1e;
  border-bottom: 1px solid #2a2a2a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header h1 {
  font-size: 18px;
  color: #ffffff;
}

.user-area span {
  margin-right: 12px;
  color: #bbbbbb;
}

.user-area a {
  color: #4da3ff;
  text-decoration: none;
}

/* =========================
   layout
========================= */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container {
  flex: 1;
  display: flex;
  background-color: #121212;
}

/* =========================
   sidebar (PC)
========================= */
.sidebar {
  width: 220px;
  background-color: #1a1a1a;
  border-right: 1px solid #2a2a2a;
}

.sidebar ul {
  list-style: none;
}

.sidebar li {
  border-bottom: 1px solid #2a2a2a;
}

.sidebar a {
  display: block;
  padding: 14px 16px;
  color: #cccccc;
  text-decoration: none;
  transition: 0.2s;
}

.sidebar a:hover, .sidebar a.active {
  background-color: #2a2a2a;
  color: #ffffff;
}

/* =========================
   main
========================= */
.main {
  flex: 1;
  padding: 24px;
  background-color: #121212;
  min-width: 0; /* flexアイテムのはみ出し防止 */
}

.main h2 {
  font-size: 22px;
  margin-bottom: 20px;
}

/* =========================
   form / input
========================= */
form {
  display: grid;
  gap: 12px;
}

input, select, textarea {
  width: 100%;
  padding: 12px;
  background-color: #1a1a1a;
  border: 1px solid #333;
  border-radius: 6px;
  color: #fff;
  font-size: 16px; /* iOSのズーム防止 */
}

button {
  padding: 12px 20px;
  background-color: #4da3ff;
  border: none;
  border-radius: 6px;
  color: #000;
  font-weight: bold;
  cursor: pointer;
  transition: 0.2s;
}

button:hover {
  opacity: 0.8;
}

/* =========================
   table
========================= */
table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px;
  border-bottom: 1px solid #2a2a2a;
  text-align: left;
}

th {
  background-color: #1a1a1a;
  color: #888;
  font-size: 0.85rem;
}

/* =========================
   footer
========================= */
.footer {
  height: 40px;
  background-color: #1e1e1e;
  border-top: 1px solid #2a2a2a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #888;
}

/* =========================
   Responsive (Mobile Only)
========================= */
@media (max-width: 768px) {
  /* 1. レイアウト解除 */
  .container {
    flex-direction: column;
  }

  /* 2. サイドバーをボトムナビゲーション化 */
  .sidebar {
    width: 100%;
    height: 65px;
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 1000;
    border-right: none;
    border-top: 1px solid #333;
    background-color: #1a1a1a;
  }

  .sidebar ul {
    display: flex;
    height: 100%;
  }

  .sidebar li {
    flex: 1;
    border-bottom: none;
  }

  .sidebar a {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5px 0;
    font-size: 10px;
    color: #888;
  }

  .sidebar a.active {
    color: #4da3ff;
    background-color: transparent;
  }

/* アイコン風の記号を擬似要素で追加（FontAwesomeがない場合の代用） */
  .sidebar li:nth-child(1) a::before { content: "🏠"; font-size: 18px; margin-bottom: 2px; }
  .sidebar li:nth-child(2) a::before { content: "📝"; font-size: 18px; margin-bottom: 2px; }
  .sidebar li:nth-child(3) a::before { content: "📊"; font-size: 18px; margin-bottom: 2px; }
  .sidebar li:nth-child(4) a::before { content: "🎰"; font-size: 18px; margin-bottom: 2px; }
  .sidebar li:nth-child(5) a::before { content: "🏢"; font-size: 18px; margin-bottom: 2px; }
  .sidebar li:nth-child(6) a::before { content: "💰"; font-size: 18px; margin-bottom: 2px; }
  
  /* 3. メインエリアの調整 */
  .main {
    padding: 15px;
    padding-bottom: 100px; /* ボトムナビとフッターの被り防止 */
  }

  /* 4. インラインスタイルの上書き（!importantで強制） */
  /* ダッシュボードのグリッドや、フォームの横並びを縦1列に */
  .dashboard-grid, 
  div[style*="display: flex"], 
  div[style*="display: grid"],
  form[style*="grid-template-columns"] {
    display: block !important;
  }

  div[style*="flex: 2"], 
  div[style*="flex: 1"],
  fieldset div[style*="display: grid"] {
    width: 100% !important;
    margin-bottom: 15px;
  }

  /* 投資・回収の入力欄（45%指定など）を100%に */
  input[style*="width:45%"] {
    width: 100% !important;
    margin-bottom: 8px;
  }

  /* 5. テーブルのカード型への変換（または横スクロール） */
  .main > table, .table-container table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  /* 実戦履歴の各行を少しゆったりさせる */
  tr td {
    padding: 15px 10px;
  }

  /* 6. UIパーツのモバイル最適化 */
  button {
    width: 100% !important;
    height: 50px;
    font-size: 16px;
  }

  .quick-stats {
    grid-template-columns: 1fr !important; /* 今月の収支などを縦並びに */
    gap: 10px;
  }
}