/* ふたり家計簿 — 松葉色のアクセントに、夫＝藍・妻＝紅の2色で立替を見分ける */
:root {
  --bg: #F2F4F3;
  --surface: #FFFFFF;
  --surface-2: #E9EDEB;
  --ink: #18201C;
  --muted: #66716C;
  --line: #DDE3E0;
  --accent: #1E7356;
  --accent-ink: #FFFFFF;
  --accent-soft: #DCEEE6;
  --husband: #2F63C8;
  --husband-soft: #E2EAFA;
  --wife: #C9456A;
  --wife-soft: #F8E3EA;
  --income: #1E7356;
  --income-soft: #DCEEE6;
  --warn: #C9772A;
  --danger: #C23B30;
  --sun: #C9456A;
  --sat: #2F63C8;
  --shadow: 0 1px 2px rgba(20, 40, 30, .06), 0 4px 14px rgba(20, 40, 30, .05);
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Noto Sans CJK JP", "Yu Gothic UI", "Meiryo", sans-serif;
  --tab-h: 58px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121614;
    --surface: #1B211E;
    --surface-2: #252D29;
    --ink: #E7ECE9;
    --muted: #97A29D;
    --line: #2C3531;
    --accent: #4FC29A;
    --accent-ink: #0D1A14;
    --accent-soft: #1D3A2F;
    --husband: #7EA6F2;
    --husband-soft: #1E2B45;
    --wife: #F08AA6;
    --wife-soft: #43222D;
    --income: #4FC29A;
    --income-soft: #1D3A2F;
    --warn: #E8A35E;
    --danger: #F07A70;
    --sun: #F08AA6;
    --sat: #7EA6F2;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select { font: inherit; font-size: 16px; color: var(--ink); }
select { height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 0 10px; width: 100%; min-width: 0; }
select:disabled { opacity: .5; }
input[type="month"] { height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 0 12px; width: 100%; -webkit-appearance: none; appearance: none; }
[hidden] { display: none !important; }
.num, .amt { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); font-weight: 400; }
.center { text-align: center; }

/* ───── 枠 ───── */
#app { min-height: 100%; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; letter-spacing: .02em; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; font-size: 26px; line-height: 1; color: var(--ink); }
.icon-btn:active { background: var(--surface-2); }
.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--wife-soft); color: var(--wife); letter-spacing: .05em; }
.sync { font-size: 11px; color: var(--muted); }

main {
  padding: 4px max(16px, env(safe-area-inset-right)) calc(var(--tab-h) + env(safe-area-inset-bottom, 0px) + 24px) max(16px, env(safe-area-inset-left));
  max-width: 640px; margin: 0 auto;
}
.view { animation: fade .18s ease-out; }
@keyframes fade { from { opacity: .4; } to { opacity: 1; } }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 4px max(8px, env(safe-area-inset-right)) env(safe-area-inset-bottom, 0px) max(8px, env(safe-area-inset-left));
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.tabbar button { height: var(--tab-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: 11px; font-weight: 600; }
.tabbar svg { width: 24px; height: 24px; }
.tabbar button.on { color: var(--accent); }

/* ───── 部品 ───── */
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.card h3 { margin: 0; font-size: 16px; }
.note { margin: 0; color: var(--muted); font-size: 13px; }
.error { color: var(--danger); font-size: 13px; margin: 0; }
.section-title { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .08em; margin: 24px 2px 8px; }
.section-title.flat { margin: 0; }
.primary, .secondary, .danger {
  height: 48px; border-radius: 12px; font-weight: 700; font-size: 16px; width: 100%;
}
.primary { background: var(--accent); color: var(--accent-ink); }
.primary.big { height: 54px; font-size: 17px; }
.primary:active { filter: brightness(.92); }
.primary:disabled { opacity: .5; }
.secondary { background: var(--accent-soft); color: var(--accent); }
.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); }
.danger.armed { background: var(--danger); color: #fff; }
.link-btn { color: var(--accent); font-weight: 600; font-size: 14px; padding: 6px 4px; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input[type="text"], input[type="date"] {
  height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 0 12px; width: 100%;
  -webkit-appearance: none; appearance: none;
}
input[type="date"] { min-width: 0; display: flex; align-items: center; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
input:focus { border-color: var(--accent); outline: none; }

.chip {
  height: 38px; padding: 0 14px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line);
  font-size: 14px; font-weight: 600; white-space: nowrap;
}
.chip.small { height: 46px; padding: 0 12px; border-radius: 12px; font-size: 13px; flex: none; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); padding: 4px; border-radius: 12px; gap: 4px; }
.seg button { height: 42px; border-radius: 9px; font-size: 13px; font-weight: 700; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.seg button[data-payer="husband"].on { background: var(--husband); color: #fff; }
.seg button[data-payer="wife"].on { background: var(--wife); color: #fff; }
.seg button[data-payer="family"].on { background: var(--accent); color: var(--accent-ink); }
.seg.compact { margin: 4px 0 12px; }
.seg.compact button { height: 34px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px) + 16px);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 99px; font-size: 14px; font-weight: 600; z-index: 50;
  box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: calc(100% - 32px); text-align: center;
}

.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center-msg { min-height: 50vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--muted); }

/* ───── はじめに ───── */
.setup { display: flex; flex-direction: column; gap: 14px; padding-top: 8px; }
.card.tip { background: var(--husband-soft); box-shadow: none; }
.card.tip h3 { color: var(--husband); font-size: 15px; }
.card.tip .note { color: var(--ink); }
.setup h2 { margin: 0; font-size: 26px; text-align: center; }
.setup .lead { margin: 0 0 6px; text-align: center; color: var(--muted); }
.setup-mark { display: flex; justify-content: center; margin-top: 12px; }
.setup-mark span { width: 46px; height: 46px; border-radius: 50%; background: var(--husband); opacity: .9; }
.setup-mark span + span { background: var(--wife); margin-left: -14px; mix-blend-mode: multiply; }
@media (prefers-color-scheme: dark) { .setup-mark span + span { mix-blend-mode: screen; } }

/* ───── 入力 ───── */
#txForm { display: flex; flex-direction: column; gap: 16px; }
.edit-banner { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--husband-soft); color: var(--husband); padding: 8px 12px; border-radius: 12px; font-size: 13px; font-weight: 700; }
.amount-field {
  display: flex; align-items: baseline; gap: 6px; background: var(--surface); border-radius: var(--radius); padding: 10px 16px; box-shadow: var(--shadow);
  border: 2px solid transparent;
}
.amount-field:focus-within { border-color: var(--accent); }
.amount-field .yen { font-size: 26px; font-weight: 700; color: var(--muted); }
.amount-field input { border: 0; background: transparent; height: 56px; font-size: 38px; font-weight: 800; padding: 0; text-align: right; font-variant-numeric: tabular-nums; letter-spacing: .01em; width: 100%; min-width: 0; }
.amount-field input:focus { outline: none; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field .label { font-size: 13px; font-weight: 700; color: var(--muted); }
.date-row { display: flex; gap: 8px; }
.date-row input { flex: 1; }
.cat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cat-btn {
  min-height: 56px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 6px 2px;
  font-size: 12px; font-weight: 700; line-height: 1.2; text-align: center; word-break: keep-all; overflow-wrap: anywhere;
}
.cat-btn .ic { color: var(--c); }
.cat-btn.on { background: var(--surface-2); background: color-mix(in srgb, var(--c) 16%, var(--surface)); border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c); }

/* ───── 取引リスト ───── */
.tx-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.tx-list:empty { display: none; }
.tx-item { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-top: 1px solid var(--line); width: 100%; text-align: left; }
.tx-list li:first-child .tx-item { border-top: 0; }
.tx-item:active { background: var(--surface-2); }
.tx-dot { width: 8px; height: 30px; border-radius: 4px; background: var(--c); flex: none; }
.tx-main { flex: 1; min-width: 0; }
.tx-cat { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-cat small { font-weight: 500; color: var(--muted); margin-left: 4px; }
.tx-memo { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-right { text-align: right; flex: none; }
.tx-amt { font-weight: 800; font-size: 15px; font-variant-numeric: tabular-nums; }
.payer-tag { display: inline-block; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 99px; margin-top: 2px; }
.payer-tag.husband { background: var(--husband-soft); color: var(--husband); }
.payer-tag.wife { background: var(--wife-soft); color: var(--wife); }
.payer-tag.family { background: var(--accent-soft); color: var(--accent); }
.ex-tag { font-size: 10px; color: var(--muted); border: 1px dashed var(--line); border-radius: 4px; padding: 0 4px; margin-left: 4px; font-weight: 500; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); background: var(--surface); border-radius: var(--radius); font-size: 14px; }

/* ───── 月ナビ ───── */
.monthnav { display: flex; align-items: center; justify-content: space-between; margin: 0 -6px 8px; }
.month-label { margin: 0; font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.swipe-area { touch-action: pan-y; }
.slide-l { animation: slideL .22s ease-out; }
.slide-r { animation: slideR .22s ease-out; }
@keyframes slideL { from { transform: translateX(28px); opacity: .3; } to { transform: none; opacity: 1; } }
@keyframes slideR { from { transform: translateX(-28px); opacity: .3; } to { transform: none; opacity: 1; } }

/* ───── 家計簿 ───── */
.total-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.total-card .k { font-size: 12px; color: var(--muted); font-weight: 700; letter-spacing: .06em; }
.total-card .v { font-size: 32px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; }
.total-card .diff { font-size: 12px; color: var(--muted); }
.payer-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.payer-box { border-radius: 12px; padding: 10px 8px; background: var(--surface-2); min-width: 0; }
.payer-box .k { font-size: 11px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.payer-box .v { font-size: clamp(13px, 3.9vw, 17px); font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.payer-box.husband { background: var(--husband-soft); color: var(--husband); }
.payer-box.wife { background: var(--wife-soft); color: var(--wife); }
.payer-box.family { background: var(--accent-soft); color: var(--accent); }
.settle { margin-top: 10px; font-size: 13px; color: var(--muted); }
.settle b { color: var(--ink); }

.cat-rows { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.cat-row { border-top: 1px solid var(--line); }
.cat-row:first-child { border-top: 0; }
.cat-row > button { width: 100%; display: grid; grid-template-columns: 10px minmax(0, 1fr) 7.5em 14px; align-items: center; gap: 10px; padding: 12px 14px; text-align: left; }
.cat-row > button:active { background: var(--surface-2); }
.cat-row .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.cat-row .name { font-weight: 700; font-size: 15px; min-width: 0; }
.cat-row .bar { height: 4px; background: var(--surface-2); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.cat-row .bar i { display: block; height: 100%; background: var(--c); border-radius: 2px; }
.cat-row .val { font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.cat-row .val small { display: block; font-size: 11px; font-weight: 600; color: var(--muted); }
.cat-row .chev { color: var(--muted); transition: transform .15s; font-size: 14px; }
.cat-row.open .chev { transform: rotate(90deg); }
.cat-detail { padding: 0 14px 12px 34px; }
.sub-sums { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.sub-sums span { font-size: 12px; background: var(--surface-2); border-radius: 99px; padding: 3px 10px; font-variant-numeric: tabular-nums; }
.cat-detail .tx-list { box-shadow: none; border: 1px solid var(--line); }

/* ───── カレンダー ───── */
.cal-total { display: flex; justify-content: space-between; align-items: baseline; margin: 0 2px 8px; font-size: 13px; color: var(--muted); }
.cal-total b { font-size: 18px; color: var(--ink); font-variant-numeric: tabular-nums; }
.cal { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px 6px; }
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-head div { text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); padding: 2px 0 6px; }
.cal-head div:first-child { color: var(--sun); }
.cal-head div:last-child { color: var(--sat); }
.cal-cell { min-height: 62px; padding: 4px 2px; border-radius: 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.cal-cell .d { font-size: 13px; font-weight: 700; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.cal-cell .s { font-size: 10px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap; letter-spacing: -.02em; }
.cal-cell.sun .d { color: var(--sun); }
.cal-cell.sat .d { color: var(--sat); }
.cal-cell.today .d { background: var(--accent); color: var(--accent-ink); }
.cal-cell.sel { background: var(--accent-soft); }
.cal-cell.blank { visibility: hidden; }
.cal-cell:active { background: var(--surface-2); }
.day-head { display: flex; justify-content: space-between; align-items: center; margin: 20px 2px 8px; }
.day-head h3 { margin: 0; font-size: 15px; }
.day-head .amt { font-weight: 800; }
.add-day { margin-top: 10px; }

/* ───── 推移 ───── */
.chart-box { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 8px 6px; height: 280px; position: relative; }
.chart-box canvas { width: 100% !important; height: 100% !important; }
.check-head { display: flex; align-items: center; gap: 6px; margin: 20px 2px 8px; }
.check-head .section-title { flex: 1; }
.checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.check { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; font-size: 13px; font-weight: 700; min-width: 0; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check .box { width: 18px; height: 18px; border-radius: 5px; border: 2px solid var(--c); flex: none; display: grid; place-items: center; }
.check input:checked + .box { background: var(--c); }
.check input:checked + .box::after { content: ""; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.check .t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check:has(input:focus-visible) { outline: 2px solid var(--accent); }
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.table-wrap table { border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; min-width: 100%; }
.table-wrap th, .table-wrap td { padding: 8px 10px; white-space: nowrap; text-align: right; border-bottom: 1px solid var(--line); }
.table-wrap th:first-child, .table-wrap td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); font-weight: 700; }
.table-wrap thead th { color: var(--muted); font-weight: 700; }
.table-wrap tr.sum td { font-weight: 800; }

/* ───── 設定 ───── */
.settings { display: flex; flex-direction: column; gap: 4px; }
.settings .card { margin-bottom: 4px; }
.invite-box { font-size: 12px; word-break: break-all; background: var(--surface-2); border-radius: 10px; padding: 10px; font-family: ui-monospace, Menlo, monospace; user-select: all; -webkit-user-select: all; }
.btn-row { display: flex; gap: 8px; }
.btn-row > * { flex: 1; }
.name-row { display: grid; grid-template-columns: 84px 1fr; align-items: center; gap: 10px; }
.name-row label { font-size: 13px; font-weight: 700; color: var(--muted); }
.cat-edit { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.cat-edit:first-of-type { border-top: 0; padding-top: 0; }
.cat-edit-head { display: grid; grid-template-columns: 40px 40px minmax(0, 1fr) auto auto auto; gap: 6px; align-items: center; }
.cat-edit-head input[type="color"] { padding: 2px; height: 40px; width: 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.cat-edit-head input[type="text"] { height: 40px; }
.mini { width: 34px; height: 34px; border-radius: 9px; background: var(--surface-2); font-size: 14px; font-weight: 700; color: var(--muted); }
.mini.del { color: var(--danger); }
.mini.armed { background: var(--danger); color: #fff; }
.sub-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sub-chip { display: inline-flex; align-items: center; gap: 2px; height: 30px; padding: 0 4px 0 10px; border-radius: 99px; background: var(--surface-2); font-size: 13px; }
.sub-chip button { width: 24px; height: 24px; border-radius: 50%; color: var(--muted); font-size: 14px; }
.add-sub { display: flex; gap: 6px; }
.add-sub input { height: 36px; font-size: 16px; }
.add-sub button { flex: none; height: 36px; padding: 0 12px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; }
.member { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 14px; padding: 6px 0; border-top: 1px solid var(--line); }
.member:first-of-type { border-top: 0; }
.member small { color: var(--muted); display: block; font-size: 11px; }
.version { text-align: center; color: var(--muted); font-size: 11px; margin-top: 12px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (min-width: 520px) {
  .cat-grid { grid-template-columns: repeat(6, 1fr); }
  .checks { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ───── 1.1 追加：収入・固定費・予算・取込み ───── */
.inc-c { color: var(--income); }
.neg { color: var(--danger); }
.over { color: var(--danger); font-weight: 700; }
.form-top { display: flex; gap: 8px; align-items: stretch; }
.form-top .seg { flex: 1; }
.seg.kind button { height: 38px; }
.seg.kind button[data-type="expense"].on { background: var(--ink); color: var(--bg); }
.seg.kind button[data-type="income"].on { background: var(--income); color: var(--accent-ink); }
.fixed-btn { flex: none; border-radius: 12px; padding: 0 12px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; font-weight: 700; color: var(--accent); }
.fixed-btn[aria-expanded="true"] { background: var(--accent-soft); border-color: var(--accent); }
.fixed-pick { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-top: -6px; }
.fp-head { font-size: 12px; font-weight: 700; padding: 10px 14px 6px; color: var(--ink); }
.fp-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 10px 14px; border-top: 1px solid var(--line); }
.fp-item:active { background: var(--surface-2); }
.fp-name { flex: 1; min-width: 0; font-weight: 700; font-size: 14px; }
.fp-name small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); }
.fp-state { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.fp-item:not(.done) .fp-state { background: var(--wife-soft); color: var(--wife); }
#txForm.is-income .amount-field input, #txForm.is-income .amount-field .yen { color: var(--income); }
.tx-item.inc .tx-amt { color: var(--income); }
.payer-tag.income { background: var(--income-soft); color: var(--income); }
.ex-tag.fx { border-style: solid; color: var(--accent); border-color: var(--accent-soft); }
.day-head .amt small { font-size: 12px; margin-left: 4px; }
.cal-total { gap: 12px; }
.cal-total span:last-child { margin-left: auto; }
.cal-cell .s.inc-c { color: var(--income); }

.io-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.io-row > div { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; border-top: 1px solid var(--line); padding-top: 8px; font-size: 12px; color: var(--muted); font-weight: 700; min-width: 0; }
.io-row b { font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.budget-total { margin-top: 12px; background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.bt-line { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 700; color: var(--muted); }
.bt-line span:last-child { color: var(--ink); font-variant-numeric: tabular-nums; }
.bt-left { font-size: 12px; margin-top: 4px; color: var(--muted); }
.bar.budget { height: 6px; background: var(--bg); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.budget-total .bar.budget i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.budget-total.is-over .bar.budget i { background: var(--danger); }
.cat-row .bar.budget { background: var(--surface-2); }
.cat-row.is-over .bar i { background: var(--danger); }
.cat-row > button:disabled { cursor: default; }
.budget-note { font-size: 12px; color: var(--muted); margin-bottom: 6px; }

.fx-list { gap: 0; }
.fx-list .note { margin-bottom: 10px; }
.fx-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 10px 0; border-bottom: 1px solid var(--line); }
.fx-row:last-of-type { margin-bottom: 12px; }
.fx-main { flex: 1; min-width: 0; }
.fx-main b { display: block; font-size: 14px; }
.fx-main small { font-size: 11px; color: var(--muted); }
.fx-amt { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 14px; white-space: nowrap; }
.fx-form { gap: 16px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-cards { display: grid; gap: 8px; }
.mode-card { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.mode-card b { font-size: 14px; }
.mode-card span { font-size: 12px; color: var(--muted); }
.mode-card.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.mode-card.on span { color: var(--ink); }

.budget-list { display: flex; flex-direction: column; }
.budget-row { display: grid; grid-template-columns: 10px 1fr 9.5em; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.budget-row .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.budget-row .bn { font-weight: 700; font-size: 14px; min-width: 0; }
.bi { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.bi input { height: 38px; text-align: right; font-variant-numeric: tabular-nums; }
.budget-sum { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); font-weight: 700; padding-top: 4px; }
.budget-sum b { color: var(--ink); font-variant-numeric: tabular-nums; }

.file-pick { position: relative; display: grid; place-items: center; height: 56px; border-radius: 12px; border: 2px dashed var(--accent); color: var(--accent); font-weight: 700; background: var(--accent-soft); }
.file-pick input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.table-wrap.flat { box-shadow: none; border: 1px solid var(--line); border-radius: 10px; }
.table-wrap.flat td { text-align: left; font-size: 11px; padding: 6px 8px; max-width: 12em; overflow: hidden; text-overflow: ellipsis; }
.table-wrap.flat tr.th td { font-weight: 700; background: var(--surface-2); }
.table-wrap.flat td:first-child { position: static; }
.colmap { display: grid; grid-template-columns: 1fr; gap: 8px; }
.colmap label { display: grid; grid-template-columns: 9.5em 1fr; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--muted); }
.colmap em { font-style: normal; color: var(--danger); font-size: 10px; }
.colmap select { height: 40px; }
.map-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1.1fr); align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.map-src { min-width: 0; }
.map-src b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-src small { font-size: 11px; color: var(--muted); }
.map-row .arrow { color: var(--muted); }
.map-row select { height: 40px; font-size: 14px; }
.check-line { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-top: 6px; }
.check-line input { width: 18px; height: 18px; accent-color: var(--accent); }
.imp-sum { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.imp-sum > div { background: var(--surface-2); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; }
.imp-sum span { font-size: 11px; color: var(--muted); font-weight: 700; }
.imp-sum b { font-size: 18px; }
.imp-sum small { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.table-wrap tr.inc-row td { color: var(--income); }

/* ───── 1.2 追加：費目アイコン ───── */
.ic { flex: none; display: block; }
.ic-badge { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: var(--c); background: var(--surface-2); background: color-mix(in srgb, var(--c) 16%, var(--surface)); }
.cat-row .ic-badge { width: 28px; height: 28px; }
.cat-row > button { grid-template-columns: 28px minmax(0, 1fr) 7.5em 14px; }
.budget-row { grid-template-columns: 26px 1fr 9.5em; }
.budget-row .ic-badge { width: 26px; height: 26px; }
.cat-btn { gap: 5px; min-height: 64px; }
.icon-pick { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: var(--c); background: var(--surface-2); background: color-mix(in srgb, var(--c) 16%, var(--surface)); border: 1px solid transparent; }
.icon-pick.on { border-color: var(--c); }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px; padding: 8px; background: var(--surface-2); border-radius: 12px; }
.icon-opt { height: 54px; border-radius: 10px; background: var(--surface); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--c); border: 1px solid transparent; min-width: 0; }
.icon-opt span { font-size: 9px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; padding: 0 2px; }
.icon-opt.on { border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c); }
