/* 焼き菓子と喫茶 ミズハラ堂（デモ）経費の記録と月の集計 */
/* 共通部品は ⑩（10-shift）のクラス名のまま。:root の色の値だけ design.md §1 に替えた。.desk・.paper は ⑥、入力欄・.seg は ⑨ から */
:root {
  --c-base: #F6F4F0;
  --c-surface: #FFFFFF;
  --c-soft: #EAEEF2;
  --c-desk: #E3E7EC;
  --c-main: #2C4A63;
  --c-accent: #9A4B16;
  --c-accent-dark: #7D3C11;
  --c-text: #232B33;
  --c-sub: #59626B;
  --c-line: #D8DDE3;
  --c-good: #2E6B47;
  --c-good-bg: #E8F0EA;
  --c-bad: #B3261E;
  --c-bad-bg: #FDEDEB;
  --c-warn-bg: #FFF3D6;
  --c-warn: #5C4300;
  --c-warn-edge: #A87800;
  --c-info: #1F4E8C;
  --c-info-bg: #E3EEFA;
  --c-off-bg: #EDEDEA;
  --c-off: #4E5257;

  /* 紙面 */
  --p-ink: #1E2124;
  --p-sub: #555A60;
  --p-rule: #C9CCD1;
  --p-head: #EEF0F2;
  --p-seal: #B23A2E;

  --font-body: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", "Meiryo", "Noto Sans JP", sans-serif;
  --font-head: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", var(--font-body);
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --pad-x: 16px;
  --gap-block: 32px;
  --pad-card: 16px;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(35, 43, 51, .06);
  --tabs-h: 72px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--c-base);
  color: var(--c-text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.8;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
h1, h2, h3, h4, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--c-main); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--c-main); outline-offset: 2px; }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 var(--pad-x); }
.sub { font-size: 14px; color: var(--c-sub); line-height: 1.6; }
.sub--13 { font-size: 13px; }
.num { text-align: right; }
.nw { white-space: nowrap; }
svg { flex: none; }
[tabindex="-1"]:focus { outline: none; }
[tabindex="-1"]:focus-visible { outline: 3px solid var(--c-main); }
.card, .panel, [id^="h-"], .exp-card, .exp-list tr { scroll-margin-top: calc(var(--tabs-h) + 8px); }
.exp-list tbody tr { scroll-margin-top: calc(var(--tabs-h) + 56px); }
.pc-only { display: none; }

/* ---------- TENKA LAB バー（作品例・デモ 共通） ---------- */
.tl-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 40px; padding: 8px 16px; background: #1B2A41; color: #FFFFFF;
  font-family: var(--font-body); font-size: 13px; line-height: 1.5; letter-spacing: .04em;
}
.tl-bar__text { margin: 0; }
.tl-bar strong { font-weight: 700; }
.tl-bar__back {
  flex: none; position: relative; color: #FFFFFF; font-weight: 700;
  text-decoration: underline; text-underline-offset: 3px;
}
.tl-bar__back:hover { color: #FFFFFF; text-decoration-thickness: 2px; }
.tl-bar__back::before { content: ""; position: absolute; inset: -15px -8px; }
.tl-bar__back::after { content: "→"; margin-left: 4px; }
.tl-bar__back:focus-visible { outline: 3px solid #FFFFFF; outline-offset: 2px; }
@media (min-width: 768px) { .tl-bar { padding: 8px 32px; } }

/* ---------- ヘッダー ---------- */
.site-header { padding: 16px 0; border-bottom: 1px solid var(--c-line); }
.brand {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  font-size: 20px; font-weight: 700; line-height: 1.4; color: var(--c-main);
}
.brand__name { font-family: var(--font-head); }
.brand__logo { flex: none; }
.brand__demo {
  display: inline-flex; align-items: center; height: 20px; padding: 0 6px;
  background: var(--c-text); color: #fff; border-radius: 4px;
  font-family: var(--font-body); font-size: 12px; font-weight: 700; line-height: 1;
}
.brand__sub { margin-top: 4px; font-size: 14px; color: var(--c-sub); line-height: 1.6; }

main { padding-top: var(--gap-block); padding-bottom: var(--gap-block); }
main > * + * { margin-top: var(--gap-block); }

/* ---------- h1・リード・手順 ---------- */
.page-title { font-size: 22px; font-weight: 700; line-height: 1.4; color: var(--c-main); text-wrap: balance; }
.intro__lead { margin-top: 12px; }
.steps { display: grid; gap: 8px; margin-top: 24px; }
.step a {
  display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 16px;
  background: var(--c-surface); border: 1px solid var(--c-line); border-radius: 8px;
  color: var(--c-text); text-decoration: none; font-size: 14px; font-weight: 700; line-height: 1.5;
}
.step a:hover { border-color: var(--c-main); }
.step__num {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%; background: var(--c-main); color: #fff; font-size: 13px; font-weight: 700; line-height: 1;
}
.intro__notes { margin-top: 16px; font-size: 14px; color: var(--c-sub); line-height: 1.6; }

/* ---------- カード ---------- */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-line); border-top: 4px solid var(--c-main);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: var(--pad-card); min-width: 0;
}
.card__head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px;
  margin-bottom: 16px;
}
.card__head h2 { font-size: 18px; line-height: 1.4; color: var(--c-main); }
.card__head h3 { font-size: 16px; line-height: 1.5; color: var(--c-main); }
.card__link { margin-top: 24px; font-size: 14px; }

/* ---------- ボタン ---------- */
.btn-main {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 52px; padding: 0 32px; border: 0; border-radius: 26px;
  background: var(--c-accent); color: #fff; font-size: 16px; font-weight: 700; line-height: 1.3; cursor: pointer;
}
.btn-main [data-icon], .btn-sub [data-icon] { display: inline-flex; }
.btn-main:hover, .btn-main:active { background: var(--c-accent-dark); }
.btn-sub {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 20px; border: 2px solid var(--c-main); border-radius: 24px;
  background: var(--c-surface); color: var(--c-main); font-size: 15px; font-weight: 700; line-height: 1.3; cursor: pointer;
}
.btn-sub:hover { background: var(--c-soft); }
[aria-disabled="true"].btn-main, [aria-disabled="true"].btn-sub {
  background: var(--c-off-bg); color: var(--c-off); border-color: var(--c-off-bg); cursor: not-allowed;
}
.btn-sm {
  position: relative; min-height: 40px; padding: 0 14px; border-width: 1.5px; border-radius: 20px;
  font-size: 14px; gap: 2px; white-space: nowrap;
}
.btn-sm::before { content: ""; position: absolute; inset: -5px -2px; }
.btn-danger { border-color: var(--c-bad); color: var(--c-bad); }
.btn-danger:hover { background: var(--c-bad-bg); }
.text-link {
  display: inline-flex; align-items: center; gap: 6px; min-height: 48px;
  color: var(--c-main); font-size: 15px; text-decoration: underline; text-underline-offset: 3px;
}
.dot-list li { position: relative; padding-left: 1em; }
.dot-list li::before { content: "・"; position: absolute; left: 0; }

/* ---------- 切替（⑨の .seg） ---------- */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--c-line); border-radius: 24px; background: #FFFFFF; overflow: hidden; }
.seg__btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-height: 48px; padding: 0 6px; border: 0; background: #FFFFFF; color: var(--c-text);
  font-size: 15px; font-weight: 400; line-height: 1.3; cursor: pointer; text-align: center; white-space: nowrap;
}
.seg__btn + .seg__btn { border-left: 1px solid var(--c-line); }
.seg__btn[aria-checked="true"] { background: var(--c-main); color: #FFFFFF; font-weight: 700; }
.seg__btn:hover:not([aria-checked="true"]) { background: var(--c-soft); }
.seg__btn:focus-visible { outline-offset: -4px; outline-color: var(--c-main); }
.seg__btn[aria-checked="true"]:focus-visible { outline-color: #FFFFFF; }

/* ---------- 上の数字（.summary） ---------- */
.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.summary--3 .summary__box--flag { grid-column: 1 / -1; }
.summary__box {
  min-width: 0; min-height: 96px; padding: 12px 16px; background: var(--c-surface);
  border: 1px solid var(--c-line); border-radius: 12px; display: flex; flex-direction: column;
}
.summary__box--flag { box-shadow: inset 4px 0 0 var(--c-warn-edge); }
.summary__box--flag.is-ok { box-shadow: inset 4px 0 0 var(--c-good); }
.summary__label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; line-height: 1.4; }
.summary__icon { display: inline-flex; }
.summary__box--flag .summary__icon { color: var(--c-warn); }
.summary__box--flag.is-ok .summary__icon { color: var(--c-good); }
.summary__val { margin-top: 4px; line-height: 1.2; container-type: inline-size; }
.summary__val--delta { display: flex; align-items: center; gap: 4px; --yen-ic: 20px; }
.summary__n { font-size: 28px; font-weight: 700; }
/* 金額は折らずに、箱の幅と桁数（--yen-len：半角1・全角2。app.js が入れる）から文字の大きさを決める。
   1文字 .6em で見積もり、--yen-max より大きくはしない。三角の記号の分（--yen-ic）は先に引く
   （768px 以上の .summary__n の 32px に負けないよう、.summary__val を付けて強くする） */
.summary__val .summary__n--yen {
  --yen-max: 24px;
  font-size: clamp(12px, calc((100cqi - var(--yen-ic, 0px)) / (var(--yen-len, 8) * .6)), var(--yen-max));
  white-space: nowrap;
}
.summary--4 .summary__n--yen { --yen-max: 21px; }
.summary__unit { margin-left: 4px; font-size: 14px; color: var(--c-sub); }
.summary__break { margin-top: 6px; font-size: 13px; color: var(--c-text); line-height: 1.6; }
.summary__break .bk { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.summary__break .bk--dup { color: var(--c-warn); }
.summary__break .bk--nocat { color: var(--c-bad); }
.summary__break .bk--big { color: var(--c-info); }
.summary__break .bk > span { color: var(--c-text); }
.summary__break.is-ok { color: var(--c-good); font-weight: 700; }
.summary__link { margin-top: auto; padding-top: 4px; font-size: 14px; line-height: 1.4; }
.summary__link a { position: relative; display: inline-flex; align-items: center; min-height: 32px; font-weight: 700; text-underline-offset: 3px; }
.summary__link a::before { content: ""; position: absolute; inset: -8px -6px; }
.summary__note { margin-top: auto; padding-top: 6px; font-size: 13px; color: var(--c-sub); line-height: 1.4; }
.summary__note--text { color: var(--c-text); }
.delta__i { display: inline-flex; color: var(--c-text); }

/* ---------- タブ ---------- */
.tabs {
  position: sticky; top: 0; z-index: 20; display: flex; gap: 4px;
  background: var(--c-base); border-bottom: 1px solid var(--c-line);
}
.tabs__tab {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap;
  min-height: 52px; padding: 4px 6px; border: 0; border-radius: 8px 8px 0 0; background: transparent;
  color: var(--c-sub); font-size: 15px; font-weight: 700; line-height: 1.3; text-align: center; cursor: pointer;
  box-shadow: inset 0 -4px 0 transparent;
}
.tabs__tab:hover { background: var(--c-soft); }
.tabs__tab[aria-selected="true"] { color: var(--c-main); background: var(--c-surface); box-shadow: inset 0 -4px 0 var(--c-main); }
.tabs__tab:focus-visible { outline-offset: -3px; }
.tabs__badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 11px; background: var(--c-main); color: #FFFFFF; font-size: 12px; font-weight: 700; line-height: 1; white-space: nowrap;
}
.tabs__badge--warn { background: var(--c-warn-bg); color: var(--c-warn); border: 1px solid var(--c-warn); }
.panel { padding-top: 24px; }
.panel > * + * { margin-top: 24px; }

/* ---------- 入力欄（⑨） ---------- */
.field + .field { margin-top: 16px; }
.field__label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 700; line-height: 1.4; }
.field__req { margin-left: 6px; font-size: 12px; font-weight: 400; color: var(--c-sub); }
.field__hint { margin-top: 6px; font-size: 13px; color: var(--c-sub); line-height: 1.5; }
.field__err { margin-top: 6px; font-size: 14px; font-weight: 700; color: var(--c-bad); line-height: 1.5; }
.select, .input {
  display: block; width: 100%; min-height: 48px; padding: 0 12px; border: 1.5px solid var(--c-sub); border-radius: 8px;
  background: #FFFFFF; font-size: 16px; line-height: 1.4;
}
.input[type="date"] { appearance: none; -webkit-appearance: none; }
.select { padding-right: 36px; appearance: none; -webkit-appearance: none;
  background: #FFFFFF url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%232C4A63' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center / 16px 16px;
}
.textarea { min-height: 80px; padding: 12px; resize: vertical; line-height: 1.5; }
.input[aria-invalid="true"] { border: 2px solid var(--c-bad); }
.yen-input { position: relative; }
.yen-input .input { padding-right: 40px; }
.yen-input__unit { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 15px; color: var(--c-sub); pointer-events: none; }
.seg--pay .seg__btn svg { width: 16px; height: 16px; }
.cat-hint {
  display: flex; align-items: flex-start; gap: 6px; margin-top: 6px; padding: 8px 12px;
  background: var(--c-soft); border-radius: 8px; font-size: 13px; line-height: 1.5; color: var(--c-text);
}
.cat-hint__i { display: inline-flex; color: var(--c-main); margin-top: 2px; }
.entry__add { margin-top: 24px; }

/* ---------- 気づきの印（§1-2） ---------- */
.flags { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.flag {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px 0 6px;
  border-radius: 4px; font-size: 13px; font-weight: 700; line-height: 1; white-space: nowrap;
}
.flag--dup { background: var(--c-warn-bg); border: 1px solid var(--c-warn); color: var(--c-warn); }
.flag--nocat { background: var(--c-bad-bg); border: 1.5px dashed var(--c-bad); color: var(--c-bad); }
.flag--big { background: var(--c-info-bg); border: 1px solid var(--c-info); color: var(--c-info); border-radius: 14px; }
[data-edge="dup"] { --edge: var(--c-warn-edge); }
[data-edge="nocat"] { --edge: var(--c-bad); }
[data-edge="big"] { --edge: var(--c-info); }
.cat-none { font-weight: 700; color: var(--c-bad); }

/* ---------- 一覧（§7-5・7-6） ---------- */
.filters { display: grid; gap: 12px; margin-bottom: 16px; }
.filters .field__label { margin-bottom: 4px; }
.check { display: inline-flex; align-items: center; gap: 10px; min-height: 48px; font-size: 15px; font-weight: 700; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--c-main); }
.list-none { padding: 16px 0; font-size: 14px; color: var(--c-sub); }
.list-none .text-link { margin-left: 8px; font-size: 14px; }

.exp-cards { display: grid; gap: 8px; }
.exp-card {
  display: block; width: 100%; min-height: 72px; padding: 12px 16px; text-align: left; cursor: pointer;
  background: #FFFFFF; border: 1px solid var(--c-line); border-radius: 12px; line-height: 1.4;
}
.exp-card[data-edge] { box-shadow: inset 4px 0 0 var(--edge); }
.exp-card:hover { border-color: var(--c-main); }
.exp-card > span { display: block; }
.exp-card__date { font-size: 13px; color: var(--c-sub); }
.exp-card__r1 { display: flex !important; justify-content: space-between; align-items: baseline; gap: 12px; margin-top: 2px; }
.exp-card__payee { font-size: 16px; font-weight: 700; min-width: 0; }
.exp-card__amt { font-size: 16px; font-weight: 700; white-space: nowrap; }
.exp-card__r2 { display: flex !important; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 4px; font-size: 13px; color: var(--c-sub); }
.exp-card__memo { margin-top: 4px; font-size: 13px; color: var(--c-sub); line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.exp-list { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.exp-list .c-date { width: 88px; }
.exp-list .c-cat { width: 120px; }
.exp-list .c-pay { width: 72px; }
.exp-list .c-amt { width: 104px; }
.exp-list .c-op { width: 80px; }
.exp-list thead th {
  position: sticky; top: var(--tabs-h); z-index: 5; height: 48px; padding: 4px 8px; background: var(--c-soft); color: var(--c-sub);
  font-size: 13px; font-weight: 700; line-height: 1.4; text-align: left;
}
.exp-list thead th.num { text-align: right; }
.exp-list thead th.op { text-align: center; }
.exp-list td { height: 56px; padding: 8px; border-bottom: 1px solid var(--c-line); vertical-align: middle; font-size: 14px; line-height: 1.4; }
.exp-list tr[data-edge] > td:first-child { box-shadow: inset 4px 0 0 var(--edge); }
.exp-list td:first-child { padding-left: 12px; }
.exp-list__date { color: var(--c-sub); white-space: nowrap; }
.exp-list__payee { display: block; font-size: 15px; font-weight: 700; }
.exp-list__memo { display: block; font-size: 13px; color: var(--c-sub); line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exp-list .flags { margin-top: 4px; }
.exp-list__amt { font-size: 15px; font-weight: 700; text-align: right; white-space: nowrap; }
.exp-list__op { text-align: center; }
.exp-list__pay-in { display: none; }
.is-new { animation: row-new 1.2s ease-out; }
.is-new > td { animation: row-new 1.2s ease-out; }
@keyframes row-new { from { background-color: #FFF3D6; } to { background-color: #FFFFFF; } }

/* ---------- 修正の窓（§7-8） ---------- */
.edit {
  width: 100%; max-width: none; max-height: calc(100dvh - 24px); margin: auto 0 0; padding: 0;
  border: 0; border-radius: 16px 16px 0 0; background: #FFFFFF; color: var(--c-text); overflow-y: auto;
}
.edit::backdrop, .confirm::backdrop { background: rgba(35, 43, 51, .5); }
.edit__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 8px 4px 16px; }
.edit__title { font-size: 18px; font-weight: 700; color: var(--c-main); line-height: 1.4; }
.edit__x { display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; border: 0; background: none; color: var(--c-main); cursor: pointer; border-radius: 8px; }
.edit__meta { padding: 0 16px 12px; font-size: 14px; color: var(--c-sub); border-bottom: 1px solid var(--c-line); }
.edit__body { padding: 16px; }
.edit__ops { display: grid; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--c-line); }

/* ---------- 月の集計（§8） ---------- */
.bar { position: relative; flex: 1 1 auto; min-width: 0; height: 12px; border-radius: 6px; background: var(--c-soft); overflow: hidden; }
.bar__fill { display: block; height: 100%; border-radius: 6px; background: var(--c-main); }
.bar__fill--none { background: var(--c-bad); }
.share { display: flex; align-items: center; gap: 8px; }
.share__pct { flex: none; width: 56px; text-align: right; font-weight: 700; white-space: nowrap; }
.delta { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; color: var(--c-text); }
.delta--zero, .delta--na { color: var(--c-sub); }
.delta__pct { display: block; font-size: 13px; }

.cat-table, .pay-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 15px; line-height: 1.5; }
.cat-table th, .cat-table td, .pay-table th, .pay-table td { padding: 10px 8px; border-bottom: 1px solid var(--c-line); text-align: left; vertical-align: middle; }
.cat-table thead th, .pay-table thead th { padding: 8px; background: var(--c-soft); color: var(--c-sub); font-size: 13px; font-weight: 700; line-height: 1.4; }
.cat-table .num, .pay-table .num { text-align: right; white-space: nowrap; }
.cat-table tbody th, .pay-table tbody th { font-weight: 700; }
.cat-table .c-name, .pay-table .c-name { width: 168px; }
.row-none { white-space: nowrap; }
.cat-table .c-n, .pay-table .c-n { width: 64px; }
.cat-table .c-sum, .pay-table .c-sum { width: 120px; }
.cat-table .c-oct { width: 104px; }
.cat-table .c-delta { width: 152px; }
.cat-table .t-sum, .pay-table .t-sum { font-weight: 700; }
.cat-table .t-oct { font-size: 14px; color: var(--c-sub); }
.cat-table tr.is-total > *, .pay-table tr.is-total > * { border-top: 2px solid var(--c-main); font-weight: 700; }
.row-none { display: inline-flex; align-items: center; gap: 4px; color: var(--c-bad); }
.pay-name { display: inline-flex; align-items: center; gap: 6px; }
.pay-name svg { color: var(--c-main); }
.cat__note { margin-top: 12px; }
.pay__note { margin-top: 4px; }
.pay__note--row { display: block; font-weight: 400; }
.linkbtn { padding: 0 4px; border: 0; background: none; cursor: pointer; font-weight: 700; }

.cat-block { padding: 12px 0; border-bottom: 1px solid var(--c-line); }
.cat-block.is-total { border-top: 2px solid var(--c-main); border-bottom: 0; }
.cat-block__r1 { display: flex; align-items: baseline; gap: 8px; }
.cat-block__name { font-size: 15px; font-weight: 700; }
.cat-block__n { font-size: 13px; color: var(--c-sub); }
.cat-block__sum { margin-left: auto; font-size: 16px; font-weight: 700; white-space: nowrap; }
.cat-block .share { margin-top: 6px; font-size: 14px; }
.cat-block__oct { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; margin-top: 6px; font-size: 13px; line-height: 1.5; }
.cat-block__oct .delta__pct { display: inline; }

.left-line { font-size: 16px; line-height: 1.8; }
.left-line .lp { display: inline-block; margin-right: 6px; }
.left-line strong { font-size: 18px; }
.left__notes { margin-top: 12px; }
.left__notes li + li { margin-top: 2px; }
.left__notes a, .work-safe a { position: relative; }
.left__notes a::before, .work-safe a::before { content: ""; position: absolute; inset: -16px -4px; }

/* ---------- 出力（§9） ---------- */
.out__desc { font-size: 14px; line-height: 1.7; }
.out__row { display: grid; gap: 8px; margin-top: 16px; }
.out__peek-h { margin-top: 24px; margin-bottom: 8px; font-size: 14px; font-weight: 700; }
.csv-peek {
  margin: 0; padding: 12px 16px; background: var(--c-desk); border-radius: 8px; color: var(--c-text);
  font-family: var(--font-mono); font-size: 13px; line-height: 1.6; white-space: pre; overflow-x: auto; max-width: 100%;
}
.rules { margin-top: 16px; }
.rules summary {
  display: flex; align-items: center; min-height: 48px; cursor: pointer;
  font-size: 14px; font-weight: 700; color: var(--c-main);
}
.cols { border-collapse: collapse; font-size: 14px; margin: 4px 0 8px; }
.cols th, .cols td { padding: 4px 10px; border-bottom: 1px solid var(--c-line); text-align: left; }
.cols thead th { background: var(--c-soft); color: var(--c-sub); font-size: 13px; }

.desk { background: var(--c-desk); border-radius: var(--radius); padding: 12px; }
.paper {
  max-width: 640px; margin: 0 auto; padding: 16px;
  background: #FFFFFF; color: var(--p-ink); border-radius: 2px;
  box-shadow: 0 1px 2px rgba(31, 26, 23, .08), 0 12px 32px rgba(59, 47, 40, .14);
  font-size: 13px; line-height: 1.5;
}
.sheet__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 8px 16px; margin-bottom: 12px; }
.sheet__title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.sheet__t { font-family: var(--font-head); font-size: 20px; font-weight: 700; }
.sheet__period { font-size: 13px; }
.sheet__shop { position: relative; display: flex; align-items: center; gap: 4px; padding-right: 30px; font-size: 13px; }
.sheet__shop .stamp { position: absolute; right: -6px; top: 50%; width: 40px; height: 40px; margin-top: -20px; transform: rotate(-4deg); opacity: .9; }
.sheet__h { margin: 12px 0 6px; font-size: 14px; font-weight: 700; }
.sheet__scroll { overflow-x: auto; }
.sheet table { border-collapse: collapse; table-layout: fixed; border: 1.5px solid var(--p-ink); }
.sheet th, .sheet td { padding: 4px 6px; border-bottom: 1px solid var(--p-rule); text-align: left; vertical-align: top; line-height: 1.4; }
.sheet thead th { background: var(--p-head); font-size: 12px; font-weight: 700; border-bottom: 1.5px solid var(--p-ink); }
.sheet .num { text-align: right; white-space: nowrap; }
.sheet__cats { width: 100%; max-width: 480px; min-width: 360px; }
.sheet__cats .sw-name { width: 42%; }
.sheet__cats .sw-n { width: 15%; }
.sheet__cats .sw-sum { width: 25%; }
.sheet__cats .sw-pct { width: 18%; }
.sheet__sum th, .sheet__sum td { border-top: 1.5px solid var(--p-ink); font-weight: 700; background: var(--p-head); }
.sheet__sum .sheet__yen { font-family: var(--font-head); }
.sheet__more { margin-top: 8px; font-size: 12px; color: var(--p-sub); }
.sheet__note { margin-top: 6px; font-size: 12px; color: var(--p-sub); }
.sheet__foot { margin-top: 12px; padding-top: 6px; border-top: 1px solid var(--p-rule); font-size: 12px; color: var(--p-sub); text-align: center; }

/* ---------- 最初の状態に戻す ---------- */
.reset-btn { width: 100%; }

/* ---------- 実際のお仕事では ---------- */
.work-boxes { display: grid; gap: 16px; margin-top: 24px; }
.work-box { padding: 20px; background: var(--c-base); border: 1px solid var(--c-line); border-radius: 8px; }
.work-box h3 { margin-top: 8px; font-size: 16px; line-height: 1.5; }
.work-box .dot-list { margin-top: 8px; font-size: 15px; line-height: 1.7; }
.work-safe { margin-top: 16px; font-size: 14px; line-height: 1.6; }

/* ---------- 確認の窓（⑩） ---------- */
.confirm {
  width: min(480px, calc(100% - 32px)); max-width: none; padding: 24px; border: 0; border-top: 4px solid var(--c-main);
  border-radius: 12px; background: #FFFFFF; color: var(--c-text);
}
.confirm__title { font-size: 18px; font-weight: 700; color: var(--c-main); line-height: 1.4; }
.confirm__body { margin-top: 12px; font-size: 15px; line-height: 1.7; }
.confirm__ops { display: grid; gap: 8px; margin-top: 24px; }
.confirm__cancel {
  min-height: 48px; padding: 0 16px; border: 0; background: none; color: var(--c-main);
  font-size: 15px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}

/* ---------- 知らせ ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 30; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; width: max-content; max-width: min(480px, calc(100% - 32px));
  padding: 12px 16px; background: var(--c-text); color: #fff; border-radius: 8px; font-size: 15px; line-height: 1.5;
}
.toast.is-in { animation: toast-in 200ms ease-out both; }
@keyframes toast-in { from { transform: translate(-50%, 8px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* ---------- フッター ---------- */
.site-footer {
  background: var(--c-text); color: var(--c-base); font-size: 15px; line-height: 1.8;
  padding: 48px 16px; text-align: center;
}
.site-footer p + p { margin-top: 16px; }
.site-footer :focus-visible { outline-color: #FFFFFF; }
.btn {
  display: flex; align-items: center; justify-content: center; width: 100%; max-width: 100%; min-height: 52px;
  margin: 0 auto; border-radius: 26px; background: var(--c-accent); color: #fff;
  font-size: 16px; font-weight: 700; text-decoration: none;
}
.btn:hover, .btn:active { background: var(--c-accent-dark); }
.copy { font-size: 12px; }

#print-root { display: none; }

@media (prefers-reduced-motion: reduce) {
  .toast.is-in, .is-new, .is-new > td { animation: none; }
  html { scroll-behavior: auto; }
}

/* ---------- 〜767px ---------- */
@media screen and (max-width: 767px) {
  .sheet__scroll .sheet__cats { min-width: 480px; }
  /* 「入力・一覧」と印のバッジを1行に収めるため、このタブだけ少し広くする */
  .tabs__tab { font-size: 14px; gap: 4px; }
  #tab-entry { flex: 1.35; }
}

/* ---------- 768px 以上 ---------- */
@media (min-width: 768px) {
  :root { --pad-x: 32px; --gap-block: 48px; --pad-card: 24px; }
  .sp-only { display: none; }
  .pc-only { display: inline; }
  .site-header { padding: 24px 0; }
  .brand { font-size: 22px; }
  .page-title { font-size: 28px; }
  .card__head h2 { font-size: 20px; }
  .steps { grid-template-columns: 1fr 1fr 1fr; gap: 12px 24px; }
  .step a { min-height: 56px; }
  .summary { gap: 16px; }
  .summary--3 { grid-template-columns: 1fr 1fr 2fr; }
  .summary--3 .summary__box--flag { grid-column: auto; }
  .summary--4 { grid-template-columns: 1fr 1fr 1fr 1.4fr; }
  .summary__box { padding: 16px 20px; }
  .summary__label { font-size: 14px; }
  .summary__n { font-size: 32px; }
  .summary__n--yen, .summary--4 .summary__n--yen { --yen-max: 28px; }
  .tabs { justify-content: flex-start; }
  .tabs__tab { flex: none; padding: 0 16px; font-size: 16px; flex-wrap: nowrap; }
  .filters { grid-template-columns: 200px minmax(0, 320px) auto; align-items: end; gap: 12px 16px; }
  .exp-list__date { font-size: 14px; }
  .edit {
    width: 520px; max-height: calc(100dvh - 48px); margin: auto; border-radius: 12px; border-top: 4px solid var(--c-main);
  }
  .edit__ops { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
  .edit__save { width: 200px; order: 3; }
  .btn-danger { order: 1; margin-right: auto; }
  .edit__ops .confirm__cancel { order: 2; padding: 0 8px; }
  .out__row { grid-template-columns: 300px minmax(0, 1fr); align-items: center; gap: 16px; }
  .out__print { width: 280px; }
  .left-line { font-size: 16px; }
  .left-line strong { font-size: 20px; }
  .desk { padding: 24px; }
  .paper { padding: 32px; }
  .reset-btn { width: 240px; }
  .confirm__ops { display: flex; flex-direction: row-reverse; justify-content: flex-start; align-items: center; gap: 8px; }
  .work-boxes { grid-template-columns: 1fr 1fr; gap: 24px; }
  .btn { width: 280px; }
}

/* ---------- 1024px 以上（入力 360px ＋ 一覧） ---------- */
@media (min-width: 1024px) {
  .steps { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 24px; }
  .step { position: relative; }
  .step + .step::before {
    content: ""; position: absolute; left: -20px; top: 50%; width: 16px; height: 16px; margin-top: -8px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2 8h11M9 4l4 4-4 4' fill='none' stroke='%2359626B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center / 16px 16px;
  }
  .entry-body { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 32px; align-items: start; }
  .entry { position: sticky; top: calc(var(--tabs-h) + 16px); }
  .filters { grid-template-columns: minmax(0, 200px) minmax(0, 1fr); }
  .filters__item--flag { grid-column: 1 / -1; }
}
/* 1024〜1279px：一覧の支払方法の列を科目の列にまとめる（支払先の列を広く） */
@media (min-width: 1024px) and (max-width: 1279px) {
  .exp-list .c-pay, .exp-list .t-pay { display: none; }
  .exp-list__pay-in { display: block; font-size: 13px; color: var(--c-sub); }
}

/* ---------- 印刷（A4 縦・2ページ以内。§9-5） ---------- */
@page { size: A4 portrait; margin: 12mm; }

@media print {
  html, body { background: #FFFFFF !important; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; color: #000000; }
  #print-root .print-empty { font-size: 12pt; }
  #print-root .sheet { width: 186mm; font-size: 9pt; line-height: 1.3; color: #000000; }
  #print-root .sheet__head { margin: 0 0 3mm; align-items: center; flex-wrap: nowrap; }
  #print-root .sheet__t { font-size: 16pt; }
  #print-root .sheet__period, #print-root .sheet__shop { font-size: 10pt; }
  /* 角印は店名の行の上端にそろえ（上の余白の線で切れないように）、文字との間を 3mm 空ける */
  #print-root .sheet__shop { min-height: 13mm; padding-right: 15mm; }
  #print-root .sheet__shop .stamp { top: .5mm; right: .5mm; width: 12mm; height: 12mm; margin-top: 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #print-root .sheet__h { margin: 4mm 0 1.5mm; font-size: 11pt; }
  #print-root .sheet table { border: 1pt solid #000000; }
  #print-root .sheet th, #print-root .sheet td { padding: .8mm 1.5mm; border-bottom: .5pt solid var(--p-rule); color: #000000; }
  #print-root .sheet thead th { height: 6mm; font-size: 8.5pt; border-bottom: 1pt solid #000000; vertical-align: middle; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #print-root .sheet tbody tr { height: 6mm; }
  #print-root .sheet__sum th, #print-root .sheet__sum td { border-top: 1pt solid #000000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #print-root .sheet__cats { width: 120mm; min-width: 0; max-width: none; }
  #print-root .sheet__cats .sw-name { width: 50mm; }
  #print-root .sheet__cats .sw-n { width: 18mm; }
  #print-root .sheet__cats .sw-sum { width: 30mm; }
  #print-root .sheet__cats .sw-pct { width: 22mm; }
  #print-root .sheet__pays { width: 120mm; }
  #print-root .sheet__detail { width: 186mm; }
  #print-root .sheet__detail thead { display: table-header-group; }
  #print-root .sheet__detail .sw-date { width: 22mm; }
  #print-root .sheet__detail .sw-payee { width: 40mm; }
  #print-root .sheet__detail .sw-cat { width: 28mm; }
  #print-root .sheet__detail .sw-pay { width: 18mm; }
  #print-root .sheet__detail .sw-amt { width: 24mm; }
  #print-root .sheet__detail td { white-space: normal; }
  #print-root .sheet__detail td.nw { white-space: nowrap; padding-right: .5mm; }
  #print-root .sheet__memo { white-space: pre-wrap; }
  #print-root .sheet__dsum { margin-top: 2mm; font-size: 10pt; font-weight: 700; text-align: right; }
  #print-root .sheet__note { font-size: 8pt; color: #000000; }
  #print-root .sheet__foot { margin-top: 3mm; font-size: 8pt; color: #000000; }
  #print-root tr { break-inside: avoid; }
}
