/* 全体リセットと基本変数 */
:root {
  --primary-color: #6366f1;
  --primary-hover: #4f46e5;
  --secondary-color: #ec4899;
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --radius: 12px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Noto Sans JP', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

#app {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  background: var(--bg-color);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* ヘッダー */
.app-header {
  padding: 16px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

.app-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
}

.badge {
  background: #e0e7ff;
  color: #3730a3;
  padding: 4px 8px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
  margin-left: 8px;
}

/* メインコンテンツ */
.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: 80px; /* ボトムナビ領域の余白 */
}

.page {
  display: none;
}

.page.active {
  display: block;
}

/* カードコンポーネント */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
}

.card h3 {
  font-size: 1rem;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
}

.sub-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* 収支サマリー */
.balance-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
}

.balance-item {
  padding: 8px;
  background: #f1f5f9;
  border-radius: 8px;
}

.balance-item .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
}

.balance-item .value {
  font-size: 0.95rem;
  font-weight: 700;
}

.balance-item.income .value { color: #10b981; }
.balance-item.expense .value { color: #ef4444; }
.balance-item.total .value { color: var(--primary-color); }

/* クイック運動ボタン */
.workout-quick-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-quick {
  flex: 1 1 calc(50% - 4px);
  padding: 10px;
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-quick:active {
  background: #e2e8f0;
}

.btn-quick.silk {
  background: #fce7f3;
  color: #be185d;
  border-color: #fbcfe8;
}

/* フォーム関連 */
.form-group {
  margin-bottom: 12px;
}

.form-group.half {
  flex: 1;
}

.form-row {
  display: flex;
  gap: 8px;
}

label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.form-input {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
}

.form-input:focus {
  border-color: var(--primary-color);
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
}

.btn-secondary {
  width: 100%;
  padding: 12px;
  background: #f1f5f9;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
}

/* タブ切替 */
.tab-group {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 12px;
}

.tab-btn {
  flex: 1;
  padding: 8px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-weight: 500;
  cursor: pointer;
}

.tab-btn.active {
  border-bottom-color: var(--primary-color);
  color: var(--primary-color);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* リスト表示 */
.record-list {
  list-style: none;
}

.record-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
}

.record-item:last-child {
  border-bottom: none;
}

.record-info .title {
  font-weight: 500;
  font-size: 0.9rem;
}

.record-info .date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.tag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
  margin-right: 6px;
}

.tag-食費 { background: #fee2e2; color: #991b1b; }
.tag-衣服・美容 { background: #fce7f3; color: #9d174d; }
.tag-交通費 { background: #e0e7ff; color: #3730a3; }
.tag-その他 { background: #f3f4f6; color: #374151; }

/* タイムライン */
.timeline-item {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-left: 2px solid var(--primary-color);
  padding-left: 12px;
  margin-left: 6px;
  margin-bottom: 8px;
}

.timeline-time {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary-color);
  min-width: 45px;
}

/* モーダル */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: white;
  padding: 20px;
  border-radius: var(--radius);
  width: 90%;
  max-width: 360px;
  position: relative;
}

.close-modal {
  position: absolute;
  top: 10px; right: 15px;
  font-size: 1.5rem;
  cursor: pointer;
}

/* ボトムナビ */
.bottom-nav {
  position: absolute;
  bottom: 0; left: 0; width: 100%;
  height: 60px;
  background: var(--card-bg);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 10;
}

.nav-btn {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--text-muted);
  font-size: 0.7rem;
  cursor: pointer;
  flex: 1;
}

.nav-btn i {
  font-size: 1.1rem;
}

.nav-btn.active {
  color: var(--primary-color);
}