/* ファミ帳 - 色: 淡い黄色ベース + 淡い青・淡い緑 (文字は濃い色で読みやすく) */
:root {
  --bg: #fffbea;          /* 淡い黄色 (背景) */
  --surface: #ffffff;     /* カード */
  --line: #ece4c4;        /* 枠線 */
  --text: #2a2a24;        /* 文字 */
  --sub: #5c5a4e;         /* 小さい文字 */
  --blue-soft: #dcebfa;   /* 淡い青 (背景用) */
  --blue: #1e5a96;        /* 青 (ボタン・強調) */
  --green-soft: #e2f3e6;  /* 淡い緑 (背景用) */
  --green: #2e7d4f;       /* 緑 (文字・強調) */
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  /* 日本語: BIZ UDPゴシック (読みやすいUDフォント) / 韓国語: Noto Sans KR (下の :lang(ko) で切り替え) */
  font-family: "BIZ UDPGothic", "Noto Sans KR", "Meiryo", "Malgun Gothic", system-ui, sans-serif;
  font-size: 17px;
}

.layout { display: flex; flex-wrap: wrap; min-height: 100vh; }

/* 左メニュー */
.side {
  flex: 0 0 200px;
  max-width: 100%;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 24px 16px;
  display: flex; flex-direction: column; gap: 6px;
}
.brand { padding: 0 12px 20px; display: flex; flex-direction: column; gap: 4px; }
.brand-name { font-size: 23px; font-weight: 700; color: var(--blue); }
.brand-shop { font-size: 15px; color: var(--sub); }
.menu {
  display: flex; align-items: center;
  min-height: 52px; padding: 0 14px; border-radius: 12px;
  color: var(--text); text-decoration: none; font-size: 17px;
}
.menu:hover { background: var(--bg); }
.menu.active { background: var(--blue-soft); color: var(--blue); font-weight: 700; }

/* 右の本体 */
.main {
  flex: 999 1 560px; min-width: 0; max-width: 1200px;
  padding: 28px 36px 40px;
  display: flex; flex-direction: column; gap: 22px;
}
.top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.top-left, .top-right { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
h1 { margin: 0; font-size: 28px; }
h2 { margin: 0 0 8px; font-size: 19px; }

.pill {
  min-height: 44px; padding: 0 16px; border-radius: 22px;
  border: 1px solid var(--line); background: var(--surface);
  font: inherit; font-size: 16px; color: var(--text); cursor: pointer;
}

/* 信号の帯 */
.signal { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-radius: 14px; font-size: 18px; font-weight: 500; }
.signal .dot { width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0; }
.signal.ok { background: var(--green-soft); color: var(--green); }
.signal.ok .dot { background: var(--green); }

/* 今月のまとめ */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.card { background: var(--surface); border-radius: 16px; padding: 20px 22px; display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--line); }
.card .label { font-size: 16px; color: var(--sub); }
.card .num { font-size: 28px; font-weight: 700; }
.card.profit { background: var(--green-soft); border-color: transparent; }
.card.profit .num { color: var(--green); }

/* よく使う操作 */
.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.act {
  min-height: 84px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--surface);
  font: inherit; font-size: 19px; font-weight: 700; color: var(--text); cursor: pointer;
}
.act:hover { background: var(--blue-soft); }
.act.primary { background: var(--blue); border-color: var(--blue); color: #ffffff; }
.act.primary:hover { background: #174a7c; }

/* 最近の記録 */
.box { background: var(--surface); border-radius: 16px; padding: 20px 22px; border: 1px solid var(--line); }
.empty { color: var(--sub); margin: 8px 0 0; }

/* スマホ幅 */
@media (max-width: 700px) {
  .side { flex: 1 1 100%; border-right: none; border-bottom: 1px solid var(--line); flex-direction: row; flex-wrap: wrap; padding: 12px; }
  .brand { width: 100%; padding: 0 4px 8px; }
  .menu { min-height: 44px; }
  .main { padding: 20px 16px 32px; }
}

/* ===== v0.2 追加: 画面切り替え・経費フォーム ===== */
.view { display: flex; flex-direction: column; gap: 22px; }
.view[hidden] { display: none; }
a.act { display: flex; align-items: center; justify-content: center; text-decoration: none; text-align: center; padding: 0 12px; }

.two-col { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.form { flex: 3 1 480px; min-width: 0; display: flex; flex-direction: column; gap: 22px; padding: 24px 26px; }
.side-col { flex: 2 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }

.row { display: flex; flex-wrap: wrap; gap: 16px; }
.field { flex: 1 1 200px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.wide { flex: 2 1 260px; }
fieldset { border: none; margin: 0; padding: 0; min-width: 0; }
legend, .field > label { font-size: 16px; font-weight: 700; padding: 0 0 8px; }
.field > label { padding: 0; }
input[type="text"], input[type="date"] {
  height: 52px; border: 1px solid #d9d1b0; border-radius: 10px; padding: 0 14px;
  font: inherit; font-size: 18px; color: var(--text); background: #ffffff; width: 100%;
}
input:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid #8fb8e3; outline-offset: 2px; }

.chips-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.chip {
  min-height: 60px; border: 1px solid #e6dfc4; background: #ffffff; border-radius: 8px;
  font: inherit; font-size: 16px; color: var(--text); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 6px;
}
.chip .sub { font-size: 13px; color: var(--sub); }
.chip:hover { background: var(--bg); }
.chip[aria-pressed="true"] { border: 1px solid var(--blue); background: var(--blue); color: #ffffff; font-weight: 700; }
.chip[aria-pressed="true"] .sub { color: #cfe0f3; }

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pills.small { margin-top: 8px; }
.pills[hidden] { display: none; }
.opt {
  min-height: 48px; padding: 0 18px; border-radius: 24px; border: 1px solid #d9d1b0; background: #ffffff;
  font: inherit; font-size: 16px; color: var(--text); cursor: pointer;
}
.pills.small .opt { min-height: 44px; font-size: 15px; }
.opt[aria-pressed="true"] { border: 2px solid var(--blue); background: var(--blue-soft); color: var(--blue); font-weight: 700; }
.opt.green[aria-pressed="true"] { border-color: var(--green); background: var(--green-soft); color: var(--green); }

.btn {
  flex: 1 1 160px; min-height: 60px; border-radius: 14px; border: 1px solid #d9d1b0; background: #ffffff;
  font: inherit; font-size: 17px; color: var(--text); cursor: pointer;
}
.btn.primary { flex: 2 1 220px; border: none; background: var(--blue); color: #ffffff; font-size: 19px; font-weight: 700; }
.btn.primary:hover { background: #174a7c; }

.preview { background: var(--green-soft); border-color: transparent; display: flex; flex-direction: column; gap: 12px; }
.preview h2 { color: var(--green); }
.pv-row { display: flex; justify-content: space-between; gap: 12px; font-size: 16px; }
.pv-note { margin: 0; padding-top: 10px; border-top: 1px solid #b9dcc3; font-size: 14px; color: #2a4a35; }

.msg { margin: 0; padding: 12px 16px; border-radius: 10px; font-size: 16px; font-weight: 500; }
.msg.ok { background: var(--green-soft); color: var(--green); }
.msg.ng { background: #fde8e4; color: #a3341f; }

.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 16px; }
.tbl td { padding: 12px 8px; border-bottom: 1px solid #f0ead2; white-space: nowrap; }
.tbl tr:last-child td { border-bottom: none; }
.tbl td.num { text-align: right; font-weight: 700; }
.tbl td.warn { color: #a3501a; font-weight: 500; }
.card.profit.neg { background: #fde8e4; }
.card.profit.neg .num { color: #a3341f; }

/* ===== ログイン画面 ===== */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-box {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  padding: 40px 32px; display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center;
}
.login-box .brand-name { margin: 0; font-size: 32px; }
.login-lead { margin: 0; font-size: 18px; color: var(--sub); }
.login-btn { display: flex; align-items: center; justify-content: center; width: 100%; flex: none; text-decoration: none; }
.btn.primary.login-btn { flex: none; min-height: 60px; }

/* ===== v0.3 追加: 記録一覧・直す・削除 ===== */
[hidden] { display: none !important; }
.monthbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.monthbar .cur { font-size: 22px; font-weight: 700; min-width: 150px; text-align: center; }
.monthsum { margin-left: auto; font-size: 17px; color: var(--sub); }
.monthsum b { color: var(--text); font-size: 20px; }
.tbl th { font-size: 14px; color: var(--sub); text-align: left; padding: 8px; border-bottom: 1px solid var(--line); font-weight: 500; white-space: nowrap; }
.tbl th.num { text-align: right; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--blue-soft); }
.tbl td.go { color: var(--blue); font-weight: 700; text-align: center; }
.editband { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-radius: 14px; background: #fff1c9; color: #7a5200; font-size: 18px; font-weight: 700; }
.btn.danger { border: 2px solid #c0472f; color: #a3341f; background: #ffffff; font-weight: 700; }
.btn.danger.solid { background: #c0472f; color: #ffffff; }
.confirm { border: 2px solid #c0472f; background: #fde8e4; border-radius: 14px; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.confirm p { margin: 0; font-size: 18px; font-weight: 700; color: #a3341f; }
#delWhat { font-size: 17px; }
/* メモ欄の下に余計なすき間ができないように */
.form > .field { flex: none; }

/* ===== v0.4 追加: レシートから入力 ===== */
.upl { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; background: var(--blue-soft); border: 2px dashed #8fb8e3; border-radius: 16px; padding: 20px 24px; }
.upl .big { min-height: 64px; padding: 0 28px; border-radius: 14px; border: none; background: var(--blue); color: #ffffff; font: inherit; font-size: 19px; font-weight: 700; cursor: pointer; }
.upl .big:hover { background: #174a7c; }
.upl .big:disabled { opacity: .6; cursor: wait; }
.upl .hint { color: #1e4a75; font-size: 16px; line-height: 1.6; flex: 1 1 280px; min-width: 0; }
.msg.info { background: var(--blue-soft); color: var(--blue); }
.rc-list { display: flex; flex-direction: column; gap: 14px; }
.rc-head { font-size: 19px; font-weight: 700; color: var(--green); background: var(--green-soft); padding: 14px 20px; border-radius: 14px; }
.rc { display: flex; gap: 18px; background: #ffffff; border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; flex-wrap: wrap; }
.rc .ph { width: 110px; height: 150px; border-radius: 10px; border: 1px solid var(--line); overflow: hidden; display: flex; align-items: center; justify-content: center; background: #faf8ef; color: var(--sub); font-size: 15px; text-decoration: none; flex-shrink: 0; }
.rc .ph img { width: 100%; height: 100%; object-fit: cover; }
.rc .info { flex: 1 1 300px; display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; font-size: 17px; align-content: start; }
.rc .info > span { color: var(--sub); }
.rc .btns { display: flex; flex-direction: column; gap: 10px; flex: 0 0 210px; }
.rc .btns .btn { flex: none; min-height: 52px; }
.rc .btn:disabled { opacity: .45; cursor: not-allowed; }
.rc .note { font-size: 14px; color: #a3501a; }
.rc.done, .rc.skip { opacity: .6; }
.rc .state { font-size: 18px; font-weight: 700; color: var(--green); }
.rc.skip .state { color: var(--sub); }
.tag { display: inline-block; font-size: 13px; padding: 2px 10px; border-radius: 10px; background: #fff1c9; color: #7a5200; margin-left: 6px; font-weight: 700; }
.attached { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; background: var(--green-soft); border-radius: 12px; padding: 12px 16px; font-size: 16px; color: var(--green); font-weight: 700; }
.attached a { color: var(--blue); }
.rcpt-link { text-decoration: none; margin-left: 4px; }

/* ツールチップ・写真アイコン */
.tip { position: fixed; z-index: 1000; max-width: 340px; padding: 10px 14px; border-radius: 10px;
  background: #ffffff; color: var(--text); border: 1px solid #d9d1b0; font-size: 15px; line-height: 1.55;
  pointer-events: none; box-shadow: 0 4px 14px rgba(60,50,10,.15); }
.rcpt-icon { display: inline-flex; align-items: center; padding: 3px; border-radius: 8px; }
.rcpt-icon:hover { background: #ffffff; }
.rcpt-link { display: inline-flex; vertical-align: middle; }
.ico { display: block; }
.attached.off { background: #f3f0e2; color: var(--sub); }
.tip, #rcptMsg, [data-brk] { white-space: pre-line; }
/* 「写真がついています」と「外しました」の箱は同じ高さ (切り替えても画面が動かないように) */
.attached { min-height: 76px; }

/* ===== v0.5 追加: メニュー・ホーム・財務報告 ===== */
.menu .soon { margin-left: auto; font-size: 12px; color: var(--sub); background: #f3f0e2; padding: 2px 8px; border-radius: 8px; }
.menu.dim { color: #8a8778; }
.card .sub2 { font-size: 14px; color: var(--sub); }
.card.warnc { background: #fff6e0; border-color: #f0dca8; }
.card.warnc .num { color: #a3501a; }
.monthbar .grow { flex: 1; }
.tabs-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab { min-height: 50px; padding: 0 22px; border-radius: 12px; border: 1px solid var(--line); background: #ffffff; font: inherit; font-size: 17px; color: var(--text); cursor: pointer; }
.tab[aria-pressed="true"] { background: var(--blue-soft); color: var(--blue); border: 2px solid var(--blue); font-weight: 700; }
.chk { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 16px; color: var(--sub); cursor: pointer; }
.chk input { width: 20px; height: 20px; }
.rep { width: 100%; border-collapse: collapse; font-size: 17px; }
.rep td { padding: 12px 10px; border-bottom: 1px solid #f0ead2; vertical-align: top; line-height: 1.5; }
.rep td.num { text-align: right; font-weight: 700; white-space: nowrap; }
.rep .easy { display: block; font-size: 14px; color: var(--sub); font-weight: 400; margin-top: 4px; line-height: 1.4; }
.rep .code, .rep-jr .code { display: inline-block; min-width: 42px; margin-right: 4px; color: var(--sub); font-size: 14px; font-weight: 400; }
.rep tr.sec td { background: #faf6e4; font-weight: 700; color: #5c5a4e; font-size: 15px; padding: 8px 10px; }
.rep tr.tot td { background: var(--blue-soft); color: var(--blue); font-weight: 700; }
.rep tr.big td { background: var(--green-soft); color: var(--green); font-weight: 700; font-size: 20px; }
.rep tr.big.neg td { background: #fde8e4; color: #a3341f; }
.rep .minus { color: #a3341f; }
.rep-note { font-size: 14px; color: var(--sub); margin: 10px 0 0; white-space: pre-line; }
.rep-ok { font-size: 15px; font-weight: 700; color: var(--green); margin: 0; }
.rep-ng { font-size: 15px; font-weight: 700; color: #a3341f; margin: 0; }
.bs-two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 800px) { .bs-two { grid-template-columns: 1fr; } .chk { margin-left: 0; } }

/* ===== 年・月の選び方 (記録一覧・財務報告) ===== */
.per { display: flex; flex-direction: column; gap: 12px; }
.per-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.per-top .yr { font-size: 22px; font-weight: 700; min-width: 100px; text-align: center; }
.per-top .arrow { width: 48px; min-height: 46px; border-radius: 12px; border: 1px solid var(--line); background: #ffffff; font: inherit; font-size: 16px; color: var(--text); cursor: pointer; }
.per-top .arrow:hover, .mbtn:hover { background: var(--blue-soft); }
.per-top .sum { margin-left: auto; font-size: 17px; color: var(--sub); line-height: 1.5; }
.per-top .sum b { color: var(--text); font-size: 20px; }
.mgrid { display: grid; grid-template-columns: repeat(13, 1fr); gap: 6px; }
.mbtn { min-height: 42px; border-radius: 10px; border: 1px solid var(--line); background: #ffffff; font: inherit; font-size: 16px; color: var(--text); cursor: pointer; padding: 0; white-space: nowrap; }
.mbtn[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: #ffffff; font-weight: 700; }
.mbtn.year { background: var(--green-soft); color: var(--green); font-weight: 700; border-color: #b9dcc3; }
.mbtn.year[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #ffffff; }
@media (max-width: 900px) { .mgrid { grid-template-columns: repeat(7, 1fr); } }
.menu .soon { margin-left: auto; } .menu { gap: 6px; }

/* 韓国語表示のときは Noto Sans KR を先に (日本語の文字は BIZ UDPゴシック で表示) */
html:lang(ko) body { font-family: "Noto Sans KR", "BIZ UDPGothic", "Malgun Gothic", "Meiryo", system-ui, sans-serif; }

/* ===== v0.6 追加: 設定・ボタンの並べ替え ===== */
.sec h2 { font-size: 20px; margin: 0 0 4px; }
.sec .desc { color: var(--sub); font-size: 15px; margin: 0 0 14px; }
#view-settings { gap: 18px; }
.frow { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; }
.frow .field { flex: 1 1 220px; }
.save { min-height: 52px; padding: 0 28px; border-radius: 12px; border: none; background: var(--blue); color: #ffffff; font: inherit; font-size: 17px; font-weight: 700; cursor: pointer; }
.save:hover { background: #174a7c; }
.sec .msg { margin-top: 12px; }
.btable { width: 100%; border-collapse: collapse; font-size: 16px; min-width: 640px; }
.btable th { font-size: 14px; color: var(--sub); text-align: left; padding: 8px; border-bottom: 1px solid var(--line); font-weight: 500; white-space: nowrap; }
.btable td { padding: 8px; border-bottom: 1px solid #f0ead2; }
.btable input, .btable select { height: 44px; border: 1px solid #d9d1b0; border-radius: 8px; padding: 0 10px; font: inherit; font-size: 16px; width: 100%; background: #ffffff; color: var(--text); }
.btable tr.hid td:not(:last-child) { opacity: .5; }
.sw { display: inline-flex; align-items: center; gap: 8px; border: none; background: none; font: inherit; font-size: 15px; color: var(--text); cursor: pointer; padding: 4px; white-space: nowrap; }
.sw i { width: 46px; height: 26px; border-radius: 13px; background: #cfc8ad; position: relative; display: inline-block; transition: background .15s; }
.sw i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #ffffff; transition: left .15s; }
.sw[aria-pressed="true"] i { background: var(--green); }
.sw[aria-pressed="true"] i::after { left: 23px; }
.add { min-height: 48px; padding: 0 20px; border-radius: 12px; border: 2px dashed #8fb8e3; background: var(--blue-soft); color: var(--blue); font: inherit; font-weight: 700; font-size: 16px; margin-top: 12px; cursor: pointer; }
.ord { display: flex; gap: 10px; margin-top: 16px; align-items: center; flex-wrap: wrap; font-size: 15px; }
.btn-mini { min-height: 40px; padding: 0 16px; border-radius: 10px; border: none; background: var(--blue); color: #ffffff; font: inherit; font-weight: 700; cursor: pointer; }

/* ボタンの長押し → ゆらゆら並べ替え */
.chip { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.donebar { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: #fff6e0; border: 1px solid #f0dca8; border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; font-size: 15px; color: #7a5200; font-weight: 700; }
.donebar button { min-height: 42px; padding: 0 22px; border-radius: 10px; border: none; background: var(--blue); color: #ffffff; font: inherit; font-weight: 700; cursor: pointer; }
@keyframes jig { 0% { transform: rotate(-1.3deg); } 50% { transform: rotate(1.3deg); } 100% { transform: rotate(-1.3deg); } }
.chips-grid.jig .chip { animation: jig .32s infinite; position: relative; touch-action: none; cursor: grab; }
.chips-grid.jig .chip:nth-child(2n) { animation-delay: .12s; }
.chips-grid.jig .chip.drag { animation: none; z-index: 5; box-shadow: 0 8px 20px rgba(0,0,0,.18); background: var(--blue-soft); cursor: grabbing; }
.chip .x { position: absolute; top: -9px; left: -9px; width: 28px; height: 28px; border-radius: 50%; background: #8a8778; color: #ffffff; font-size: 16px; line-height: 28px; text-align: center; font-weight: 700; }
.btable td:nth-child(3) { min-width: 170px; }
.btable td:nth-child(4) { width: 110px; }
.btable td:nth-child(5) { width: 120px; }

/* 並べ替え中だけ右下に浮かぶ「完了」ボタン (FAB) */
.fab { position: fixed; right: 20px; bottom: 24px; z-index: 900; min-height: 60px; padding: 0 30px; border-radius: 30px; border: none;
  background: var(--blue); color: #ffffff; font: inherit; font-size: 19px; font-weight: 700; cursor: pointer; box-shadow: 0 6px 18px rgba(20,50,90,.3); }
.fab:hover { background: #174a7c; }
.fab[hidden] { display: none !important; }

/* ===== スマホ表示の調整 ===== */
/* 内容が短い画面でメニューが縦に伸びないように */
@media (max-width: 700px) {
  .layout { align-content: flex-start; }
  .side { align-content: flex-start; align-items: center; gap: 4px 6px; }
  .menu { padding: 0 12px; }
  /* 上の「日本語/한국어」「ログアウト」は1行に小さく。名前はかくす */
  .top { flex-wrap: nowrap; }
  .top-right { flex-wrap: nowrap; gap: 6px; flex-shrink: 0; }
  .top-right .pill { min-height: 40px; padding: 0 12px; font-size: 14px; white-space: nowrap; }
  .top .who { display: none; }
  h1 { font-size: 24px; }
  /* 財務報告のタブは3つ同じ幅で1行に */
  .tabs-row { flex-direction: row; align-items: center; gap: 10px 18px; }
  .tabs { display: grid; grid-template-columns: repeat(2, 1fr); flex: 1 1 100%; }
  .tab { padding: 0 6px; font-size: 16px; }
  .chk { margin-left: 0; }
}
/* 狭い画面では月ボタンの字を少し小さく (「10月」がはみ出さないように) */
@media (max-width: 480px) {
  .mgrid { gap: 4px; }
  .mbtn { font-size: 14px; min-height: 44px; letter-spacing: -0.02em; }
  .per-top .yr { font-size: 20px; min-width: 80px; }
}

/* ===== レシートの写真を見る ===== */
.viewer { position: fixed; inset: 0; z-index: 1100; background: rgba(20, 22, 20, .88); display: flex; flex-direction: column; }
.viewer[hidden] { display: none !important; }
.viewer-top { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 14px; }
.viewer-btn { min-height: 48px; min-width: 48px; padding: 0 18px; border-radius: 24px; border: none; background: rgba(255,255,255,.92);
  color: var(--text); font: inherit; font-size: 17px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; cursor: pointer; }
.viewer-btn.close { font-size: 22px; padding: 0; }
.viewer-body { flex: 1; overflow: auto; display: flex; align-items: center; justify-content: center; padding: 0 12px 16px; touch-action: pinch-zoom pan-x pan-y; }
.viewer-body img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; background: #ffffff; cursor: zoom-in; }
.viewer-body.zoom { align-items: flex-start; justify-content: flex-start; }
.viewer-body.zoom img { max-width: none; max-height: none; cursor: zoom-out; }
.viewer-msg { color: #ffffff; font-size: 18px; text-align: center; white-space: pre-line; }
body.noscroll { overflow: hidden; }

/* ===== スマホだけ: 下のメニュー・「その他」 ===== */
.tabbar, .sheet, .sheet-dim { display: none; }
@media (max-width: 700px) {
  .side { display: none; }                      /* 上のメニューは出さない */
  .top-right #logoutBtn { display: none; }      /* ログアウトは「その他」の中 */
  .main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 800;
    background: #ffffff; border-top: 1px solid var(--line); padding: 6px 4px calc(8px + env(safe-area-inset-bottom)); }
  .tb { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 58px; border-radius: 12px;
    color: var(--sub); text-decoration: none; font: inherit; font-size: 13px; background: none; border: none; cursor: pointer; }
  .tb.on { color: var(--blue); font-weight: 700; background: var(--blue-soft); }
  .sheet-dim:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 850; background: rgba(0,0,0,.28); }
  .sheet:not([hidden]) { display: flex; flex-direction: column; position: fixed; left: 0; right: 0; bottom: 0; z-index: 860; background: #ffffff;
    border-radius: 20px 20px 0 0; box-shadow: 0 -6px 20px rgba(0,0,0,.15); padding: 12px 16px calc(96px + env(safe-area-inset-bottom)); }
  .sheet-handle { width: 42px; height: 5px; border-radius: 3px; background: #d9d1b0; margin: 0 auto 10px; }
  .sheet-it { display: flex; align-items: center; gap: 12px; min-height: 58px; border: none; border-bottom: 1px solid #f0ead2; background: none;
    font: inherit; font-size: 18px; color: var(--text); text-decoration: none; text-align: left; padding: 0 6px; cursor: pointer; }
  .sheet-it.dim { color: #8a8778; }
  .sheet-it .soon { margin-left: auto; font-size: 12px; color: var(--sub); background: #f3f0e2; padding: 2px 8px; border-radius: 8px; }
  #sheetLogout { color: #a3341f; border-bottom: none; }
  .fab { bottom: calc(96px + env(safe-area-inset-bottom)); }    /* 「完了」は下のメニューの上に */
  /* ホーム: カードは2×2、ボタンは「レシートから入力」だけ大きく (ほかは下のメニューにある) */
  .cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card { padding: 14px 16px; }
  .card .num { font-size: 23px; }
  .actions { grid-template-columns: 1fr; }
  .actions .act:not(#actReceipt) { display: none; }
  .act#actReceipt { min-height: 68px; }
}
@media (max-width: 700px) { .tabbar { z-index: 870; } }

/* ===== 要相談・対象外 ===== */
.opt.ask[aria-pressed="true"] { border-color: #e0a800; background: #ffe9a6; color: #5a4300; }
.opt.out[aria-pressed="true"] { border-color: #9a9a90; background: #ecebe6; color: #555; }
.st-note { margin: 8px 0 0; font-size: 15px; color: var(--sub); }
tr.st-ask td { background: #fff4cc; }
tr.st-out td { color: #9a9a90; text-decoration: line-through; }
tr.st-out td.go { color: var(--blue); text-decoration: none; }
.badge { display: inline-block; font-size: 13px; padding: 1px 8px; border-radius: 8px; margin-left: 4px; vertical-align: middle; text-decoration: none; }
.badge.ask { background: #f5b400; color: #3a2c00; }
.badge.out { background: #ddd; color: #555; }
.ask-note { display: block; font-size: 15px; color: #8a6a00; text-align: right; }
.ask-note.rep { text-align: left; margin: 0 0 10px; }
.ask-band { background: #fff4cc; border: 2px solid #f5b400; color: #3a2c00; border-radius: 12px; padding: 12px 16px; margin: 0 0 12px; font-weight: 700; font-size: 17px; }
.st-filter { margin-bottom: 12px; }
.chk.ask-chk { color: #8a6a00; }
.chk.ask-chk + .chk { margin-left: 16px; }

/* ===== 入力画面: 1行まとめ と 開く部分 ===== */
.optsum { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: #f7f4e6; border-radius: 10px; padding: 12px 16px; font-size: 17px; }
.optsum .dot { color: #bbb; margin: 0 6px; }
.optsum .badge { font-size: 15px; font-weight: 700; margin-left: 0; }
.chg { border: none; background: none; color: var(--blue); font: inherit; font-size: 16px; font-weight: 700; cursor: pointer; padding: 4px 0; margin-left: auto; }
.fold { border: 1px solid #e6dfc4; border-radius: 10px; padding: 16px; margin-top: -10px; display: flex; flex-direction: column; gap: 12px; }
.fold[hidden] { display: none; }
.fl { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fl .t { width: 110px; font-size: 15px; font-weight: 700; color: var(--sub); }
.pills.seg { gap: 0; border: 1px solid #d8cfa8; border-radius: 8px; overflow: hidden; flex-wrap: nowrap; }
.pills.seg .opt { border: none; border-left: 1px solid #e6dfc4; border-radius: 0; min-height: 44px; padding: 0 14px; font-size: 15px; white-space: nowrap; }
.pills.seg .opt:first-child { border-left: none; }
.pills.seg .opt[aria-pressed="true"] { border: none; background: var(--blue); color: #ffffff; }
.pills.seg .opt.ask[aria-pressed="true"] { background: #f5b400; color: #3a2c00; }
.pills.seg .opt.out[aria-pressed="true"] { background: #9a9a90; color: #ffffff; }
.fold .st-note { margin: 0; }
@media (max-width: 700px) {
  .fl .t { width: 100%; }
  .pills.seg { flex-wrap: wrap; }
}
.optsum .nw { white-space: nowrap; }

/* ===== 月別集計 ===== */
.yonly .mgrid { opacity: .35; pointer-events: none; }   /* 月別集計: 月はえらべない (高さはそのまま) */
.yo-note { margin-left: auto; font-size: 15px; color: var(--sub); }
.mo-wrap { overflow-x: auto; }
.mo { border-collapse: separate; border-spacing: 0; font-size: 16px; white-space: nowrap; }
.mo th { font-size: 14px; color: var(--sub); font-weight: 700; padding: 8px 10px; border-bottom: 2px solid var(--line); text-align: right; background: #ffffff; }
.mo td { padding: 10px 10px; border-bottom: 1px solid #f0ead2; text-align: right; line-height: 1.5; background: #ffffff; }
.mo .acc { position: sticky; left: 0; z-index: 2; width: 170px; min-width: 170px; max-width: 170px; text-align: left; white-space: normal; font-weight: 700; }
.mo .yt { position: sticky; left: 170px; z-index: 2; font-weight: 700; background: #f4f8fc; border-right: 2px solid var(--line); }
.mo .easy { display: block; font-size: 13px; color: var(--sub); font-weight: 400; margin-top: 2px; line-height: 1.35; }
.mo .z { color: #cccccc; }
.mo tr.tot td { background: var(--blue-soft); color: var(--blue); font-weight: 700; border-bottom: none; }
.mo .code { margin-right: 6px; }
@media (max-width: 700px) {
  .mo .acc { width: 118px; min-width: 118px; max-width: 118px; }
  .mo .yt { left: 118px; }
  .yo-note { margin-left: 0; width: 100%; }
}

/* ===== 経費 / 収入 ===== */
.kindseg { width: max-content; max-width: 100%; }
.pills.seg.kindseg .opt { min-height: 50px; padding: 0 32px; font-size: 17px; }
.kindseg[hidden] { display: none; }
.inc-mode .exp-only, .inc-mode #rcptResults, .inc-mode #rcptAttached, .inc-mode #rcptRemoved { display: none !important; }
.inc-mode .pills.seg .opt[aria-pressed="true"], .inc-mode .chip[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #ffffff; }
.inc-mode .chip[aria-pressed="true"] .sub { color: #d3eedc; }
.inc-mode .btn.primary { background: var(--green); border-color: var(--green); }
.badge.inc { background: var(--green-soft); color: var(--green); font-weight: 700; }
.inc-note { display: block; font-size: 15px; color: var(--green); text-align: right; }
.inc-mode #rcptBox { opacity: .35; pointer-events: none; }   /* 収入: レシート入力は使わない (場所はそのまま) */
.per-top .ask-note, .per-top .inc-note { margin-top: 6px; line-height: 1.4; }

/* ===== 記録がある月 ===== */
.mbtn.has { background: #e6f0fb; border-color: #b9d3ef; color: var(--blue); font-weight: 700; }
.mbtn.has[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: #ffffff; }
.mleg { display: flex; align-items: center; gap: 6px; margin-top: -6px; font-size: 13px; color: var(--sub); }
.mleg .sw { width: 16px; height: 16px; border-radius: 4px; background: #e6f0fb; border: 1px solid #b9d3ef; }
.st-filter { align-items: center; }
.st-filter .notes { margin-left: auto; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.note-ask { font-size: 15px; color: #8a6a00; background: #fff4cc; border-radius: 8px; padding: 6px 12px; }
.note-inc { font-size: 15px; color: var(--green); }

/* ===== 記録する画面: 広い画面は左右2分割 ===== */
.main.wide { max-width: 1680px; }
.exp-layout { display: flex; flex-direction: column; gap: 20px; }
.exp-left { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.exp-layout .side-col { flex: none; }
.exp-left .form { flex: none; }
@media (min-width: 1300px) {
  .exp-layout { display: grid; grid-template-columns: minmax(560px, 680px) minmax(0, 1fr); align-items: start; gap: 24px; }
  .exp-layout .side-col { position: sticky; top: 16px; }
}
.rh { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.rh h2 { margin: 0; }
.rh-sum { font-size: 16px; color: var(--sub); }
.rh-sum b { font-size: 20px; color: var(--text); }
.side-col .more { display: block; text-align: right; margin-top: 12px; color: var(--blue); font-weight: 700; text-decoration: none; font-size: 16px; }
tr.just td { background: #e8f4ec; }

/* ===== 上の帯 (ヘッダーバー): ホーム=緑 / 仕事の画面=青 / 設定=紫  (やわらかいパステル) ===== */
.top { padding: 14px 20px; border-radius: 14px; }
.top-left { align-items: baseline; gap: 12px; }
.hsub { font-size: 14px; opacity: .85; }
.top.c-home { background: #dcefe3; color: #2e6e4a; }
.top.c-work { background: #dce9f7; color: #1e5a96; }
.top.c-set  { background: #e9e3f5; color: #5b4a8f; }
.top .pill { background: #ffffff; color: inherit; }
.top.c-home .pill { border-color: #b9dcc3; }
.top.c-work .pill { border-color: #b9d3ef; }
.top.c-set .pill  { border-color: #d3c9ea; }
/* 左メニュー: 3つのまとまり */
.msep { height: 1px; background: var(--line); margin: 8px 10px; }
.mgrow { flex: 1; }
@media (min-width: 701px) {   /* 左メニューは画面に固定 (設定がいつも下に見える) */
  .side { position: sticky; top: 0; height: 100vh; align-self: flex-start; overflow-y: auto; }
}
@media (max-width: 700px) {
  .top { padding: 10px 14px; }
  .hsub { display: none; }
  .msep, .mgrow { display: none; }
}

/* レシート候補: 残りを全部やめる */
.rc-all { display: flex; justify-content: flex-end; }
.rc-all .btn { flex: none; min-height: 48px; padding: 0 20px; }
.rc-all.ask { flex-wrap: wrap; align-items: center; gap: 10px; background: #fdecea; border: 1px solid #f1c4bd; border-radius: 12px; padding: 12px 16px; }
.rc-all.ask span { flex: 1 1 260px; font-weight: 700; color: #8a2c1c; }

/* 読み取った候補を直しているとき */
#expForm[hidden] { display: none; }
.candband { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  background: #fff4cc; border: 1px solid #f0d98a; border-radius: 12px; padding: 10px 14px; font-weight: 700; color: #5a4300; }
.candband[hidden] { display: none; }

/* 左メニュー: まとまりの名前 (押せない) と、その下の項目 */
.mgrp { font-size: 13px; font-weight: 700; color: #8a8676; letter-spacing: .05em; padding: 10px 14px 2px; }
.menu.sub { padding-left: 28px; }
@media (max-width: 700px) { .mgrp { display: none; } .menu.sub { padding-left: 14px; } }

/* ===== スマホ: 財務報告のチェック / その他メニュー / 直す画面 / 選ぶボタン ===== */
@media (max-width: 700px) {
  .chk.ask-chk + .chk { margin-left: 0; }
  .sheet-it.go { background: #f7f4e6; border-radius: 12px; border-bottom: none; padding: 0 14px; }
  .sheet-it .ic { display: flex; color: var(--text); }
  .sheet-it .ar { margin-left: auto; color: #8a8676; font-size: 24px; }
  .sheet-out { margin-top: 20px; min-height: 52px; border: 2px solid #c0472f; border-radius: 12px; background: #ffffff;
    color: #a3341f; font: inherit; font-size: 17px; font-weight: 700; cursor: pointer; }
  .sheet-who { margin-top: 8px; text-align: center; font-size: 13px; color: var(--sub); }
  .top.editing .hsub { display: inline; }
  .top.editing .top-left { flex-direction: column; align-items: flex-start; gap: 2px; }
  /* 消費税・払い方などは、つながった棒ではなく同じ大きさのボタンを3つずつ */
  .fold .pills.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; border: none; overflow: visible; width: 100%; }
  .fold .pills.seg .opt, .fold .pills.seg .opt:first-child { border: 1px solid #d8cfa8; border-radius: 8px; padding: 0 2px; white-space: nowrap; font-size: 14px; letter-spacing: -0.02em; }
  .fold .pills.seg .opt[aria-pressed="true"] { border-color: var(--blue); }
  .inc-mode .fold .pills.seg .opt[aria-pressed="true"] { border-color: var(--green); }
  .fold .pills.seg .opt.ask[aria-pressed="true"] { border-color: #f5b400; }
  .fold .pills.seg .opt.out[aria-pressed="true"] { border-color: #9a9a90; }
}

/* ホームの数字のカード: 押せる (記録一覧へ) */
.card.go { position: relative; text-decoration: none; color: inherit; cursor: pointer; }
.card.go::after { content: "›"; position: absolute; top: 12px; right: 16px; font-size: 24px; color: #a8a390; }
.card.go:hover { border-color: #b9d3ef; }

/* 直している途中で移ろうとしたときの確認 (画面の下に出す) */
.leave-ask { position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 950; width: min(560px, calc(100% - 24px));
  background: #ffffff; border: 2px solid #f0c36d; border-radius: 16px; box-shadow: 0 8px 28px rgba(0,0,0,.22); padding: 16px 18px; }
.leave-ask[hidden] { display: none; }
.leave-ask p { margin: 0 0 12px; font-weight: 700; font-size: 17px; color: #5a4300; }
.leave-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.leave-btns .btn { flex: 1 1 140px; min-height: 50px; }
@media (max-width: 700px) { .leave-ask { bottom: calc(92px + env(safe-area-inset-bottom)); } }

/* ===== 同じレシートがもうある ===== */
.dup { background: #fff4cc; border: 2px solid #f0c36d; border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; color: #5a4300; font-size: 15px; display: flex; flex-direction: column; gap: 6px; grid-column: 1 / -1; }
.dup b { font-size: 16px; }
.dup-old { display: flex; align-items: center; width: 100%; text-align: left; background: #ffffff; border: 1px solid #f0d98a; border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 15px; color: var(--text); cursor: pointer; }
.dup-old .go { margin-left: auto; color: #a8a390; font-size: 20px; }
.dup .tap { font-size: 12px; color: #8a6a00; }
.dup-now { background: #e8f4ec; border-radius: 8px; padding: 8px 10px; font-size: 15px; margin: 6px 0 12px; }
#dupAskList .dup-old { margin-bottom: 6px; }
.btn.warnb { border: 2px solid #e0a800; color: #5a4300; font-weight: 700; }
.peek { position: fixed; inset: 0; z-index: 960; background: rgba(0,0,0,.42); display: flex; align-items: center; justify-content: center; padding: 16px; }
.peek[hidden] { display: none; }
.peek-box { width: min(520px, 100%); max-height: 90vh; overflow-y: auto; background: #ffffff; border-radius: 18px; padding: 18px; box-shadow: 0 10px 30px rgba(0,0,0,.25); display: flex; flex-direction: column; gap: 10px; }
.peek-box h3 { margin: 0; font-size: 19px; }
.peek-note { font-size: 13px; color: var(--sub); }
.peek-body { display: flex; gap: 14px; align-items: flex-start; }
.peek-ph { flex: none; width: 100px; height: 130px; border-radius: 8px; overflow: hidden; background: #f3f0e2; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; color: var(--sub); }
.peek-ph img { width: 100%; height: 100%; object-fit: cover; }
.peek-body .info { flex: 1; display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; font-size: 15px; }
.peek-body .info span { color: var(--sub); }
.peek-body .info .easy { display: block; font-size: 13px; color: var(--sub); font-weight: 400; }
.peek-box .btn { min-height: 52px; flex: none; }

/* ===== 記録一覧: 絞りこみ (重ねて使える) ===== */
.fbar { display: flex; gap: 10px; }
.fbar input[type=search] { flex: 1; min-width: 0; min-height: 48px; border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; font: inherit; font-size: 17px; background: #ffffff; color: var(--text); }
.fopen { min-height: 48px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--blue); background: #ffffff; color: var(--blue); font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap; }
.fopen .cnt { display: inline-block; min-width: 22px; height: 22px; line-height: 22px; margin-left: 8px; border-radius: 11px; background: var(--blue); color: #ffffff; font-size: 13px; text-align: center; }
.fopen .cnt[hidden] { display: none; }
.fchips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.fchips:empty { display: none; }
.fchip { display: inline-flex; align-items: center; background: var(--blue-soft); color: var(--blue); border-radius: 999px; padding: 2px 2px 2px 14px; font-size: 15px; font-weight: 700; }
.fchip button { border: none; background: none; color: var(--blue); font-size: 20px; line-height: 1; width: 34px; height: 34px; cursor: pointer; border-radius: 50%; }
.fchip button:hover { background: #ffffff; }
.fclear { border: none; background: none; color: var(--sub); text-decoration: underline; font: inherit; font-size: 14px; cursor: pointer; padding: 8px; }
.fresult { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 18px; margin: 14px 0 10px; color: var(--sub); font-size: 16px; }
.fresult b { color: var(--text); font-size: 20px; }
.fresult .notes { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.fp-head { display: flex; align-items: center; justify-content: space-between; font-size: 18px; margin-bottom: 10px; }
.fp-head button { border: none; background: none; font-size: 20px; width: 40px; height: 40px; cursor: pointer; color: var(--sub); }
.fp-sec { margin-bottom: 18px; }
.fp-sec h4 { margin: 0 0 8px; font-size: 15px; color: var(--sub); font-weight: 700; }
.fp-sec .pills .opt { min-height: 44px; font-size: 15px; }
.fp-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.fp-row input { flex: 1; min-width: 0; min-height: 46px; border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; font: inherit; font-size: 16px; background: #ffffff; color: var(--text); }
.fp-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; }
.fp-foot .act { flex: 1; min-height: 50px; }
.fdim { display: none; }
@media (max-width: 1099px) {
  .fdim:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 880; background: rgba(0,0,0,.28); }
  .fpanel { display: none; }
  .fpanel.open { display: flex; flex-direction: column; position: fixed; left: 0; right: 0; bottom: 0; z-index: 890; background: #ffffff; border-radius: 20px 20px 0 0; max-height: 88vh; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 24px rgba(0,0,0,.18); }
  .fp-body { overflow-y: auto; flex: 1; }
}
@media (min-width: 1100px) {
  .list-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; }
  .fpanel { display: flex; flex-direction: column; position: sticky; top: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; }
  .fopen, #fClose, #fGo, .fdim { display: none !important; }
  .fp-foot { justify-content: flex-start; }
}
