:root {
  --bg: #f6f5f0; --surface: #ffffff; --surface-2: #f1f0ea; --text: #1d2a1f; --muted: #5d685f;
  --line: #e3e4dc; --brand: #1b5e20; --brand-soft: #e6f2e6; --sunyra: #4b3fa8; --sunyra-soft: #ecebfa;
  --ok: #1e7b34; --ok-soft: #e3f4e6; --bad: #b3261e; --bad-soft: #fbe9e7; --warn: #8a5a00; --warn-soft: #fff4dc;
  --inc: #2e7d32; --exp: #c0623b; --goal: #8a5a00;
  --radius: 16px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1310; --surface: #171d18; --surface-2: #1d251e; --text: #e8eee8; --muted: #a2afa4;
    --line: #2a332b; --brand: #8fd18f; --brand-soft: #1d2b1e; --sunyra: #b3a9ff; --sunyra-soft: #24213d;
    --ok: #7fd18a; --ok-soft: #173020; --bad: #ff8a80; --bad-soft: #3a1b18; --warn: #ffcf70; --warn-soft: #382c12;
    --inc: #7fd18a; --exp: #f0a07c; --goal: #ffcf70; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1310; --surface: #171d18; --surface-2: #1d251e; --text: #e8eee8; --muted: #a2afa4;
  --line: #2a332b; --brand: #8fd18f; --brand-soft: #1d2b1e; --sunyra: #b3a9ff; --sunyra-soft: #24213d;
  --ok: #7fd18a; --ok-soft: #173020; --bad: #ff8a80; --bad-soft: #3a1b18; --warn: #ffcf70; --warn-soft: #382c12;
  --inc: #7fd18a; --exp: #f0a07c; --goal: #ffcf70; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", sans-serif; }
h1, h2 { margin: 0 0 8px; line-height: 1.25; }
h1 { font-size: 26px; }
h2 { font-size: 16px; font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.logo { color: var(--brand); }
.who { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); min-width: 0; }
.who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { max-width: 1180px; margin: 0 auto; padding: 16px; }
.card, .table-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0; }
.card.center { max-width: 460px; margin: 10vh auto; text-align: center; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.card-h h2 { margin: 0; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid > .card { margin: 0; }
.span2 { grid-column: span 2; }
@media (max-width: 760px) { .grid { grid-template-columns: 1fr; } .span2 { grid-column: auto; } }

.gsi { display: flex; justify-content: center; min-height: 44px; margin: 18px 0 8px; }
.msg { min-height: 1.5em; font-size: 14px; }
.msg.bad { color: var(--bad); }
.msg.ok { color: var(--ok); }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 12px; margin-bottom: 4px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 8px 14px; border-radius: 999px; font: inherit; font-size: 14px; cursor: pointer; }
.tabs button.on { background: var(--brand); border-color: var(--brand); color: var(--surface); font-weight: 600; }

.btn { border: 0; background: var(--brand); color: var(--surface); font: inherit; font-size: 14px; font-weight: 600; padding: 8px 14px; border-radius: 10px; cursor: pointer; white-space: nowrap; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 500; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid var(--line); }
.btn:disabled { opacity: .5; cursor: default; }

input, select, textarea { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-width: 0; }
textarea { width: 100%; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; resize: vertical; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline input { flex: 1 1 180px; }
.stack { display: grid; gap: 10px; }
.stack label { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack input { width: 140px; }
.search { width: 100%; margin-bottom: 10px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex: 0 0 auto; background: var(--muted); }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); } .dot.warn { background: var(--warn); }

.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.tag.laisha { background: var(--brand-soft); color: var(--brand); }
.tag.sunyra { background: var(--sunyra-soft); color: var(--sunyra); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }

.day { margin-top: 14px; }
.day h3 { font-size: 14px; margin: 0 0 4px; color: var(--muted); font-weight: 600; }
.task { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-top: 1px solid var(--line); }
.task input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--brand); flex: 0 0 auto; }
.task .title { flex: 1; min-width: 0; }
.task.done .title { color: var(--muted); text-decoration: line-through; }
.task.moved { opacity: .6; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; position: sticky; top: 0; white-space: nowrap; }
td { max-width: 340px; overflow-wrap: anywhere; }
tr:last-child td { border-bottom: 0; }
.exports { display: flex; gap: 6px; }
.count { color: var(--muted); font-size: 13px; font-weight: 400; margin-left: 6px; }
.empty { color: var(--muted); padding: 14px 4px; }

.purchase { border-top: 1px solid var(--line); padding: 12px 0; }
.purchase:first-child { border-top: 0; }
.purchase.undelivered { border: 2px solid var(--bad); border-radius: 10px; padding: 10px 12px; margin: 6px 0; background: var(--bad-soft); }
.undelivered-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--bad); margin-bottom: 6px; }
.purchase .head { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; justify-content: space-between; }
.purchase .amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.steps { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.step { font-size: 12.5px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.step.ok { background: var(--ok-soft); color: var(--ok); }
.step.bad { background: var(--bad-soft); color: var(--bad); }
.step::before { content: "○ "; }
.step.ok::before { content: "✓ "; }
.step.bad::before { content: "✕ "; }

.chart svg { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.sw.inc { background: var(--inc); } .sw.exp { background: var(--exp); } .sw.goal { background: var(--goal); }

.lines { display: grid; gap: 6px; margin: 8px 0 12px; }
.line-row { display: grid; grid-template-columns: 1fr 130px auto; gap: 6px; }
.month-pick { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.goalbar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 6px 0 2px; }
.goalbar i { display: block; height: 100%; background: var(--inc); }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 20; max-width: calc(100vw - 32px); }

/* Money funnel */
.seg { display: flex; gap: 6px; }
.seg .btn.on { background: var(--ink, #222); color: var(--surface, #fff); }
.funnel-steps { display: grid; gap: 8px; margin: 8px 0 4px; }
.funnel-row { display: grid; grid-template-columns: minmax(130px, 1.2fr) 3fr auto; gap: 10px; align-items: center; font-size: 14px; }
.funnel-bar { height: 12px; border-radius: 999px; background: var(--line); overflow: hidden; }
.funnel-bar i { display: block; height: 100%; background: var(--accent, #1f5f4a); border-radius: 999px; min-width: 2px; }
.funnel-row b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.funnel-lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 12px; }
.funnel-lists ol { margin: 4px 0 0; padding-left: 18px; font-size: 13.5px; }
.funnel-lists li { overflow-wrap: anywhere; }
/* Festivals card: rows wrap on a phone (text first, then status and button). */
#festive-card .list li { flex-wrap: wrap; align-items: center; }
#festive-card .list .grow { flex: 1 1 240px; min-width: 0; }
#festive-global { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; }
