/* 家族の家計トラッカー */
:root {
  --primary: #4A90E2;
  --primary-light: #6BA8E8;
  --accent: #FF6B6B;
  --success: #51CF66;
  --warning: #FFD43B;
  --bg: #F5F7FA;
  --card: #FFFFFF;
  --text: #2C3E50;
  --text-light: #7F8C8D;
  --border: #E0E6ED;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding-bottom: env(safe-area-inset-bottom);
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
}

/* ヘッダー */
header {
  text-align: center;
  margin: 16px 0 24px;
}
header h1 { font-size: 24px; margin-bottom: 8px; }
.subtitle { color: var(--text-light); font-size: 14px; }
.subtitle span { color: var(--primary); font-weight: bold; font-size: 16px; }

/* カード共通 */
.card {
  background: var(--card);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.card h2 {
  font-size: 18px;
  margin-bottom: 16px;
  color: var(--text);
}
.card h3 {
  font-size: 14px;
  color: var(--text-light);
  margin: 16px 0 8px;
  font-weight: 600;
}

/* プログレスバー */
.progress-bar {
  position: relative;
  height: 32px;
  background: var(--border);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 16px;
}
.progress-fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  width: 0%;
  transition: width 1s ease-out;
  border-radius: 16px;
}
.progress-text {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-weight: bold;
  color: var(--text);
  font-size: 14px;
  text-shadow: 0 0 4px rgba(255,255,255,0.8);
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 16px 0;
}
.stat-label { font-size: 12px; color: var(--text-light); }
.stat-value { font-size: 20px; font-weight: bold; color: var(--text); margin-top: 4px; }
.pl-note {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 2px;
}
.pl-positive { color: var(--success); }
.pl-negative { color: var(--accent); }

.completion-date {
  background: var(--bg);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}
.completion-date span { font-size: 12px; color: var(--text-light); display: block; margin-bottom: 4px; }
.completion-date strong { font-size: 18px; color: var(--primary); }

/* マイルストーン */
.milestones {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.milestone-item {
  display: flex;
  align-items: center;
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
  gap: 12px;
}
.milestone-item.achieved {
  background: linear-gradient(135deg, var(--success), #6BD986);
  color: white;
  animation: glow 2s ease-in-out infinite;
}
@keyframes glow {
  0%, 100% { box-shadow: 0 0 8px rgba(81, 207, 102, 0.4); }
  50% { box-shadow: 0 0 16px rgba(81, 207, 102, 0.8); }
}
.milestone-icon { font-size: 24px; }
.milestone-label { flex: 1; }
.milestone-percent { font-weight: bold; }

/* チェックボックス */
.checkbox-row {
  display: flex;
  align-items: center;
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
  margin: 4px 0;
  cursor: pointer;
  transition: all 0.2s;
}
.checkbox-row input[type="checkbox"] {
  width: 20px; height: 20px;
  margin-right: 12px;
  cursor: pointer;
  accent-color: var(--primary);
}
.checkbox-row:has(input:checked) {
  background: #E8F5E9;
  color: var(--success);
}
.checkbox-row:has(input:checked) span {
  text-decoration: line-through;
  opacity: 0.7;
}
.fixed-item, .annual-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 8px;
  margin: 4px 0;
}
.fixed-item input, .annual-item input {
  margin-right: 8px;
  accent-color: var(--primary);
}
.fixed-item label, .annual-item label {
  display: flex;
  align-items: center;
  flex: 1;
  cursor: pointer;
}
.fixed-item .amount, .annual-item .amount {
  color: var(--text-light);
  font-size: 14px;
  font-weight: 600;
}
.fixed-item:has(input:checked) label span,
.annual-item:has(input:checked) label span {
  text-decoration: line-through;
  opacity: 0.5;
}
.fixed-item, .annual-item {
  flex-wrap: wrap;
  position: relative;
}
.skip-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  padding: 4px 8px;
  color: var(--text-light);
  cursor: pointer;
  margin-left: 8px;
}
.skip-btn:hover {
  background: var(--warning);
  color: var(--text);
}
.fixed-item.skipped, .annual-item.skipped {
  opacity: 0.45;
  background: #F8F9FA;
}
.fixed-item.skipped label span, .annual-item.skipped label span {
  text-decoration: line-through;
  color: var(--text-light);
}
.auto-skip {
  font-size: 11px;
  color: var(--text-light);
  padding: 4px 8px;
  background: var(--bg);
  border-radius: 6px;
  margin-left: 8px;
}
.due-note {
  width: 100%;
  font-size: 11px;
  color: var(--text-light);
  margin-top: 4px;
  padding-left: 32px;
}

.month-select {
  margin-bottom: 16px;
}
.month-select input[type="month"] {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 16px;
}

/* 収支グリッド */
.income-grid {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}
.income-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 8px;
}
.income-item.total {
  background: var(--primary);
  color: white;
  font-weight: bold;
}
.balance > div {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  margin: 4px 0;
}
.balance .positive { color: var(--success); }
.balance .negative { color: var(--accent); }

/* 年間カレンダー */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.calendar-month {
  background: var(--bg);
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
}
.calendar-month .month-name {
  font-weight: bold;
  font-size: 14px;
  margin-bottom: 4px;
}
.calendar-month .month-amount {
  font-size: 11px;
  color: var(--text-light);
}
.calendar-month.heavy { background: #FFE5E5; }
.calendar-month.medium { background: #FFF4D4; }
.calendar-month.light { background: #E8F5E9; }

/* お祝いアニメーション */
@keyframes celebrate {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
.celebrate { animation: celebrate 0.6s ease-out; }

footer {
  text-align: center;
  color: var(--text-light);
  font-size: 11px;
  margin-top: 24px;
  padding-bottom: 24px;
}
