:root {
  --bg: #ece9e3;
  --paper: #fbfaf7;
  --card: #ffffff;
  --line: #dcd8d0;
  --ink: #2f2f33;
  --muted: #7d796f;
  --faint: #c3beb3;
  --accent: #3d4b5c;
  --good: #3f8a5a;
  --bad: #c0504d;
  --hand: "Patrick Hand", "Comic Sans MS", cursive;
  --serif: "Cormorant Garamond", Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.45 Inter, system-ui, -apple-system, sans-serif;
  display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
a { color: inherit; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- navigation ---------- */
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; padding: 18px 12px; background: var(--paper); border-right: 1px solid var(--line); }
.brand { font-family: var(--serif); font-size: 26px; font-weight: 600; padding: 0 10px 14px; display: flex; gap: 8px; align-items: center; }
.logo { color: #d98a8f; font-size: 18px; }
.side a { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 8px; text-decoration: none; color: #4b4943; font-weight: 500; }
.side a:hover { background: #f1eee8; }
.side a.on { background: var(--accent); color: #fff; }
.side .grow { flex: 1; }
.tabbar { display: none; }

main { padding: 24px 28px 80px; max-width: 1160px; width: 100%; outline: none; }
.page-title { font-family: var(--serif); font-weight: 500; font-size: 40px; margin: 0 0 4px; }
.page-sub { color: var(--muted); margin: 0 0 20px; }

/* ---------- cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.card h2 { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; font-weight: 600; }
.card .big { font-size: 30px; font-weight: 600; }
.item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid #efece6; }
.item:first-of-type { border-top: 0; }
.item .when { margin-left: auto; color: var(--muted); font-size: 14px; white-space: nowrap; }
.empty { color: var(--muted); font-size: 15px; padding: 6px 0; }
.soon { border-style: dashed; background: transparent; }
.soon p { margin: 6px 0 0; color: var(--muted); }
.pill { font-family: Inter, system-ui, sans-serif; vertical-align: middle; letter-spacing: 0; text-transform: none; display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 999px; background: #efece6; color: var(--muted); font-weight: 500; }
.btn { border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 600; cursor: pointer; }
.btn.pri { background: var(--accent); color: #fff; }
.btn.sec { background: #ebe8e1; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.morelist a { display: flex; align-items: center; gap: 12px; padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; text-decoration: none; margin-bottom: 10px; font-weight: 500; font-size: 17px; }

.banner { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: #fff7e0; border: 1px solid #ecd9a0; color: #6d5a1f; padding: 8px 14px; border-radius: 10px; font-size: 13px; z-index: 30; max-width: calc(100% - 32px); }

/* ---------- money ---------- */
.statrow { display: flex; flex-wrap: wrap; gap: 8px 28px; margin-bottom: 6px; }
.big.in, .amt.in, .in { color: var(--good); }
.owed { color: var(--bad); }
.acct-ico, .emo { font-size: 20px; width: 28px; text-align: center; flex: none; }
.amt { margin-left: auto; text-align: right; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.item .amt { font-weight: 600; color: var(--ink); }
.item .amt.owed { color: var(--bad); }
.section { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 26px 0 10px; font-weight: 600; }
.txhead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 26px 0 10px; }
.txhead .section { margin: 0; }
.txlist { padding-top: 4px; }
.daylabel { display: flex; justify-content: space-between; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 14px 0 4px; border-bottom: 1px solid var(--line); }
.tx { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #f0ede7; }
.tx:last-child { border-bottom: 0; }
.txmain { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.txmain b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txmain .note { margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill.personal { background: #e7f0e4; color: #46703d; }
.pill.business { background: #e3e9f3; color: #3d5577; }
.pill.warn { background: #fbecd0; color: #8a5a12; }
.soonred { color: var(--bad); font-size: 13px; }
.amt .soonred, .amt span { font-weight: 500; font-size: 13px; color: var(--muted); }
.amt .soonred { color: var(--bad); }
.bar { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.barlabel { width: 42%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bartrack { flex: 1; height: 10px; background: #efece6; border-radius: 5px; overflow: hidden; }
.bartrack span { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.pick { display: flex; gap: 6px; margin-left: auto; flex: none; }
.pick button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 10px; font-size: 13px; cursor: pointer; }
.pick button[data-s=personal]:hover { background: #e7f0e4; }
.pick button[data-s=business]:hover { background: #e3e9f3; }
.checkrow { flex-wrap: wrap; }
.checkrow .txmain { min-width: 150px; }

/* ---------- planner ---------- */
.sq { width: 11px; height: 11px; border-radius: 2px; display: inline-block; flex: none; }
.ptop { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.seg { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 999px; font-size: 14px; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--accent); color: #fff; }
.yearpick { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.circle { border: 1px solid var(--line); background: #fff; width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 16px; }

.paper { background: var(--paper); border-radius: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.06); padding: 22px 28px 30px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-family: var(--hand); font-size: 17px; text-transform: uppercase; letter-spacing: .04em; color: #55524c; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.ptitle { font-family: var(--serif); font-weight: 500; font-size: clamp(44px, 7vw, 80px); text-align: center; margin: 6px 0 10px; color: #4a4a50; }
.quarters { display: flex; justify-content: center; gap: 6px; margin-bottom: 14px; }
.quarters button { border: 1px solid var(--line); background: none; padding: 5px 14px; border-radius: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.quarters button.on { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.mname { text-align: center; font-size: 11px; letter-spacing: .25em; text-transform: uppercase; color: var(--muted); padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 8px; min-height: 30px; border-bottom: 1px solid var(--line); cursor: pointer; padding: 2px 4px; }
.row:hover { background: #f3f1ec; }
.row.na { cursor: default; background: repeating-linear-gradient(135deg, transparent 0 6px, #f1eee8 6px 7px); }
.row.today .dn, .cell.today .n { color: #fff; background: var(--accent); border-radius: 4px; }
.dn { font-size: 10px; color: var(--faint); width: 20px; text-align: center; flex: none; padding: 1px 0; }
.dw { font-size: 9px; color: var(--faint); width: 12px; flex: none; }
.ents { display: flex; flex-wrap: wrap; gap: 2px 10px; min-width: 0; }
.ent { display: inline-flex; align-items: center; gap: 6px; font-family: var(--hand); font-size: 16px; text-transform: uppercase; color: #3b3b40; line-height: 1.15; }
.ent.auto { color: #6b6760; }
.ent.cameup, .chip.cameup { color: var(--bad); }

.mhead { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 14px 0 12px; }
.mhead h2 { font-family: var(--serif); font-weight: 500; font-size: 40px; margin: 0; min-width: 260px; text-align: center; }
.mwrap { display: grid; grid-template-columns: 1fr 280px; gap: 22px; }
.dows, .mgrid { display: grid; grid-template-columns: repeat(7, 1fr); }
.dows div { font-size: 11px; letter-spacing: .15em; text-transform: uppercase; color: var(--muted); text-align: center; padding-bottom: 6px; }
.mgrid { border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cell { min-height: 96px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px 5px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cell:hover { background: #f3f1ec; }
.cell.out { background: #f4f2ed; cursor: default; }
.cell .n { font-size: 12px; color: var(--muted); align-self: flex-start; padding: 0 5px; }
.chips { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.chip { display: flex; align-items: center; gap: 4px; font-family: var(--hand); font-size: 14px; line-height: 1.1; text-transform: uppercase; overflow: hidden; }
.chip .sq { width: 8px; height: 8px; }
.chip span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mside { display: flex; flex-direction: column; gap: 16px; }
.box { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fff; }
.box h3 { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; font-weight: 600; }
.todo { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-family: var(--hand); font-size: 17px; }
.todo input { width: 18px; height: 18px; accent-color: var(--accent); }
.todo.done span { text-decoration: line-through; color: var(--muted); }
.todo button { margin-left: auto; border: 0; background: none; color: var(--faint); cursor: pointer; font-size: 18px; }
.addline input { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: none; font-family: var(--hand); font-size: 17px; padding: 4px 2px; outline: none; }
textarea.lined { width: 100%; min-height: 104px; border: 0; resize: vertical; font-family: var(--hand); font-size: 17px; background: repeating-linear-gradient(transparent 0 25px, var(--line) 25px 26px); line-height: 26px; outline: none; }
.money-line { display: flex; justify-content: space-between; font-size: 14px; padding: 3px 0; }
.note { font-size: 12px; color: var(--muted); margin-top: 6px; }

.scrim { position: fixed; inset: 0; background: rgba(30,30,35,.35); display: none; align-items: center; justify-content: center; padding: 16px; z-index: 40; }
.scrim.open { display: flex; }
.editor { background: var(--paper); border-radius: 12px; width: 100%; max-width: 420px; padding: 18px; box-shadow: 0 20px 50px rgba(0,0,0,.25); max-height: calc(100vh - 32px); overflow: auto; }
.editor h4 { margin: 0 0 10px; font-family: var(--serif); font-size: 28px; font-weight: 500; }
.editor .eitem { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-family: var(--hand); font-size: 17px; text-transform: uppercase; }
.editor .eitem small { font-family: Inter, sans-serif; text-transform: none; font-size: 11px; color: var(--muted); margin-left: auto; }
.editor .eitem button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 20px; }
.editor input[type=text] { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 11px; font-size: 16px; background: #fff; margin-top: 10px; }
.cats { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.cats button { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 11px; font-size: 13px; cursor: pointer; }
.cats button.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.opts { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.opts select { font: inherit; font-size: 13px; padding: 5px; border-radius: 6px; border: 1px solid var(--line); background: #fff; }
.opts label { display: inline-flex; align-items: center; gap: 5px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- phone ---------- */
@media (max-width: 860px) {
  body { grid-template-columns: 1fr; }
  .side { display: none; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--paper); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; text-decoration: none; color: var(--muted); padding: 4px 0; border-radius: 8px; }
  .tabbar a span { font-size: 20px; line-height: 1.1; }
  .tabbar a.on { color: var(--accent); font-weight: 600; background: #eceae4; }
  main { padding: 18px 16px 96px; }
  .page-title { font-size: 34px; }
  .banner { bottom: 84px; left: 16px; right: 16px; transform: none; max-width: none; text-align: center; }
  .mwrap { grid-template-columns: 1fr; }
  .tx .pill { display: none; }
  .tx .pill.warn { display: inline-block; }
  .card .big { font-size: 24px; }
  .cell { min-height: 58px; padding: 3px; }
  .chips { flex-direction: row; flex-wrap: wrap; gap: 3px; }
  .chip span:last-child { display: none; }
  .mhead h2 { font-size: 30px; min-width: 0; }
}
@media (max-width: 700px) {
  .paper { padding: 16px 12px 22px; }
  .cols { grid-template-columns: 1fr; gap: 26px; }
}

/* ---------- categories ---------- */
.section .sub { text-transform: none; letter-spacing: 0; font-weight: 400; }
.catlist { padding-top: 4px; padding-bottom: 4px; }
.catrow { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #f0ede7; cursor: pointer; }
.catrow:last-child { border-bottom: 0; }
.catrow:hover { background: #faf8f4; }
.sq.big { width: 22px; height: 22px; border-radius: 5px; margin: 0 3px; }
.ord { display: flex; gap: 2px; flex: none; }
.ord button, .editbtn { border: 1px solid var(--line); background: #fff; border-radius: 8px; min-width: 34px; height: 34px; cursor: pointer; color: var(--ink); font-size: 14px; }
.ord button:disabled { opacity: .3; cursor: default; }
.editbtn { padding: 0 12px; font-weight: 500; flex: none; }
.tx.tap { cursor: pointer; }
.tx.tap:hover { background: #faf8f4; }
.catedit .flabel { display: block; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 14px 0 6px; font-weight: 600; }
.catedit .seg { flex-wrap: wrap; }
.catedit .frow { display: flex; gap: 8px; align-items: center; }
.catedit .frow input[type=text] { margin-top: 0; }
.catedit input.emojibox { width: 58px; flex: none; text-align: center; font-size: 22px; padding: 7px; }
.catedit select { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 16px; background: #fff; margin: 6px 0 10px; }
.catedit .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.danger-zone { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 12px; }
.linkbtn { background: none; border: 0; padding: 0; cursor: pointer; font-size: 14px; text-decoration: underline; }
.linkbtn.bad, .bad { color: var(--bad); }
.btn.bad { background: var(--bad); color: #fff; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatches button { width: 34px; height: 34px; border-radius: 8px; border: 2px solid transparent; cursor: pointer; }
.swatches button.on { border-color: var(--ink); box-shadow: 0 0 0 2px #fff inset; }
.swatches .custom { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.swatches input[type=color] { width: 34px; height: 34px; border: 0; padding: 0; background: none; cursor: pointer; }
.catchips { display: flex; flex-wrap: wrap; gap: 6px; }
.catchips button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 12px; font-size: 14px; cursor: pointer; }
.catchips button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.checkline { display: flex; gap: 8px; align-items: center; margin-top: 14px; font-size: 14px; }
@media (max-width: 700px) { .catrow .pill { display: none; } }
#catAdd { margin: 0 0 16px 10px; vertical-align: top; }

/* ---------- home photo banner ---------- */
.hero { position: relative; min-height: 230px; border-radius: 14px; overflow: hidden; margin-bottom: 18px; display: flex; align-items: flex-end;
  background: #3d4b5c url(/img/home-banner.jpg) 55% 22% / cover no-repeat; }
.hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(25,28,34,.72) 0%, rgba(25,28,34,.35) 38%, rgba(25,28,34,0) 60%); }
.hero-text { position: relative; padding: 22px 26px; color: #fff; max-width: 46%; }
.hero h1 { font-family: var(--serif); font-weight: 500; font-size: 42px; margin: 0; line-height: 1.05; text-shadow: 0 1px 8px rgba(0,0,0,.35); }
.hero p { margin: 6px 0 0; font-size: 16px; opacity: .95; }
@media (max-width: 700px) {
  .hero { min-height: 190px; background-position: 58% 18%; }
  .hero::before { background: linear-gradient(0deg, rgba(25,28,34,.75) 0%, rgba(25,28,34,.25) 45%, rgba(25,28,34,0) 70%); }
  .hero-text { max-width: none; padding: 16px 18px; }
  .hero h1 { font-size: 32px; }
}
