/* ===== 基本設定（色はここで変えられます） ===== */
:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #222;
  --sub: #777;
  --main: #2f6f5e;   /* メインカラー */
  --plus: #2f6f5e;   /* 黒字 */
  --minus: #d33a3a;  /* 赤字 */
  --line: #e3e5e8;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Hiragino Sans", "Yu Gothic", sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, select { font: inherit; }

/* ===== 月の切り替え ===== */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
  background: var(--main); color: #fff;
}
header h1 { margin: 0; font-size: 18px; }
header button {
  width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: rgba(255,255,255,.2); color: #fff; font-size: 24px;
}

/* ===== タブ ===== */
#tabs { display: flex; background: var(--main); }
#tabs button {
  flex: 1; height: 48px; border: 0; background: none;
  color: rgba(255,255,255,.7); font-size: 16px;
  border-bottom: 4px solid transparent;
}
#tabs button.active { color: #fff; font-weight: bold; border-bottom-color: #fff; }

/* ===== カード ===== */
main { padding: 12px; max-width: 600px; margin: 0 auto; }
.card { background: var(--card); border-radius: 12px; padding: 16px; margin-bottom: 12px; }
.card h2 { margin: 0 0 12px; font-size: 16px; }
.small { margin: 0; color: var(--sub); font-size: 13px; }

/* ===== 残高 ===== */
.balance { margin: 4px 0 12px; font-size: 40px; font-weight: bold; color: var(--plus); }
.balance.minus, .minus { color: var(--minus); }
.rows div { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--line); }
.rows dt { color: var(--sub); }
.rows dd { margin: 0; font-weight: bold; }

/* ===== フォーム ===== */
.form { display: grid; gap: 10px; }
.form input, .form select {
  height: 48px; padding: 0 12px; font-size: 16px; /* 16px未満だとiPhoneで拡大されます */
  border: 1px solid var(--line); border-radius: 8px; background: #fff; width: 100%;
}
button.primary {
  height: 50px; border: 0; border-radius: 8px;
  background: var(--main); color: #fff; font-size: 17px; font-weight: bold;
}

/* ===== リスト ===== */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.empty { color: var(--sub); text-align: center; padding: 12px 0; }
.catRow { display: flex; justify-content: space-between; }
.bar { height: 6px; background: var(--line); border-radius: 3px; margin-top: 6px; }
.bar span { display: block; height: 100%; background: var(--main); border-radius: 3px; }
.expRow { display: flex; align-items: center; gap: 8px; }
.expInfo { flex: 1; min-width: 0; }
.expInfo small { display: block; color: var(--sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.expAmount { font-weight: bold; }
.delBtn { width: 44px; height: 44px; border: 0; background: none; font-size: 20px; }

/* ===== ポップアップ ===== */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal.hidden { display: none; }
.modalBox { background: #fff; border-radius: 12px; padding: 20px; width: 100%; max-width: 360px; display: grid; gap: 12px; }
.modalBox h2, .modalBox p { margin: 0; }
.modalBox input { height: 48px; padding: 0 12px; font-size: 16px; border: 1px solid var(--line); border-radius: 8px; }

/* ===== STEP 2 追加分 ===== */
header { display: block; }
.appName { font-weight: bold; font-size: 15px; padding: 0 4px; }
.appName span { font-size: 11px; opacity: .7; letter-spacing: .08em; }
.monthRow { display: flex; align-items: center; justify-content: space-between; }
header button:disabled { opacity: .3; }

#errorBar { position: sticky; top: 0; z-index: 20; background: var(--minus); color: #fff; padding: 10px 14px; font-size: 14px; }
.hidden { display: none !important; }

.cardHead { display: flex; justify-content: space-between; align-items: center; }
.linkBtn { border: 0; background: none; color: var(--main); font-size: 14px; min-height: 44px; }
button.secondary { height: 48px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 16px; }
button.secondary.small { height: 40px; padding: 0 14px; font-size: 14px; }

.expInfo { cursor: pointer; padding: 4px 0; }

.modalBox.wide { max-width: 480px; max-height: 90vh; overflow-y: auto; }
.modalBox select { height: 48px; padding: 0 12px; font-size: 16px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.modalHead { display: flex; justify-content: space-between; align-items: center; }
.modalBox h3 { margin: 8px 0 0; font-size: 15px; }
.catManageRow .name { font-weight: bold; }
.catManageRow .off { color: var(--sub); font-weight: normal; font-size: 13px; }
.catBtns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.miniBtn { min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 14px; }
.miniBtn:disabled { opacity: .35; }
.histRow { display: flex; justify-content: space-between; }

/* ===== STEP 3 追加分（年間集計） ===== */
#viewSwitch { display: flex; gap: 8px; padding: 12px 12px 0; max-width: 600px; margin: 0 auto; }
#viewSwitch button { flex: 1; height: 44px; border: 1px solid var(--main); background: #fff; color: var(--main); border-radius: 8px; font-size: 16px; }
#viewSwitch button.active { background: var(--main); color: #fff; font-weight: bold; }

.card.yearNav { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; }
.yearNav h2 { margin: 0; font-size: 18px; }
.yearNav button { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--main); color: #fff; font-size: 24px; }
.yearNav button:disabled { opacity: .3; }

.rows dd.note { font-weight: normal; font-size: 13px; text-align: right; }
.chartRow { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.chartRow .m { width: 36px; color: var(--sub); font-size: 14px; }
.chartRow .track { flex: 1; height: 16px; background: var(--line); border-radius: 4px; overflow: hidden; }
.chartRow .track span { display: block; height: 100%; background: var(--main); }
.chartRow .v { width: 96px; text-align: right; font-size: 14px; font-weight: bold; }
.chartRow.off { opacity: .45; }
.chartRow.tap { cursor: pointer; }
.avgText { color: var(--sub); font-size: 13px; margin-top: 2px; }

/* ===== STEP 4 追加分（バックアップ・復元） ===== */
.notice { margin: 0; padding: 10px 12px; background: #fff6e0; border-radius: 8px; font-size: 13px; line-height: 1.6; }
.warnText { color: var(--minus); font-weight: bold; }
.errText { color: var(--minus); font-size: 14px; line-height: 1.6; margin: 0; }
/* 本物のファイル選択欄は画面外に隠し、下のボタン（label）から開く */
.visuallyHidden { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
.fileBtn { display: flex; align-items: center; justify-content: center; height: 48px; border: 1px solid var(--main); border-radius: 8px; background: #fff; color: var(--main); font-size: 16px; font-weight: bold; cursor: pointer; }
#restoreFileName { margin: 0; word-break: break-all; }

/* 金額欄の ▲▼（スピンボタン）を非表示にする。数字キーボードは inputmode="numeric" のまま */
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#restoreResult { font-size: 14px; }
#restoreResult .ok { color: var(--plus); font-weight: bold; margin: 0 0 4px; }
.summary { margin: 0 0 8px; padding-left: 18px; line-height: 1.7; }

/* ===== STEP 5 追加分（iPhone向け） ===== */
html { -webkit-text-size-adjust: 100%; }   /* 横向きなどで文字が勝手に大きくならないように */
button, label, select { touch-action: manipulation; }  /* ダブルタップでの拡大を防ぐ */
