/* =========================================================
   風神チャプター会計アプリ - デザインシステム / スタイル
   白ベース × BNIレッドのアクセント。銀行アプリのような
   清潔感・信頼感を優先する。
   ========================================================= */

:root {
  --color-bg: #f7f7f8;
  --color-surface: #ffffff;
  --color-border: #e7e5e6;
  --color-border-strong: #d8d5d6;

  --color-red: #c8102e;
  --color-red-dark: #a20d26;
  --color-red-light: #fdecef;
  --color-red-tint: #fbf1f2;

  --color-text: #232326;
  --color-text-muted: #6b6b70;
  --color-text-faint: #9a9a9e;

  --color-gray-dark: #3a3a3d;
  --color-gray: #77777c;
  --color-gray-light: #efeff0;

  --color-success: #2f6d4f;
  --color-warn: #c8102e;

  --shadow-sm: 0 1px 2px rgba(20, 20, 25, 0.05);
  --shadow-md: 0 4px 14px rgba(20, 20, 25, 0.07);
  --shadow-lg: 0 10px 30px rgba(20, 20, 25, 0.12);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --sidebar-w: 240px;
  --header-h: 60px;
  --bottomnav-h: 64px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Yu Gothic", "Noto Sans JP", "Segoe UI", Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

img { max-width: 100%; }
[hidden] { display: none !important; }
button, input, select, textarea { font-family: inherit; }

a { color: var(--color-red); text-decoration: none; }

/* ---------- ログイン画面 ---------- */

#auth-root {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-top: calc(24px + var(--safe-top));
  padding-bottom: calc(24px + var(--safe-bottom));
  background: var(--color-bg);
}

.auth-wrap { width: 100%; max-width: 380px; }

.auth-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 28px 24px;
}

.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-title { font-weight: 800; font-size: 16px; color: var(--color-text); }
.auth-sub { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }

.auth-card .form-field { margin-bottom: 14px; }

.auth-error {
  color: var(--color-red-dark);
  font-size: 12.5px;
  font-weight: 600;
  background: var(--color-red-light);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}

.auth-note { font-size: 11.5px; color: var(--color-text-faint); margin-top: 16px; text-align: center; line-height: 1.6; }

/* ---------- ログアウト ---------- */

.logout-link {
  display: block;
  margin-top: 10px;
  background: none;
  border: none;
  padding: 0;
  color: var(--color-red);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}
.logout-link:hover { text-decoration: underline; }

.more-sheet-list .logout-item { color: var(--color-red); }

/* ---------- レイアウト ---------- */

#app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding-top: var(--safe-top);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--color-border);
}

.sidebar-brand .brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--color-red);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

.sidebar-brand .brand-text { line-height: 1.25; }
.sidebar-brand .brand-title { font-weight: 700; font-size: 14.5px; color: var(--color-text); }
.sidebar-brand .brand-sub { font-size: 11.5px; color: var(--color-text-muted); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.nav-item .nav-icon { width: 19px; height: 19px; flex-shrink: 0; }
.nav-item:hover { background: var(--color-gray-light); color: var(--color-text); }

.nav-item.active {
  background: var(--color-red-light);
  color: var(--color-red);
  font-weight: 700;
}
.nav-item.active .nav-icon { color: var(--color-red); }

.sidebar-footer {
  padding: 14px 18px calc(16px + var(--safe-bottom));
  border-top: 1px solid var(--color-border);
  font-size: 11px;
  color: var(--color-text-faint);
  line-height: 1.6;
}

.main-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255,255,255,0.92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--color-border);
  padding: calc(14px + var(--safe-top)) 24px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-titles { min-width: 0; flex: 1; }

.topbar h1 {
  font-size: 19px;
  margin: 0;
  font-weight: 700;
  letter-spacing: .01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar .topbar-sub {
  font-size: 12.5px; color: var(--color-text-muted); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }

/* ---------- 会計年度セレクター ---------- */
.fy-switcher { display: flex; align-items: center; gap: 6px; }
.fy-switcher-label { font-size: 11px; color: var(--color-text-muted); font-weight: 700; white-space: nowrap; }
.fy-select {
  border: 1px solid var(--color-border-strong);
  border-radius: 999px;
  background: #fff;
  color: var(--color-red);
  font-weight: 700;
  font-size: 13px;
  padding: 6px 10px;
  cursor: pointer;
}
.fy-select:focus { outline: none; border-color: var(--color-red); box-shadow: 0 0 0 3px var(--color-red-light); }

.view-root {
  flex: 1;
  padding: 20px 24px calc(28px + var(--safe-bottom));
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
}

/* ---------- ボトムナビ（スマホ） ---------- */

.bottom-nav {
  display: none;
}

.plus-sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(20,20,25,0.35);
  z-index: 60;
}

.plus-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 61;
  background: var(--color-surface);
  border-radius: 20px 20px 0 0;
  padding: 10px 16px calc(20px + var(--safe-bottom));
  box-shadow: var(--shadow-lg);
}

.plus-sheet .sheet-handle {
  width: 40px; height: 4px; border-radius: 2px;
  background: var(--color-border-strong);
  margin: 6px auto 14px;
}

.sheet-option {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #fff;
  margin-bottom: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
}
.sheet-option .sheet-icon {
  width: 40px; height: 40px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sheet-option.income .sheet-icon { background: var(--color-red-light); color: var(--color-red); }
.sheet-option.expense .sheet-icon { background: var(--color-gray-light); color: var(--color-gray-dark); }

.more-sheet-list { display: flex; flex-direction: column; gap: 4px; }
.more-sheet-list .nav-item { font-size: 14.5px; padding: 13px 12px; }

/* ---------- カード / 共通コンポーネント ---------- */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 18px;
}

.card + .card { margin-top: 16px; }

.card-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-sub { font-size: 11.5px; color: var(--color-text-muted); margin: 0 0 12px; }

.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 980px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
}
.stat-label {
  font-size: 12px; color: var(--color-text-muted); font-weight: 600;
  display: flex; align-items: center; gap: 6px; margin-bottom: 8px;
}
.stat-value { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; color: var(--color-text); }
.stat-value.accent { color: var(--color-red); }
.stat-value.positive { color: var(--color-gray-dark); }
.stat-note { font-size: 11.5px; color: var(--color-text-faint); margin-top: 6px; }

/* ---------- ボタン ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .05s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--color-red); color: #fff; }
.btn-primary:hover { background: var(--color-red-dark); }

.btn-outline { background: #fff; color: var(--color-red); border-color: var(--color-red); }
.btn-outline:hover { background: var(--color-red-tint); }

.btn-ghost { background: transparent; color: var(--color-text-muted); border-color: var(--color-border); }
.btn-ghost:hover { background: var(--color-gray-light); }

.btn-plain { background: var(--color-gray-light); color: var(--color-text); }

.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn-danger { background: #fff; color: var(--color-red); border-color: var(--color-red-light); }
.btn-danger:hover { background: var(--color-red-light); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.icon-btn {
  width: 34px; height: 34px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--color-border); background: #fff; color: var(--color-text-muted);
  cursor: pointer;
}
.icon-btn:hover { background: var(--color-gray-light); }

/* ---------- フォーム ---------- */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.span-2 { grid-column: 1 / -1; }

.form-label {
  font-size: 12.5px; font-weight: 700; color: var(--color-text);
  display: flex; align-items: center; gap: 6px;
}
.form-label .req { color: var(--color-red); font-size: 11px; }
.form-hint { font-size: 11px; color: var(--color-text-muted); }

.input, select.input, textarea.input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-strong);
  background: #fff;
  font-size: 14.5px;
  color: var(--color-text);
}
.input:focus, select.input:focus, textarea.input:focus {
  outline: none;
  border-color: var(--color-red);
  box-shadow: 0 0 0 3px var(--color-red-light);
}
textarea.input { resize: vertical; min-height: 64px; }

.amount-input-wrap { position: relative; }
.amount-input-wrap .yen-prefix {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--color-text-muted); font-weight: 700; font-size: 14.5px;
}
.amount-input-wrap input { padding-left: 28px; font-weight: 700; text-align: right; }

.segmented {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.segmented button {
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--color-border-strong);
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
}
.segmented button.active {
  background: var(--color-red);
  border-color: var(--color-red);
  color: #fff;
}

.form-actions {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--color-border);
}

.link-add {
  font-size: 12.5px; font-weight: 700; color: var(--color-red);
  background: none; border: none; cursor: pointer; padding: 4px 0;
  display: inline-flex; align-items: center; gap: 4px;
}

.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--color-text); }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--color-red); }

/* ---------- 検索可能セレクト（コンボボックス） ---------- */

.combo { position: relative; }
.combo-input-row { display: flex; gap: 8px; }
.combo-input-row .input { cursor: pointer; background: #fff; }
.combo-panel {
  position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; right: 0;
  background: #fff; border: 1px solid var(--color-border-strong); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); max-height: 280px; display: flex; flex-direction: column; overflow: hidden;
}
.combo-search { padding: 10px; border-bottom: 1px solid var(--color-border); }
.combo-search input { width: 100%; border: 1px solid var(--color-border-strong); border-radius: 8px; padding: 8px 10px; font-size: 14px; }
.combo-list { overflow-y: auto; padding: 6px; }
.combo-option {
  padding: 10px 10px; border-radius: 8px; font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.combo-option:hover, .combo-option.highlighted { background: var(--color-red-tint); }
.combo-option .opt-meta { font-size: 11px; color: var(--color-text-faint); }
.combo-empty { padding: 16px 10px; text-align: center; color: var(--color-text-muted); font-size: 13px; }
.combo-add {
  border-top: 1px solid var(--color-border);
  padding: 10px; font-size: 13px; font-weight: 700; color: var(--color-red);
  cursor: pointer; text-align: center;
}
.combo-add:hover { background: var(--color-red-tint); }

/* ---------- テーブル ---------- */

.table-wrap { overflow-x: auto; }
.mobile-card-list { display: none; }

.list-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 10px; margin-bottom: 14px;
}

.add-toolbar { display: flex; justify-content: flex-end; margin-bottom: 14px; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
table.data-table th {
  text-align: left; font-size: 11.5px; color: var(--color-text-muted);
  padding: 8px 10px; border-bottom: 1px solid var(--color-border); white-space: nowrap;
  font-weight: 700;
}
table.data-table td { padding: 11px 10px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
table.data-table tr:last-child td { border-bottom: none; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
}
.badge-red { background: var(--color-red-light); color: var(--color-red); }
.badge-gray { background: var(--color-gray-light); color: var(--color-gray-dark); }
.badge-outline { background: #fff; border: 1px solid var(--color-border-strong); color: var(--color-text-muted); }

.amt-in { color: var(--color-gray-dark); font-weight: 700; }
.amt-out { color: var(--color-red); font-weight: 700; }

/* ---------- カテゴリーカラーバッジ ---------- */
.cat-badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap; line-height: 1.6;
}

.color-swatch-row { display: flex; gap: 6px; align-items: center; }
.color-swatch {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; padding: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06);
}
.color-swatch.selected { border-color: var(--color-text); box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--color-text); }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.empty-state {
  text-align: center; padding: 40px 20px; color: var(--color-text-muted);
}
.empty-state .empty-icon { font-size: 30px; margin-bottom: 10px; }
.empty-state .btn { margin-top: 14px; }

/* ---------- フィルターバー ---------- */

.filter-bar {
  display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; align-items: flex-end;
}
.filter-field { display: flex; flex-direction: column; gap: 4px; }
.filter-field label { font-size: 11px; color: var(--color-text-muted); font-weight: 700; }
.filter-field .input { min-width: 140px; }

/* ---------- モーダル ---------- */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20,20,25,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal {
  background: #fff; border-radius: var(--radius-lg);
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 22px;
}
.modal.modal-lg { max-width: 640px; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; gap: 10px; }
.modal-header h2 { font-size: 17px; margin: 0; font-weight: 800; }
.modal-header p { margin: 4px 0 0; font-size: 12.5px; color: var(--color-text-muted); }
.modal-close { background: none; border: none; color: var(--color-text-faint); font-size: 20px; cursor: pointer; line-height: 1; padding: 4px; }

.confirm-modal p { font-size: 14px; color: var(--color-text); line-height: 1.6; }
.confirm-modal .confirm-note { font-size: 12.5px; color: var(--color-text-muted); background: var(--color-gray-light); padding: 10px 12px; border-radius: 10px; margin-top: 10px; }
.confirm-modal .confirm-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---------- トースト ---------- */

.toast-stack {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%); z-index: 200;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: min(90vw, 380px);
}
.toast {
  background: var(--color-gray-dark); color: #fff; padding: 11px 18px;
  border-radius: 999px; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 8px;
  animation: toast-in .18s ease-out;
}
.toast.success { background: #22321f; }
.toast.error { background: var(--color-red-dark); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- タブ ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--color-border); margin-bottom: 16px; flex-wrap: wrap; }
.tab-btn {
  padding: 10px 14px; border: none; background: none; cursor: pointer;
  font-size: 13.5px; font-weight: 700; color: var(--color-text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab-btn.active { color: var(--color-red); border-bottom-color: var(--color-red); }

/* ---------- グラフ ---------- */
.chart-wrap { width: 100%; overflow-x: auto; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 12px; font-size: 12px; color: var(--color-text-muted); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

/* ---------- アコーディオン（ヘルプ） ---------- */
.accordion-item { border: 1px solid var(--color-border); border-radius: var(--radius-md); margin-bottom: 10px; overflow: hidden; background: #fff; }
.accordion-head {
  width: 100%; text-align: left; padding: 14px 16px; background: none; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; font-size: 14px; font-weight: 700; color: var(--color-text);
}
.accordion-head .chev { transition: transform .15s ease; color: var(--color-text-faint); }
.accordion-item.open .accordion-head .chev { transform: rotate(180deg); color: var(--color-red); }
.accordion-body { padding: 0 16px 16px; font-size: 13.5px; color: var(--color-text-muted); line-height: 1.8; }
.accordion-body p { margin: 0 0 10px; }
.accordion-body ul { margin: 0 0 10px; padding-left: 18px; }

.notice-banner {
  background: var(--color-red-tint); border: 1px solid var(--color-red-light);
  color: var(--color-red-dark); padding: 12px 14px; border-radius: var(--radius-sm);
  font-size: 12.5px; font-weight: 600; margin-bottom: 16px; display: flex; gap: 8px; align-items: flex-start;
}

/* ---------- 設定：区分リスト ---------- */
.cat-manage-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}
.cat-manage-row:last-child { border-bottom: none; }
.cat-manage-row .cat-name { flex: 1; font-size: 14px; font-weight: 600; }
.cat-manage-row.disabled .cat-name { color: var(--color-text-faint); text-decoration: line-through; }
.cat-manage-row .cat-desc { font-size: 11.5px; color: var(--color-text-muted); }

/* ---------- ヘッダーのページタイトルエリア（モバイル用） ---------- */
.page-heading { margin-bottom: 16px; }
.page-heading h2 { margin: 0 0 2px; font-size: 18px; font-weight: 800; }
.page-heading p { margin: 0; font-size: 12.5px; color: var(--color-text-muted); }

.section-title {
  font-size: 13px; font-weight: 800; color: var(--color-text); margin: 22px 0 10px;
  display: flex; align-items: center; gap: 6px;
}
.section-title:first-child { margin-top: 0; }

.helper-text { font-size: 12px; color: var(--color-text-muted); margin-top: 4px; }

.diff-ok { color: var(--color-gray-dark); font-weight: 700; }
.diff-warn { color: var(--color-red); font-weight: 700; }

/* =========================================================
   スマートフォン表示
   ========================================================= */

@media (max-width: 860px) {
  .sidebar { display: none; }

  #app-shell { display: block; }

  .main-col { min-height: 100vh; }

  .topbar { padding: calc(12px + var(--safe-top)) 16px 12px; gap: 8px; }
  .topbar h1 { font-size: 17px; }

  .fy-switcher-label { display: none; }
  .fy-select { font-size: 12px; padding: 5px 8px; }

  .view-root { padding: 14px 14px calc(90px + var(--safe-bottom)); }

  .bottom-nav {
    display: flex;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: rgba(255,255,255,0.96);
    backdrop-filter: saturate(180%) blur(10px);
    border-top: 1px solid var(--color-border);
    padding: 6px 6px calc(6px + var(--safe-bottom));
    justify-content: space-between;
    align-items: flex-end;
  }

  .bottom-nav .bn-item {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    background: none; border: none; color: var(--color-text-faint);
    font-size: 10.5px; font-weight: 700; padding: 6px 2px;
  }
  .bottom-nav .bn-item .bn-icon { width: 21px; height: 21px; }
  .bottom-nav .bn-item.active { color: var(--color-red); }

  .bottom-nav .bn-plus {
    flex: 1;
    display: flex; flex-direction: column; align-items: center;
    margin-top: -22px;
  }
  .bottom-nav .bn-plus .bn-plus-btn {
    width: 52px; height: 52px; border-radius: 50%;
    background: var(--color-red); color: #fff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 14px rgba(200,16,46,0.4);
    border: 3px solid #fff;
  }
  .bottom-nav .bn-plus span { font-size: 10.5px; font-weight: 700; color: var(--color-red); margin-top: 2px; }

  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }

  .grid-4, .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }

  /* フィルターバーは縦積みにして、各項目を横幅いっぱいにする */
  .filter-bar { flex-direction: column; align-items: stretch; gap: 10px; }
  .filter-field { width: 100%; }
  .filter-field .input, .filter-field select.input { width: 100%; min-width: 0; }
  .filter-bar .btn { width: 100%; }

  /* テーブルをそのまま縮小せず、モバイルではカード一覧に切り替える */
  .desktop-table-wrap { display: none; }
  .mobile-card-list { display: flex; flex-direction: column; gap: 10px; }

  /* 一覧上部のツールバー（追加ボタン・チェックボックスなど）は縦積みにする */
  .list-toolbar { flex-direction: column; align-items: stretch; }
  .list-toolbar .btn { width: 100%; }
  .add-toolbar .btn { width: 100%; }

  .data-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 14px;
  }
  .data-card-top {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; margin-bottom: 8px;
  }
  .data-card-date { font-size: 11.5px; color: var(--color-text-faint); }
  .data-card-badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
  .data-card-main {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 10px; margin-bottom: 4px;
  }
  .data-card-title { font-weight: 700; font-size: 14.5px; word-break: break-word; }
  .data-card-sub { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; word-break: break-word; }
  .data-card-amount { font-size: 15.5px; font-weight: 800; white-space: nowrap; flex-shrink: 0; }
  .data-card-memo {
    font-size: 12px; color: var(--color-text-muted); margin-top: 6px;
    padding-top: 8px; border-top: 1px dashed var(--color-border); word-break: break-word;
  }
  .data-card-rows { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
  .data-card-row { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; }
  .data-card-row .k { color: var(--color-text-muted); flex-shrink: 0; }
  .data-card-row .v { text-align: right; font-weight: 600; word-break: break-word; }
  .data-card-actions {
    display: flex; gap: 8px; margin-top: 10px; padding-top: 10px;
    border-top: 1px solid var(--color-border);
  }
  .data-card-actions .btn { flex: 1; }

  /* レポートの円グラフカードなど、縦積み時に凡例が窮屈にならないように */
  .chart-wrap, #rp-income-donut, #rp-expense-donut, #chart-expense-cat { width: 100%; }
}

@media (max-width: 420px) {
  .stat-value { font-size: 20px; }
}

/* 印刷・大画面時など将来拡張用の余白調整 */
.spacer-16 { height: 16px; }
.hidden-desktop { display: none; }
@media (max-width: 860px) { .hidden-desktop { display: initial; } .hidden-mobile { display: none !important; } }
