:root {
  --bg: #f6f3ec;
  --card: #fffdf8;
  --ink: #1d2320;
  --muted: #6b716c;
  --line: #e4ded1;
  --accent: #1f5d4c;
  --accent-soft: #e3eee9;
  --up: #1d7a4f;
  --down: #b3412e;
  --warn: #b3412e;
  --chip: #efe9dc;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816; --card: #1b201d; --ink: #e9ece8; --muted: #9aa29c; --line: #2b322e;
    --accent: #7cc4a8; --accent-soft: #22322b; --up: #6fd19f; --down: #f08a74; --warn: #f08a74; --chip: #262d29;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.pad { padding: 24px; }
.num { font-variant-numeric: tabular-nums; }
.up { color: var(--up); } .down { color: var(--down); }

/* header */
.top { max-width: 1180px; margin: 0 auto; padding: 28px 24px 0; display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between; }
.kicker { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
h1 { font-family: var(--serif); font-weight: 600; font-size: 34px; line-height: 1.1; margin: 4px 0 0; }
h2 { font-family: var(--serif); font-weight: 600; font-size: 20px; margin: 0; }
h3 { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 16px 0 6px; font-weight: 600; }
.tabs { display: flex; gap: 4px; background: var(--chip); padding: 4px; border-radius: 999px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 7px 14px; border-radius: 999px; cursor: pointer; color: var(--muted); white-space: nowrap; }
.tabs button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

main { max-width: 1180px; margin: 0 auto; padding: 20px 24px 60px; }
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.span-7 { grid-column: span 7; } .span-5 { grid-column: span 5; } .span-12 { grid-column: span 12; }
@media (max-width: 860px) { .span-7, .span-5 { grid-column: span 12; } h1 { font-size: 28px; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.link { text-decoration: none; background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font-size: 13px; }

.cols { display: grid; grid-template-columns: 7fr 5fr; gap: 16px; align-items: start; }
.col { display: grid; gap: 16px; min-width: 0; }
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } }
.meter { height: 8px; background: var(--chip); border-radius: 999px; overflow: hidden; margin: 10px 0 6px; }
.meter span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.meter.warm span { background: #c07a2b; }
.meter.hot span { background: var(--down); }

/* money */
.big { font-family: var(--serif); font-size: 36px; font-weight: 600; line-height: 1.1; }
.delta { font-size: 15px; margin-left: 8px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
td { padding: 8px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--chip); border-radius: 999px; padding: 3px 10px; font-size: 13px; }
.chip.on { background: var(--accent); color: var(--card); }
button.chip { border: 0; cursor: pointer; }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.grow { flex: 1; min-width: 0; }
.sub { font-size: 13px; color: var(--muted); }
.done .title { text-decoration: line-through; color: var(--muted); }
.overdue { color: var(--warn); font-weight: 600; }
input[type="checkbox"] { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); cursor: pointer; }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.icon-btn:hover { background: var(--chip); color: var(--ink); }

/* calendar */
.day { display: grid; grid-template-columns: 92px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.day:last-child { border-bottom: 0; }
.day-label { font-weight: 600; font-size: 13px; white-space: nowrap; }
.day-label.today { color: var(--accent); }
.event { display: flex; gap: 10px; font-size: 14px; padding: 2px 0; }
.event .time { width: 64px; flex: none; color: var(--muted); font-variant-numeric: tabular-nums; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; margin-top: 7px; }

/* diary */
.tag { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.entry-body { white-space: pre-wrap; margin-top: 4px; }
.month { font-family: var(--serif); font-size: 18px; margin: 22px 0 6px; }

/* forms */
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
input:not([type="checkbox"]), select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { width: 100%; min-height: 70px; resize: vertical; }
.btn { background: var(--accent); color: var(--card); border: 0; border-radius: 10px; padding: 8px 16px; cursor: pointer; font-weight: 600; }
.btn.ghost { background: var(--chip); color: var(--ink); }
.stack { display: grid; gap: 10px; }
.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.notice { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.error { color: var(--warn); font-size: 13px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; }
.demo-banner { max-width: 1180px; margin: 12px auto 0; padding: 0 24px; }

/* auth */
body.signed-out .tabs { display: none; }
.auth { display: grid; place-items: center; padding: 24px 0 60px; }
.auth-card { width: 100%; max-width: 420px; padding: 28px 28px 24px; display: grid; gap: 14px; }
.auth-card h2 { font-size: 26px; }
.auth-card .sub { margin: -6px 0 0; }
.auth-brand { display: flex; align-items: center; gap: 8px; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.auth-mark { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--card); display: grid; place-items: center; font-size: 13px; }
.auth-card input { width: 100%; padding: 10px 12px; }
.auth-footer { display: grid; gap: 6px; font-size: 14px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 14px; }
.auth-footer .link { font-size: 14px; }
.btn.wide { width: 100%; padding: 11px 16px; }
.btn:disabled { opacity: .6; cursor: progress; }
.hint { font-size: 12px; margin-top: -4px !important; }
.error[hidden] { display: none; }
.auth-by { text-transform: none; letter-spacing: 0; font-size: 12px; margin-left: 2px; }
.notice.warn { background: #f6e7d8; color: #6b3d16; }
@media (prefers-color-scheme: dark) { .notice.warn { background: #3a2a1c; color: #f3c9a1; } }
.list.errors li { padding: 4px 0; font-size: 13px; }
.expander { background: none; border: 0; cursor: pointer; color: var(--muted); padding: 0 4px 0 0; font-size: 12px; }
.lots-row > td { background: var(--bg); padding: 4px 8px 10px 28px; }
table.lots td, table.lots th { padding: 5px 8px; font-size: 13px; }
.tag.sell { background: #f6e1dc; color: var(--down); }
.btn.small { padding: 3px 10px; font-size: 12px; font-weight: 600; margin-right: 4px; }
.nowrap { white-space: nowrap; }
.tag.warm { background: #f6e7d8; color: #8a4b12; }
.tag.muted-tag { background: var(--chip); color: var(--muted); }
tr.lot.sold td { color: var(--muted); }
tr.lot.sale td { background: transparent; font-size: 12px; }
tr.holding-row.closed td { color: var(--muted); }
.sell-form-row > td { background: var(--accent-soft); padding: 10px 12px; border-radius: 8px; }
.sell-form-row form { gap: 6px; }
.toggle { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.toggle input { width: 15px; height: 15px; margin: 0; }
