/* ==========================================================================
   家計簿アプリ スタイルシート（public/css/app.css）

   ■ このファイルについて
   - アプリの見た目は、すべてこの1ファイルで決めています。
   - 保存してブラウザを再読み込みすれば反映されます（ビルド作業は不要）。
     ※ 読み込み時にファイルの更新日時を付けているので、古いCSSが残ることはありません。

   ■ どこを触ればいいか
   - 色や角の丸みを変えたい      → 「1. 色とサイズの設定」だけ変えればOK
   - 特定の画面の見た目を変えたい → 各セクションの見出しに「使っている画面」を書いています

   ■ 読み方のコツ
   - 「.card」のように点で始まるものは、HTMLの class="card" の部分に効きます。
   - 「var(--accent)」は、1. で決めた色の名前を呼び出しています。
   ========================================================================== */


/* ==========================================================================
   1. 色とサイズの設定
   ここを変えると、アプリ全体の色がまとめて変わります。
   色は「#」＋6桁の英数字で書きます（例: #ff0000 は赤）。
   ========================================================================== */
:root {
    /* --- 基本の色 --- */
    --bg: #f5f4f0;           /* 画面の背景（うすいベージュ） */
    --card: #ffffff;         /* カード（白い箱）の背景 */
    --ink: #1f2328;          /* 文字の色（ほぼ黒） */
    --muted: #6a6f76;        /* 補足の文字（グレー） */
    --line: #e3e1db;         /* 区切り線・枠線 */

    /* --- アプリのテーマ色（ボタン、選択中のタブなど） --- */
    --accent: #2f6f5e;       /* 濃い緑 */
    --accent-soft: #e4efe9;  /* うすい緑（成功メッセージの背景など） */

    /* --- 注意・エラーの色 --- */
    --warn: #a15c07;         /* 注意の文字（茶色） */
    --warn-soft: #fdf3e2;    /* 注意の背景（未入力の固定費の箱） */
    --danger: #b42318;       /* エラー・削除の文字（赤） */
    --danger-soft: #fdecea;  /* エラーの背景（うすい赤） */

    /* --- 形とサイズ --- */
    --radius: 12px;          /* カードの角の丸み（0pxにすると四角） */
    --tabbar-h: 64px;        /* 画面下のメニューの高さ */
}


/* ==========================================================================
   2. ページ全体の基本
   ========================================================================== */

/* 幅の計算に枠線と余白を含める（レイアウトが崩れにくくなるおまじない） */
* {
    box-sizing: border-box;
}

/* スマホを横向きにしたときに文字が勝手に大きくならないようにする */
html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-size: 16px;
    line-height: 1.6;
    /* 文字の種類。左から順に、その端末にあるものが使われる */
    font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
    /* 画面下のメニューに中身が隠れないよう、下に余白をとる
       env(safe-area-inset-bottom) は iPhone の画面下のバー分の高さ */
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
}

a {
    color: var(--accent);
}

/* 見出しの大きさ（h1 が一番大きい） */
h1 {
    font-size: 1.25rem;
    margin: 0 0 12px;
}

h2 {
    font-size: 1.05rem;
    margin: 0 0 8px;
}

h3 {
    font-size: 0.95rem;
    margin: 16px 0 8px;
    color: var(--muted);
}

p {
    margin: 8px 0;
}


/* ==========================================================================
   3. よく使う小さな部品（どの画面でも使う）
   ========================================================================== */

/* 中身の横幅を最大720pxにして中央に寄せる（PCで見たときに横に広がりすぎない） */
.wrap {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 16px;
}

.main {
    padding-top: 12px;
}

/* 文字をグレーにする */
.muted {
    color: var(--muted);
}

/* 文字を小さくする */
.small {
    font-size: 0.85rem;
}

/* 文字を太くする */
.strong {
    font-weight: 600;
}

/* 金額の表示：数字の幅をそろえて右寄せ、途中で改行しない */
.num {
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

/* 大きな金額（ホームの精算額） */
.big {
    font-size: 1.6rem;
    font-weight: 700;
}

/* 画面には見せず、読み上げソフトにだけ伝える文字 */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* 箇条書きの余白を小さくする（エラーメッセージの一覧） */
.plain {
    margin: 0;
    padding-left: 1.2em;
}


/* ==========================================================================
   4. 画面上のヘッダー（「家計簿」の文字と名前）
   使っている場所: layouts/app.blade.php
   ========================================================================== */
.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--line);
    /* スクロールしても上に貼り付いたままにする */
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-inner {
    /* 横並びにして、左右の端に寄せる */
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 48px;
}

.brand {
    font-weight: 700;
    color: var(--ink);
    text-decoration: none;
}


/* ==========================================================================
   5. 画面下のメニュー（ホーム / 支出 / ＋入力 / 設定）
   使っている場所: layouts/app.blade.php
   ========================================================================== */
.tabbar {
    /* 画面の一番下に固定する */
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    /* 4つのボタンを同じ幅で横に並べる */
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    background: var(--card);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}

/* メニューの各ボタン（アイコンの下に文字）。ボタンを増やすときは上の repeat(5, 1fr) の数字も変える */
.tabbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 0.75rem;
    color: var(--muted);
    text-decoration: none;
}

/* アイコン（◎ ≡ ＋ ⚙ の記号） */
.tabbar .ico {
    font-size: 1.25rem;
    line-height: 1;
}

/* いま開いている画面のボタン */
.tabbar a.on {
    color: var(--accent);
    font-weight: 600;
}

/* 「＋入力」だけ緑の丸にする */
.tabbar a.add .ico {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: grid;
    place-items: center;   /* 記号を丸の真ん中に置く */
    background: var(--accent);
    color: #fff;
}


/* ==========================================================================
   6. カード（白い箱）とメッセージ
   使っている場所: ほぼすべての画面
   ========================================================================== */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

/* ログイン画面の細いカード */
.card.narrow {
    max-width: 420px;
    margin: 32px auto;
}

/* カードの見出しと「＋追加」ボタンを横に並べる（設定画面） */
.card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.card-head h2 {
    margin: 0;
}

/* 未入力の固定費の箱（ホーム） */
.warn-card {
    border-color: #f0c98a;
    background: var(--warn-soft);
}

/* 「登録しました」などのお知らせ */
.flash {
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 12px;
    font-size: 0.9rem;
}

.flash.ok {
    background: var(--accent-soft);
    color: #1d4d40;
}

.flash.err {
    background: var(--danger-soft);
    color: var(--danger);
}

/* 灰色の注意書き（固定費項目の行を編集するとき） */
.note {
    background: var(--bg);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.9rem;
}

/* 小さなラベル（「精算済み」「3」など） */
.badge {
    display: inline-block;
    border-radius: 999px;   /* 大きな値にすると両端が丸くなる */
    padding: 0 8px;
    font-size: 0.75rem;
    font-weight: 600;
    vertical-align: middle;
}

.badge.ok {
    background: var(--accent-soft);
    color: var(--accent);
}

.badge.warn {
    background: #f7d9a8;
    color: var(--warn);
}


/* ==========================================================================
   7. 月の切り替え（‹ 2026年11月 ›）
   使っている場所: partials/month-nav.blade.php（ホームと支出一覧）
   ========================================================================== */
.month-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 4px 0 12px;
}

/* 「2026年11月」の文字。タップすると月を選ぶ画面が開く */
.month-pick {
    position: relative;
}

/* 月を選ぶ入力欄は、透明にして文字の上に重ねている */
.month-pick input {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    opacity: 0;
    cursor: pointer;
}

.month-label {
    font-size: 1.15rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 8px;
}

/* キーボードで選んだときに枠を出す */
.month-pick:focus-within .month-label {
    outline: 2px solid var(--accent);
}

/* 丸い ‹ › ボタン */
.btn-icon {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--card);
    border: 1px solid var(--line);
    color: var(--ink);
    font-size: 1.4rem;
    text-decoration: none;
}


/* ==========================================================================
   8. 精算の箱
   使っている場所: home.blade.php
   ========================================================================== */

/* 「花梨 → 翔貴　21,331円」の行 */
.settle-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin: 4px 0 12px;
}

.settle-head .arrow {
    color: var(--accent);
    font-weight: 700;
}

/* 「精算済み」ラベルと取り消しボタンの行 */
.settled {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}


/* ==========================================================================
   9. 表（精算の内訳、カテゴリ別の集計、金額の履歴）
   使っている場所: home.blade.php、settings/recurring-form.blade.php
   ========================================================================== */
.grid {
    width: 100%;
    border-collapse: collapse;   /* セルの枠線を1本にまとめる */
    font-size: 0.9rem;
}

.grid th,
.grid td {
    padding: 6px 4px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    font-weight: normal;
}

/* 表の一番上の行（翔貴 / 花梨 などの見出し） */
.grid thead th {
    color: var(--muted);
    font-size: 0.8rem;
}

.grid .num {
    text-align: right;
}

/* 合計の行は太字＋太い下線 */
.grid tr.total th,
.grid tr.total td {
    font-weight: 700;
    border-bottom-width: 2px;
}

/* 「固定費」「変動費」の区切り行 */
.grid tr.group th {
    padding-top: 14px;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
}

/* 0円のカテゴリは薄く表示 */
.grid tr.zero {
    color: var(--muted);
}

.grid a {
    color: inherit;
    text-decoration: none;
}


/* ==========================================================================
   9-2. 年間の一覧（月ごとのカレンダー）
   使っている場所: years/show.blade.php
   ========================================================================== */

/* ホームの「2026年の一覧を見る」リンク */
.to-year {
    margin: -6px 0 12px;
    text-align: center;
}

/* 未精算の月数と差し引き額 */
.year-unsettled {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

/* 12か月のマス目。スマホは3列（4段）、広い画面は4列（3段） */
.year-cal {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    margin-bottom: 16px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

@media (min-width: 560px) {
    .year-cal {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* 1か月分のマス */
.mcell {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    min-height: 132px;
    padding: 8px;
    /* マスの区切り線（右と下に引く） */
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    color: var(--ink);
    text-decoration: none;
}

.mcell:hover,
.mcell:active {
    background: var(--bg);
}

/* 今月のマスは黄色（カレンダーの「今日」と同じ考え方） */
.mcell.is-current {
    background: #fff9c4;
}

/* これからの月・記録のない月は薄く */
.mcell.is-future,
.mcell.is-empty {
    color: var(--muted);
}

.mcell.is-future .mnum,
.mcell.is-empty .mnum {
    color: #b5b3ad;
}

/* 月の数字と「済」ラベルの行 */
.mcell-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 4px;
}

/* 大きな月の数字 */
.mnum {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--accent);
}

.mnum small {
    font-size: 0.8rem;
    margin-left: 1px;
}

/* その月の2人の合計 */
.mtotal {
    text-align: left;
    font-size: 1rem;
    font-weight: 700;
}

.mtotal small {
    font-size: 0.7rem;
    font-weight: normal;
    margin-left: 1px;
}

/* 固定費・変動費の小さい表示 */
.msub {
    font-size: 0.72rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 精算（花梨→翔貴 21,331） */
.msettle {
    margin-top: auto;
    font-size: 0.72rem;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msettle strong {
    font-size: 0.85rem;
}


/* ==========================================================================
   10. 一覧（支出の一覧、設定の固定費項目など）
   使っている場所: expenses/index.blade.php、settings/index.blade.php
   ========================================================================== */

/* 「全員」「全カテゴリ」の絞り込み */
.filters {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.filters select {
    flex: 1;   /* 2つの選択欄を同じ幅で並べる */
}

/* 「26件　155,396円」の行 */
.list-head {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
    font-size: 0.9rem;
    margin: 4px 4px 8px;
}

.list-head strong {
    color: var(--ink);
}

/* 一覧全体の箱 */
.list {
    list-style: none;   /* 箇条書きの「・」を消す */
    margin: 0;
    padding: 0;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

/* カードの中に一覧を入れたとき（設定画面）は、カードの端まで広げる */
.card .list {
    border: 0;
    border-radius: 0;
    margin: 0 -16px -16px;
    border-top: 1px solid var(--line);
}

/* 行と行の間の線 */
.list li + li {
    border-top: 1px solid var(--line);
}

/* 1行分（左に内容、右に金額） */
.list .row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: inherit;
    text-decoration: none;
}

/* 押している間だけ色を変える */
.list .row:active {
    background: var(--bg);
}

/* 行の左側（カテゴリ、店名、日付・支払者を縦に並べる） */
.row-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* 店名が長いときは「…」で省略する */
.row-main .memo {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.row-main .sub {
    font-size: 0.8rem;
    color: var(--muted);
}

/* 行の右側の金額 */
.amount {
    font-weight: 600;
}

/* 未入力の金額は茶色 */
.amount.warn {
    color: var(--warn);
}

/* 「この条件の支出はありません」 */
.empty {
    padding: 16px;
    text-align: center;
}

/* カテゴリ名の小さなラベル（変動費は緑、固定費は紫） */
.chip {
    align-self: flex-start;
    font-size: 0.72rem;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
}

.chip.fixed {
    background: #ece9f6;
    color: #4b3f8f;
}


/* ==========================================================================
   10-2. 支出の表（スプレッドシートのように編集できる表）
   使っている場所: expenses/index.blade.php、expenses/_row.blade.php
   動き: public/js/expenses-grid.js
   ========================================================================== */

.sheet-help {
    margin: 0 4px 8px;
}

/* 支出の画面だけ、PCでは横幅を広く使う（layouts/app.blade.php の main_class） */
.wrap.wide {
    max-width: 1100px;
}

/* 表が画面より広いときは、表だけ横にスクロールできるようにする */
.sheet-wrap {
    overflow-x: auto;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.sheet {
    width: 100%;
    min-width: 680px;          /* これより狭いと横スクロール */
    border-collapse: collapse;
    font-size: 0.9rem;
}

/* 見出しの行（スクロールしても上に残る） */
.sheet thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f0efe9;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    text-align: left;
    padding: 6px 8px;
    border-bottom: 1px solid var(--line);
}

/* 列の幅（左から 支払日 / カテゴリ / 金額 / 支払者 / 備考） */
.sheet .c-date { width: 132px; }
.sheet .c-cat { width: 140px; }
.sheet .c-amount { width: 110px; text-align: right; }
.sheet .c-user { width: 88px; }
.sheet .c-tools { width: 80px; }

/* スマホでは、金額まで横スクロールなしで見えるよう少し詰める */
@media (max-width: 560px) {
    .sheet { min-width: 620px; }
    .sheet .c-date { width: 118px; }
    .sheet .c-cat { width: 116px; }
    .sheet .c-amount { width: 96px; }
}

/* セル（マス目の線） */
.sheet td {
    padding: 0;
    border-bottom: 1px solid var(--line);
    border-right: 1px solid var(--line);
}

.sheet td:last-child {
    border-right: 0;
}

/* セルの中の入力欄は枠をなくして、マス目そのものに見せる
   （「td」まで書くのは、11. の入力欄の共通スタイルより優先させるため） */
.sheet td input,
.sheet td select {
    width: 100%;
    min-height: 40px;
    padding: 6px 8px;
    border: 0;
    border-radius: 0;
    background: transparent;
    font-size: 0.9rem;
}

/* 入力中のセルを緑の枠で示す */
.sheet td input:focus,
.sheet td select:focus {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    background: #fff;
}

.sheet td input.num {
    text-align: right;
}

/* 金額欄の上下の矢印（スピンボタン）を消す */
.sheet td input[type=number]::-webkit-inner-spin-button,
.sheet td input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.sheet td input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* 変更できないセル（固定費項目の支払者・カテゴリ） */
.sheet select:disabled {
    color: var(--ink);
    opacity: 1;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg);
}

/* 未入力の金額（電気・水道・ガスなど） */
.sheet td input.is-unfilled {
    background: var(--warn-soft);
}

/* 保存できなかったセル */
.sheet td input.is-error,
.sheet td select.is-error {
    background: var(--danger-soft);
    outline: 2px solid var(--danger);
    outline-offset: -2px;
}

/* 行の状態（保存中は薄い黄色、保存できたら薄い緑） */
.sheet tr[data-state="saving"] td {
    background: #fffbe6;
}

.sheet tr[data-state="saved"] td {
    background: #f0f8f4;
}

/* 別の月に移った行は薄くしてから消す */
.sheet tr.is-moved td {
    opacity: 0.4;
    transition: opacity 0.3s;
}

/* 一番右の列（状態の表示と削除ボタン） */
.sheet .row-tools {
    padding: 0 6px;
    white-space: nowrap;
    text-align: right;
}

.row-status {
    font-size: 0.72rem;
    color: var(--muted);
}

.sheet tr[data-state="error"] .row-status {
    color: var(--danger);
    white-space: normal;
}

.row-delete {
    width: 28px;
    height: 28px;
    margin-left: 4px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    font-size: 1.1rem;
    cursor: pointer;
}

.row-delete:hover {
    background: var(--danger-soft);
    color: var(--danger);
}

/* 一番下の「新しい行」 */
.sheet tfoot td {
    background: #f7faf8;
    border-top: 2px solid var(--line);
}


/* ==========================================================================
   10-3. レシート取込
   使っている場所: receipts/index.blade.php、receipts/show.blade.php
   動き: public/js/receipt-upload.js
   ========================================================================== */

/* 「撮影する」「写真から選ぶ」の大きなボタン */
.upload-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.upload-btn {
    min-height: 64px;
    font-size: 1rem;
    gap: 6px;
}

/* アップロードの進み具合 */
.upload-progress {
    min-height: 1.4em;
    margin: 8px 0 0;
    color: var(--accent);
    font-weight: 600;
}

/* レシートの一覧（小さな画像つき） */
.receipt-list {
    list-style: none;
    margin: 0 -16px -16px;
    padding: 0;
    border-top: 1px solid var(--line);
}

.receipt-list li + li {
    border-top: 1px solid var(--line);
}

.receipt-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: inherit;
    text-decoration: none;
}

.receipt-item:active {
    background: var(--bg);
}

/* 一覧の小さな画像 */
.receipt-item img {
    width: 48px;
    height: 64px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--line);
    flex-shrink: 0;
}

.receipt-item .row-main {
    flex: 1;
}

/* 確認画面: スマホは画像が上、PCは左に画像・右に入力欄 */
.receipt-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

@media (min-width: 760px) {
    .receipt-layout {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        align-items: start;
    }
}

.receipt-image {
    text-align: center;
}

/* レシート画像。スマホでは高さを抑えて、下の入力欄が見えるようにする */
.receipt-image img {
    max-width: 100%;
    max-height: 45vh;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: #fff;
}

@media (min-width: 760px) {
    .receipt-image {
        position: sticky;
        top: 64px;
    }

    .receipt-image img {
        max-height: 80vh;
    }
}

.receipt-form h1 {
    display: flex;
    align-items: center;
    gap: 8px;
}

.read-form {
    margin-bottom: 12px;
}

/* 読み取った内容の詳細（たたんで表示） */
.read-detail {
    margin-top: 16px;
}

.read-detail summary {
    cursor: pointer;
    color: var(--accent);
}

/* 支出一覧の 🧾（レシートを見る） */
.row-receipt {
    text-decoration: none;
    margin-left: 4px;
}

/* 設定画面: カードの追加欄 */
.card-add {
    display: grid;
    grid-template-columns: 80px 1fr 90px auto;
    gap: 6px;
    margin-top: 12px;
}


/* ==========================================================================
   11. 入力フォーム
   使っている場所: 支出の入力、設定の各画面、ログイン
   ========================================================================== */

/* 入力欄を縦に並べる */
.form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* 項目名（金額、支払日など）とその下の入力欄 */
.form label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    font-size: 0.9rem;
    font-weight: 600;
}

.form label .muted {
    font-weight: normal;
}

/* 項目名と入力欄を別々に書くときの入れ物（プルダウンで使用）
   例: <div class="field"><label for="x">カテゴリ</label><select id="x">…</select></div> */
.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.field > label {
    font-size: 0.9rem;
    font-weight: 600;
}

/* 文字・数字・日付の入力欄と選択欄の共通の見た目 */
input[type=text],
input[type=email],
input[type=password],
input[type=number],
input[type=date],
input[type=month],
select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 44px;   /* 指で押しやすい高さ */
    padding: 10px 12px;
    border: 1px solid #cfccc4;
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-weight: normal;
}

/* 入力中の欄を緑の枠で示す */
input:focus,
select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 0;
    border-color: var(--accent);
}

/* 支出入力の「金額」欄だけ大きくする */
.big-input {
    font-size: 1.5rem !important;
    font-variant-numeric: tabular-nums;
}

/* 2つの入力欄を横に並べる（支払日と対象月など） */
.two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* 横並びの中身が枠からはみ出さないようにする */
.two > * {
    min-width: 0;
}

/* チェックボックス・ラジオボタンと文字を横に並べる */
label.check {
    flex-direction: row !important;
    align-items: center;
    gap: 8px !important;
    font-weight: normal !important;
}

label.check input {
    width: 18px;
    height: 18px;
}

/* 項目のまとまり（枠線は出さない） */
fieldset {
    border: 0;
    padding: 0;
    margin: 0;
}

legend {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 4px;
}

/* 固定費項目の「金額の種類」の選択肢 */
.radios {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* --- 支払者の切り替えボタン（翔貴 / 花梨） ---
   本当はラジオボタンですが、丸を隠して大きなボタンに見せています */
.seg {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.seg legend {
    width: 100%;
}

.seg label {
    flex: 1;
}

/* ラジオボタンの丸を隠す */
.seg input {
    position: absolute;
    opacity: 0;
}

/* ボタンの見た目（選ばれていないとき）。label の直下の span だけに効かせる */
.seg label > span {
    display: block;
    padding: 10px;
    border: 1px solid #cfccc4;
    border-radius: 10px;
    background: #fff;
    text-align: center;
    font-weight: 600;
    cursor: pointer;
}

/* 選ばれているボタンは緑 */
.seg input:checked + span {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.seg input:focus-visible + span {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ホームの「未入力の固定費」1行（名前 / 金額欄 / 保存ボタン） */
.inline-amount {
    display: grid;
    grid-template-columns: 1fr 120px auto;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
}

.inline-amount label {
    font-size: 0.9rem;
    font-weight: 600;
}

/* --- 設定画面のカテゴリ一覧 --- */
.cat-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* 1行（並び順 / 名前 / 使う / 保存） */
.cat-row {
    display: grid;
    grid-template-columns: 64px 1fr auto auto;
    gap: 6px;
    align-items: center;
}

/* 使っていないカテゴリは名前を薄くする */
.cat-row.inactive input[type=text] {
    color: var(--muted);
    background: var(--bg);
}

.cat-row .sort {
    padding: 10px 6px;
    text-align: center;
}

.cat-del {
    margin: -2px 0 4px 70px;
}

/* 新しいカテゴリの追加欄 */
.cat-add {
    display: grid;
    grid-template-columns: 1fr 100px auto;
    gap: 6px;
    margin-top: 16px;
}


/* ==========================================================================
   12. ボタン
   class="btn" に、primary（緑）、small（小）などを組み合わせて使います。
   例: <button class="btn primary">登録</button>
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 8px 16px;
    border: 1px solid #cfccc4;
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

/* 小さいボタン */
.btn.small {
    min-height: 36px;
    padding: 4px 12px;
    font-size: 0.85rem;
}

/* メインのボタン（緑） */
.btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* 背景なしのボタン */
.btn.ghost {
    background: transparent;
}

/* 削除ボタン（赤い文字） */
.btn.danger {
    color: var(--danger);
    border-color: #f0b4ad;
}

/* 横幅いっぱいのボタン */
.btn.block {
    width: 100%;
}

/* リンクのように見えるボタン（「‹ 設定」や「削除」の文字） */
.link {
    background: none;
    border: 0;
    padding: 0;
    color: var(--accent);
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.link.danger {
    color: var(--danger);
}

/* ボタンを横に並べる */
.actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.actions form {
    margin: 0;
}

/* 削除ボタンの上に線を引いて、他のボタンと離す */
.danger-zone {
    margin-top: 20px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}


/* ==========================================================================
   13. 小さいスマホ用（画面の幅が380px以下のとき）
   ========================================================================== */
@media (max-width: 380px) {
    /* 横並びの入力欄を縦並びにする */
    .two {
        grid-template-columns: 1fr;
    }

    .inline-amount {
        grid-template-columns: 1fr 100px auto;
    }
}
