/* ============================================
   家計簿アプリ - セージグリーン基調デザイン
   ============================================ */

:root {
  /* メインカラー - セージグリーン */
  --sage-50:  #F4F7F1;
  --sage-100: #E5EDDF;
  --sage-200: #C9D9BD;
  --sage-300: #AEC59B;
  --sage-400: #9CAF88;
  --sage-500: #7E956A;
  --sage-600: #607851;
  --sage-700: #4A5E40;

  /* カテゴリ色 */
  --c-food:     #E8A4A4;  /* 外食 */
  --c-grocery:  #D88B8B;  /* 食料品 */
  --c-housing:  #6E8FA8;  /* 住居 */
  --c-transit:  #9CAF88;  /* 交通 */
  --c-utility:  #B8B98F;  /* 光熱 */
  --c-comm:     #A8B5C9;  /* 通信 */
  --c-daily:    #E8B978;  /* 日用品 */
  --c-fun:      #C9A8D3;  /* 娯楽 */
  --c-medical:  #88B5B0;  /* 医療 */
  --c-clothes:  #D9B98F;  /* 衣服 */
  --c-social:   #D9A89C;  /* 交際 */
  --c-insurance:#AABBA8;  /* 保険 */
  --c-loan:     #B89C9C;  /* 返済 */
  --c-sub:      #A09CB8;  /* サブスク */
  --c-invest:   #8FB89C;  /* 投資 */
  --c-other:    #DCD3BC;  /* その他 */

  /* 機能色 */
  --bg:         #F7F8F4;
  --card:       #FFFFFF;
  --text:       #2C3328;
  --text-mute:  #7B8278;
  --text-light: #A6ADA3;
  --border:     #ECEFE8;
  --shadow:     0 1px 3px rgba(60, 80, 50, 0.04), 0 4px 12px rgba(60, 80, 50, 0.04);
  --shadow-lg:  0 4px 16px rgba(60, 80, 50, 0.08);
  --danger:     #D67676;
  --warn:       #E0A958;
  --success:    var(--sage-500);
}

/* ============================================
   リセット & ベース
   ============================================ */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overscroll-behavior: none; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Yu Gothic UI', 'Meiryo', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
svg { width: 100%; height: 100%; display: block; }

/* ============================================
   レイアウト
   ============================================ */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  background: var(--bg);
  padding-bottom: env(safe-area-inset-bottom);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  padding: 12px 16px calc(12px + env(safe-area-inset-top, 0px)) 16px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: var(--bg);
}

.icon-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--text);
  transition: background 0.15s;
}
.icon-btn:active { background: var(--sage-100); }
.icon-btn svg { width: 22px; height: 22px; }

.month-picker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
}
.month-picker svg { width: 16px; height: 16px; }
.month-picker:active { background: var(--sage-100); }

.screen {
  padding: 4px 16px 100px 16px;
  min-height: calc(100vh - 64px);
}

/* ============================================
   カード共通
   ============================================ */
.card {
  background: var(--card);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.card-action {
  font-size: 12px;
  color: var(--sage-500);
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.card-action svg { width: 14px; height: 14px; }

/* ============================================
   月予算サマリーカード
   ============================================ */
.summary-card {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 16px;
  align-items: center;
  padding: 20px 18px;
}
.summary-donut {
  position: relative;
  width: 130px;
  height: 130px;
  margin: 0 auto;
}
.summary-donut canvas { position: absolute; inset: 0; }
.summary-donut-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.summary-donut-pct {
  font-size: 32px;
  font-weight: 600;
  color: var(--sage-600);
  line-height: 1;
}
.summary-donut-pct .unit {
  font-size: 18px;
  margin-left: 1px;
}
.summary-donut-sub {
  font-size: 11px;
  color: var(--text-mute);
  margin-top: 4px;
}
.summary-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.summary-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.summary-stat-label {
  font-size: 13px;
  color: var(--text-mute);
}
.summary-stat-value {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  font-feature-settings: "tnum";
}
.summary-stat-row.divider {
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 2px;
}
.summary-stat-row.highlight .summary-stat-value {
  color: var(--sage-600);
}
.summary-message {
  text-align: center;
  font-size: 12px;
  color: var(--text-mute);
  padding-top: 14px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
  grid-column: 1 / -1;
}

/* ============================================
   カテゴリタイル(横スクロール)
   ============================================ */
.category-tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.category-tile {
  background: var(--card);
  border-radius: 16px;
  padding: 14px 8px 12px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 0.1s;
}
.category-tile:active { transform: scale(0.97); }
.category-icon {
  width: 38px; height: 38px;
  border-radius: 50%;
  margin: 0 auto 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}
.category-icon svg { width: 20px; height: 20px; }
.category-name {
  font-size: 11px;
  color: var(--text-mute);
  margin-bottom: 2px;
}
.category-amount {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  font-feature-settings: "tnum";
  margin-bottom: 6px;
}
.category-progress {
  font-size: 9px;
  color: var(--text-light);
  margin-bottom: 4px;
}
.category-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.category-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s;
}

/* ============================================
   2カラムカード(内訳と目標)
   ============================================ */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.two-col .card { margin-bottom: 12px; }

.breakdown-chart-wrap {
  position: relative;
  width: 110px; height: 110px;
  margin: 0 auto 8px;
}
.breakdown-chart-wrap canvas { position: absolute; inset: 0; }
.breakdown-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  pointer-events: none;
}
.breakdown-center-label {
  font-size: 9px; color: var(--text-mute);
}
.breakdown-center-value {
  font-size: 13px; font-weight: 600; font-feature-settings: "tnum";
}

.breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11px;
}
.breakdown-item {
  display: grid;
  grid-template-columns: 8px 1fr auto;
  align-items: center;
  gap: 6px;
}
.breakdown-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
}
.breakdown-name { color: var(--text); }
.breakdown-pct { color: var(--text-mute); font-feature-settings: "tnum"; }

/* 今月の目標 — ミニカード(縦積みレイアウト) */
.goal-mini-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.goal-mini-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 10px 12px;
  background: var(--bg);
  border: 1px solid transparent;
  border-radius: 14px;
  width: 100%;
  text-align: center;
  transition: all 0.1s;
}
.goal-mini-item:active {
  background: var(--sage-50);
  border-color: var(--sage-200);
}
.goal-mini-chev {
  position: absolute;
  top: 10px;
  right: 10px;
  color: var(--text-light);
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.goal-mini-chev svg { width: 14px; height: 14px; }
.goal-mini-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  width: 100%;
  padding: 0 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.goal-mini-donut {
  position: relative;
  width: 72px;
  height: 72px;
}
.goal-mini-donut svg {
  width: 100%;
  height: 100%;
}
.goal-mini-pct {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--sage-700);
  font-feature-settings: "tnum";
  line-height: 1;
}
.goal-mini-pct small {
  font-size: 10px;
  font-weight: 500;
  margin-left: 1px;
}
.goal-mini-amounts {
  font-size: 11px;
  color: var(--text-mute);
  font-feature-settings: "tnum";
  white-space: nowrap;
  line-height: 1.3;
}

.goal-add-btn {
  display: block;
  width: 100%;
  padding: 8px;
  background: var(--sage-50);
  color: var(--sage-600);
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
}

/* ============================================
   最近の取引
   ============================================ */
.txn-list {
  display: flex;
  flex-direction: column;
}
.txn-item {
  display: grid;
  grid-template-columns: 36px 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.txn-item:last-child { border-bottom: none; }
.txn-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white;
}
.txn-icon svg { width: 18px; height: 18px; }
.txn-detail { min-width: 0; }
.txn-name {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.txn-cat {
  font-size: 11px;
  color: var(--text-mute);
  margin-top: 1px;
}
.txn-date {
  font-size: 12px;
  color: var(--text-mute);
  margin-right: 8px;
  font-feature-settings: "tnum";
}
.txn-amount {
  font-size: 14px;
  font-weight: 600;
  font-feature-settings: "tnum";
}

/* 未引き落とし(予定) */
.txn-item.is-scheduled .txn-name,
.txn-item.is-scheduled .txn-amount,
.txn-item.is-scheduled .txn-date {
  color: var(--text-mute);
}
.txn-item.is-scheduled .txn-icon {
  opacity: 0.55;
}
.badge-scheduled {
  display: inline-block;
  margin-left: 5px;
  padding: 1px 6px 2px;
  font-size: 9px;
  font-weight: 600;
  background: var(--sage-100);
  color: var(--sage-700);
  border-radius: 6px;
  letter-spacing: 0.5px;
  vertical-align: middle;
}

/* ============================================
   表示切替トグル(カレンダー / リスト)
   ============================================ */
.view-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--card);
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  gap: 2px;
}
.view-toggle-btn {
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-mute);
  border-radius: 11px;
  text-align: center;
  transition: all 0.15s;
}
.view-toggle-btn.active {
  background: var(--sage-400);
  color: white;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(124, 149, 106, 0.25);
}

/* ============================================
   カレンダー
   ============================================ */
.calendar-card {
  padding: 14px 8px 10px;
}
.cal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 8px 12px;
}
.cal-nav-group {
  display: flex;
  gap: 4px;
  align-items: center;
}
.cal-nav-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-mute);
  transition: background 0.1s;
}
.cal-nav-btn:active { background: var(--sage-100); }
.cal-nav-btn svg { width: 14px; height: 14px; }
.cal-month-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  padding: 0 6px;
  font-feature-settings: "tnum";
}
.cal-this-month-btn {
  font-size: 11px;
  font-weight: 500;
  color: var(--sage-700);
  background: var(--sage-50);
  padding: 5px 12px;
  border-radius: 12px;
  transition: background 0.1s;
}
.cal-this-month-btn:active { background: var(--sage-100); }

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 0 2px 4px;
}
.cal-weekday {
  text-align: center;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-mute);
  padding: 4px 0;
}
.cal-weekday.sun { color: #D67676; }
.cal-weekday.sat { color: #6E8FA8; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
}
.cal-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 5px 1px 6px;
  background: transparent;
  border-radius: 8px;
  min-height: 50px;
  gap: 2px;
  transition: background 0.1s;
}
.cal-day:active { background: var(--sage-50); }
.cal-day-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  font-feature-settings: "tnum";
}
.cal-day-num.selected-circle {
  background: var(--sage-400);
  color: white;
  font-weight: 600;
}
.cal-day.is-today .cal-day-num {
  border: 1.5px solid var(--sage-400);
}
.cal-day.is-today .cal-day-num.selected-circle {
  border: none;
}
.cal-day:nth-child(7n+1) .cal-day-num { color: #D67676; }
.cal-day:nth-child(7n) .cal-day-num { color: #6E8FA8; }
.cal-day .cal-day-num.selected-circle { color: white !important; }
.cal-day.is-other-month .cal-day-num,
.cal-day.is-other-month .cal-day-amount { opacity: 0.35; }
.cal-day-amount {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 9px;
  color: var(--text-mute);
  font-feature-settings: "tnum";
  line-height: 1;
}
.cal-day-amount-empty { height: 11px; }
.cal-day-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* 日詳細 */
.day-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.day-detail-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.day-detail-total {
  font-size: 13px;
  font-weight: 600;
  color: var(--sage-600);
  font-feature-settings: "tnum";
}

/* ============================================
   ボトムナビゲーション
   ============================================ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 4px;
  color: var(--text-light);
  font-size: 10px;
  position: relative;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item.active { color: var(--sage-500); }
.nav-item.active span { font-weight: 600; }

.nav-add { position: relative; }
.add-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--sage-400);
  color: white;
  display: flex; align-items: center; justify-content: center;
  margin-top: -16px;
  box-shadow: 0 4px 12px rgba(124, 149, 106, 0.4);
  transition: transform 0.1s;
}
.add-circle:active { transform: scale(0.93); }
.add-circle svg { width: 22px; height: 22px; }
.nav-add span { color: var(--sage-500); font-weight: 500; margin-top: 2px; }

/* ============================================
   モーダル
   ============================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal.hidden { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 30, 20, 0.45);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s;
}
.modal-content {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: var(--bg);
  border-radius: 24px 24px 0 0;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.05);
  padding-bottom: env(safe-area-inset-bottom);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 8px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1;
}
.modal-title {
  font-size: 17px;
  font-weight: 600;
}
.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--sage-100);
  color: var(--sage-600);
}
.modal-close svg { width: 16px; height: 16px; }
.modal-body { padding: 12px 20px 24px; }

/* ============================================
   フォーム
   ============================================ */
.form-group {
  margin-bottom: 18px;
}
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-mute);
  margin-bottom: 6px;
}
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 14px 14px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 16px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  font-feature-settings: "tnum";
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--sage-400);
}
.form-textarea { resize: none; min-height: 80px; }

.form-amount {
  font-size: 28px;
  font-weight: 600;
  text-align: right;
  font-feature-settings: "tnum";
  padding: 18px 16px;
}
.form-amount-prefix {
  position: relative;
}
.form-amount-prefix::before {
  content: "¥";
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 22px;
  font-weight: 500;
  color: var(--text-mute);
  z-index: 1;
}
.form-amount-prefix .form-input { padding-left: 40px; }

.cat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.cat-pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 4px;
  border-radius: 14px;
  background: var(--card);
  border: 2px solid transparent;
  transition: all 0.15s;
}
.cat-pick.selected {
  border-color: var(--sage-400);
  background: var(--sage-50);
}
.cat-pick .cat-pick-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white;
}
.cat-pick .cat-pick-icon svg { width: 18px; height: 18px; }
.cat-pick .cat-pick-name {
  font-size: 11px;
  color: var(--text);
}

.pay-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.pay-pick {
  padding: 12px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 13px;
  color: var(--pay-color, var(--text));
  text-align: center;
  transition: all 0.15s;
  font-weight: 500;
}
.pay-pick.selected {
  border-color: var(--pay-color, var(--sage-400));
  background: color-mix(in srgb, var(--pay-color, #9CAF88) 12%, white);
  color: var(--pay-color, var(--sage-700));
  font-weight: 700;
  box-shadow: 0 0 0 1px var(--pay-color, var(--sage-400)) inset;
}

/* 数字パッド */
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.numpad-btn {
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  font-size: 22px;
  font-weight: 500;
  color: var(--text);
  font-feature-settings: "tnum";
  box-shadow: var(--shadow);
  transition: background 0.1s;
}
.numpad-btn:active { background: var(--sage-100); }
.numpad-btn.fn { color: var(--sage-600); font-size: 16px; font-weight: 600; }

.btn-primary {
  display: block;
  width: 100%;
  padding: 16px;
  background: var(--sage-400);
  color: white;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  transition: background 0.1s;
  margin-top: 18px;
}
.btn-primary:active { background: var(--sage-500); }
.btn-primary:disabled { background: var(--sage-200); }

.btn-secondary {
  display: block;
  width: 100%;
  padding: 14px;
  background: var(--sage-50);
  color: var(--sage-600);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
}

.btn-danger-text {
  color: var(--danger);
  font-size: 13px;
  padding: 8px;
}

.btn-danger-outline {
  display: block;
  width: 100%;
  padding: 14px;
  background: rgba(214, 118, 118, 0.08);
  color: var(--danger);
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.1s;
}
.btn-danger-outline:active {
  background: rgba(214, 118, 118, 0.18);
}

/* ============================================
   トースト
   ============================================ */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--sage-700);
  color: white;
  padding: 12px 22px;
  border-radius: 24px;
  font-size: 13px;
  z-index: 200;
  animation: toastIn 0.25s, toastOut 0.25s 1.7s forwards;
  box-shadow: 0 8px 24px rgba(60, 80, 50, 0.25);
}
.toast.hidden { display: none; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 16px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes toastOut { to { opacity: 0; transform: translate(-50%, 16px); } }

/* ============================================
   設定画面
   ============================================ */
.settings-section {
  margin-bottom: 20px;
}
.settings-section-title {
  font-size: 12px;
  color: var(--text-mute);
  font-weight: 600;
  margin: 0 4px 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.settings-list {
  background: var(--card);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.settings-row {
  display: grid;
  grid-template-columns: 28px 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }
.settings-row-icon {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  color: var(--sage-500);
}
.settings-row-icon svg { width: 18px; height: 18px; }
.settings-row-label {
  font-size: 14px;
  color: var(--text);
}
.settings-row-value {
  font-size: 14px;
  color: var(--text-mute);
  font-feature-settings: "tnum";
}
.settings-row-chev {
  color: var(--text-light);
  width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
}
.settings-row-chev svg { width: 16px; height: 16px; }

/* ============================================
   分析画面
   ============================================ */
.analytics-tabs {
  display: flex;
  background: var(--card);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.analytics-tab {
  flex: 1;
  padding: 10px;
  font-size: 13px;
  border-radius: 9px;
  color: var(--text-mute);
  font-weight: 500;
  text-align: center;
}
.analytics-tab.active {
  background: var(--sage-100);
  color: var(--sage-700);
}

.bar-chart {
  height: 200px;
  margin: 8px 0;
}

/* カラーピッカー */
.color-picker {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  padding: 4px 6px;
}
.color-swatch {
  aspect-ratio: 1;
  width: 100%;
  border: 2px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.1s;
  position: relative;
}
.color-swatch:active { transform: scale(0.9); }
.color-swatch.selected {
  border-color: var(--text);
  box-shadow: 0 0 0 2px white inset;
}

.icon-picker .cat-pick { padding: 8px 4px; }
.icon-picker .cat-pick.selected {
  background: var(--sage-50);
  border-color: var(--sage-400);
}

.legend-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text);
  min-width: 0;
}
.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.legend-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-rank-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 8px;
}
.cat-rank-item {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 10px;
  border-radius: 10px;
  transition: background 0.1s;
}
.cat-rank-item:active { background: var(--sage-50); }
.cat-rank-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white;
}
.cat-rank-icon svg { width: 16px; height: 16px; }
.cat-rank-info { min-width: 0; }
.cat-rank-name {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 4px;
}
.cat-rank-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.cat-rank-bar-fill { height: 100%; border-radius: 3px; }
.cat-rank-amount {
  font-size: 13px;
  font-weight: 600;
  font-feature-settings: "tnum";
  text-align: right;
}
.cat-rank-pct {
  font-size: 10px;
  color: var(--text-mute);
}

/* ============================================
   取引リスト画面(日付グループ)
   ============================================ */
.day-group { margin-bottom: 16px; }
.day-header {
  display: flex;
  justify-content: space-between;
  padding: 0 4px 6px;
  font-size: 12px;
  color: var(--text-mute);
  font-weight: 500;
}
.day-header-total { font-feature-settings: "tnum"; }
.day-list {
  background: var(--card);
  border-radius: 14px;
  padding: 4px 14px;
  box-shadow: var(--shadow);
}
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-mute);
  font-size: 13px;
}
.empty-state-icon {
  width: 56px; height: 56px;
  margin: 0 auto 12px;
  background: var(--sage-50);
  color: var(--sage-400);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.empty-state-icon svg { width: 28px; height: 28px; }

/* ============================================
   認証画面
   ============================================ */
.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: linear-gradient(135deg, var(--sage-100), var(--sage-50));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-top: calc(24px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}
.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border-radius: 24px;
  padding: 32px 28px;
  box-shadow: 0 8px 40px rgba(60, 80, 50, 0.12);
  text-align: center;
}
.auth-icon {
  width: 64px; height: 64px;
  margin: 0 auto 14px;
  background: var(--sage-100);
  color: var(--sage-600);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.auth-icon svg { width: 30px; height: 30px; }
.auth-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.auth-sub {
  font-size: 13px;
  color: var(--text-mute);
  margin-bottom: 22px;
}
.auth-input {
  width: 100%;
  padding: 16px;
  font-size: 22px;
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.4em;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  outline: none;
  background: var(--bg);
  color: var(--text);
  font-feature-settings: "tnum";
  transition: border-color 0.15s;
}
.auth-input:focus {
  border-color: var(--sage-400);
}
.auth-error {
  margin-top: 10px;
  font-size: 12px;
  color: var(--danger);
}
.auth-hint {
  font-size: 11px;
  color: var(--text-light);
  line-height: 1.5;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* クラウド同期バッジ */
.cloud-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}
.cloud-badge.synced {
  background: var(--sage-100);
  color: var(--sage-700);
}
.cloud-badge.local {
  background: #F0EFE8;
  color: var(--text-mute);
}

/* ============================================
   ユーティリティ
   ============================================ */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-mute { color: var(--text-mute); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warn { color: var(--warn); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-8 { gap: 8px; }
.between { justify-content: space-between; }
