* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Meiryo", sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  padding-bottom: 70px;
}

/* ===== ヘッダー ===== */
.app-header {
  background: #1a73e8;
  color: white;
  padding: 10px 16px 14px;
  position: sticky; top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.header-top {
  font-size: 11px; opacity: 0.85; letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.header-row {
  display: flex; justify-content: space-between; align-items: center;
}
.app-header h1 { font-size: 18px; font-weight: 600; }
.app-header .subtitle { font-size: 12px; opacity: 0.85; }
.header-buttons { display: flex; gap: 4px; }
.icon-btn {
  background: none; border: none; color: white;
  font-size: 16px; padding: 8px; cursor: pointer;
}

/* ===== コンテナ ===== */
.container { max-width: 600px; margin: 0 auto; padding: 12px; }

/* ===== サマリーカード ===== */
.summary-card {
  background: white; border-radius: 16px; padding: 20px;
  margin-bottom: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.summary-row { display: flex; gap: 16px; margin-bottom: 12px; }
.summary-item { flex: 1; text-align: center; padding: 12px; border-radius: 12px; }
.summary-item.income { background: #e8f5e9; }
.summary-item.expense { background: #fce4ec; }
.summary-label { font-size: 12px; color: #666; margin-bottom: 4px; }
.summary-amount { font-size: 18px; font-weight: 700; }
.summary-item.income .summary-amount { color: #2e7d32; }
.summary-item.expense .summary-amount { color: #c62828; }
.summary-balance {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-radius: 12px; background: #f5f5f5;
  font-weight: 600;
}
.summary-balance.positive { color: #2e7d32; }
.summary-balance.negative { color: #c62828; }

/* ===== セクションカード ===== */
.section-card {
  background: white; border-radius: 16px; padding: 16px;
  margin-bottom: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.section-title { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.section-header-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.text-btn {
  background: none; border: none; color: #1a73e8;
  font-size: 13px; cursor: pointer; padding: 4px;
}

/* ===== 内訳バー ===== */
.breakdown-list { display: flex; flex-direction: column; gap: 8px; }
.breakdown-row {
  display: flex; align-items: center; gap: 8px; font-size: 13px;
}
.breakdown-icon { font-size: 16px; width: 24px; text-align: center; }
.breakdown-label { width: 100px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breakdown-bar-bg { flex: 1; height: 8px; background: #f0f0f0; border-radius: 4px; overflow: hidden; }
.breakdown-bar { height: 100%; background: #ef5350; border-radius: 4px; transition: width 0.3s; }
.breakdown-amount { font-weight: 600; white-space: nowrap; min-width: 80px; text-align: right; }

/* ===== 取引行 ===== */
.tx-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid #f0f0f0;
}
.tx-row:last-child { border-bottom: none; }
.tx-icon { font-size: 20px; width: 32px; text-align: center; }
.tx-info { flex: 1; min-width: 0; }
.tx-cat { font-size: 14px; font-weight: 500; }
.tx-note { font-size: 11px; color: #888; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-amount { font-size: 15px; font-weight: 600; white-space: nowrap; }
.tx-amount.positive { color: #2e7d32; }
.tx-amount.negative { color: #c62828; }

/* ===== 日別グループ ===== */
.day-group {
  background: white; border-radius: 12px; padding: 12px 16px;
  margin-bottom: 8px; box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.day-header {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 8px; border-bottom: 1px solid #eee; margin-bottom: 4px;
  font-size: 13px; font-weight: 600;
}
.day-total.positive { color: #2e7d32; }
.day-total.negative { color: #c62828; }

/* ===== 追加画面 ===== */
.add-section { padding: 12px 0; }
.add-label { display: block; font-size: 13px; font-weight: 600; color: #555; margin-bottom: 6px; }
.add-input {
  width: 100%; padding: 12px; border: 1.5px solid #ddd; border-radius: 10px;
  font-size: 16px; background: white; transition: border-color 0.2s;
}
.add-input:focus { border-color: #1a73e8; outline: none; box-shadow: 0 0 0 3px rgba(26,115,232,0.1); }

.amount-input-row { display: flex; align-items: center; gap: 8px; }
.amount-input { text-align: right; flex: 1; }
.amount-unit { font-size: 15px; color: #666; }

/* 収入/支出タブ */
.type-tabs { display: flex; gap: 0; border-radius: 10px; overflow: hidden; border: 2px solid #ddd; }
.type-tab {
  flex: 1; padding: 12px; text-align: center; font-size: 15px; font-weight: 600;
  border: none; cursor: pointer; background: white; color: #888; transition: all 0.2s;
}
.type-tab.active[data-type="expense"] { background: #c62828; color: white; }
.type-tab.active[data-type="income"] { background: #2e7d32; color: white; }

/* カテゴリグリッド */
.category-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.cat-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 4px; border: 2px solid #eee; border-radius: 12px;
  background: white; cursor: pointer; transition: all 0.15s;
}
.cat-btn.selected { border-color: #1a73e8; background: #e8f0fe; }
.cat-btn:active { transform: scale(0.95); }
.cat-icon { font-size: 22px; }
.cat-label { font-size: 10px; color: #555; text-align: center; line-height: 1.2; }

/* アクションボタン */
.add-actions { padding: 16px 0 32px; display: flex; flex-direction: column; gap: 10px; }
.btn {
  display: block; width: 100%; padding: 14px; border: none; border-radius: 12px;
  font-size: 15px; font-weight: 600; cursor: pointer; text-align: center; transition: all 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: #1a73e8; color: white; }
.btn-primary:disabled { background: #94c2f8; }
.btn-secondary { background: white; color: #1a73e8; border: 2px solid #1a73e8; }
.btn-danger { background: white; color: #c62828; border: 2px solid #c62828; }

/* OCR */
.ocr-buttons { display: flex; gap: 8px; }
.ocr-buttons .ocr-btn { flex: 1; font-size: 13px; padding: 12px 8px; }
.ocr-btn { display: flex; align-items: center; justify-content: center; gap: 8px; }
.ocr-status {
  margin-top: 10px; padding: 10px 14px; border-radius: 10px;
  font-size: 13px; display: none; align-items: center; gap: 8px;
  background: #f5f5f5;
}
.ocr-status.show { display: flex; }
.ocr-status.success { background: #e8f5e9; color: #2e7d32; }
.ocr-status.error { background: #fce4ec; color: #c62828; }

/* カメラオーバーレイ */
.camera-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100dvh;
  background: black; z-index: 1000; display: flex; flex-direction: column;
  overflow: hidden;
}
.camera-container {
  width: 100%; height: 100dvh; display: flex; flex-direction: column;
  position: relative; overflow: hidden;
}
#camera-video {
  width: 100%; flex: 1; object-fit: cover; background: #111;
  min-height: 0;
}
.camera-guide {
  position: absolute; top: 0; left: 0; width: 100%; bottom: 120px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
}
.camera-guide-box {
  width: 80%; height: 60%; border: 2px dashed rgba(255,255,255,0.6); border-radius: 12px;
}
.camera-hint {
  color: rgba(255,255,255,0.8); font-size: 13px; margin-top: 12px; text-align: center;
}
.camera-controls {
  display: flex; justify-content: space-around; align-items: center;
  padding: 16px 20px; background: rgba(0,0,0,0.9); height: 120px;
  flex-shrink: 0; padding-bottom: env(safe-area-inset-bottom, 20px);
}
.camera-btn {
  border: none; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.camera-btn.cancel {
  background: rgba(255,255,255,0.2); color: white;
  width: 48px; height: 48px; font-size: 12px; border-radius: 24px;
  padding: 0 12px; width: auto;
}
.camera-btn.shutter {
  width: 68px; height: 68px; background: white; font-size: 28px;
  box-shadow: 0 0 0 4px rgba(255,255,255,0.3);
}
.camera-btn.shutter:active { transform: scale(0.9); }
.camera-btn.switch {
  background: rgba(255,255,255,0.2); color: white;
  width: 48px; height: 48px; font-size: 20px;
}

/* 設定 */
.setting-field { margin-bottom: 16px; }
.setting-field span { font-size: 14px; color: #666; margin-left: 4px; }

/* サマリー詳細行 */
.summary-detail-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid #f0f0f0; font-size: 13px;
}
.summary-detail-row:last-child { border-bottom: none; }

/* レポートボタン */
.report-btn { margin-top: 16px; }

/* ===== 下部ナビ ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: white; display: flex; justify-content: space-around; align-items: center;
  height: 64px; box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
  z-index: 100;
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: none; color: #888; cursor: pointer;
  padding: 8px 16px; font-size: 10px;
}
.nav-item.active { color: #1a73e8; }
.nav-icon { font-size: 22px; }
.nav-label { font-size: 10px; }
.nav-item-add, .add-btn-nav { position: relative; }
.nav-icon-add {
  width: 52px; height: 52px; border-radius: 50%;
  background: #1a73e8; color: white; display: flex;
  align-items: center; justify-content: center;
  font-size: 28px; font-weight: 300;
  box-shadow: 0 4px 12px rgba(26,115,232,0.4);
  margin-top: -20px;
}

.nav-spacer { height: 80px; }

/* ===== 空状態 ===== */
.empty-state { text-align: center; padding: 48px 20px; color: #888; }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-sub { font-size: 13px; margin-top: 4px; }

/* ===== スピナー ===== */
.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 3px solid rgba(255,255,255,0.3); border-radius: 50%;
  border-top-color: white; animation: spin 0.8s linear infinite;
  vertical-align: middle; margin-right: 6px;
}
.spinner-dark {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid #ddd; border-radius: 50%;
  border-top-color: #1a73e8; animation: spin 0.8s linear infinite;
  vertical-align: middle; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 説明書 ===== */
.help-content { padding-bottom: 20px; }
.help-section {
  background: white; border-radius: 12px; padding: 20px;
  margin-bottom: 12px; box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.help-section h2 {
  font-size: 16px; font-weight: 700; color: #1a73e8;
  margin-bottom: 12px; padding-bottom: 8px; border-bottom: 2px solid #e8f0fe;
}
.help-section p { font-size: 14px; line-height: 1.7; margin-bottom: 8px; }
.help-section ol, .help-section ul {
  font-size: 14px; line-height: 1.8; padding-left: 20px; margin-bottom: 8px;
}
.help-section li { margin-bottom: 4px; }
.help-box {
  background: #f8f9fa; border-radius: 10px; padding: 14px;
  margin: 10px 0;
}
.help-box h3 { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.help-box ol { margin-bottom: 0; }
.help-note { font-size: 12px; color: #888; margin-top: 8px; margin-bottom: 0; }
.help-faq { margin-bottom: 16px; }
.help-faq:last-child { margin-bottom: 0; }
.help-faq h3 { font-size: 14px; font-weight: 600; color: #333; margin-bottom: 4px; }
.help-faq p { font-size: 13px; color: #555; margin-bottom: 0; }
.help-table {
  width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 12px;
}
.help-table td {
  padding: 8px 10px; border-bottom: 1px solid #f0f0f0;
}
.help-table td:first-child { white-space: nowrap; font-weight: 500; width: 120px; }
.help-cat-title { font-size: 14px; font-weight: 600; margin: 12px 0 6px; }
.help-cat-title.expense-title { color: #c62828; }
.help-cat-title.income-title { color: #2e7d32; }
.help-important { border: 2px solid #ff9800; }
.help-important h2 { color: #e65100; border-bottom-color: #ffe0b2; }
.help-important-box {
  background: #fff8e1; border-radius: 10px; padding: 14px; margin: 10px 0;
}
.help-important-box.warning { background: #fce4ec; border-left: 4px solid #c62828; }
.help-important-box h3 { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.help-important-box p { font-size: 13px; line-height: 1.7; margin-bottom: 6px; }
.help-important-box p:last-child { margin-bottom: 0; }
.help-important-box ul { font-size: 13px; line-height: 1.8; padding-left: 20px; margin: 8px 0; }
.help-contact { text-align: center; }
.help-contact p { font-size: 14px; }

/* ===== OCR確認モーダル ===== */
.modal-overlay {
  display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.5); z-index: 200; justify-content: center; align-items: flex-end;
}
.modal-overlay.show { display: flex; }
.modal {
  background: white; border-radius: 16px 16px 0 0; padding: 24px;
  width: 100%; max-width: 600px; max-height: 85vh; overflow-y: auto;
}
.ocr-confirm-modal h3 { font-size: 16px; margin-bottom: 8px; }
.ocr-store { font-size: 14px; color: #555; margin-bottom: 4px; }
.ocr-confirm-hint { font-size: 12px; color: #888; margin-bottom: 16px; }
.ocr-items-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.ocr-item {
  background: #f8f9fa; border-radius: 10px; padding: 12px;
}
.ocr-item-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.ocr-item-name { flex: 1; font-size: 14px; font-weight: 500; }
.ocr-item-amount {
  width: 90px; padding: 8px; border: 1px solid #ddd; border-radius: 8px;
  font-size: 15px; text-align: right;
}
.ocr-item-cat {
  width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 8px;
  font-size: 14px; background: white;
}
.ocr-confirm-actions { display: flex; flex-direction: column; gap: 8px; }

/* ===== 通帳 ===== */
.bankbook-intro { font-size: 14px; line-height: 1.7; margin-bottom: 8px; }
.bankbook-actions { display: flex; gap: 8px; }
.bankbook-actions .ocr-btn { flex: 1; font-size: 13px; padding: 12px 8px; }
.bankbook-grid { display: flex; flex-direction: column; gap: 8px; }
.bankbook-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px; background: #f8f9fa; border-radius: 10px; position: relative;
}
.bankbook-thumb { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid #ddd; }
.bankbook-item-info { flex: 1; }
.bankbook-item-label { font-size: 14px; font-weight: 500; display: block; }
.bankbook-item-date { font-size: 11px; color: #888; }
.bankbook-delete {
  background: none; border: none; color: #c62828; font-size: 18px;
  cursor: pointer; padding: 8px; line-height: 1;
}
.bankbook-guide { width: 85%; height: 50%; }

/* ===== お問い合わせ ===== */
.contact-intro { font-size: 14px; color: #555; margin-bottom: 16px; line-height: 1.7; }
.contact-field { margin-bottom: 16px; }
.contact-textarea {
  resize: vertical; min-height: 120px; line-height: 1.6; font-family: inherit;
}
.required { color: #c62828; font-size: 11px; font-weight: 400; }
.contact-field-note { font-size: 12px; color: #888; margin-top: 6px; }
.line-qr-container { text-align: center; padding: 16px 0; }
.line-qr-image { max-width: 200px; width: 100%; border-radius: 8px; }
.line-qr-placeholder { color: #888; font-size: 13px; }
.btn-line {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: #06C755; color: white; text-decoration: none;
  padding: 14px; border-radius: 12px; font-size: 15px; font-weight: 600;
  margin-top: 12px;
}
.btn-line:active { opacity: 0.85; }
.line-icon { font-size: 20px; }

/* ===== トースト ===== */
.toast {
  position: fixed; bottom: 80px; left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #333; color: white; padding: 12px 24px;
  border-radius: 8px; font-size: 14px; z-index: 300;
  transition: transform 0.3s ease; white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: #2e7d32; }
.toast.error { background: #c62828; }

/* ===== 月切り替えナビ ===== */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 0;
  flex-wrap: wrap;
}
.month-arrow {
  background: #1a73e8;
  color: white;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.month-arrow:active { background: #1557b0; }
.month-label {
  font-size: 18px;
  font-weight: bold;
  min-width: 120px;
  text-align: center;
}
.month-today-btn {
  background: none;
  border: 1px solid #1a73e8;
  color: #1a73e8;
  border-radius: 16px;
  padding: 4px 12px;
  font-size: 13px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.month-today-btn:active { background: #e3f2fd; }
