ownledger 0.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/AGENTS.md +94 -0
  2. package/CHANGELOG.md +30 -0
  3. package/LICENSE +21 -0
  4. package/README.md +101 -1
  5. package/assets/_headers +5 -0
  6. package/assets/app.css +61 -0
  7. package/assets/app.js +369 -0
  8. package/assets/icon.svg +1 -0
  9. package/assets/index.html +30 -0
  10. package/assets/manifest.webmanifest +1 -0
  11. package/dist/cli/check.d.ts +3 -0
  12. package/dist/cli/check.js +21 -0
  13. package/dist/cli/deploy.d.ts +1 -0
  14. package/dist/cli/deploy.js +258 -0
  15. package/dist/cli/dev.d.ts +3 -0
  16. package/dist/cli/dev.js +107 -0
  17. package/dist/cli/import.d.ts +3 -0
  18. package/dist/cli/import.js +151 -0
  19. package/dist/cli/index.d.ts +2 -0
  20. package/dist/cli/index.js +47 -0
  21. package/dist/cli/init.d.ts +1 -0
  22. package/dist/cli/init.js +73 -0
  23. package/dist/cli/jsonc.d.ts +2 -0
  24. package/dist/cli/jsonc.js +39 -0
  25. package/dist/engine/actions.d.ts +61 -0
  26. package/dist/engine/actions.js +227 -0
  27. package/dist/engine/balances.d.ts +30 -0
  28. package/dist/engine/balances.js +75 -0
  29. package/dist/engine/categories.d.ts +17 -0
  30. package/dist/engine/categories.js +35 -0
  31. package/dist/engine/check.d.ts +11 -0
  32. package/dist/engine/check.js +229 -0
  33. package/dist/engine/dates.d.ts +15 -0
  34. package/dist/engine/dates.js +56 -0
  35. package/dist/engine/defaults.d.ts +2 -0
  36. package/dist/engine/defaults.js +61 -0
  37. package/dist/engine/index.d.ts +13 -0
  38. package/dist/engine/index.js +13 -0
  39. package/dist/engine/load.d.ts +23 -0
  40. package/dist/engine/load.js +129 -0
  41. package/dist/engine/networth.d.ts +12 -0
  42. package/dist/engine/networth.js +73 -0
  43. package/dist/engine/registry.d.ts +24 -0
  44. package/dist/engine/registry.js +41 -0
  45. package/dist/engine/reports.d.ts +68 -0
  46. package/dist/engine/reports.js +149 -0
  47. package/dist/engine/schedules.d.ts +75 -0
  48. package/dist/engine/schedules.js +208 -0
  49. package/dist/engine/types.d.ts +132 -0
  50. package/dist/engine/types.js +2 -0
  51. package/dist/engine/write.d.ts +30 -0
  52. package/dist/engine/write.js +105 -0
  53. package/dist/import/hash.d.ts +1 -0
  54. package/dist/import/hash.js +17 -0
  55. package/dist/import/index.d.ts +6 -0
  56. package/dist/import/index.js +6 -0
  57. package/dist/import/mapping.d.ts +96 -0
  58. package/dist/import/mapping.js +54 -0
  59. package/dist/import/profile.d.ts +39 -0
  60. package/dist/import/profile.js +125 -0
  61. package/dist/import/run.d.ts +101 -0
  62. package/dist/import/run.js +416 -0
  63. package/dist/import/workbook.d.ts +13 -0
  64. package/dist/import/workbook.js +168 -0
  65. package/dist/import/xlsx-write.d.ts +6 -0
  66. package/dist/import/xlsx-write.js +38 -0
  67. package/dist/node/files.d.ts +3 -0
  68. package/dist/node/files.js +26 -0
  69. package/dist/node/scaffold.d.ts +14 -0
  70. package/dist/node/scaffold.js +45 -0
  71. package/dist/worker/api.d.ts +3 -0
  72. package/dist/worker/api.js +139 -0
  73. package/dist/worker/auth.d.ts +11 -0
  74. package/dist/worker/auth.js +182 -0
  75. package/dist/worker/env.d.ts +27 -0
  76. package/dist/worker/env.js +6 -0
  77. package/dist/worker/github.d.ts +29 -0
  78. package/dist/worker/github.js +154 -0
  79. package/dist/worker/index.d.ts +5 -0
  80. package/dist/worker/index.js +64 -0
  81. package/dist/worker/mcp.d.ts +4 -0
  82. package/dist/worker/mcp.js +301 -0
  83. package/dist/worker/store.d.ts +42 -0
  84. package/dist/worker/store.js +92 -0
  85. package/dist/worker/tar.d.ts +2 -0
  86. package/dist/worker/tar.js +62 -0
  87. package/dist/worker/version.d.ts +1 -0
  88. package/dist/worker/version.js +2 -0
  89. package/package.json +66 -4
  90. package/presets/misa.mapping.yaml +48 -0
  91. package/templates/repo/.github/dependabot.yml +11 -0
  92. package/templates/repo/.github/workflows/check.yml +15 -0
  93. package/templates/repo/.github/workflows/deploy.yml +21 -0
  94. package/templates/repo/README.md +10 -0
package/AGENTS.md ADDED
@@ -0,0 +1,94 @@
1
+ # AGENTS.md: rules for any AI working in an ownledger data repo
2
+
3
+ This repo is a personal finance ledger. The owner's money is in these files: be exact, never guess
4
+ amounts, and never write without the owner's go. `npx ownledger check` must pass after every change.
5
+
6
+ ## Files
7
+
8
+ | Path | What |
9
+ |---|---|
10
+ | `data/meta.yaml` | `format` (data format version), `base` (base currency, e.g. VND), `locale` (vi/en), `owner` (GitHub login) |
11
+ | `data/assets.yaml` | List of assets: the base currency, plus gold, funds, stocks, ETFs, crypto, foreign currency (`id`, `name`, `kind`, `unit`) |
12
+ | `data/accounts.yaml` | List of accounts: `id`, `name`, `type`, `asset` (default base), `opened`, `closed`, `group`, `details` |
13
+ | `data/categories.yaml` | `income:` and `expense:` trees of `{id, name, children}`; a category is referred to by its path, `food/eating-out` |
14
+ | `data/plans.yaml` | Instalments, loans, insurance premiums, deposit schedules: `{id, kind, account, principal?, count?, every, start, amount?, fee?, rate?}` |
15
+ | `data/budgets.yaml` | Optional: `{category, amount, every: month|year}` |
16
+ | `data/prices.csv` | `date,asset,price`: price of 1 unit in base currency |
17
+ | `data/ledger/yyyy/mm.jsonl` | One transaction per line, in the month file of its date |
18
+ | `imports/raw/` | Original exports, kept as received |
19
+ | `imports/<source>.mapping.yaml` | How to read one app's export (see below) |
20
+
21
+ ## Transactions
22
+
23
+ ```json
24
+ {"id":"t_8f3a…","date":"2026-11-18","time":"18:40","note":"Lunch","who":null,"event":null,"tags":[],
25
+ "lines":[{"account":"card-visa","amount":-168500},{"category":"food/eating-out","amount":168500}]}
26
+ ```
27
+
28
+ - Each line has **either** `account` **or** `category`. `amount` is a signed whole number in the base currency's
29
+ smallest unit (VND: đồng). **The lines of a transaction sum to 0.**
30
+ - Money leaving an account is negative on the account line. Spending: positive on the expense category line.
31
+ Income: negative on the income category line.
32
+ - Moves between the owner's own accounts (transfers, card payments, deposits opened or closed, investments
33
+ bought, loans given or repaid, borrowing) have **only account lines**, so they never count as income or spending.
34
+ - Non-base assets: the account line adds `asset` and `qty`. 2 chỉ of gold for 17,200,000:
35
+ `{"account":"cash","amount":-17200000}`, `{"account":"gold","asset":"GOLD_CHI","qty":2,"amount":17200000}`.
36
+ - System categories: `_opening` (opening balances) and `_adjust` (rounding or corrections). They never count as income or spending.
37
+ - `void: true` hides a transaction but keeps it in history. Don't delete lines from ledger files.
38
+ - `plan: "<plan id>"` marks a payment of an instalment, loan or premium.
39
+ - `src: {import, key}` ties an imported transaction to its source row. Never change it.
40
+ - `trail: [{op, at, via, client?, reason?}]` records each add/edit/void made through a connector (who, when, why). Append only; never edit or remove entries.
41
+
42
+ ## Account types
43
+
44
+ `cash`, `bank`, `ewallet`, `credit_card` (details: `statement_day`, `due_day`, `limit`), `bnpl`, `deposit`
45
+ (details: `principal`, `rate` (annual %), `term_months`, `start`, `maturity`, `rollover`), `savings_goal` (`target`, `by`),
46
+ `gold`, `fund`, `stock`, `etf`, `crypto`, `insurance`, `loan_given`, `loan_taken`, `other`.
47
+ A type not on this list is still fine: it loads as a plain account with a warning. Extra keys are kept.
48
+
49
+ ## Rules for writes
50
+
51
+ 1. Show the owner exactly what will change (the transactions, with amounts and accounts) and wait for their go.
52
+ 2. Never invent an amount, date or account. Ask if anything is missing.
53
+ 3. Run `npx ownledger check`; it must pass.
54
+ 4. One commit per change, with a readable message.
55
+
56
+ ## First import of a new app
57
+
58
+ The importer is generic: it reads any table-shaped export (xlsx, csv, json) through a mapping file, and
59
+ the mapping is written once, by you, on the first import. Later imports run it as plain code.
60
+
61
+ 1. `npx ownledger import <file>` prints a profile of the file: its sheets, header rows, the figures above
62
+ the header (opening and closing balances, totals), sample rows, distinct values (categories, wallets), and the
63
+ notes of rows with an empty category, which are often transfers. If the profile names a preset
64
+ (e.g. MISA), run `npx ownledger import <file> --preset <name>` to start from it.
65
+ 2. Write `imports/<source>.mapping.yaml`:
66
+ - **How to read:** `header_row`, `account_from` (`sheet`, `column` or `fixed`), `columns`
67
+ (date, time, in/out or amount, category, subcategory, who, event, note), `date_format`, `decimal`, and
68
+ `totals` (labels of the source's own figures, used for reconciling).
69
+ - **`transfers`:** regexes on the note for money going out and coming in, with a named group `wallet`
70
+ for the other account's name. The importer pairs the two sides by date, time and amount.
71
+ - **`accounts`:** every source account becomes an ownledger account: `id` (short, kebab-case), `name`, `type`,
72
+ and `details`. Users often write facts into wallet names (a card's statement and due day as
73
+ emoji + number, a deposit's term and start date): lift them into `details`, and list the full names
74
+ from transfer notes in `names` when sheet names are cut.
75
+ - **`categories`:** `"Parent/Child"` or `"Parent"` → an ownledger category path (see `data/categories.yaml`).
76
+ Don't map savings and investments to spending: they are transfers to an account (fund, gold, deposit),
77
+ so map the wallet as an account of that type.
78
+ - **`uncategorized`:** rules (regex on the note, optional `sign: in|out`) for rows with no category that
79
+ are not transfers. Don't assume every uncategorised row is a transfer.
80
+ - Any category target can be `account:<id>` instead: the row becomes a move to that account (loans given,
81
+ gold bought, savings and investments with no wallet of their own). Declare such accounts in `accounts` under
82
+ a key starting with `_`.
83
+ - **`rules`:** checked first on every non-transfer row, whatever its source category (e.g. the app's own
84
+ balance corrections → `_adjust`, so they never count as income or spending).
85
+ - **`skip_sheets`** leaves accounts out (e.g. a business account in a personal ledger); **`unpaired`**
86
+ (regex on the other wallet's name → category or `account:<id>`) says where transfers to it go.
87
+ - **`zero_closed: true`** books an `_adjust` on each closed account's closing date so it ends at 0, which clears the
88
+ source app's rounding leftovers. Only with the owner's go; they are listed in the report.
89
+ 3. Show the owner the account list (types, details) and the category map, and get their go.
90
+ 4. Run `npx ownledger import <file>`. It refuses unless every source account reconciles: opening + in − out
91
+ must equal the source's closing balance, and every row must be imported, paired or listed. Amounts
92
+ are rounded to whole units; the rounding is booked as `_adjust` and reported. Fix the mapping until it passes.
93
+ 5. `npx ownledger import <file> --yes` writes, checks and commits. Re-running with a newer export adds only new
94
+ rows, and reports rows that changed or disappeared in the source. The owner decides about those.
package/CHANGELOG.md ADDED
@@ -0,0 +1,30 @@
1
+ # Changelog
2
+
3
+ ## 1.1.0 (2026-11-22)
4
+
5
+ - Transactions record where they came from: `trail` gets one entry per add/edit/void made through the MCP
6
+ connector (`op`, `at`, `via`, `client`, `reason`). Imports keep `src`; rows without a trail are unchanged.
7
+ - `add_transaction`, `edit_transaction` and `void_transaction` now require `reason`: one line saying what the
8
+ owner asked for. It is shown in the preview, kept on the trail and added to the commit message
9
+ (`Reason: …` / `Via: mcp (<app>)`).
10
+ - The connected app's name is saved at sign-in and recorded on writes. Reconnect an app once to get it.
11
+ - `check` refuses a malformed `trail`.
12
+
13
+ ## 1.0.0 (2026-11-22)
14
+
15
+ First release.
16
+
17
+ - Data format 1: YAML for accounts, assets, categories, plans, budgets; monthly JSONL ledger; prices CSV.
18
+ Unknown account types and detail keys load with a warning, never an error.
19
+ - Engine: check, balances, net worth (with monthly series), reports by category/account/who/event/tag/month
20
+ vs the previous period, search (accents ignored), cards (statement, to pay, due), plans and dues,
21
+ deposits (maturity, interest), budgets, today.
22
+ - Write actions with preview → check → commit: add/edit/void transaction, add/edit/close account,
23
+ add plan, add price, add/rename/move category (remaps every line).
24
+ - Generic import of xlsx/csv/json through a mapping file: stable keys, transfer pairing, reconcile against
25
+ the source's own figures, rounding and closed-account leftovers booked as `_adjust`, re-import adds only
26
+ new rows. MISA Sổ Thu Chi preset.
27
+ - Worker: MCP (Streamable HTTP, stateless), OAuth (DCR, PKCE) with GitHub sign-in and a login allowlist,
28
+ GitHub App access to one repo, atomic commits refused if `main` moved, ledger cached by commit.
29
+ - Dashboard: overview, transactions, accounts, plans, reports, import, connected apps.
30
+ - CLI: init, check, import, deploy, dev.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 phucbm
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,103 @@
1
1
  # ownledger
2
2
 
3
- Placeholder release. See https://github.com/phucbm/ownledger
3
+ **Your money, your repo, your server.**
4
+
5
+ ownledger is a personal finance ledger you use through AI chat (Claude, ChatGPT, any client with custom MCP connectors). Your data lives in your own private GitHub repo, and your own Cloudflare Worker serves your connector and dashboard. Nobody else's server ever sees your data.
6
+
7
+ - **Every kind of personal finance:** cash, bank accounts, e-wallets, credit cards, instalments, BNPL, term deposits, savings goals, gold, funds, stocks, ETFs, crypto, insurance, loans given and taken. A new kind never breaks old data: unknown account types load as plain accounts.
8
+ - **Bring your history from any app:** on the first import, your AI reads the app's export and writes a mapping. Later imports are plain code, safe to re-run, and checked against the app's own balances. MISA Sổ Thu Chi ships as a preset.
9
+ - **Every write is previewed, checked and committed:** the AI shows you the change, you say go, it's checked, and it becomes one git commit. Anything can be undone.
10
+
11
+ ## Setup (about 10 minutes)
12
+
13
+ You need Node 22+, a GitHub account with [`gh`](https://cli.github.com) signed in, and a free Cloudflare account.
14
+
15
+ ```sh
16
+ npx ownledger init my-money # your data repo (private on GitHub), base currency, category language
17
+ cd my-money && npm install
18
+ npx ownledger import <export.xlsx> # optional: your history (profile → mapping → preview → --yes)
19
+ npx ownledger deploy # your Worker on your Cloudflare; prints your connector URL
20
+ ```
21
+
22
+ `deploy` walks you through:
23
+
24
+ 1. Signing in to Cloudflare (browser) and creating a KV namespace.
25
+ 2. Deploying your Worker to `<name>.<you>.workers.dev`.
26
+ 3. Creating **your own GitHub App** in one click (permission: *contents* of the repos you choose, nothing else; no webhooks). Install it on **your data repo only**.
27
+ 4. Storing the app's keys as **Worker secrets** (never in the repo, never printed).
28
+
29
+ Then add the connector:
30
+
31
+ - **Claude:** Settings → Connectors → Add custom connector → `https://<name>.<you>.workers.dev/mcp` → Connect → Allow → sign in with GitHub.
32
+ - **ChatGPT:** custom MCP connectors with OAuth work on plans that offer them (OpenAI's docs differ on which plans allow write tools; Business/Enterprise/Edu do). Add the same URL under Apps & Connectors.
33
+
34
+ The dashboard is at `https://<name>.<you>.workers.dev/` (same GitHub sign-in). It can be installed as an app on your phone.
35
+
36
+ ### Redeploy on every push (optional)
37
+
38
+ Copy `node_modules/ownledger/templates/repo/.github/workflows/deploy.yml` into your repo and add two repo secrets: `CLOUDFLARE_API_TOKEN` (a token from the "Edit Cloudflare Workers" template) and `CLOUDFLARE_ACCOUNT_ID`. Dependabot (set up by `init`) proposes ownledger updates; the `check` workflow runs them against your data before you merge. Major versions are never proposed automatically.
39
+
40
+ ## Use it
41
+
42
+ Ask in chat:
43
+
44
+ - "Hôm nay có gì?" / "What's due this week?" → `today`, `plans_due`, `cards`
45
+ - "Lunch 85k on my Visa" → a **preview** → you say go → one commit
46
+ - "How much did I spend on food this year vs last year?" → `report`
47
+ - "Net worth over the last 12 months" → `net_worth`
48
+ - "Move category cafe under drinks" → preview of the remap of every line → go
49
+
50
+ Tools: `about`, `rules`, `accounts`, `transactions`, `report`, `net_worth`, `cards`, `plans_due`, `deposits`, `today`; previews `add_transaction`, `edit_transaction`, `void_transaction`, `add_account`, `edit_account`, `add_plan`, `add_price`, `add_category`, `edit_category`; and `apply(preview_id)`, which commits a preview and is refused if the data changed since.
51
+
52
+ ## What talks to what
53
+
54
+ | Part | Talks to | Never |
55
+ |---|---|---|
56
+ | Your Worker | GitHub's API only (your repo, with a 1-hour token scoped to that one repo) | any other server, analytics, telemetry |
57
+ | Your AI client | your Worker's `/mcp` with a token your Worker issued (1 h, refreshable 30 days, revocable in the dashboard) | your GitHub credentials |
58
+ | GitHub sign-in | proves who you are; your Worker reads your login, then revokes that GitHub token at once | kept anywhere |
59
+ | The CLI | GitHub (`gh`), Cloudflare (`wrangler`), npm | sending your data anywhere |
60
+
61
+ Only the GitHub logins in `ALLOWED_LOGINS` (yours, set by `deploy`) can sign in. Writes are refused unless the whole ledger still passes `ownledger check`; your repo's CI runs the same check on every push.
62
+
63
+ ## Your data repo
64
+
65
+ ```
66
+ data/meta.yaml format version, base currency, locale
67
+ data/accounts.yaml accounts: id, name, type, details (card statement/due day, deposit rate/term…)
68
+ data/assets.yaml currencies, gold, funds, stocks…
69
+ data/categories.yaml income and spending tree
70
+ data/plans.yaml instalments, loans, premiums
71
+ data/prices.csv date,asset,price
72
+ data/ledger/yyyy/mm.jsonl one transaction per line; lines sum to 0
73
+ imports/ raw exports + one mapping per source app
74
+ AGENTS.md the rules any AI follows in this repo
75
+ ```
76
+
77
+ Plain text, diffable, yours. See [AGENTS.md](AGENTS.md) for the format.
78
+
79
+ ## CLI
80
+
81
+ ```
82
+ ownledger init [name] create a data repo
83
+ ownledger check [dir] check the data (CI runs it)
84
+ ownledger import <file> import an export (--profile, --preset misa, --yes)
85
+ ownledger deploy deploy or update your Worker
86
+ ownledger dev [dir] run your Worker locally against the local folder (sign-in skipped)
87
+ ```
88
+
89
+ ## Development
90
+
91
+ ```sh
92
+ pnpm install
93
+ pnpm test # engine, import, actions, worker helpers (made-up fixtures only)
94
+ pnpm build
95
+ node dist/cli/index.js dev fixtures/demo # Worker + dashboard on localhost:8787
96
+ node scripts/smoke-mcp.mjs http://localhost:8787 --write
97
+ ```
98
+
99
+ Fixtures are invented. Never put real financial data in this repo.
100
+
101
+ ## License
102
+
103
+ MIT
@@ -0,0 +1,5 @@
1
+ /*
2
+ Content-Security-Policy: default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self'; frame-ancestors 'none'; base-uri 'none'; form-action 'self'
3
+ X-Content-Type-Options: nosniff
4
+ Referrer-Policy: no-referrer
5
+ X-Frame-Options: DENY
package/assets/app.css ADDED
@@ -0,0 +1,61 @@
1
+ :root {
2
+ color-scheme: light;
3
+ --surface-0: #f4f4f2;
4
+ --surface-1: #fcfcfb;
5
+ --border: #e3e2de;
6
+ --grid: #ecebe7;
7
+ --text-primary: #0b0b0b;
8
+ --text-secondary: #52514e;
9
+ --text-muted: #7c7b76;
10
+ --series-1: #2a78d6; /* income, net worth, magnitude */
11
+ --series-2: #eb6834; /* spending */
12
+ --good: #1f7a1f;
13
+ --critical: #c0392b;
14
+ --radius: 12px;
15
+ }
16
+ * { box-sizing: border-box; }
17
+ body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text-primary); background: var(--surface-0); }
18
+ a { color: var(--series-1); text-decoration: none; }
19
+ a:hover { text-decoration: underline; }
20
+ .top { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; padding: .75rem 1.25rem; background: var(--surface-1); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 2; }
21
+ .brand { font-weight: 700; color: var(--text-primary); }
22
+ nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
23
+ nav a { color: var(--text-secondary); padding: .3rem .6rem; border-radius: 8px; }
24
+ nav a.on { background: var(--surface-0); color: var(--text-primary); }
25
+ main { max-width: 1120px; margin: 0 auto; padding: 1.25rem; }
26
+ h1 { font-size: 1.35rem; margin: .25rem 0 1rem; }
27
+ h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
28
+ .muted { color: var(--text-muted); }
29
+ .small { font-size: .85rem; }
30
+ .grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
31
+ .grid.two { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
32
+ .card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; min-width: 0; }
33
+ .stat .label { color: var(--text-secondary); font-size: .85rem; }
34
+ .stat .value { font-size: 1.6rem; font-weight: 650; font-variant-numeric: tabular-nums; }
35
+ .stat .delta { font-size: .85rem; color: var(--text-secondary); }
36
+ .num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
37
+ .neg { color: var(--critical); }
38
+ .pos { color: var(--good); }
39
+ table { width: 100%; border-collapse: collapse; font-size: .92rem; }
40
+ th, td { padding: .45rem .5rem; border-bottom: 1px solid var(--grid); text-align: left; vertical-align: top; }
41
+ th { color: var(--text-secondary); font-weight: 600; font-size: .82rem; }
42
+ tr.void td { color: var(--text-muted); text-decoration: line-through; }
43
+ .filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
44
+ input, select, button { font: inherit; padding: .4rem .6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-1); color: var(--text-primary); }
45
+ button { cursor: pointer; }
46
+ button.primary { background: var(--text-primary); color: var(--surface-1); border-color: var(--text-primary); }
47
+ button:disabled { opacity: .5; cursor: default; }
48
+ .pill { display: inline-block; padding: 0 .45rem; border-radius: 999px; background: var(--surface-0); color: var(--text-secondary); font-size: .78rem; margin-right: .25rem; }
49
+ .status { display: inline-flex; gap: .3rem; align-items: center; font-weight: 600; }
50
+ .status.bad { color: var(--critical); }
51
+ .status.ok { color: var(--good); }
52
+ .legend { display: flex; gap: 1rem; font-size: .85rem; color: var(--text-secondary); margin-bottom: .4rem; }
53
+ .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }
54
+ svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
55
+ svg.chart text { fill: var(--text-muted); font-size: 11px; font-family: inherit; }
56
+ svg.chart .grid line { stroke: var(--grid); }
57
+ .tip { position: fixed; pointer-events: none; background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px; padding: .4rem .6rem; font-size: .85rem; box-shadow: 0 4px 16px rgba(0,0,0,.08); z-index: 10; }
58
+ details.table summary { cursor: pointer; color: var(--text-secondary); font-size: .85rem; margin-top: .5rem; }
59
+ .empty { padding: 2rem; text-align: center; color: var(--text-muted); }
60
+ pre { white-space: pre-wrap; font-size: .82rem; background: var(--surface-0); padding: .6rem; border-radius: 8px; }
61
+ @media (max-width: 640px) { .grid.two { grid-template-columns: 1fr; } .stat .value { font-size: 1.3rem; } main { padding: .75rem; } }