:root {
  color-scheme: light dark;
  --bg: #f4f7fa;
  --card: #fff;
  --ink: #17212b;
  --muted: #66717c;
  --line: #d8e0e7;
  --brand: #1769aa;
  --brand-strong: #0f4f83;
  --danger: #b42318;
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: system-ui, -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif; line-height: 1.45; }
button, input, select, textarea { font: inherit; }
button, select, input, textarea { min-height: 44px; }
button { cursor: pointer; touch-action: manipulation; }
button:active { transform: scale(.98); }
main { max-width: 560px; margin: 0 auto; padding: calc(16px + var(--safe-top)) 16px calc(96px + var(--safe-bottom)); }
.topbar, .field-heading, .sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar { margin-bottom: 14px; }
.eyebrow { color: var(--brand); font-size: 12px; font-weight: 700; letter-spacing: .08em; margin: 0; }
h1 { font-size: 24px; margin: 2px 0 0; }
.main-link { color: var(--brand); font-size: 12px; min-height: 44px; display: inline-flex; align-items: center; }
.gear-button { width: 44px; min-height: 44px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--brand); }
.modebar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px; }
.mode-button, .sheet-choice, .chip, .more-button { border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); }
.mode-button { font-weight: 700; }
.mode-button.is-active, .chip.is-selected { background: var(--brand); color: #fff; border-color: var(--brand); }
.current-mode { color: var(--muted); font-size: 14px; margin: 4px 0 14px; }
.message { min-height: 24px; color: var(--danger); font-size: 14px; margin: 0 0 6px; }
.sheet { position: fixed; z-index: 10; left: 0; right: 0; bottom: 0; padding: 16px 16px calc(16px + var(--safe-bottom)); background: var(--card); border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; box-shadow: 0 -8px 28px rgb(0 0 0 / .15); }
.sheet-head { margin-bottom: 8px; }
.sheet-choice { display: block; width: 100%; text-align: left; padding: 10px 12px; margin-top: 6px; }
.plain-button { border: 0; background: transparent; color: var(--brand); min-height: 44px; }
.amount-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.amount-wrap { display: flex; align-items: center; gap: 8px; padding: 0 4px; border-bottom: 2px solid var(--brand); margin-bottom: 20px; }
.amount-wrap span { font-size: 30px; color: var(--muted); }
#amount { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 42px; font-weight: 700; padding: 4px 0 8px; }
.field-section { margin: 18px 0; }
.field-heading, .field-section > label { font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.field-hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.chip { padding: 8px 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-chip { min-height: 58px; overflow: visible; text-overflow: clip; white-space: normal; overflow-wrap: anywhere; line-height: 1.25; }
.account-chips { grid-template-columns: repeat(4, 1fr); }
.account-other { margin-top: 8px; }
.more-button { width: 100%; padding: 8px; margin-top: 8px; color: var(--brand); }
select, textarea, input[type="date"] { width: 100%; border: 1px solid var(--line); border-radius: 9px; background: var(--card); color: var(--ink); padding: 9px 10px; }
.destination-box { margin-top: 8px; border-radius: 9px; border: 1px dashed var(--brand); padding: 10px; color: var(--brand); font-size: 14px; }
details { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 20px; }
summary { color: var(--brand); cursor: pointer; min-height: 44px; padding-top: 8px; }
details label { display: block; font-size: 13px; color: var(--muted); margin: 7px 0 3px; }
.memo-section { margin-top: 18px; }
.memo-section label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 3px; }
.memo-section textarea { min-height: 44px; resize: vertical; }
.save-button { width: 100%; border: 0; border-radius: 12px; background: var(--brand); color: #fff; font-weight: 700; margin-top: 18px; padding: 12px; }
.save-button:disabled { opacity: .6; }
.status-card, .recent-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-top: 16px; }
.status-card { font-size: 14px; }
.failed-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--danger); border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }
.failed-item button { border: 1px solid var(--danger); border-radius: 8px; background: transparent; color: var(--danger); padding: 4px 8px; }
.recent-card h2 { font-size: 15px; margin: 0 0 4px; }
.recent-card ol { padding-left: 22px; margin: 0; }
.recent-card li { padding: 5px 0; font-size: 13px; }
.recent-amount { float: right; font-weight: 700; }
.bottom-tabs { position: sticky; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 24px -16px 0; padding: 8px 16px calc(8px + var(--safe-bottom)); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px); }
.bottom-tab { min-height: 48px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--muted); font-weight: 700; }
.bottom-tab.is-active { background: var(--brand); color: #fff; border-color: var(--brand); }
.period-nav { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin: 8px 0 14px; text-align: center; }
.period-button { border: 1px solid var(--line); border-radius: 9px; background: var(--card); color: var(--brand); padding: 5px 8px; }
.period-button:last-child { justify-self: end; }
.period-button:disabled { opacity: .45; }
.summary-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-top: 12px; }
.summary-card h2 { font-size: 16px; margin: 0 0 10px; }
.summary-numbers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.summary-numbers div { display: grid; gap: 3px; }
.summary-numbers span, .summary-numbers small { color: var(--muted); font-size: 12px; }
.summary-numbers strong { font-size: 18px; }
.summary-numbers small { grid-column: 1 / -1; text-align: left; margin-top: 5px; }
.budget-row { margin: 10px 0; }
.budget-head, .account-row, .lending-card { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.budget-head { font-size: 13px; }
.budget-track { height: 8px; margin-top: 5px; background: var(--line); border-radius: 99px; overflow: hidden; }
.budget-bar { height: 100%; background: var(--brand); border-radius: inherit; }
.budget-bar.is-over { background: var(--danger); }
.account-row { border-top: 1px solid var(--line); padding: 9px 0; font-size: 14px; }
.account-row:first-child { border-top: 0; }
.lending-card strong { color: var(--brand); }
.date-heading { color: var(--muted); font-size: 12px; margin: 15px 0 4px; }
.transaction-row { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 12px; border: 0; border-top: 1px solid var(--line); background: transparent; color: var(--ink); padding: 10px 0; text-align: left; }
.transaction-main { display: grid; gap: 2px; min-width: 0; }
.transaction-main small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transaction-row > strong { white-space: nowrap; }
.transaction-row.is-locked { opacity: .65; }
.empty-state, .sheet-note { color: var(--muted); font-size: 13px; }
.login-panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-top: 10px; }
.login-panel p { margin: 0 0 10px; }
.wide-sheet { max-height: 88vh; overflow: auto; }
.wide-sheet label { display: block; color: var(--muted); font-size: 13px; margin: 9px 0 3px; }
.wide-sheet input, .wide-sheet select, .wide-sheet textarea { width: 100%; }
.special-form { margin-top: 4px; }
.danger-button { width: 100%; min-height: 44px; border: 1px solid var(--danger); border-radius: 10px; background: transparent; color: var(--danger); font-weight: 700; margin-top: 8px; }
.sheet-choice + .sheet-note { margin-bottom: 0; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; } button:active { transform: none; } }
@media (prefers-color-scheme: dark) { :root { --bg: #101820; --card: #18232d; --ink: #edf3f7; --muted: #a9b5bd; --line: #344552; --brand: #65b5ef; --brand-strong: #8acbfa; } }

/* 経費申請への入口（記録ボタンの下） */
.claim-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; margin-top: 14px; padding: 10px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; color: var(--ink); text-decoration: none; }
.claim-row:active { background: var(--line); }
.claim-text { display: flex; flex-direction: column; gap: 2px; }
.claim-text strong { font-size: 15px; }
.claim-text span { font-size: 12px; color: var(--muted); }
.claim-chevron { color: var(--muted); flex: none; }

/* 段階2a：提出（締め日の残高） */
.closing-period-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.closing-period-head select { width: auto; min-width: 150px; }
.closing-step { white-space: pre-line; border-top: 1px solid var(--line); padding: 12px 0; font-size: 14px; }
.closing-step:first-child { border-top: 0; }
.closing-step.is-active { width: 100%; border-left: 0; border-right: 0; border-bottom: 0; background: transparent; color: var(--brand); text-align: left; font-weight: 700; }
.closing-accounts { margin-top: 12px; }
.closing-account-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-top: 12px; }
.closing-account-card h3 { font-size: 17px; margin: 0 0 10px; overflow-wrap: anywhere; }
.closing-account-card label { display: block; color: var(--muted); font-size: 13px; margin-top: 10px; }
.closing-account-card input, .closing-account-card textarea { width: 100%; }
.closing-book, .closing-diff, .closing-state { margin: 6px 0; font-size: 14px; }
.closing-diff { font-weight: 700; }
.closing-state { color: var(--muted); }
.closing-evidence { margin-top: 8px; font-size: 13px; }
.closing-evidence > div { display: flex; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); padding: 7px 0; }
.closing-evidence span { overflow-wrap: anywhere; }
.closing-evidence a { color: var(--brand); white-space: nowrap; }
.closing-upload-state, .closing-locked-note { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.closing-account-card input:disabled, .closing-account-card textarea:disabled, .closing-account-card button:disabled { opacity: .65; }

/* 下部タブは常に画面の一番下に固定（中身が短い画面でも途中に浮かせない）。
   本文側は main の下余白（96px＋セーフエリア）で隠れないようにしている */
.bottom-tabs { position: fixed; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; box-sizing: border-box; }
