:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #1b1b1b;
  --muted: #6d6d6d;
  --accent: #1f6feb;
}

* {
  box-sizing: border-box;
  font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

.topbar {
  padding: 12px 16px;
  background: linear-gradient(90deg, #f0e6d6, #f6f4ef);
  border-bottom: 1px solid #e4dfd5;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: -1px;
  color: #fff;
  background: linear-gradient(135deg, #00b4a0, #00cc6a);
  box-shadow: 0 4px 12px rgba(0, 180, 160, 0.35);
}

.brand-text {
  font-weight: 800;
}

.nav {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.nav a {
  color: var(--ink);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 6px;
  background: #fff5e6;
}
.nav a:hover {
  text-decoration: underline;
}

.container {
  padding: 16px;
}

.card {
  background: var(--card);
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  margin-bottom: 16px;
}

.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 16px;
}

.metric {
  font-size: 24px;
  font-weight: 700;
  margin-top: 6px;
}

.label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

input, select, button {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #d6d1c8;
  background: #fff;
  font-size: 14px;
}

button {
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
}

button:not(:disabled):hover {
  filter: brightness(0.88);
}

button.secondary {
  background: #555;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid #eee;
  border-right: 1px solid #eee;
}

th {
  text-align: center !important;
}

/* number input のスピナー非表示 */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] {
  -moz-appearance: textfield;
}

.inbox-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.txn {
  background: #fff9f0;
  border-radius: 12px;
  padding: 12px;
  border: 1px solid #f0e3cf;
}

.txn-main {
  margin-bottom: 8px;
}

.txn-desc {
  font-weight: 600;
}

.txn-meta {
  color: var(--muted);
  font-size: 12px;
}

.txn-amount {
  font-weight: 700;
  margin-bottom: 8px;
}

.txn-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.note {
  color: var(--muted);
  font-size: 12px;
}

.section-desc {
  margin: 6px 0 12px;
  font-size: 13px;
  color: #6d6d6d;
  line-height: 1.6;
}

.tree details {
  margin: 8px 0;
}

.tree ul {
  list-style: none;
  padding-left: 16px;
}

.tree li {
  margin: 4px 0;
}

.panel {
  margin-top: 16px;
  padding: 12px;
  border: 1px dashed #d9d2c6;
  border-radius: 10px;
  background: #fffdf7;
}


.field {
  min-width: 220px;
}

.edit-toggle {
  background: #e67e22;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  display: inline-block;
  user-select: none;
}
.edit-toggle:hover {
  filter: brightness(0.88);
}

.minor-label {
  padding-left: 12px;
  color: #5f5b52;
}

.budget-cell {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
}

.budget-display {
  min-width: 100px;
}

.budget-cell,
.budget-display,
.budget-input {
  white-space: nowrap;
}

.tree-table {
  width: min(720px, 100%);
  table-layout: fixed;
}

.col-category {
  width: 60%;
}

.col-budget {
  width: 40%;
}

.tree-table th,
.tree-table td {
  display: table-cell;
  text-align: left;
  vertical-align: middle;
}

.tree-table th:last-child,
.tree-table td:last-child {
  padding-left: 16px;
  border-left: 1px solid #eee;
  text-align: left !important;
}

.major-row {
  background: #fff8ec;
}

.major-row:hover {
  background: #fff1d6;
}

.caret {
  display: inline-block;
  width: 16px;
}

.major-click,
.minor-row label {
  color: #1b1b1b;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.major-click:hover,
.minor-row label:hover {
  text-decoration: underline;
}
.toggle-major {
  cursor: pointer;
  color: #1b1b1b;
}

.toggle-major:hover {
  text-decoration: underline;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
}

.section-underline {
  height: 2px;
  background: #e07a24;
  margin-bottom: 12px;
}

.summary-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  background: #fbf5ea;
  border: 1px solid #e9e1d2;
  border-radius: 10px;
  padding: 12px;
}

.summary-cell {
  text-align: center;
}

.summary-label {
  font-weight: 700;
  color: #3b352f;
  margin-bottom: 6px;
}

.summary-value {
  font-size: 18px;
  font-weight: 700;
}

.summary-op {
  font-weight: 700;
  color: #6d6d6d;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.manual-button {
  background: #e67e22;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 700;
}

.manual-panel {
  display: none;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid #e6ddcc;
  border-radius: 10px;
  background: #fffaf1;
}

.manual-panel.is-open {
  display: block;
}

.cycle-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.cycle-range {
  font-size: 20px;
  font-weight: 700;
}

.cycle-nav,
.cycle-today {
  padding: 6px 10px;
  border: 1px solid #d6d1c8;
  border-radius: 6px;
  background: #fff;
  text-decoration: none;
  color: #1b1b1b;
}

.cycle-nav:not(.cycle-nav-disabled):hover,
.cycle-today:hover {
  background: #f0ece4;
}

.cycle-nav-disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

.cycle-select {
  min-width: 140px;
}

.detail-links {
  display: flex;
  gap: 16px;
  color: #1f6feb;
  font-weight: 600;
  margin-bottom: 8px;
}

.table-wrap {
  overflow-x: auto;
}

.detail-table th,
.detail-table td {
  border-bottom: 1px solid #eee;
  padding: 4px 8px;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1.3;
}

.budget-table {
  width: 100%;
  border-collapse: collapse;
}

.budget-table th,
.budget-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #eee;
  border-right: 1px solid #eee;
}

.budget-table th:last-child,
.budget-table td:last-child {
  border-right: none;
}

.detail-table th:last-child,
.detail-table td:last-child {
  border-right: none;
}

.detail-table thead th {
  background: #fbf5ea;
}

.filter-row th {
  background: #fff;
}

.amount-negative {
  color: #c0392b;
  font-weight: 700;
}

.amount-income {
  color: #1f6feb;
  font-weight: 700;
}

.delete-cell {
  text-align: center;
}

/* ── 旧 row-edit / row-save / row-delete (予算セクションで使用) ── */
.row-save,
.row-delete {
  padding: 3px 8px;
  font-size: 12px;
  margin: 1px;
}

.row-edit {
  padding: 3px 8px;
  font-size: 12px;
  margin: 1px;
}

.row-save,
.row-delete {
  display: none;
}

.detail-table tr.is-editing .row-save,
.detail-table tr.is-editing .row-delete {
  display: inline-block;
}

/* ── 鉛筆アイコン編集 UI ───────────────────────────────────
   editable-cell: ホバーで右端に ✏ アイコンを表示
   is-cell-editing: 個別セル編集モード（td 単位）
──────────────────────────────────────────────────────── */
.editable-cell {
  position: relative;
}

/* 鉛筆ボタン本体 */
.pencil-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  font-size: 18px;
  line-height: 1;
  background: rgba(255,255,255,0.95);
  border: 1px solid #a8a09a;
  border-radius: 5px;
  cursor: pointer;
  color: #444;
  padding: 2px 7px;
  transition: opacity 0.12s, color 0.12s;
  pointer-events: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

/* セルホバーで鉛筆を表示 */
.editable-cell:hover .pencil-btn {
  opacity: 1;
  pointer-events: auto;
}
.pencil-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: #eef3ff;
}

/* 編集中は鉛筆を非表示 */
.editable-cell.is-cell-editing .pencil-btn {
  display: none;
}


.budget-input,
.budget-save {
  display: none;
}

.budget-row.is-editing .budget-input,
.budget-row.is-editing .budget-save {
  display: inline-block;
}

.budget-row.is-editing .budget-display {
  display: none;
}

.budget-low {
  background: #fff3cd;
}

.budget-over {
  background: #f8d7da;
}

.budget-rate {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.budget-over .budget-rate {
  color: #c0392b;
  font-weight: 700;
}

/* ツリー展開ボタン */
.tree-toggle {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  color: #888;
  padding: 0 4px 0 0;
  vertical-align: middle;
}

.tree-toggle:hover {
  color: #333;
}

.tree-toggle-placeholder {
  display: inline-block;
  width: 16px;
}

/* サブカテゴリ行 */
.budget-sub-row td {
  background: #f9f8f6;
  color: #555;
  font-size: 13px;
  padding: 5px 10px;
}

.budget-sub-cat {
  padding-left: 28px !important;
  color: #555;
}

.sub-dash {
  color: #bbb;
}

.empty {
  text-align: center;
  color: #6d6d6d;
}

.cell-input,
.cell-select {
  width: 100%;
  min-width: 100px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #d6d1c8;
  background: #fff;
  font-size: 13px;
}

.amount-input {
  text-align: right;
}

.cell-input,
.cell-select {
  display: none;
}

.cell-display {
  display: inline-block;
}

.detail-table td.is-cell-editing .cell-input,
.detail-table td.is-cell-editing .cell-select {
  display: inline-block;
}

.detail-table td.is-cell-editing .cell-display {
  display: none;
}

.sort-icons {
  display: inline-flex;
  flex-direction: column;
  margin-left: 6px;
  vertical-align: middle;
}

.sort-btn,
.budget-sort-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 10px;
  line-height: 10px;
  padding: 0;
  color: #6d6d6d;
}

.sort-btn:hover,
.budget-sort-btn:hover {
  color: #1b1b1b;
}

.small-amount {
  width: 90px;
}

/* ---- 計画出費チェックボックス列 ---- */
.flag-th {
  width: 38px;
  text-align: center;
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
}

.flag-cell {
  text-align: center;
  padding: 0 2px;
}

.flag-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  padding: 2px 3px;
  border-radius: 4px;
  opacity: 0.18;
  transition: opacity 0.12s, transform 0.1s;
  line-height: 1;
}

.flag-btn:hover {
  opacity: 0.55;
}

.flag-btn.is-flagged {
  opacity: 1;
}

tr:has(.flag-btn.is-flagged) td {
  background-color: #fff8f0;
}

.del-cell { width: 30px; text-align: center; }
.del-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 3px;
  opacity: 0.15;
  transition: opacity 0.12s;
  line-height: 1;
}
.del-btn:hover { opacity: 0.7; }

/* 記憶しないボタン */
.no-learn-btn {
  background: none;
  border: none;
  outline: none;
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
  font-family: monospace;
  letter-spacing: -0.03em;
  padding: 0 3px;
  border-radius: 3px;
  color: #e05050;
  transition: color 0.12s;
  line-height: inherit;
  white-space: nowrap;
}
.no-learn-btn:focus, .no-learn-btn:focus-visible {
  outline: none;
  box-shadow: none;
}
.no-learn-btn:hover { color: #c03030; }
.no-learn-btn.is-no-learn {
  color: #bbb;
  text-decoration: line-through;
}
.no-learn-btn.is-no-learn:hover { color: #999; }

/* シミュレーション口座行 */
.sim-acc-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: #f8f6f2;
  border-radius: 6px;
  font-size: 13px;
  flex-wrap: wrap;
}
.sim-acc-label {
  flex: 1;
  min-width: 80px;
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
}

/* シミュレーション 2カラムレイアウト */
.sim-config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 14px;
}
@media (max-width: 680px) {
  .sim-config-grid { grid-template-columns: 1fr; }
}
.sim-col {
  background: #fafaf8;
  border: 1px solid #e8e4dc;
  border-radius: 10px;
  padding: 14px 16px;
}
.sim-col-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--ink);
}
.sim-sub-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 6px;
}

/* 計算式 */
.formula-details {
  margin-top: 18px;
  border-top: 1px solid #eee;
  padding-top: 10px;
}
.formula-details > summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  user-select: none;
}
.formula-box {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
  background: #f8f6f2;
  border-radius: 8px;
}
.formula-section {}
.formula-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 5px;
  border-bottom: 1px solid #e0dbd0;
  padding-bottom: 3px;
}
.formula-line {
  font-size: 12px;
  color: #555;
  line-height: 1.7;
  font-family: "Menlo", "Courier New", monospace;
}

.planned-th {
  width: 44px;
  text-align: center;
  font-size: 11px;
  line-height: 1.2;
}

.planned-cell {
  text-align: center;
}

/* ---- 年間計画テーブル ---- */
.annual-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.annual-table th,
.annual-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #e8e4dc;
  vertical-align: middle;
}

.annual-table th {
  background: #f0ece4;
}

.annual-table .num {
  text-align: right;
}

/* ---- 月別実績テーブル ---- */
.monthly-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.monthly-table th,
.monthly-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #e8e4dc;
}

.monthly-table th {
  background: #f0ece4;
}

.monthly-table .num {
  text-align: right;
}

.total-row td {
  border-top: 2px solid #bbb;
  background: #f7f4ee;
}

/* ---- 金額色 ---- */
.amount-positive {
  color: #1f6feb;
  font-weight: 700;
}

/* ---- 追加フォーム ---- */
.add-form {
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.add-form input,
.add-form select {
  height: 32px;
  font-size: 13px;
}

/* ---- 小ボタン ---- */
.btn-sm {
  padding: 3px 10px;
  font-size: 12px;
}

/* ---- 外部連携 ---- */
.ext-badges {
  display: flex;
  gap: 6px;
  align-items: center;
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.badge-ok   { background: #d4edda; color: #155724; }
.badge-none { background: #e9ecef; color: #6c757d; }
.badge-err  { background: #f8d7da; color: #721c24; }

.ext-actions {
  display: flex;
  gap: 10px;
  margin: 12px 0 8px;
}

.btn-config {
  background: #5a6268;
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
}

.btn-sync {
  background: #1f6feb;
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
}

.sync-last {
  font-size: 13px;
  color: #555;
  margin-bottom: 4px;
  min-height: 22px;
}

.config-panel {
  margin-top: 12px;
  padding: 16px;
  background: #fffaf1;
  border: 1px solid #e6ddcc;
  border-radius: 10px;
}

.config-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 480px;
}

.config-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  color: #444;
}

.config-form input {
  padding: 6px 10px;
  border: 1px solid #d6d1c8;
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
}

.config-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}



/* ---- 外部連携 確認ステータス ---- */
.review-select {
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #d6d1c8;
  font-size: 12px;
  font-weight: 600;
}

.review-unreviewed {
  color: #c0392b;
}

.review-approved,
.review-denied {
  color: #1b1b1b;
}

/* グレーハッチング（取込済・棄却の行） */
.reviewed-row td {
  background: repeating-linear-gradient(
    135deg,
    #f0f0f0,
    #f0f0f0 4px,
    #e0e0e0 4px,
    #e0e0e0 8px
  ) !important;
  color: #888 !important;
}

/* ---- CSVボタン（サブアクション） ---- */
.btn-csv {
  background: #5a6878 !important;
}

/* ---- 認証情報フォーム ---- */
.cred-section {
  margin: 10px 0 4px;
  font-size: 13px;
}

/* ===== 使い方ページ ===== */
.howto-concept p { margin: 0 0 16px; line-height: 1.7; }

.concept-pillars {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.concept-pillar {
  flex: 1;
  min-width: 180px;
  background: #faf8f4;
  border: 1px solid #e8e0d4;
  border-radius: 10px;
  padding: 16px;
}

.pillar-icon { font-size: 28px; margin-bottom: 8px; }
.pillar-title { font-weight: 700; margin-bottom: 6px; }
.pillar-body { font-size: 13px; color: #555; line-height: 1.6; }

.howto-flow { display: flex; flex-direction: column; gap: 0; }

.flow-step {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 16px 0;
  border-bottom: 1px solid #f0ece4;
}

.flow-num {
  min-width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff6b6b, #ff9f1a);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.flow-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 8px;
}

.flow-tab {
  font-size: 11px;
  font-weight: 600;
  background: #e8f0fe;
  color: #1f6feb;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 6px;
  vertical-align: middle;
}

.flow-body p { margin: 0 0 8px; line-height: 1.6; font-size: 14px; }
.flow-body ul { margin: 0 0 8px; padding-left: 20px; font-size: 14px; line-height: 1.8; }

.flow-diagram {
  background: #f6f4ef;
  border: 1px solid #e4dfd5;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  font-family: monospace;
  line-height: 1.8;
  color: #444;
  white-space: pre-wrap;
}

.flow-arrow {
  text-align: center;
  font-size: 20px;
  color: #aaa;
  padding: 4px 0;
}

.howto-table {
  width: 100%;
  border-collapse: collapse;
}

.howto-table th,
.howto-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #eee;
  font-size: 14px;
  text-align: left;
}

.howto-table th {
  background: #fbf5ea;
  font-weight: 700;
  width: 140px;
}

.howto-faq { display: flex; flex-direction: column; gap: 12px; }

.faq-item {
  background: #faf8f4;
  border-radius: 8px;
  padding: 12px 16px;
}

.faq-q {
  font-weight: 700;
  color: #1f6feb;
  margin-bottom: 6px;
  font-size: 14px;
}

.faq-a { font-size: 14px; line-height: 1.7; color: #444; }

/* ===== Dashboard ===== */
.dash-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

/* dash-kpi-grid コンパクト化は 640px ブロックで制御 */

.dash-kpi-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.kpi-positive { border-top: 3px solid #1f6feb; }
.kpi-negative { border-top: 3px solid #c0392b; }

.dash-kpi-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.dash-kpi-value {
  font-size: 26px;
  font-weight: 800;
}

.dash-kpi-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.dash-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
  align-items: start;
}

@media (max-width: 800px) {
  .dash-body { grid-template-columns: 1fr; }
}

.dash-budget-card,
.dash-recent-card {
  margin-bottom: 0;
}

/* Budget bars */
.dash-budget-row {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.dash-budget-cat {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-cat-icon { font-size: 15px; }

.dash-bar-track {
  height: 8px;
  background: #eee;
  border-radius: 4px;
  overflow: hidden;
}

.dash-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.bar-ok   { background: #00cc6a; }
.bar-warn { background: #e67e22; }
.bar-over { background: #c0392b; }
.bar-none { background: #ccc; }

.dash-budget-nums {
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
  color: var(--muted);
}

.dash-actual {
  color: var(--ink);
  font-weight: 600;
}

.dash-budget-limit { color: var(--muted); }

.dash-pct {
  display: inline-block;
  margin-left: 4px;
  font-weight: 700;
  color: #555;
}

.pct-over { color: #c0392b; }

/* Recent transactions */
.dash-txn-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.dash-txn-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid #f0ece4;
}

.dash-txn-item:last-child { border-bottom: none; }

.dash-txn-date {
  font-size: 12px;
  color: var(--muted);
  min-width: 38px;
}

.dash-txn-info {
  flex: 1;
  min-width: 0;
}

.dash-txn-desc {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-txn-cat {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.dash-txn-amount {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.dash-more-link {
  display: block;
  margin-top: 12px;
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  text-align: right;
}

.dash-more-link:hover { text-decoration: underline; }

/* Surplus / Annual plan */
.dash-surplus-row {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.dash-surplus-main {
  min-width: 180px;
}

.dash-surplus-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.dash-surplus-value {
  font-size: 32px;
  font-weight: 800;
}

.dash-annual-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 24px;
}

.dash-annual-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dash-annual-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dash-annual-val {
  font-size: 18px;
  font-weight: 700;
}

.dash-annual-empty { flex: 1; }

/* ── 外部連携 3カテゴリ折りたたみ ──────────────────────────────
   色の階層（ウォームベージュ系で統一）:
   ページ背景  : #f6f4ef
   カテゴリ枠  : #e8e2d8  ← はっきり暗い
   ソースパネル: #ffffff  ← 白カードで最大コントラスト
   テーブル行  : #fff / #f8f4ef（縞）
─────────────────────────────────────────────────────────── */
.ext-category {
  margin-bottom: 20px;
  border: 2px solid #b8b0a4;          /* 太め・はっきり見える暖色ボーダー */
  border-radius: 10px;
  overflow: hidden;
  background: #ede8e0;                /* カテゴリ全体背景：ページより明確に暗い */
}
.ext-category > summary {
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  padding: 11px 16px;
  background: #e0d9cf;                /* サマリーはさらに一段暗い暖色 */
  list-style: none;
  user-select: none;
  border-bottom: 2px solid #b8b0a4;
}
.ext-category > summary::-webkit-details-marker { display: none; }
.ext-category:not([open]) > summary { border-bottom: none; }
.ext-category > summary::before {
  content: "▶ ";
  font-size: 11px;
  color: #6d6050;
  margin-right: 4px;
}
.ext-category[open] > summary::before { content: "▼ "; }

/* カテゴリ内コンテンツ領域のパディング */
.ext-category > *:not(summary) {
  margin: 10px 12px 10px 16px;
}

.ext-source {
  margin: 8px 12px 8px 16px;
  border: 1px solid #c4bcb2;          /* ソース枠：カテゴリ枠と色調を合わせつつ細め */
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;                /* 白カード — カテゴリ背景と明確に区別 */
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}
.ext-source > summary {
  cursor: pointer;
  font-weight: 600;
  padding: 9px 14px;
  background: #f5f0e8;                /* ソースヘッダ：白カードの中の薄暖ベージュ */
  list-style: none;
  user-select: none;
  border-bottom: 1px solid #ddd7cc;
}
.ext-source > summary::-webkit-details-marker { display: none; }
.ext-source:not([open]) > summary { border-bottom: none; }
.ext-source > *:not(summary) { padding: 10px 14px; }

/* ソースパネル内テーブルの行縞と罫線を強化 */
.ext-source .detail-table {
  border-collapse: collapse;
  width: 100%;
}
.ext-source .detail-table th,
.ext-source .detail-table td {
  border-bottom: 1px solid #ddd7cc;   /* 温かみのある罫線 */
  border-right: 1px solid #e8e2d8;
}
.ext-source .detail-table thead th {
  background: #f0e6d6;                /* 既存ウォームヘッダ色を維持 */
}
.ext-source .detail-table tbody tr:nth-child(even):not(.reviewed-row) td {
  background: #faf6f0;                /* 偶数行に薄いベージュ縞 */
}
.ext-source .detail-table tbody tr:hover:not(.reviewed-row) td {
  background: #f3ede4;
}

.cat-count {
  background: #c8c0b4;                /* バッジも暖色系でくっきり */
  color: #3a3028;
  border-radius: 12px;
  padding: 1px 8px;
  font-size: 12px;
  margin-left: 6px;
  font-weight: 600;
}
.cat-placeholder {
  color: var(--muted);
  font-style: italic;
  padding: 12px 8px;
  margin: 0;
}

/* ── 外部連携 サマリー行（MoneyForward風）── */
.ext-source-summary {
  display: flex !important;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.ext-source-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.ext-source-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}
.ext-source-sub {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
  white-space: nowrap;
}
.ext-source-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.ext-sync-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  white-space: nowrap;
}
.ext-sync-badge.sync-ok   { background: #e8f5ee; color: #1e7e44; }
.ext-sync-badge.sync-err  { background: #fdecea; color: #a93226; }
.ext-sync-badge.sync-none { background: #f0f0f0; color: var(--muted); }
.ext-balance {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

/* テーブルソート */
.sort-th {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.sort-th:hover {
  background: #e8edf2;
}
.sort-arrow {
  font-size: 11px;
  color: var(--accent);
  margin-left: 2px;
}

/* 資産・ローン 時系列グラフ */
.snap-chart-wrap {
  margin-top: 16px;
  background: var(--card);
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 12px 16px;
  max-width: 640px;
}

/* 分析パネル */
/* NISA投信カード */
.nisa-cards-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 8px;
}
.nisa-card {
  background: #f8f9fb;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 12px 16px;
  min-width: 280px;
  flex: 1;
}
.nisa-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
  line-height: 1.4;
}

.analysis-panel {
  margin-top: 20px;
  padding: 16px;
  background: #f8f9fb;
  border: 1px solid #dde1e7;
  border-radius: 10px;
}
.analysis-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.analysis-title {
  font-weight: 700;
  font-size: 14px;
}
.analysis-config-form {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 12px;
}
.loan-kpi-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 8px 0;
}
.loan-kpi {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 10px 16px;
  min-width: 120px;
  text-align: center;
}
.kpi-label {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}
.kpi-val {
  font-size: 16px;
  font-weight: 700;
}
.kpi-val.red   { color: #c0392b; }
.kpi-val.green { color: #27ae60; }

/* 2FA QR 表示ボックス */
.twofa-waiting {
  padding: 14px 16px;
  background: #edf4ff;
  border: 1px solid #90b8e8;
  border-radius: 8px;
  margin: 8px 0;
}
.twofa-waiting p {
  margin: 0 0 10px;
  font-weight: 600;
  color: #1a4a8a;
}
.twofa-qr {
  display: block;
  max-width: 100%;
  width: auto;
  height: auto;
  min-width: 120px;
  margin-bottom: 10px;
  border: 2px solid #90b8e8;
  border-radius: 4px;
  image-rendering: pixelated;
}
.twofa-note {
  font-size: 12px;
  color: #666;
  font-weight: 400 !important;
  margin: 4px 0 12px !important;
}

/* ── 資産タブ ── */
.profile-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 0 12px;
  border-bottom: 1px solid #e4dfd5;
  margin-bottom: 12px;
}
.profile-bar-label {
  font-size: 16px;
  font-weight: 700;
  margin-right: 4px;
}
.profile-select-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}
.profile-select {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #ccc;
  font-size: 14px;
}
.asset-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 2px solid #e4dfd5;
  padding-bottom: 0;
}
.asset-tab {
  padding: 8px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
.asset-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.asset-tab:hover:not(.active) { color: var(--ink); }

/* ── 資産ページ KPI グリッド ── */
.asset-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.asset-kpi-card {
  background: var(--card);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.07);
  border-top: 4px solid #ccc;
}
.kpi-asset { border-top-color: #27ae60; }
.kpi-liab  { border-top-color: #c0392b; }
.kpi-net   { border-top-color: #1f6feb; }
.asset-kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.asset-kpi-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--ink);
  margin-bottom: 6px;
}
.asset-kpi-trend {
  font-size: 12px;
  color: var(--muted);
  min-height: 16px;
}

/* 前月比バッジ: 支出増=赤(悪い), 支出減=青(良い) */
.pct-up   { color: #c0392b; font-weight: 700; }
.pct-down { color: #2980b9; font-weight: 700; }
.pct-zero { color: var(--muted); }
.pct-na   { color: #bbb; }

/* ── 資産グラフセクション ── */
.asset-chart-section {
  margin-bottom: 16px;
  padding: 16px 20px 20px;
}
.asset-chart-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eee;
}
.asset-chart-wrap {
  position: relative;
  max-width: 100%;
}

/* 月次テーブル */
.asset-monthly-table td { font-size: 13px; }
.asset-monthly-table td:first-child { font-weight: 600; white-space: nowrap; }

/* 注釈 */
.asset-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

/* ── 家計簿 / 外部連携 モバイルカードリスト（PC 非表示・スマホ表示）── */
.txn-card-list { display: none; }
.ext-card-list  { display: none; }

/* 外部連携カード: メタ行（カテゴリ・日付 + ステータスselect を横並び） */
.ext-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  overflow: visible;   /* .txn-card-meta の overflow:hidden を上書き（select がクリップされる対策） */
  white-space: normal; /* 同上 */
}
.ext-card-meta > span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ext-card-status {
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 4px;
  border: 1px solid #ccc;
  background: #fff;
  color: #333;
  cursor: pointer;
  min-height: 0 !important;
  flex-shrink: 0;
  white-space: nowrap;
}
.ext-card-status.status-unreviewed { border-color: #e74c3c; color: #c0392b; font-weight: 700; }
.ext-card-status.status-denied     { border-color: #aaa;   color: #888; }
.ext-card-reviewed { opacity: 0.65; }

/* 外部連携 メタバー（同期状態 + 認証情報 1行） */
.ext-meta-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 6px 14px;
  font-size: 12px;
  border-bottom: 1px solid #f0ede7;
}
.sync-last-date { color: var(--muted); font-size: 11px; }

.date-group { border-top: 1px solid #e8e4de; }
.date-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 14px 5px;
  background: var(--bg);
}
.date-group-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.03em;
}
.date-group-total {
  font-size: 13px;
  font-weight: 700;
}
.txn-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 14px;
  background: var(--card);
  border-bottom: 1px solid #f0ede7;
  cursor: default;
  transition: background 0.1s;
}
.txn-card:active { background: #f5f3ef; }
.txn-card-flagged { background: #fffbf0 !important; }
.icon-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #eef0f4;
  font-size: 19px;
  flex-shrink: 0;
}
.circle-income { background: #edfbf3; }
.txn-card-body { flex: 1; min-width: 0; }
.txn-card-desc {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.txn-card-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.txn-flag-icon { font-size: 11px; margin-right: 2px; }
.txn-card-amount {
  flex-shrink: 0;
  font-size: 15px;
  font-weight: 700;
  text-align: right;
  min-width: 72px;
}
.txn-card-empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--muted);
  font-size: 14px;
}

/* ── ログインページ ─────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-box {
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.10);
  padding: 40px 36px 36px;
  width: 100%;
  max-width: 360px;
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.login-brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}
.login-error {
  background: #fdecea;
  color: #a93226;
  border: 1px solid #f5aca6;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 14px;
  margin-bottom: 16px;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.login-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.login-input {
  padding: 10px 12px;
  border: 1px solid #d0cec8;
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}
.login-input:focus { border-color: var(--accent); }
.login-btn {
  padding: 11px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s;
}
.login-btn:hover { filter: brightness(1.1); }

/* ── ナビ ログアウト ────────────────────────────── */
.nav-logout {
  margin-left: auto;
  color: var(--muted) !important;
  font-size: 13px;
}
.nav-logout:hover { color: #c0392b !important; }

/* ── パスワード変更フォーム ─────────────────────── */
.pw-form { display: flex; flex-direction: column; gap: 14px; max-width: 360px; }
.pw-label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--muted); }
.pw-input { padding: 8px 10px; border: 1px solid #d0cec8; border-radius: 6px; font-size: 14px; }
.pw-input:focus { outline: none; border-color: var(--accent); }

/* ═══════════════════════════════════════════════════════
   スマホ対応 (max-width: 640px)
   ═══════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  /* ナビ: 横スクロール */
  .nav {
    padding: 0 8px;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a, .nav-logout {
    white-space: nowrap;
    font-size: 13px;
    padding: 12px 10px;
  }

  /* コンテナ */
  .container { padding: 10px 8px; }

  /* カード */
  .card { padding: 14px 12px; }

  /* KPIグリッド: 縦積み */
  .kpi-grid {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }

  /* 月次収支: 1行コンパクト */
  .summary-row {
    display: flex !important;
    padding: 8px 10px;
    gap: 0;
  }
  .summary-op { display: none; }
  .summary-cell {
    flex: 1;
    text-align: center;
    padding: 2px 6px;
  }
  .summary-cell + .summary-cell { border-left: 1px solid #e0d8ce; }
  .summary-label { font-size: 10px; margin-bottom: 3px; }
  .summary-value { font-size: 15px; }

  /* ダッシュボード KPI: 3列コンパクト */
  .dash-kpi-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 6px;
  }
  .dash-kpi-card { padding: 10px 8px; }
  .dash-kpi-label { font-size: 10px; margin-bottom: 4px; letter-spacing: 0; }
  .dash-kpi-value { font-size: 16px; }
  .dash-kpi-sub   { font-size: 9px; }

  /* ダッシュボード detail-header */
  .detail-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  /* テーブル: 横スクロール (block化せずラッパーで制御) */
  .table-wrap,
  .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  /* ページ全体の横はみ出しを防ぐ */
  body { overflow-x: hidden; }
  .container, .card { max-width: 100%; box-sizing: border-box; }

  /* ボタン・入力: タッチしやすいサイズ */
  input[type="text"],
  input[type="date"],
  input[type="number"],
  input[type="password"],
  input[type="email"],
  select:not(.ext-card-status),
  textarea {
    font-size: 16px !important; /* iOS zoom 防止 */
    min-height: 40px;
  }
  /* カード内ステータスselectは小さく保つ */
  .ext-card-status { font-size: 10px !important; min-height: 0 !important; padding: 2px 4px; }
  button, .btn {
    min-height: 40px;
    font-size: 14px;
  }

  /* ══════════════════════════════════════════
     外部連携ページ
  ══════════════════════════════════════════ */
  /* カテゴリ折りたたみ */
  .ext-category { margin-bottom: 10px; }
  .ext-category > summary { font-size: 14px; padding: 8px 10px; }
  .ext-source { margin-left: 8px; }

  /* サイクルバー: コンパクト2行（ナビ+今月 / セレクト全幅） */
  .cycle-bar { gap: 6px; }
  .cycle-range { font-size: 13px; font-weight: 700; }
  .cycle-nav, .cycle-today { padding: 4px 8px; font-size: 13px; }
  .cycle-select { flex: 1 1 100%; min-width: 0; font-size: 14px !important; min-height: 36px; }

  /* ext-meta-bar: よりコンパクトに */
  .ext-meta-bar { padding: 4px 12px; gap: 6px 12px; font-size: 11px; }
  .cred-section { font-size: 11px; }

  /* 認証情報フォーム: 縦積み・全幅 */
  .cred-form .row {
    flex-direction: column;
    gap: 8px;
  }
  .cred-form .row label,
  .cred-form .row input {
    width: 100% !important;
    box-sizing: border-box;
  }

  /* 同期ボタン: 全幅 */
  .btn-sync { width: 100%; box-sizing: border-box; }
  .ext-actions { margin-top: 8px; gap: 6px; }

  /* ローン・投資KPIカード: 2列グリッド */
  .loan-kpi-row {
    flex-wrap: wrap;
    gap: 8px;
  }
  .loan-kpi {
    flex: 1 1 calc(50% - 8px);
    min-width: 120px;
  }

  /* 分析設定フォーム: 縦積み */
  .analysis-config-form .row {
    flex-direction: column;
    gap: 8px;
  }
  .analysis-config-form .row > label,
  .analysis-config-form .row > input,
  .analysis-config-form .row > button {
    width: 100% !important;
    box-sizing: border-box;
  }

  /* ══════════════════════════════════════════
     家計簿ページ
  ══════════════════════════════════════════ */
  /* 取引追加フォーム: 2列グリッドで折り返し */
  form.row {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  form.row input[name="description"],
  form.row input[name="memo"] {
    grid-column: 1 / -1; /* 内容・メモは全幅 */
  }
  form.row button[type="submit"] {
    grid-column: 1 / -1;
    width: 100%;
  }

  /* 明細テーブル: スマホでは列を間引く
     表示列: 日付(3), 内容(4), 金額(5), 大項目(7), 中項目(8)
     非表示: 🚩(1), 計画(2), 保存機関(6), メモ(9), アクション列はそのまま */
  .txn-table .flag-th,
  .txn-table td.flag-cell,
  .txn-table .planned-th,
  .txn-table td.planned-cell,
  .txn-table th:nth-child(6),
  .txn-table td:nth-child(6),
  .txn-table th:nth-child(9),
  .txn-table td:nth-child(9) { display: none; }

  /* filter-row の同列も非表示 */
  .txn-table .filter-row th:nth-child(1),
  .txn-table .filter-row th:nth-child(2),
  .txn-table .filter-row th:nth-child(6),
  .txn-table .filter-row th:nth-child(9) { display: none; }

  /* 家計簿: テーブル非表示 → カードリスト表示 */
  .txn-table-wrap { display: none !important; }
  .txn-card-list  { display: block; }
  .txn-card-list .date-group:first-child { border-top: none; }

  /* 外部連携: テーブル非表示 → カードリスト表示 */
  .ext-table-wrap { display: none !important; }
  .ext-card-list  { display: block; }
  .ext-card-list .date-group:first-child { border-top: none; }

  /* 予算テーブル: 圧縮 */
  .budget-table { font-size: 12px; }
  .budget-table th, .budget-table td { padding: 5px 4px; }

  /* ══════════════════════════════════════════
     資産・その他ページ
  ══════════════════════════════════════════ */
  /* 資産タブ */
  .asset-kpi-grid { grid-template-columns: 1fr 1fr !important; gap: 10px; }
  .kpi-net { grid-column: 1 / -1; }
  .asset-kpi-value { font-size: 20px; }
  .asset-chart-section { padding: 12px 12px 16px; }

  /* 手動登録フォーム */
  .add-form {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .add-form input[id="f-label"],
  .add-form input[id="f-memo"],
  .add-form button[type="submit"] {
    grid-column: 1 / -1;
  }

  /* 年間計画プロファイルバー */
  .profile-bar { flex-wrap: wrap; gap: 6px; }
  .profile-bar select { min-width: 0; flex: 1 1 140px; }

  /* ログインカード */
  .login-card { padding: 24px 16px; }

  /* h1サイズ */
  h1 { font-size: 20px; }
  h2 { font-size: 16px; }
}

/* ── パレートグラフ 期間ボタン ── */
.pareto-period-btn {
  padding: 3px 10px;
  font-size: 12px;
  border: 1px solid #ccc;
  border-radius: 12px;
  background: #f4f6f8;
  color: #555;
  cursor: pointer;
}
.pareto-period-btn.active {
  background: #0077cc;
  color: #fff;
  border-color: #0077cc;
  font-weight: 600;
}

/* ── 取込済・棄却を非表示トグル ── */
.hide-reviewed-toggle {
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 4px;
}
.hide-reviewed-toggle input[type="checkbox"] {
  cursor: pointer;
}
.hide-reviewed .reviewed-row { display: none !important; }
.hide-reviewed .ext-card-reviewed { display: none !important; }

/* ── 経費相殺・経費反映チェックボックス ── */
.expense-offset-label {
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 4px;
}
.expense-offset-label input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--accent);
}
.expense-offset-label span {
  white-space: nowrap;
}

/* ── AI診断・対話 ── */
.ai-status-idle    { color: #888;    font-size: 12px; }
.ai-status-running { color: #0077cc; font-size: 12px; font-weight: 600; }
.ai-status-done    { color: #27ae60; font-size: 12px; font-weight: 600; }
.ai-status-error   { color: #c0392b; font-size: 12px; font-weight: 600; }
.ai-run-btn {
  background: linear-gradient(135deg, #00b4a0, #0077cc);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.ai-run-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ai-toggle-btn {
  background: #f4f6f8;
  color: #333;
  border: 1px solid #b8c4d1;
  padding: 5px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.ai-toggle-btn:hover { background: #e8eef4; border-color: #0077cc; color: #0077cc; }
/* "💬 質問する" のように装飾的なボタンはアクセントを効かせる */
#ai-diagnose-followup-toggle {
  background: linear-gradient(135deg, #e3f2fd, #f0f7ff);
  color: #0077cc;
  border-color: #0077cc;
}
#ai-diagnose-followup-toggle:hover {
  background: linear-gradient(135deg, #0077cc, #00b4a0);
  color: #fff;
  border-color: transparent;
}
.ai-empty   { color: #999; font-size: 13px; padding: 8px 0; }
.ai-meta    { color: #888; font-size: 11px; margin-bottom: 6px; }
.ai-summary { font-size: 14px; line-height: 1.6; }
#ai-diagnose-full h1, #ai-diagnose-full h2, #ai-diagnose-full h3 {
  margin: 12px 0 6px; font-weight: 700;
}
#ai-diagnose-full h2 { font-size: 16px; color: #0077cc; }
#ai-diagnose-full h3 { font-size: 14px; color: #555; }
#ai-diagnose-full ul, #ai-diagnose-full ol { margin: 6px 0 6px 22px; }
#ai-diagnose-full li { margin: 3px 0; font-size: 13px; line-height: 1.6; }
#ai-diagnose-full p  { margin: 6px 0; font-size: 13px; line-height: 1.6; }
#ai-diagnose-full code { background: #f4f6f8; padding: 1px 5px; border-radius: 3px; font-size: 12px; }

/* AIチャット */
.ai-chat-container {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 600px; overflow-y: auto;
  padding: 12px; background: #fafafa; border-radius: 6px;
}
.ai-chat-msg {
  padding: 8px 12px; border-radius: 10px; font-size: 13px; line-height: 1.6;
  max-width: 85%;
}
.ai-chat-msg.user      { background: #1f6feb; color: #fff; align-self: flex-end;   border-bottom-right-radius: 2px; }
.ai-chat-msg.assistant { background: #fff;    color: #222; align-self: flex-start; border: 1px solid #ddd; border-bottom-left-radius: 2px; }
.ai-chat-input-row {
  display: flex; gap: 6px; margin-top: 10px;
}
.ai-chat-input {
  flex: 1; padding: 8px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 13px;
  resize: vertical; min-height: 60px;
}
.ai-chat-send {
  background: #0077cc; color: #fff; border: none;
  padding: 8px 16px; border-radius: 6px; font-weight: 600; cursor: pointer;
}
.ai-chat-send:disabled { opacity: 0.5; cursor: not-allowed; }
.ai-sessions-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-wrap: wrap; gap: 6px;
}
.ai-session-item {
  padding: 4px 10px; background: #eef; border-radius: 12px;
  font-size: 12px; cursor: pointer; border: 1px solid #ccd;
}
.ai-session-item.active { background: #0077cc; color: #fff; border-color: #0077cc; }
.ai-session-item .ai-session-del { color: #c33; margin-left: 6px; cursor: pointer; }
.ai-suggest-box {
  margin-top: 8px; padding: 10px; background: #fef9e7; border: 1px solid #f4d03f;
  border-radius: 6px; font-size: 13px;
}
.ai-suggest-box button {
  margin-top: 6px; background: #f39c12; color: #fff;
  border: none; padding: 6px 12px; border-radius: 4px; font-weight: 600; cursor: pointer;
}

/* ── AI長期計画チャット（洗練版） ── */
.ai-chat-card {
  padding: 16px 18px;
}
.ai-card-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 12px;
}
.ai-session-zone {
  background: #fafbfd;
  border: 1px solid #e4e7eb;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 14px;
}
.ai-zone-title {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; font-weight: 600; color: #555;
  margin-bottom: 8px;
}
.ai-zone-count {
  font-size: 11px; color: #888; background: #fff;
  padding: 2px 8px; border-radius: 10px; border: 1px solid #ddd;
}
.ai-sessions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.ai-no-sessions {
  color: #999; font-size: 12px; padding: 16px;
  text-align: center; background: #fff; border: 1px dashed #ccc; border-radius: 6px;
}
.ai-session-card {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid #ddd; border-radius: 8px;
  padding: 8px 10px; cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.ai-session-card:hover { border-color: #0077cc; box-shadow: 0 2px 6px rgba(0,119,204,0.1); }
.ai-session-card.active { background: linear-gradient(135deg, #e3f2fd, #fff); border-color: #0077cc; }
.ai-session-card-icon { font-size: 20px; flex-shrink: 0; }
.ai-session-card-body { flex: 1; min-width: 0; }
.ai-session-card-title {
  font-size: 13px; font-weight: 600; color: #222;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ai-session-card-meta { font-size: 11px; color: #888; margin-top: 2px; }
.ai-session-card-del {
  background: transparent; border: none; color: #c33;
  font-size: 16px; cursor: pointer; padding: 2px 6px;
  border-radius: 50%; line-height: 1;
}
.ai-session-card-del:hover { background: #fee; }

.ai-new-session-bar {
  display: flex; gap: 6px; padding-top: 10px; border-top: 1px dashed #ddd;
}
.ai-topic-select {
  flex: 1; padding: 8px 12px;
  border: 1px solid #ccc; border-radius: 6px;
  font-size: 13px; background: #fff;
}
.ai-new-btn {
  background: linear-gradient(135deg, #00b4a0, #0077cc);
  color: #fff; border: none; padding: 8px 18px;
  border-radius: 6px; font-weight: 600; font-size: 13px; cursor: pointer;
  white-space: nowrap;
}
.ai-new-btn:hover { opacity: 0.92; }

/* チャット領域 */
.ai-chat-area {
  background: #fff; border: 2px solid #0077cc; border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,119,204,0.08);
}
.ai-chat-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: linear-gradient(135deg, #0077cc, #00b4a0);
  color: #fff;
}
.ai-chat-title { font-weight: 600; font-size: 14px; }
.ai-chat-close {
  background: rgba(255,255,255,0.2); border: none; color: #fff;
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
  font-size: 16px; line-height: 1; font-weight: 700;
}
.ai-chat-close:hover { background: rgba(255,255,255,0.35); }

#ai-chat-container.ai-chat-container,
#ai-followup-container.ai-chat-container {
  display: block;
  max-height: 480px; min-height: 200px;
  padding: 14px; background: #f8f9fc;
  overflow-y: auto;
}

/* メッセージ行（アバター+本文） */
.ai-msg-row {
  display: flex; gap: 8px; margin-bottom: 12px;
  align-items: flex-start;
}
.ai-msg-row.user { flex-direction: row-reverse; }
.ai-msg-avatar {
  flex-shrink: 0;
  width: 32px; height: 32px;
  background: #fff; border: 1px solid #ddd; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.ai-msg-row.user .ai-msg-avatar { background: #1f6feb; color: #fff; border: none; }
.ai-msg-body { max-width: calc(100% - 50px); min-width: 0; }
.ai-msg-row.user .ai-msg-body { text-align: right; }
.ai-msg-meta { font-size: 10px; color: #999; margin-bottom: 3px; }
.ai-msg-row.user .ai-msg-meta { text-align: right; }

/* 既存のai-chat-msgを行内で使う */
.ai-msg-row .ai-chat-msg {
  display: inline-block; max-width: 100%;
  text-align: left;
}
.ai-msg-row.user .ai-chat-msg.user {
  background: #1f6feb; color: #fff;
  border-radius: 12px 12px 4px 12px;
}
.ai-msg-row.assistant .ai-chat-msg.assistant {
  background: #fff; border: 1px solid #e0e4e8;
  border-radius: 12px 12px 12px 4px;
}
.ai-msg-row .ai-chat-msg p:first-child { margin-top: 0; }
.ai-msg-row .ai-chat-msg p:last-child { margin-bottom: 0; }
.ai-msg-row .ai-chat-msg h1, .ai-msg-row .ai-chat-msg h2, .ai-msg-row .ai-chat-msg h3 {
  font-size: 14px; margin: 8px 0 4px; color: #0077cc;
}
.ai-msg-row .ai-chat-msg ul, .ai-msg-row .ai-chat-msg ol { margin: 4px 0 4px 20px; }
.ai-msg-row .ai-chat-msg pre, .ai-msg-row .ai-chat-msg code {
  background: #f0f4f8; border-radius: 3px; padding: 1px 4px; font-size: 12px;
}

/* オンボーディング */
.ai-onboard {
  text-align: center; padding: 40px 20px; color: #666;
}

/* 入力エリア */
.ai-chat-input-area {
  padding: 12px 14px; background: #fff; border-top: 1px solid #e4e7eb;
}
.ai-chat-input-pretty {
  width: 100%; box-sizing: border-box;
  padding: 10px 14px; border: 1px solid #ccc; border-radius: 8px;
  font-size: 13px; font-family: inherit; resize: none;
  min-height: 50px; max-height: 200px;
  transition: border-color 0.15s;
}
.ai-chat-input-pretty:focus { outline: none; border-color: #0077cc; }
.ai-chat-footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 8px;
}
.ai-send-btn {
  background: linear-gradient(135deg, #1f6feb, #00b4a0);
  color: #fff; border: none; padding: 8px 20px;
  border-radius: 6px; font-weight: 600; font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
}
.ai-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ai-send-btn:hover:not(:disabled) { opacity: 0.92; }
.ai-send-icon { font-size: 11px; }

/* 起票提案ボックス（リファイン） */
.ai-suggest-box {
  margin: 0 14px 8px; padding: 12px;
  background: linear-gradient(135deg, #fffbe6, #fff7d4);
  border: 1px solid #f4d03f; border-radius: 8px;
  font-size: 13px; line-height: 1.6;
}
.ai-suggest-box > b { display: block; margin-bottom: 4px; color: #b87b00; }
.ai-suggest-box button {
  margin-top: 8px; background: #f39c12; color: #fff;
  border: none; padding: 7px 14px; border-radius: 5px; font-weight: 600;
  cursor: pointer; font-size: 12px;
}
.ai-suggest-box button:hover { background: #e67e22; }

@media (max-width: 720px) {
  .ai-sessions-grid { grid-template-columns: 1fr; }
  .ai-new-session-bar { flex-direction: column; }
  .ai-new-btn { width: 100%; }
}

/* ── フィルタ結果サマリー ── */
.filter-summary {
  margin-top: 8px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #f0f7ff, #fafbfd);
  border: 1px solid #cde0f3;
  border-radius: 8px;
}
.filter-summary-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  font-size: 13px;
}
.filter-summary-label {
  font-weight: 600; color: #0077cc;
  background: #fff; border-radius: 4px;
  padding: 2px 8px; border: 1px solid #cde0f3;
}
.filter-summary-count { color: #666; font-size: 12px; }
.filter-summary-sep   { color: #ccc; }
.filter-summary-item  { color: #555; }
.filter-summary-item b { font-weight: 700; margin-left: 4px; }
