:root {
  color-scheme: light;
  --bg: #f4f5f3; --card: #ffffff; --ink: #1c211f; --sub: #5f6964; --line: #dfe3e0; --soft: #eceeec;
  --accent: #17604c; --on-accent: #ffffff; --warn: #8f4a00; --warn-bg: #fff2dc; --bad: #b3261e;
  --burden: #eb6834; --earned: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #101312; --card: #191919; --ink: #ecefed; --sub: #a0aaa5; --line: #303633; --soft: #262b29;
    --accent: #6cc7a9; --on-accent: #08221a; --warn: #ffc67a; --warn-bg: #38290f; --bad: #ff9a91;
    --burden: #d95926; --earned: #3987e5;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.5;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif; font-size: 15px; }
button, input, select, textarea { font: inherit; color: inherit; }
/* 16px 未満だと iPhone が入力時に画面を拡大する */
input, select, textarea { font-size: 16px; width: 100%; min-width: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
input[type=checkbox] { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
button { cursor: pointer; border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 8px 13px; min-height: 40px; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
button.danger { color: var(--bad); }
button.small { padding: 4px 10px; min-height: 34px; font-size: 14px; }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }
h1 { font-size: 20px; margin: 0; } h2 { font-size: 16px; margin: 0; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.sub { color: var(--sub); font-size: 13px; }
.bad { color: var(--bad); }

nav { position: fixed; inset: auto 0 0 0; z-index: 5; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
nav a, nav button { flex: 1; border: 0; background: none; border-radius: 0; padding: 9px 0; min-height: 50px; display: grid; place-items: center; text-decoration: none; color: var(--sub); font-size: 13px; }
nav a[aria-current] { color: var(--accent); font-weight: 700; box-shadow: inset 0 2px var(--accent); }
nav button { color: var(--accent); font-weight: 700; }
main { max-width: 1080px; margin: 0 auto; padding: calc(14px + env(safe-area-inset-top)) 16px calc(80px + env(safe-area-inset-bottom)); display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.head { display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; min-width: 0; }
.card > .head { margin-bottom: 8px; }
.grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.total { font-size: 34px; font-weight: 700; line-height: 1.2; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-top: 8px; }
.facts b { display: block; font-size: 17px; color: var(--ink); }
.notice { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 10px 12px; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; text-decoration: none; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.row { display: flex; gap: 10px; align-items: center; justify-content: space-between; width: 100%; padding: 9px 2px; text-align: left; border: 0; border-radius: 0; background: none; }
.row > :first-child { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.row > :last-child { text-align: right; }
.acts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.day { background: var(--soft); padding: 4px 10px; border-radius: 6px; font-size: 13px; color: var(--sub); display: flex; justify-content: space-between; margin-top: 8px; }
.tag { font-size: 12px; background: var(--soft); border-radius: 5px; padding: 1px 6px; color: var(--sub); white-space: nowrap; }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filters input[type=search] { grid-column: 1 / -1; }
.month { display: flex; align-items: center; gap: 6px; }
.month input { width: 160px; }
.bar { height: 6px; border-radius: 3px; background: var(--soft); margin-top: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

dialog { border: 0; padding: 0; background: var(--card); color: var(--ink); width: 100%; max-width: 100%; max-height: 94dvh; margin: auto 0 0; border-radius: 16px 16px 0 0; }
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog form { display: grid; gap: 12px; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); grid-template-columns: minmax(0, 1fr); }
dialog form > .acts { position: sticky; bottom: 0; background: var(--card); padding: 8px 0; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--sub); min-width: 0; }
label > input, label > select, label > textarea { color: var(--ink); }
label.check { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 15px; padding: 6px 0; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: end; }
.big input { font-size: 26px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.seg { display: flex; background: var(--soft); border-radius: 10px; padding: 3px; }
.seg button { flex: 1; border: 0; background: none; padding: 6px; }
.seg button[aria-pressed=true] { background: var(--card); font-weight: 700; box-shadow: 0 1px 3px rgb(0 0 0 / .2); }
.error { color: var(--bad); margin: 0; white-space: pre-wrap; }
.error:empty { display: none; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; margin: 8px 0 0; }
.toast { position: fixed; left: 50%; bottom: calc(74px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); border-radius: 10px; padding: 10px 16px; z-index: 20; max-width: 90vw; }

.legend { display: flex; gap: 14px; font-size: 13px; color: var(--sub); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; }
.chart text { fill: var(--sub); font-size: 11px; }
.tip { position: absolute; top: 0; pointer-events: none; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 13px; box-shadow: 0 3px 12px rgb(0 0 0 / .2); white-space: nowrap; }
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 6px 8px; border-top: 1px solid var(--line); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
th { color: var(--sub); font-weight: 500; } th:first-child, td:first-child { text-align: left; }
summary { cursor: pointer; padding: 6px 0; }
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(340px, 100%); display: grid; gap: 14px; }

@media (min-width: 800px) {
  nav { position: sticky; inset: 0 0 auto 0; border: 0; border-bottom: 1px solid var(--line); justify-content: center; }
  nav a, nav button { flex: 0 0 120px; font-size: 15px; }
  nav a[aria-current] { box-shadow: inset 0 -2px var(--accent); }
  main { padding: 20px 24px 60px; }
  .grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .filters { grid-template-columns: 2fr 1fr 1fr 1fr; } .filters input[type=search] { grid-column: auto; }
  dialog { max-width: 520px; margin: auto; border-radius: 16px; }
  .toast { bottom: 30px; }
}
