/* ============================================================
   家計簿モック - スタイル
   ライトテーマ1本。閲覧側がダークでも見え方を変えない。
   ============================================================ */

:root {
  color-scheme: light;

  /* 面 */
  --plane:        #f9f9f7;
  --surface:      #fcfcfb;
  --surface-2:    #f2f1ed;
  --surface-hover:#f4f3ef;

  /* 文字 */
  --text:         #0b0b0b;
  --text-2:       #52514e;
  --text-muted:   #898781;

  /* 罫線 */
  --border:       rgba(11, 11, 11, 0.10);
  --grid:         #e1e0d9;
  --axis:         #c3c2b7;

  /* 系列（収入=青 / 支出=橙） */
  --series-income:  #2a78d6;
  --series-expense: #eb6834;

  /* カテゴリ（固定順） */
  --cat-1: #2a78d6;
  --cat-2: #eb6834;
  --cat-3: #1baf7a;
  --cat-4: #eda100;
  --cat-5: #e87ba4;
  --cat-6: #008300;
  --cat-7: #4a3aa7;
  --cat-8: #e34948;

  /* 状態 */
  --good:     #006300;
  --critical: #d03b3b;
  --warning:  #fab219;

  --radius:   14px;
  --radius-sm: 9px;
  --shadow:   0 1px 2px rgba(11,11,11,.04), 0 8px 24px rgba(11,11,11,.05);
  --shadow-lg:0 12px 48px rgba(11,11,11,.18);
  --font: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--plane);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

.sr-only {
  position: absolute; left: 0; top: 0; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: -999px; top: 8px; z-index: 100;
  background: var(--surface); color: var(--text); padding: 8px 14px; border-radius: 8px;
}
.skip-link:focus { left: 16px; }

/* ── ヘッダー ───────────────────────────── */
.app-header {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: color-mix(in srgb, var(--surface) 93%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  backdrop-filter: blur(18px) saturate(180%);
  border-bottom: 1px solid var(--border);
}
.app-header__inner {
  max-width: 1120px; margin: 0 auto;
  padding: 12px max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px));
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.brand__mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: var(--series-income); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 18px;
}
.brand__name { font-size: 17px; font-weight: 700; letter-spacing: .02em; }
.brand__sub { font-size: 11px; color: var(--text-muted); letter-spacing: .06em; }

.month-nav {
  display: flex; align-items: center; gap: 4px;
  background: var(--surface-2); border-radius: 999px; padding: 4px;
}
.month-nav__label { text-align: center; min-width: 118px; line-height: 1.25; padding: 2px 4px; }
.month-nav__label span { display: block; }
.month-nav__label #monthLabel { font-weight: 650; font-size: 15px; }
.month-nav__range { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.header-actions { display: flex; gap: 8px; align-items: center; }
.btn__ico { display: none; }
.btn--icon { width: 38px; height: 38px; display: grid; place-items: center; padding: 0; font-size: 17px; }

/* ── ボタン ───────────────────────────── */
.btn {
  border: 1px solid transparent; border-radius: 10px; padding: 8px 15px;
  font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, opacity .15s ease;
}
.btn--primary { background: var(--series-income); color: #fff; }
.btn--primary:hover { filter: brightness(1.06); }
.btn--secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn--secondary:hover { background: var(--surface-hover); }
.btn--ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--sm { padding: 5px 12px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.icon-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 0; background: transparent;
  color: var(--text-2); font-size: 19px; line-height: 1; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
:focus-visible { outline: 2px solid var(--series-income); outline-offset: 2px; }

/* ── レイアウト ─────────────────────────── */
.layout { max-width: 1120px; margin: 0 auto; padding: 24px 16px 108px; display: grid; gap: 20px; }
.layout > *, .stat-grid > *, .month-list > * { min-width: 0; }
#yearView, #monthView { display: grid; gap: 20px; }

/* ── サマリー ───────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat--hero { background: linear-gradient(180deg, var(--surface), var(--surface-2)); }
.stat__label {
  font-size: 12.5px; color: var(--text-2); font-weight: 600;
  display: flex; align-items: center; gap: 7px;
}
.stat__value {
  font-size: clamp(20px, 2vw, 27px); font-weight: 700; letter-spacing: -.01em;
  margin-top: 6px; white-space: nowrap;
}
.stat--hero .stat__value { font-size: clamp(24px, 2.4vw, 34px); }
.stat__delta { font-size: 12px; color: var(--text-2); margin-top: 3px; font-variant-numeric: tabular-nums; }
.stat__delta--muted { color: var(--text-muted); }
.stat__sub { font-size: 12px; color: var(--text-2); margin-top: 4px; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.stat__sub b { font-size: 14px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.stat__sub-note { font-size: 11px; color: var(--text-muted); }
.is-up { color: var(--good); font-weight: 650; }
.is-down { color: var(--critical); font-weight: 650; }

.swatch { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.swatch--income { background: var(--series-income); }
.swatch--expense { background: var(--series-expense); }

/* ── カード ───────────────────────────── */
.card {
  position: relative;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px 20px;
}
.card__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card__head--wrap { flex-wrap: wrap; }
.card__title { font-size: 15px; font-weight: 700; display: flex; align-items: baseline; gap: 8px; }
.card__note { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.count { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.hint { font-size: 11.5px; color: var(--text-muted); font-weight: 500; margin-left: 10px; }
.table tbody tr.is-tappable { cursor: pointer; }

/* ── 年収（額面） ─────────────────────── */
.gross { display: grid; gap: 10px; }
.gross--empty { grid-template-columns: 1fr auto; align-items: center; gap: 14px; }
.gross__value { font-size: clamp(26px, 2.6vw, 34px); font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.gross__note { font-size: 12.5px; color: var(--text-2); margin-top: -4px; }
.gross__bar {
  display: flex; height: 12px; border-radius: 6px; overflow: hidden;
  background: repeating-linear-gradient(135deg, var(--surface-2) 0 6px, var(--grid) 6px 12px);
}
.gross__bar-net { display: block; height: 100%; background: var(--series-income); border-radius: 6px 0 0 6px; transition: width .35s ease; }
.gross__bar-proj {
  display: block; height: 100%; transition: width .35s ease;
  background: repeating-linear-gradient(135deg,
    color-mix(in srgb, var(--series-income) 34%, transparent) 0 5px,
    color-mix(in srgb, var(--series-income) 16%, transparent) 5px 10px);
}
.gross__legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.gross__legend li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gross__legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.gross__legend i.is-rest { background: repeating-linear-gradient(135deg, var(--surface-2) 0 3px, var(--axis) 3px 6px); }
.gross__legend i.is-proj { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--series-income) 40%, transparent) 0 3px, transparent 3px 6px); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--series-income) 40%, transparent); }
.gross__legend b { margin-left: auto; color: var(--text); font-variant-numeric: tabular-nums; }
.gross__legend small { color: var(--text-muted); width: 72px; text-align: right; }
.gross__kpi {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 4px 0 0;
  padding-top: 14px; border-top: 1px solid var(--grid);
}
.gross__kpi > div { display: grid; gap: 1px; min-width: 0; }
.gross__kpi dt { font-size: 12px; color: var(--text-2); font-weight: 600; }
.gross__kpi dd { margin: 0; font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gross__kpi-note { font-size: 11px !important; font-weight: 500 !important; color: var(--text-muted); white-space: normal !important; }
.gross__foot { font-size: 11.5px; color: var(--text-muted); }

/* ── 月ごとのサマリーカード ───────────────── */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 2px 12px; flex-wrap: wrap; }
.section-title { font-size: 15px; font-weight: 700; }
.section-note { font-size: 12px; color: var(--text-muted); }

.month-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); }
.mcard {
  display: grid; gap: 9px; text-align: left; cursor: pointer; font: inherit; color: inherit;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
  transition: transform .12s ease, border-color .15s ease;
}
.mcard:hover { border-color: var(--axis); transform: translateY(-1px); }
.mcard:active { transform: none; }
.mcard.is-current { border-color: var(--series-income); }
.mcard--empty {
  background: transparent; box-shadow: none; border-style: dashed; color: var(--text-muted);
  display: flex; align-items: center; justify-content: space-between; padding: 12px 16px;
}
.mcard--empty:hover { transform: none; }
.mcard--empty { align-self: start; }
.mcard__head { display: flex; align-items: center; gap: 8px; }
.mcard__month { font-weight: 700; font-size: 15px; }
.badge { font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: var(--series-income); color: #fff; }
.mcard__count { margin-left: auto; font-size: 11.5px; color: var(--text-muted); }
.mcard__net { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mcard__bars { display: grid; gap: 3px; }
.mcard__bar { display: block; height: 6px; background: var(--surface-2); border-radius: 0 4px 4px 0; overflow: hidden; }
.mcard__bar i { display: block; height: 100%; border-radius: 0 3px 3px 0; min-width: 2px; }
.mcard__nums { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; font-size: 12px; color: var(--text-2); }
.mcard__nums span { display: flex; align-items: center; gap: 6px; }
.mcard__nums b { text-align: right; font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; }
.mcard__none { font-size: 12.5px; }

.legend { display: flex; gap: 14px; list-style: none; margin: 0; padding: 0; font-size: 12px; color: var(--text-2); }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend__mark { width: 10px; height: 10px; border-radius: 3px; }

/* ── 内訳リスト（カテゴリ別 / 店・項目別） ── */
.bd-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bd-list { display: grid; gap: 4px; }
.bd-row {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 10px;
  width: 100%; text-align: left; font: inherit; color: inherit;
  background: transparent; border: 0; padding: 7px 6px; border-radius: 9px;
}
button.bd-row { cursor: pointer; }
button.bd-row:hover { background: var(--surface-2); }
.bd-row__name { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; font-weight: 600; color: var(--text-2); }
.bd-row__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-row__dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.bd-row__sub { font-size: 11.5px; font-weight: 500; color: var(--text-muted); white-space: nowrap; }
.bd-row__val { font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bd-row__val small { color: var(--text-muted); font-weight: 500; margin-left: 6px; }
.bd-row__track { grid-column: 1 / -1; display: block; height: 9px; background: var(--surface-2); border-radius: 0 5px 5px 0; overflow: hidden; }
.bd-row__bar { display: block; height: 100%; border-radius: 0 4px 4px 0; min-width: 3px; transition: width .35s ease; }
.bd-row:hover .bd-row__bar { filter: brightness(1.1); }
.bd-more {
  margin-top: 10px; width: 100%; padding: 9px; border-radius: 10px; cursor: pointer;
  border: 1px dashed var(--axis); background: transparent; color: var(--text-2); font-size: 13px; font-weight: 600;
}
.bd-more:hover { background: var(--surface-2); color: var(--text); }

/* ── 月次推移 ───────────────────────────── */
.trend { position: relative; }
.trend svg { display: block; width: 100%; height: auto; overflow: visible; }
.trend__tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); padding: 9px 12px; font-size: 12px; min-width: 132px;
  transform: translate(-50%, 0); opacity: 0; transition: opacity .12s ease;
}
.trend__tip.is-on { opacity: 1; }
.trend__tip dl { margin: 0; display: grid; grid-template-columns: auto auto; gap: 2px 12px; }
.trend__tip dt { color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.trend__tip dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; }
.trend__tip h4 { margin: 0 0 6px; font-size: 12px; font-weight: 700; }
.tip__mark { width: 8px; height: 8px; border-radius: 2px; }

/* ── テーブル ───────────────────────────── */
.card--table { padding-bottom: 8px; }
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 2px; }
.seg__btn {
  border: 0; background: transparent; color: var(--text-2); cursor: pointer;
  padding: 5px 13px; border-radius: 7px; font-size: 13px; font-weight: 600;
}
.seg__btn.is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg--modal { margin-bottom: 18px; }

.input {
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  padding: 8px 12px; font-size: 14px;
  width: 100%; min-width: 0; max-width: 100%;
}
/* iOSのSafariは日付・月の入力欄が固有幅を持ち、器より広がって横スクロールを生む。
   見た目を自前のスタイルに寄せて、幅を器に合わせる。 */
input[type="date"], input[type="month"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%; min-width: 0; max-width: 100%;
}
.input--search { width: 210px; background: var(--surface-2); }
.input::placeholder { color: var(--text-muted); }

.table-wrap { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 11.5px; font-weight: 650; color: var(--text-muted);
  letter-spacing: .04em; padding: 6px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap;
}
.table td { padding: 11px 10px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-hover); }
.c-date { width: 88px; }
.c-title { min-width: 0; }
.c-cat  { width: 122px; }
.c-src  { width: 96px; }
.c-amt  { width: 128px; text-align: right; }
.c-act  { width: 44px; }
.c-chk  { width: 40px; }
.table td.c-date, .table td.c-amt { font-variant-numeric: tabular-nums; }
.table td.c-amt { text-align: right; font-weight: 650; }
.amt--income { color: var(--good); }
.tx-title { font-weight: 600; }
.tx-memo { font-size: 12px; color: var(--text-muted); }

.tag {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text-2);
  white-space: nowrap;
}
.tag__dot { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.src {
  font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 2px 7px; border-radius: 5px;
  border: 1px solid var(--border); color: var(--text-2); background: var(--surface-2);
}
.row-del {
  border: 0; background: transparent; color: var(--text-muted); cursor: pointer;
  font-size: 15px; padding: 2px 6px; border-radius: 6px; opacity: 0;
}
tr:hover .row-del, .row-del:focus-visible { opacity: 1; }
.row-del:hover { color: var(--critical); background: var(--surface-2); }

.empty { text-align: center; color: var(--text-muted); font-size: 13.5px; padding: 40px 16px; }

.foot .is-warn { color: var(--critical); font-weight: 600; }
.foot {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  color: var(--text-muted); font-size: 12px; padding: 4px 4px 0;
}

/* ── 新規登録モーダル内の一括取り込み導線 ── */
.entry-alt {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 0 0 18px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
}
.entry-alt__title { font-size: 13.5px; font-weight: 650; }
.entry-alt__note { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── 取り込み履歴 ─────────────────────── */
.imp-history { margin-top: 18px; border-top: 1px solid var(--grid); padding-top: 14px; }
.imp-history__title { font-size: 12.5px; font-weight: 700; color: var(--text-2); margin: 0 0 6px; }
.imp-history__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.imp { display: flex; align-items: center; gap: 12px; padding: 8px 2px; border-bottom: 1px solid var(--grid); }
.imp:last-child { border-bottom: 0; }
.imp__main { display: grid; gap: 1px; min-width: 0; }
.imp__name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp__meta { font-size: 11.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.imp__undo {
  margin-left: auto; border: 1px solid var(--border); background: transparent; color: var(--text-2);
  border-radius: 8px; padding: 5px 11px; font-size: 12.5px; cursor: pointer; white-space: nowrap;
}
.imp__undo:hover { background: color-mix(in srgb, var(--critical) 10%, transparent); color: var(--critical); }

/* ── カテゴリ管理 ─────────────────────── */
.cat-manage { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 2px; max-height: 46vh; overflow-y: auto; }
.cm { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--grid); }
.cm:last-child { border-bottom: 0; }
.cm__dot { width: 11px; height: 11px; border-radius: 4px; }
.cm__main { min-width: 0; display: grid; gap: 2px; }
.cm__name { font-weight: 650; font-size: 14px; display: flex; align-items: baseline; gap: 8px; }
.cm__use { font-size: 11px; font-weight: 500; color: var(--text-muted); }
.cm__kw { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm__nokw { color: var(--text-muted); }
.cm__ops { display: flex; gap: 4px; align-items: center; }
.cm__op {
  border: 1px solid var(--border); background: transparent; color: var(--text-2);
  border-radius: 8px; min-width: 32px; height: 32px; padding: 0 8px; font-size: 13px; cursor: pointer;
}
.cm__op:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.cm__op:disabled { opacity: .3; cursor: not-allowed; }
.cm__op--edit { font-size: 12.5px; }

.swatch-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch-opt {
  width: 30px; height: 30px; border-radius: 9px; cursor: pointer;
  border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
}
.swatch-opt.is-on { border-color: var(--text); }
.field__help { font-size: 11.5px; color: var(--text-muted); }
textarea.input { resize: vertical; font-family: inherit; line-height: 1.5; }
.check--learn { margin-top: 12px; display: flex; gap: 8px; align-items: flex-start; line-height: 1.5; }

/* ── これからの計上予定 ─────────────────── */
.upcoming {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: color-mix(in srgb, var(--cat-7) 9%, var(--surface));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 11px 16px; font-size: 13px; color: var(--text-2);
}
.upcoming b { color: var(--text); font-variant-numeric: tabular-nums; }
.upcoming__tag {
  font-size: 11px; font-weight: 700; letter-spacing: .03em; white-space: nowrap;
  padding: 3px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--cat-7) 20%, var(--surface)); color: var(--text);
}
.upcoming__sum { margin-left: auto; font-variant-numeric: tabular-nums; }

/* ── 固定費リスト ─────────────────────── */
.fixed-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.fx {
  display: grid; grid-template-columns: 74px 1fr auto auto; align-items: center; gap: 10px;
  padding: 11px 4px; border-bottom: 1px solid var(--grid);
}
.fx:last-child { border-bottom: 0; }
.fx__day {
  font-size: 11.5px; color: var(--text-2); background: var(--surface-2);
  border-radius: 7px; padding: 4px 8px; text-align: center; white-space: nowrap;
}
.fx__day b { font-size: 14px; font-weight: 700; color: var(--text); margin: 0 1px; }
.fx__main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.fx__title { font-weight: 600; }
.fx__memo { font-size: 12px; color: var(--text-muted); }
.fx__amt { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fx__edit {
  border: 1px solid var(--border); background: transparent; color: var(--text-2);
  border-radius: 8px; padding: 5px 11px; font-size: 12.5px; cursor: pointer;
}
.fx__edit:hover { background: var(--surface-2); color: var(--text); }
.card__note--foot { margin-top: 12px; display: block; }
.src--fixed { background: color-mix(in srgb, var(--cat-7) 16%, var(--surface)); color: var(--text); border-color: transparent; }
.row-edit { font-size: 13px; }
.btn--danger { background: transparent; color: var(--critical); border-color: color-mix(in srgb, var(--critical) 40%, transparent); }
.btn--danger:hover { background: color-mix(in srgb, var(--critical) 12%, transparent); }
.btn--danger-solid { background: var(--critical); color: #fff; }
.btn--danger-solid:hover { filter: brightness(1.06); }
#confirmBody { white-space: pre-line; }
#confirmModal { padding-bottom: var(--modal-pb); }
#confirmModal .modal__foot { position: static; border-top: 0; margin: 22px 0 0; padding: 0; }
.modal--login { padding-bottom: var(--modal-pb); }
.modal__foot--split { flex-wrap: wrap; }
.modal__foot-space { flex: 1; }

/* ── モーダル ───────────────────────────── */
.modal {
  --modal-px: 26px; --modal-pb: 26px;
  border: 1px solid var(--border); border-radius: 18px;
  padding: var(--modal-pb) var(--modal-px) 0;
  background: var(--surface); color: var(--text);
  width: min(560px, calc(100vw - 32px)); box-shadow: var(--shadow-lg);
}
.modal--wide { width: min(820px, calc(100vw - 32px)); }
.modal--sm { width: min(400px, calc(100vw - 32px)); }
.modal { max-height: 86dvh; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; }
.modal::backdrop { background: rgba(11,11,11,.5); backdrop-filter: blur(3px); }
.modal__close-form { position: absolute; top: 14px; right: 14px; margin: 0; }
.icon-btn--close { font-size: 22px; }
.modal__title { font-size: 19px; font-weight: 700; padding-right: 32px; }
.modal__lead { font-size: 13px; color: var(--text-2); margin-top: 8px; }
.modal__foot {
  display: flex; justify-content: flex-end; gap: 10px; align-items: center;
  /* 入力欄を開いている間もボタンが見えるように、モーダル下部に貼り付ける */
  position: sticky; bottom: 0; z-index: 3;
  margin: 20px calc(-1 * var(--modal-px)) 0;
  padding: 12px var(--modal-px) max(var(--modal-pb), env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-top: 1px solid var(--grid);
  border-radius: 0 0 17px 17px;
}
.modal__foot--form { margin-top: 16px; }

.dropzone {
  margin-top: 18px; border: 2px dashed var(--axis); border-radius: var(--radius);
  padding: 32px 20px; text-align: center; cursor: pointer; background: var(--surface-2);
  transition: border-color .15s ease, background .15s ease;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--series-income); background: var(--surface-hover); }
.dropzone__icon { font-size: 22px; color: var(--text-muted); }
.dropzone__main { font-weight: 650; margin-top: 6px; }
.dropzone__sub { font-size: 12.5px; color: var(--text-muted); }
.dropzone__hint { font-size: 12px; color: var(--text-muted); margin-top: 12px; text-align: center; }
.sample-btns { display: flex; gap: 8px; justify-content: center; margin-top: 8px; flex-wrap: wrap; }

.import-summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 18px 0 10px; font-size: 13px; flex-wrap: wrap;
}
.import-summary__meta { color: var(--text-muted); margin-left: 10px; font-variant-numeric: tabular-nums; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.table-wrap--preview { max-height: 320px; overflow-y: auto; border: 1px solid var(--grid); border-radius: var(--radius-sm); }
.table--preview th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
.table--preview td { padding: 8px 10px; }
.table--preview select { border: 1px solid var(--border); border-radius: 7px; padding: 4px 7px; font-size: 12.5px; background: var(--surface-2); }
.row-off { opacity: .4; }

.note { font-size: 12.5px; margin-top: 12px; padding: 9px 12px; border-radius: var(--radius-sm); }
.note--warn { background: color-mix(in srgb, var(--warning) 16%, var(--surface)); color: var(--text); }
.note--error { background: color-mix(in srgb, var(--critical) 14%, var(--surface)); color: var(--text); }

.form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 4px; min-width: 0; }
.field { display: grid; gap: 5px; min-width: 0; }
.field--full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 650; color: var(--text-2); }
.field__opt { font-weight: 500; color: var(--text-muted); margin-left: 6px; }
.input-money { position: relative; display: flex; align-items: center; }
.input-money span { position: absolute; left: 12px; color: var(--text-muted); font-size: 14px; }
.input-money .input { padding-left: 26px; font-variant-numeric: tabular-nums; }

/* ── 下部メニュー（リキッドグラス） ───────── */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: center;
  padding: 0 16px calc(14px + env(safe-area-inset-bottom, 0px));
  pointer-events: none;
}
.dock__glass {
  position: relative; pointer-events: auto;
  display: flex; align-items: center; gap: 4px; padding: 5px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 62%, transparent);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid color-mix(in srgb, var(--text) 9%, transparent);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .65),
    inset 0 -1px 0 rgba(255, 255, 255, .18),
    0 10px 30px rgba(11, 11, 11, .16),
    0 2px 6px rgba(11, 11, 11, .07);
}
/* 上面の映り込み */
.dock__glass::before {
  content: ''; position: absolute; inset: 1px 1px 45% 1px; border-radius: 999px 999px 60% 60% / 999px 999px 100% 100%;
  background: linear-gradient(180deg, rgba(255, 255, 255, .5), rgba(255, 255, 255, 0));
  pointer-events: none;
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .dock__glass { background: var(--surface); }
}

.dock__seg { display: flex; gap: 2px; position: relative; }
.dock__tab {
  border: 0; background: transparent; cursor: pointer; color: var(--text-2);
  font-size: 14px; font-weight: 650; padding: 9px 18px; border-radius: 999px;
  min-width: 76px; font-variant-numeric: tabular-nums;
  transition: color .15s ease, background .15s ease;
}
.dock__tab.is-active {
  background: var(--surface); color: var(--text);
  box-shadow: 0 1px 2px rgba(11, 11, 11, .16), inset 0 1px 0 rgba(255, 255, 255, .7);
}
.dock__arrow {
  border: 0; background: transparent; cursor: pointer; color: var(--text-2);
  width: 40px; height: 40px; border-radius: 50%; font-size: 21px; line-height: 1;
}
.dock__arrow:hover { background: color-mix(in srgb, var(--text) 7%, transparent); color: var(--text); }

/* ── ログイン画面 ─────────────────────── */
.modal--login::backdrop { background: var(--plane); }
.login { text-align: center; display: grid; gap: 4px; padding: 6px 0; }
.login__mark {
  width: 48px; height: 48px; border-radius: 14px; margin: 0 auto 10px;
  background: var(--series-income); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 24px;
}
.login .modal__title { padding: 0; }
.login .modal__lead { margin: 4px 0 16px; }
.login .input { text-align: center; letter-spacing: .08em; }
.login__submit { width: 100%; margin-top: 12px; padding: 11px; }
.login__note { font-size: 11.5px; color: var(--text-muted); margin-top: 14px; }
.login__setup { font-size: 12.5px; color: var(--text-2); text-align: left; margin-top: 10px; line-height: 1.7; }
.login .note--error { text-align: left; }
.foot__actions { display: flex; gap: 8px; }

/* ── トースト ───────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--text); color: var(--plane); padding: 11px 20px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow-lg); z-index: 50;
  animation: toast-in .2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ── レスポンシブ ───────────────────────── */
@media (max-width: 900px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 620px) {
  .app-header__inner { gap: 8px; }
  .brand__sub { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* アクションはアイコンだけにしてヘッダーを1行に収める */
  .btn__txt { display: none; }
  .btn__ico { display: block; font-size: 17px; line-height: 1; }
  .header-actions .btn { width: 42px; height: 42px; display: grid; place-items: center; padding: 0; }
  .stat__value { font-size: 23px; }
  .stat--hero .stat__value { font-size: 30px; }
  .stat__label { font-size: 12px; }
  .stat__delta { font-size: 11px; }
  .stat-grid > .stat:nth-child(4) { grid-column: 1 / -1; }
  .stat { padding: 14px 16px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat--hero { grid-column: 1 / -1; }
  .form { grid-template-columns: 1fr; }
  .input--search { width: 100%; }
  .layout { padding: 16px 16px 104px; }
  .card { padding: 16px; }
  .card--table { padding-bottom: 6px; }
  .month-list { grid-template-columns: 1fr 1fr; gap: 10px; }
  .mcard { padding: 12px 13px; gap: 7px; }
  .mcard__net { font-size: 18px; }
  .mcard__nums { font-size: 11.5px; }

  /* 明細は表ではなくカード型の行にして、横スクロールをなくす */
  .table-wrap { overflow-x: visible; }
  .table, .table tbody, .table tr, .table td { display: block; }
  .table thead { display: none; }
  .table tr {
    display: grid;
    grid-template-columns: 38px minmax(0, auto) minmax(0, 1fr) auto;
    grid-template-areas: "date title title amt" "date cat src act";
    align-items: center; gap: 3px 8px; padding: 11px 2px;
    border-bottom: 1px solid var(--grid);
  }
  .table tbody tr:last-child { border-bottom: 0; }
  .table td { border: 0; padding: 0; width: auto; }
  .table td.c-date { grid-area: date; align-self: start; padding-top: 2px; font-size: 12px; color: var(--text-muted); }
  .table td.c-title { grid-area: title; }
  .table td.c-cat { grid-area: cat; }
  .table td.c-src { grid-area: src; }
  .table td.c-amt { grid-area: amt; }
  .table td.c-act { grid-area: act; text-align: right; }
  .tx-title { word-break: break-word; }

  .upcoming { padding: 11px 14px; gap: 7px; font-size: 12.5px; }
  .gross--empty { grid-template-columns: 1fr; }
  .gross--empty .btn { width: 100%; }
  .gross__legend small { width: auto; margin-left: 8px; }
  .gross__kpi { grid-template-columns: 1fr 1fr; gap: 10px 12px; }
  .gross__kpi dd { font-size: 17px; }
  .entry-alt { gap: 10px; }
  .entry-alt .btn { width: 100%; }
  .bd-controls { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .bd-controls .seg:first-of-type { grid-column: 1 / -1; }
  .bd-controls .seg__btn { flex: 1; padding: 8px 6px; white-space: nowrap; }
  .bd-controls .btn--sm { width: 100%; }
  .bd-row__name { flex-wrap: wrap; gap: 6px; }
  .cm { grid-template-columns: auto 1fr; grid-template-areas: "dot main" "ops ops"; }
  .cm__dot { grid-area: dot; }
  .cm__main { grid-area: main; }
  .cm__ops { grid-area: ops; justify-content: flex-end; }
  .cat-manage { max-height: none; }
  .upcoming__sum { margin-left: 0; width: 100%; }

  .fx {
    grid-template-columns: 1fr auto;
    grid-template-areas: "main amt" "day edit";
    gap: 6px 10px; padding: 12px 2px;
  }
  .fx__main { grid-area: main; }
  .fx__amt { grid-area: amt; }
  .fx__day { grid-area: day; justify-self: start; }
  .fx__edit { grid-area: edit; justify-self: end; }

  /* 取り込みプレビューも同様に */
  .table--preview tr {
    grid-template-columns: 26px minmax(0, auto) minmax(0, 1fr) auto;
    grid-template-areas: "chk title title amt" "chk cat cat date";
    padding: 11px 4px;
  }
  .table--preview td.c-chk { grid-area: chk; align-self: start; padding-top: 2px; }
  .table--preview td.c-title { grid-area: title; }
  .table--preview td.c-date { grid-area: date; text-align: right; }
  .table--preview td.c-cat { grid-area: cat; }
  .table--preview td.c-amt { grid-area: amt; }
}
/* ホバーできない端末（iPhoneなど）では削除ボタンを常時表示 */
@media (hover: none) {
  .row-del { opacity: 1; }
  .icon-btn { width: 40px; height: 40px; }
  .dropzone { padding: 26px 16px; }
}

/* iOSは16px未満の入力欄でフォーカス時に自動ズームするため */
@media (max-width: 820px) {
  .input, .table--preview select { font-size: 16px; }
  .seg__btn { padding: 8px 14px; }
  .row-del { font-size: 18px; padding: 4px 8px; }
  .modal { --modal-px: 18px; --modal-pb: 22px; }
  .modal--wide, .modal { width: min(820px, calc(100vw - 20px)); }
  .table--preview td, .table--preview th { padding: 10px 8px; }
  .foot .is-warn { color: var(--critical); font-weight: 600; }
.foot { padding-bottom: env(safe-area-inset-bottom, 0px); }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
