opencode-statboard 2.10.31 → 2.10.33

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 (2) hide show
  1. package/package.json +1 -1
  2. package/public/index.html +101 -89
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-statboard",
3
- "version": "2.10.31",
3
+ "version": "2.10.33",
4
4
  "description": "Real-time dashboard for opencode token usage and cost statistics",
5
5
  "main": "server.js",
6
6
  "bin": {
package/public/index.html CHANGED
@@ -6,97 +6,98 @@
6
6
  <title>opencode Dashboard</title>
7
7
  <style>
8
8
  :root {
9
- --bg: #0d1117; --panel: #161b22; --border: #30363d; --text: #e6edf3; --muted: #8b949e;
10
- --in: #58a6ff; --out: #3fb950; --cache: #d29922; --cost: #f778ba; --tool: #a371f7;
11
- --warn: #e3b341; --dim: #6e7681;
9
+ --bg: #0a0c10; --panel: #12151c; --border: #1e2230; --text: #e8eaed; --muted: #9aa0a6;
10
+ --in: #4a9eff; --out: #34a853; --cache: #f9ab00; --cost: #ff6b9d; --tool: #a78bfa;
11
+ --warn: #fdd663; --dim: #5f6368;
12
12
  }
13
13
  * { box-sizing: border-box; margin: 0; padding: 0; }
14
- body { background: var(--bg); color: var(--text); font-family: "Segoe UI", "Microsoft JhengHei", sans-serif; padding: 24px; max-width: 1560px; margin: 0 auto; }
15
- header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
16
- h1 { font-size: 20px; font-weight: 600; }
17
- h1 .dot { color: #3fb950; }
18
- .status { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
19
- .pill { padding: 4px 12px; border-radius: 999px; font-size: 12px; border: 1px solid var(--border); cursor: pointer; user-select: none; white-space: nowrap; }
20
- .pill.ok { color: #3fb950; border-color: #238636; background: rgba(63,185,80,.08); }
21
- .pill.err { color: #f85149; border-color: #da3633; background: rgba(248,81,73,.08); }
22
- .pill.lang { color: var(--text); border-color: var(--border); background: rgba(139,148,158,.08); }
23
- .pill.lang:hover { background: rgba(139,148,158,.18); }
24
- .pill.backup { color: var(--cache); border-color: var(--cache); background: rgba(210,153,34,.08); }
25
- .pill.backup:hover { background: rgba(210,153,34,.18); }
14
+ body { background: var(--bg); color: var(--text); font-family: "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft JhengHei", sans-serif; padding: 32px 24px; max-width: 1440px; margin: 0 auto; line-height: 1.5; }
15
+ header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; }
16
+ h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.3px; }
17
+ h1 .dot { color: #34a853; }
18
+ .status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
19
+ .pill { padding: 6px 14px; border-radius: 8px; font-size: 12px; border: 1px solid var(--border); cursor: pointer; user-select: none; white-space: nowrap; transition: all 0.15s; }
20
+ .pill.ok { color: #34a853; border-color: #1e8e3e; background: rgba(52,168,83,.1); }
21
+ .pill.err { color: #f85149; border-color: #da3633; background: rgba(248,81,73,.1); }
22
+ .pill.lang { color: var(--text); border-color: var(--border); background: rgba(154,160,166,.08); }
23
+ .pill.lang:hover { background: rgba(154,160,166,.15); }
24
+ .pill.backup { color: var(--cache); border-color: var(--cache); background: rgba(249,171,0,.08); }
25
+ .pill.backup:hover { background: rgba(249,171,0,.15); }
26
26
  .pill.backup.busy { opacity: .6; pointer-events: none; }
27
- .version { font-size: 11px; color: var(--muted); background: var(--panel); border: 1px solid var(--border); padding: 2px 8px; border-radius: 4px; }
27
+ .version { font-size: 11px; color: var(--muted); background: var(--panel); border: 1px solid var(--border); padding: 3px 9px; border-radius: 6px; }
28
28
 
29
29
  /* ---- caveat line ---- */
30
- .caveat { font-size: 11px; color: var(--dim); line-height: 1.6; margin-bottom: 14px; letter-spacing: .1px; }
30
+ .caveat { font-size: 11px; color: var(--dim); line-height: 1.7; margin-bottom: 20px; letter-spacing: .2px; }
31
31
 
32
32
  /* ---- single global scope bar ---- */
33
- .scopebar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin-bottom: 18px; position: sticky; top: 0; z-index: 20; box-shadow: 0 6px 20px rgba(0,0,0,.35); }
34
- .scopebar .sb-label { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; }
35
- .range-btns { display: flex; gap: 4px; flex-wrap: wrap; }
36
- .range-btns .pill.active { color: var(--text); border-color: #58a6ff; background: rgba(88,166,255,.12); font-weight: 600; }
33
+ .scopebar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 20px; margin-bottom: 24px; position: sticky; top: 0; z-index: 20; backdrop-filter: blur(12px); box-shadow: 0 4px 24px rgba(0,0,0,.4); }
34
+ .scopebar .sb-label { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 600; }
35
+ .range-btns { display: flex; gap: 6px; flex-wrap: wrap; }
36
+ .range-btns .pill.active { color: var(--text); border-color: #4a9eff; background: rgba(74,158,255,.15); font-weight: 600; }
37
37
  .range-btns .pill:not(.active) { color: var(--muted); border-color: var(--border); background: transparent; }
38
- .range-btns .pill:not(.active):hover { background: rgba(139,148,158,.08); }
39
- .scopebar .sb-now { font-size: 12px; color: var(--text); margin-left: auto; font-weight: 600; }
38
+ .range-btns .pill:not(.active):hover { background: rgba(154,160,166,.1); }
39
+ .scopebar .sb-now { font-size: 13px; color: var(--text); margin-left: auto; font-weight: 600; }
40
40
 
41
- h2 { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 14px; }
41
+ h2 { font-size: 14px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 16px; }
42
42
 
43
43
  /* ---- headline cards: the dominant tier ---- */
44
- .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
45
- .card { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
46
- .card.hero { border-color: #2d3748; box-shadow: inset 0 1px 0 rgba(255,255,255,.03); }
47
- .card .v { font-size: 26px; font-weight: 700; margin-top: 4px; line-height: 1.15; letter-spacing: -.5px; }
48
- .card.hero .v { font-size: 34px; }
49
- .card .l { font-size: 12px; color: var(--muted); }
50
- .card .subs { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
44
+ .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
45
+ .card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 20px; transition: border-color 0.2s; }
46
+ .card:hover { border-color: #2a2f3a; }
47
+ .card.hero { border-color: #252a35; box-shadow: 0 2px 12px rgba(0,0,0,.3); }
48
+ .card .v { font-size: 28px; font-weight: 700; margin-top: 6px; line-height: 1.2; letter-spacing: -0.5px; }
49
+ .card.hero .v { font-size: 36px; }
50
+ .card .l { font-size: 13px; color: var(--muted); font-weight: 500; }
51
+ .card .subs { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
51
52
  .card .subs b { color: var(--text); font-weight: 600; }
52
53
  .subs .k-in { color: var(--in); } .subs .k-out { color: var(--out); }
53
54
  .subs .k-incl { flex-basis: 100%; font-variant-numeric: tabular-nums; }
54
55
  .subs .k-reasoning { color: var(--tool); } .subs .k-cache { color: var(--cache); }
55
56
  .subs .warn { color: var(--warn); cursor: pointer; border-bottom: 1px dashed var(--warn); }
56
- .subs .warn:hover { color: #f0c674; }
57
- .foot-note { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin-top: 14px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
57
+ .subs .warn:hover { color: #fdd663; }
58
+ .foot-note { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; margin-top: 16px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
58
59
 
59
60
  /* ---- breakdown / pricing tables ---- */
60
61
  .scrollx { overflow-x: auto; }
61
62
  .scrollx table { min-width: 1080px; }
62
63
  td.clip { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
63
- .track { background: #21262d; border-radius: 4px; height: 12px; overflow: hidden; }
64
- .track.share { min-width: 90px; height: 10px; }
64
+ .track { background: #1a1f2a; border-radius: 6px; height: 14px; overflow: hidden; }
65
+ .track.share { min-width: 90px; height: 12px; }
65
66
  /* horizontal bar list (tools). The container must NOT be a .bar-row — each
66
67
  child is a grid item, so a grid container here collapses all rows into
67
68
  one column and renders as a single giant bar. */
68
69
  .bar-list { display: block; }
69
- .bar-row { display: grid; grid-template-columns: 170px 1fr 150px; align-items: center; gap: 12px; padding: 5px 0; font-size: 13px; }
70
+ .bar-row { display: grid; grid-template-columns: 180px 1fr 160px; align-items: center; gap: 16px; padding: 6px 0; font-size: 13px; }
70
71
  .bar-row .name { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
71
72
  .bar-row .val { text-align: right; font-variant-numeric: tabular-nums; }
72
73
  .stack { display: flex; height: 100%; }
73
74
  .stack > div { height: 100%; }
74
75
  table { width: 100%; border-collapse: collapse; font-size: 13px; }
75
- th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; white-space: nowrap; }
76
+ th, td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; white-space: nowrap; }
76
77
  th:first-child, td:first-child { text-align: left; }
77
78
  th { color: var(--muted); font-weight: 500; font-size: 12px; }
78
- tbody tr:hover td { background: rgba(139,148,158,.06); }
79
- td.bd-name { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
79
+ tbody tr:hover td { background: rgba(154,160,166,.06); }
80
+ td.bd-name { max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
80
81
  td.na { color: var(--dim); }
81
82
 
82
83
  .rep-hint { color: var(--muted); font-size: 12px; font-weight: 400; }
83
- .rep-pre { font-family: monospace; font-size: 12.5px; line-height: 1.6; white-space: pre; overflow-x: auto; color: var(--text); margin: 0; }
84
+ .rep-pre { font-family: "SF Mono", Monaco, "Cascadia Code", monospace; font-size: 12.5px; line-height: 1.7; white-space: pre; overflow-x: auto; color: var(--text); margin: 0; }
84
85
 
85
86
  /* ---- trend ---- */
86
- .chart { position: relative; display: flex; align-items: flex-end; gap: 2px; height: 200px; padding-top: 10px; }
87
- .chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; min-width: 0; }
88
- .chart .bars { display: flex; gap: 2px; align-items: flex-end; justify-content: center; height: 170px; width: 100%; }
89
- .trend-x { display: flex; height: 16px; margin-top: 4px; }
90
- .trend-x span { flex: 1; text-align: center; font-size: 10px; color: var(--muted); line-height: 16px; overflow: hidden; text-overflow: clip; white-space: nowrap; }
91
- .trend-wrap { display: flex; gap: 24px; flex-wrap: wrap; }
92
- .trend-wrap > div { flex: 1; min-width: 300px; }
93
- .trend-wrap #costSection { min-width: 240px; }
94
- .heatmap-wrap { display: flex; flex-direction: column; gap: 8px; }
95
- .heatmap-months { display: flex; gap: 2px; padding-left: 28px; font-size: 11px; color: var(--muted); }
87
+ .chart { position: relative; display: flex; align-items: flex-end; gap: 3px; height: 220px; padding-top: 12px; }
88
+ .chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; min-width: 0; }
89
+ .chart .bars { display: flex; gap: 3px; align-items: flex-end; justify-content: center; height: 190px; width: 100%; }
90
+ .trend-x { display: flex; height: 18px; margin-top: 6px; }
91
+ .trend-x span { flex: 1; text-align: center; font-size: 10px; color: var(--muted); line-height: 18px; overflow: hidden; text-overflow: clip; white-space: nowrap; }
92
+ .trend-wrap { display: flex; gap: 28px; flex-wrap: wrap; }
93
+ .trend-wrap > div { flex: 1; min-width: 320px; }
94
+ .trend-wrap #costSection { min-width: 260px; }
95
+ .heatmap-wrap { display: flex; flex-direction: column; gap: 10px; }
96
+ .heatmap-months { display: flex; gap: 3px; padding-left: 32px; font-size: 11px; color: var(--muted); }
96
97
  .heatmap-months span { flex: 1; text-align: left; overflow: visible; white-space: nowrap; }
97
- .heatmap-grid { display: flex; gap: 2px; }
98
- .heatmap-grid .hm-week { display: flex; flex-direction: column; gap: 2px; }
99
- .hm-cell { width: 14px; height: 14px; border-radius: 2px; background: var(--card2); border: 1px solid var(--border); box-sizing: border-box; }
98
+ .heatmap-grid { display: flex; gap: 3px; }
99
+ .heatmap-grid .hm-week { display: flex; flex-direction: column; gap: 3px; }
100
+ .hm-cell { width: 15px; height: 15px; border-radius: 3px; background: var(--card2); border: 1px solid var(--border); box-sizing: border-box; }
100
101
  /* Heatmap color scale: 10 levels from cool to hot */
101
102
  .hm-cell.hm-0 { background: var(--card2); }
102
103
  .hm-cell.hm-1 { background: #0d47a1; } /* Deep blue */
@@ -121,46 +122,47 @@
121
122
  .hm-cell.hm-19 { background: #d84315; }
122
123
  .hm-cell.hm-20 { background: #c62828; }
123
124
  .hm-cell.hm-21 { background: #b71c1c; }
124
- .heatmap-legend { display: flex; gap: 4px; align-items: center; font-size: 11px; color: var(--muted); flex-wrap: wrap; }
125
- .heatmap-legend .hm-cell { width: 12px; height: 12px; }
126
- .legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-bottom: 12px; flex-wrap: wrap; }
127
- .legend span { display: flex; align-items: center; gap: 6px; }
128
- .sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
125
+ .heatmap-legend { display: flex; gap: 5px; align-items: center; font-size: 11px; color: var(--muted); flex-wrap: wrap; }
126
+ .heatmap-legend .hm-cell { width: 13px; height: 13px; }
127
+ .legend { display: flex; gap: 18px; font-size: 12px; color: var(--muted); margin-bottom: 14px; flex-wrap: wrap; }
128
+ .legend span { display: flex; align-items: center; gap: 7px; }
129
+ .sw { width: 13px; height: 13px; border-radius: 3px; display: inline-block; }
129
130
 
130
- .error-banner { display: none; background: rgba(248,81,73,.1); border: 1px solid #da3633; color: #f85149; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
131
+ .error-banner { display: none; background: rgba(248,81,73,.1); border: 1px solid #da3633; color: #f85149; padding: 12px 16px; border-radius: 10px; margin-bottom: 20px; font-size: 13px; }
131
132
  .error-banner.show { display: block; }
132
133
 
133
134
  /* ---- collapsible sections: primary vs secondary tier ---- */
134
- details.tool-section { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 18px; margin-bottom: 18px; }
135
- details.tool-section summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
135
+ details.tool-section { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 20px; transition: border-color 0.2s; }
136
+ details.tool-section:hover { border-color: #2a2f3a; }
137
+ details.tool-section summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; justify-content: space-between; }
136
138
  details.tool-section summary::-webkit-details-marker { display: none; }
137
- details.tool-section summary::before { content: '\25B8'; font-size: 12px; color: var(--muted); transition: transform .2s; flex: none; }
139
+ details.tool-section summary::before { content: '\25B8'; font-size: 13px; color: var(--muted); transition: transform 0.2s; flex: none; }
138
140
  details.tool-section[open] summary::before { transform: rotate(90deg); }
139
141
  details.tool-section summary h2 { margin: 0; }
140
- details.tool-section.secondary { background: transparent; padding: 12px 18px; }
141
- details.tool-section.secondary[open] { padding: 18px; }
142
- details.tool-section.secondary summary h2 { font-size: 11px; }
143
- .scope-tag { font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; font-weight: 500; white-space: nowrap; flex: none; margin-left: 12px; font-variant-numeric: tabular-nums; }
142
+ details.tool-section.secondary { background: transparent; padding: 14px 20px; }
143
+ details.tool-section.secondary[open] { padding: 20px; }
144
+ details.tool-section.secondary summary h2 { font-size: 12px; }
145
+ .scope-tag { font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 8px; padding: 3px 11px; font-weight: 500; white-space: nowrap; flex: none; margin-left: 14px; font-variant-numeric: tabular-nums; }
144
146
 
145
- .subtabs { display: flex; gap: 4px; margin: 0 0 14px 20px; }
147
+ .subtabs { display: flex; gap: 6px; margin: 0 0 16px 24px; }
146
148
  .subtabs .pill { color: var(--muted); background: transparent; }
147
- .subtabs .pill.active { color: var(--text); border-color: #58a6ff; background: rgba(88,166,255,.12); font-weight: 600; }
148
-
149
- .badge { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
150
- .badge.exact { color: #3fb950; border-color: rgba(63,185,80,.4); }
151
- .badge.sibling { color: #58a6ff; border-color: rgba(88,166,255,.4); }
152
- .badge.proxy { color: #d29922; border-color: rgba(210,153,34,.4); }
153
- .badge.openrouter { color: #a371f7; border-color: rgba(163,113,247,.4); }
154
- .badge.partial { color: #f778ba; border-color: rgba(247,120,186,.4); }
149
+ .subtabs .pill.active { color: var(--text); border-color: #4a9eff; background: rgba(74,158,255,.15); font-weight: 600; }
150
+
151
+ .badge { display: inline-block; font-size: 11px; padding: 2px 9px; border-radius: 8px; border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
152
+ .badge.exact { color: #34a853; border-color: rgba(52,168,83,.4); }
153
+ .badge.sibling { color: #4a9eff; border-color: rgba(74,158,255,.4); }
154
+ .badge.proxy { color: #f9ab00; border-color: rgba(249,171,0,.4); }
155
+ .badge.openrouter { color: #a78bfa; border-color: rgba(167,139,250,.4); }
156
+ .badge.partial { color: #ff6b9d; border-color: rgba(255,107,157,.4); }
155
157
  .badge.unpriced { color: #f85149; border-color: rgba(248,81,73,.4); }
156
- .empty { color: var(--muted); font-size: 13px; padding: 12px 0; }
158
+ .empty { color: var(--muted); font-size: 13px; padding: 14px 0; }
157
159
 
158
- .trend-bar { position: absolute; bottom: 0; border-radius: 2px 2px 0 0; transition: height .4s ease; }
160
+ .trend-bar { position: absolute; bottom: 0; border-radius: 3px 3px 0 0; transition: height .4s ease; }
159
161
  .trend-bar-cache { left: 0; right: 0; opacity: .2; }
160
162
  .trend-bar-input { left: 25%; width: 22%; z-index: 1; }
161
163
  .trend-bar-output { left: 53%; width: 22%; z-index: 1; }
162
164
  .trend-bar-reasoning { left: 76%; width: 22%; z-index: 1; }
163
- @media (max-width: 640px) { body { padding: 14px; } .card.hero .v { font-size: 26px; } }
165
+ @media (max-width: 640px) { body { padding: 16px; } .card.hero .v { font-size: 28px; } }
164
166
  </style>
165
167
  </head>
166
168
  <body>
@@ -636,7 +638,7 @@ function renderReport(rep) {
636
638
  const avgTokensDay = o.days > 0 ? dayTokTotal / o.days : null;
637
639
  const meta = [t('sessionsLabel') + ' ' + fmt(o.sessions), t('messagesLabel') + ' ' + fmt(o.messages),
638
640
  t('daysLabel') + ' ' + fmt(o.days), t('avgCostDay') + ' ' + fmtCost(c.avgDay),
639
- t('avgTokensDay') + ' ' + (avgTokensDay != null ? fmt(avgTokensDay) : EM),
641
+ t('avgTokensDay') + ' ' + (avgTokensDay != null ? fmt(avgTokensDay) : '—'),
640
642
  t('avgTokensSession') + ' ' + fmt(c.avgTokensSession), t('medianTokensSession') + ' ' + fmt(c.medianTokensSession)];
641
643
  $('hl-meta').textContent = meta.join(' · ');
642
644
 
@@ -750,29 +752,39 @@ function renderPricing(rep) {
750
752
  $('pricing-empty').textContent = prov.length ? '' : t('noData');
751
753
  }
752
754
 
753
- function fmtUsd(v) { if (v == null) return EM; return '$' + Number(v).toFixed(4); }
755
+ function fmtUsd(v) { if (v == null) return '—'; return '$' + Number(v).toFixed(4); }
754
756
  function renderQuota(q) {
755
757
  const body = $('quota-body');
756
758
  if (!q || !q.ok) { body.textContent = q && q.error ? q.error : t('noData'); return; }
757
759
  const rows = (q.accounts || []).map((a) => {
758
760
  if (a.error) return '<div style="color:var(--err)">' + esc(a.label) + ': ' + esc(a.error) + '</div>';
759
761
  const free = a.freeModelDaily || {};
760
- const rem = a.remainingUsd != null ? fmtUsd(a.remainingUsd) : EM;
762
+ const rem = a.remainingUsd != null ? fmtUsd(a.remainingUsd) : '—';
761
763
  const used = fmtUsd(a.usedUsd || 0);
762
764
  const lim = a.limitUsd != null ? fmtUsd(a.limitUsd) : 'unlimited';
763
765
  const pct = (a.limitUsd && a.limitUsd > 0) ? Math.round(((a.usedUsd || 0) / a.limitUsd) * 100) : null;
766
+ const freePct = (free.limit && free.limit > 0) ? Math.round((free.used / free.limit) * 100) : 0;
764
767
  const freeLine = free.limit != null
765
- ? 'free RPD ' + fmt(free.used) + '/' + fmt(free.limit) + ' (left ' + fmt(free.remaining) + ')'
768
+ ? '<div style="margin-top:4px">free RPD ' + fmt(free.used) + '/' + fmt(free.limit) + ' (left ' + fmt(free.remaining) + ')</div>'
769
+ + '<div class="track" style="margin-top:2px"><div class="fill" style="width:' + freePct + '%;background:' + (freePct > 80 ? 'var(--out)' : 'var(--in)') + '"></div></div>'
766
770
  : '';
767
- const bud = a.budgetRemaining != null ? 'budget left ' + fmtUsd(a.budgetRemaining) + (a.budgetResetInterval ? ' (resets ' + a.budgetResetInterval + ')' : '') : '';
768
- return '<div style="margin-bottom:6px"><b>' + esc(a.label) + '</b>'
769
- + ' remaining ' + rem + ' / ' + lim + (pct != null ? ' (' + pct + '% used)' : '')
770
- + ' used ' + used + (a.isFreeTier ? ' [free tier]' : '')
771
- + (freeLine ? '<br>&nbsp;&nbsp;' + freeLine : '')
772
- + (bud ? '<br>&nbsp;&nbsp;' + bud : '')
771
+ const bud = a.budgetRemaining != null ? '<div style="margin-top:4px;color:var(--muted)">budget left ' + fmtUsd(a.budgetRemaining) + '</div>' : '';
772
+ const barColor = pct != null && pct > 80 ? 'var(--out)' : pct != null && pct > 50 ? 'var(--cache)' : 'var(--in)';
773
+ return '<div style="margin-bottom:12px;padding:12px;background:var(--bg);border:1px solid var(--border);border-radius:8px">'
774
+ + '<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:6px">'
775
+ + '<b style="color:var(--text)">' + esc(a.label) + '</b>'
776
+ + '<span style="font-size:11px;color:var(--muted)">' + (a.isFreeTier ? '[free tier]' : '') + '</span>'
777
+ + '</div>'
778
+ + '<div style="display:flex;justify-content:space-between;font-size:12px;margin-bottom:4px">'
779
+ + '<span>remaining <b>' + rem + '</b> / ' + lim + '</span>'
780
+ + '<span style="color:var(--muted)">used ' + used + '</span>'
781
+ + '</div>'
782
+ + (pct != null ? '<div class="track"><div class="fill" style="width:' + pct + '%;background:' + barColor + '"></div></div>' : '')
783
+ + freeLine
784
+ + bud
773
785
  + '</div>';
774
786
  }).join('');
775
- body.innerHTML = rows + '<div style="color:var(--muted);font-size:10px;margin-top:4px">reset 00:00 UTC = 08:00 TW · cached 5 min</div>';
787
+ body.innerHTML = rows + '<div style="color:var(--muted);font-size:10px;margin-top:8px;text-align:center">reset 00:00 UTC = 08:00 TW · cached 5 min</div>';
776
788
  }
777
789
  async function loadQuota() {
778
790
  try { const r = await fetch('/api/openrouter-quota?_=' + Date.now(), { cache: 'no-store' }); const j = await r.json(); renderQuota(j); } catch (e) { $('quota-body').textContent = 'load failed: ' + e.message; }