:root {
  --bg: #f7f4fb;
  --card: #ffffff;
  --ink: #2a2433;
  --sub: #6d6479;
  --line: #ddd5e8;
  --main: #6b3fa0;
  --main-ink: #ffffff;
  --soft: #efe7f8;
  --ok: #1f7a4d;
  --ok-soft: #e3f4ea;
  --warn: #9a5b00;
  --warn-soft: #fff3dc;
  --bad: #b3261e;
  --bad-soft: #fde8e6;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.65 system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
}
header {
  position: sticky; top: 0; z-index: 10; background: var(--main); color: var(--main-ink);
  padding: 8px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px;
}
[hidden] { display: none !important; }
.brand { font-weight: 700; }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav a {
  color: var(--main-ink); text-decoration: none; padding: 8px 12px; border-radius: 10px; font-weight: 600;
}
nav a.on { background: rgba(255,255,255,.22); }
main { max-width: 860px; margin: 0 auto; padding: 16px 16px 120px; }
h1 { font-size: 1.35rem; margin: 8px 0 16px; }
h2 { font-size: 1.12rem; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.step { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--main); color: #fff; font-size: .95rem; flex: none; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 16px; }
.hint { color: var(--sub); font-size: .92rem; margin: 4px 0 10px; }
label { display: block; font-weight: 600; margin: 12px 0 4px; }
label .opt { font-weight: 400; color: var(--sub); font-size: .88rem; }
input[type=text], input[type=password], input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; padding: 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }
textarea.paste { min-height: 200px; }
input:focus, select:focus, textarea:focus { outline: 3px solid #c9b2e6; border-color: var(--main); }
.ai-filled { background: #fbf8e6; border-color: #e4cf6a; }
.row { display: grid; gap: 0 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .row.two { grid-template-columns: 1fr 1fr; } .row.three { grid-template-columns: 1fr 1fr 1fr; } }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 10px 0; }
.check input { width: 24px; height: 24px; flex: none; margin-top: 2px; }
.btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
button, .button {
  font: inherit; font-weight: 700; min-height: 52px; padding: 10px 20px; border-radius: 12px; cursor: pointer;
  border: 2px solid var(--main); background: #fff; color: var(--main); text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
button.primary, .button.primary { background: var(--main); color: var(--main-ink); }
button.big { width: 100%; font-size: 1.1rem; min-height: 60px; }
button.small { min-height: 40px; padding: 6px 14px; font-size: .92rem; }
button.danger { border-color: var(--bad); color: var(--bad); }
button:disabled { opacity: .5; cursor: default; }
.note { border-radius: 10px; padding: 12px 14px; margin: 10px 0; }
.note.ok { background: var(--ok-soft); color: var(--ok); }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.bad { background: var(--bad-soft); color: var(--bad); }
.note.info { background: var(--soft); color: var(--ink); }
.match { border: 2px solid #e4cf6a; background: #fffbea; border-radius: 12px; padding: 12px; margin: 10px 0; }
.match.chosen { border-color: var(--ok); background: var(--ok-soft); }
.match h3 { margin: 0 0 6px; font-size: 1.05rem; }
.pill { display: inline-block; font-size: .8rem; font-weight: 700; padding: 2px 10px; border-radius: 99px; background: var(--soft); color: var(--main); }
.pill.rep { background: #ffe9c7; color: #8a4b00; }
.menu-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.menu-list button { min-height: 46px; font-weight: 600; }
.menu-list button.on { background: var(--main); color: #fff; }
.people .person { border: 1px dashed var(--line); border-radius: 10px; padding: 8px 12px 12px; margin-bottom: 8px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li a { display: block; text-decoration: none; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; }
.list .name { font-weight: 700; font-size: 1.05rem; }
.list .meta { color: var(--sub); font-size: .9rem; }
dl.kv { display: grid; grid-template-columns: 8em 1fr; gap: 6px 12px; margin: 0; }
dl.kv dt { color: var(--sub); }
dl.kv dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
.purchase { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.purchase:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
table { width: 100%; border-collapse: collapse; }
td, th { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
pre.sent { white-space: pre-wrap; word-break: break-word; background: var(--soft); padding: 12px; border-radius: 10px; max-height: 260px; overflow: auto; font: .92rem/1.6 ui-monospace, Consolas, monospace; }
.dialog-back { position: fixed; inset: 0; background: rgba(30,20,40,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
@media (min-width: 640px) { .dialog-back { align-items: center; } }
.dialog { background: #fff; width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 20px 16px; }
@media (min-width: 640px) { .dialog { border-radius: 18px; } }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #2a2433; color: #fff; padding: 12px 20px; border-radius: 12px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; }
.loading { color: var(--sub); }
.sticky-save { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 20px 0 8px; }
.muted { color: var(--sub); }
.login { max-width: 420px; margin: 40px auto; }
textarea.short { min-height: 60px; }
.mb { margin-bottom: 16px; }
@media (min-width: 640px) { .mt-label { margin-top: 44px; } }
.req { font-size: .8rem; font-weight: 700; color: var(--bad); background: var(--bad-soft); padding: 2px 8px; border-radius: 99px; }

.sheet-wrap { overflow: auto; max-height: 75vh; border: 1px solid var(--line); border-radius: 12px; background: var(--card); margin-bottom: 16px; }
table.sheet { border-collapse: separate; border-spacing: 0; font-size: .92rem; white-space: nowrap; width: max-content; min-width: 100%; }
table.sheet th { position: sticky; top: 0; z-index: 2; background: var(--soft); cursor: pointer; user-select: none; font-weight: 700; }
table.sheet th:first-child, table.sheet td:first-child { position: sticky; left: 0; z-index: 1; background: var(--card); }
table.sheet th:first-child { z-index: 3; background: var(--soft); }
table.sheet td, table.sheet th { padding: 8px 12px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); }
table.sheet tbody tr { cursor: pointer; }
table.sheet tbody tr:hover td { background: #f6f0fc; }
table.sheet .num { text-align: right; }
table.sheet .wide { white-space: normal; min-width: 220px; max-width: 360px; }
table.sheet td.missing { color: var(--bad); background: var(--bad-soft); font-size: .85rem; }
table.sheet .neg { color: var(--bad); }
input.cell { width: 96px; padding: 6px 8px; text-align: right; }
.sheet-tools { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.sheet-tools input { flex: 1; min-width: 200px; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
.tile { background: var(--soft); border-radius: 12px; padding: 12px; }
.tile-label { color: var(--sub); font-size: .88rem; }
.tile-num { font-size: 1.3rem; font-weight: 700; }
.tile.good { background: var(--ok-soft); color: var(--ok); }
.tile.bad { background: var(--bad-soft); color: var(--bad); }
main.wide { max-width: 1400px; }

.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
a.note { display: block; text-decoration: none; font-weight: 600; }
select.cell-select { width: auto; padding: 6px 8px; font-size: .92rem; }
table.sheet td.est { color: var(--sub); }
.goal { margin: 4px 0 8px; }
.goal-num { font-size: 2rem; font-weight: 800; }
.bar { height: 14px; border-radius: 99px; background: var(--soft); overflow: hidden; margin: 6px 0 16px; }
.bar-fill { height: 100%; width: 0; background: var(--main); border-radius: 99px; transition: width .4s; }
h3 { font-size: 1rem; margin: 18px 0 4px; }
.card.inbox { border: 2px solid var(--main); }

a.brand { color: var(--main-ink); text-decoration: none; }
nav { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; max-width: 100%; }
nav::-webkit-scrollbar { display: none; }
nav a { white-space: nowrap; flex: none; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; text-decoration: none; color: inherit; text-align: center; }
.stat-num { font-size: 1.6rem; font-weight: 800; color: var(--main); }
.stat-label { font-size: .82rem; color: var(--sub); line-height: 1.3; }
.todos { display: grid; gap: 8px; }
a.todo { display: flex; gap: 12px; align-items: flex-start; text-decoration: none; color: inherit; padding: 10px 12px; border-radius: 12px; background: var(--soft); }
.todo-icon { font-size: 1.3rem; line-height: 1.4; }
a.month-card { display: block; text-decoration: none; color: inherit; }
.section-title { margin: 24px 0 12px; }
.page-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 640px) { .page-grid { grid-template-columns: repeat(4, 1fr); } }
a.page-tile { display: flex; flex-direction: column; gap: 4px; padding: 16px; min-height: 120px; background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius); text-decoration: none; color: inherit; }
a.page-tile:hover, a.page-tile:focus { border-color: var(--main); }
.page-icon { font-size: 1.8rem; }
.page-name { font-weight: 800; font-size: 1.1rem; }
.page-desc { font-size: .85rem; color: var(--sub); line-height: 1.4; }
