Repository navigation
Expand file tree
/
Copy pathdashboard.py
More file actions
3607 lines (3385 loc) · 161 KB
/
Copy pathdashboard.py
File metadata and controls
3607 lines (3385 loc) · 161 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""Dashboard 路由 — 流量与用量可视化看板."""
from __future__ import annotations
import hashlib
import json
import logging
import traceback
from pathlib import Path
from typing import Any, get_args
from fastapi import Request
from fastapi.responses import HTMLResponse, Response
from pydantic import BaseModel
from pydantic_core import PydanticUndefined, to_jsonable_python
from starlette.staticfiles import StaticFiles
from ..config.routing import VendorConfig
from ..config.schema import ProxyConfig
from ..config.ui_registry import REGISTRY
from ..logging.db import TimePeriod
# ── 品牌图标:Tabler prompt 核心笔划(> 与 _)+ 通透青绿圆环 ──────────────
# 设计(方案 d05):全透明底 + 青绿渐变细圆环(stroke 0.5,仅原 1/3,通透若隐)+
# 饱和青绿渐变 >_ 笔划(stroke 2.5)。极细环与饱和笔划形成权重对比,>_ 为绝对主角;
# 青绿(#22d3ee -> #2dd4bf)承载终端/代码语义,通透明快。基础笔划取自 Tabler prompt
# (chevron M5 7l5 5l-5 5 + 下划线 M13 17l6 0,下划线长 6 单位、不会小尺寸点化)。
# 渐变用 gradientUnits="userSpaceOnUse" + 绝对坐标:纯水平下划线包围盒高度为 0,若用
# 默认 objectBoundingBox 渐变会映射失效而不着色(下划线消失),userSpaceOnUse 规避。
# 单一事实源:_PROMPT_PATHS 与 _LOGO_DEFS 同时供 favicon SVG(f-string)与页面
# logo({{PROMPT}} / {{LOGO_DEFS}} 模板替换)消费。
_BRAND_FROM, _BRAND_TO = "#22d3ee", "#2dd4bf"
_LOGO_DEFS = (
'<defs><linearGradient id="cpBrand" gradientUnits="userSpaceOnUse" '
'x1="4" y1="4" x2="20" y2="20">'
f'<stop offset="0" stop-color="{_BRAND_FROM}"/>'
f'<stop offset="1" stop-color="{_BRAND_TO}"/>'
"</linearGradient></defs>"
)
_PROMPT_PATHS = '<path d="M5 7l5 5l-5 5" /><path d="M13 17l6 0" />'
# ── Favicon (SVG, 现代浏览器主选) ──────────────────────────────────────────
def _build_favicon_svg() -> str:
"""生成 24×24 SVG favicon:通透青绿圆环 + 品牌渐变 prompt 笔划(方案 d05).
全透明底 + 青绿渐变细圆环(``r=11``、``stroke-width=0.5``、``stroke-opacity=.55``,
通透若隐)+ 饱和青绿渐变 ``>`` 与 ``_`` 笔划(``stroke-width=2.5``)。极细环与饱和
笔划形成权重对比,``>_`` 为视觉主角。独立 SVG 文档无 CSS 上下文,``currentColor``
不可靠,故渐变复用 ``_LOGO_DEFS``(userSpaceOnUse,规避水平下划线不着色)单一事实源。
"""
return (
'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">'
f"{_LOGO_DEFS}"
'<circle cx="12" cy="12" r="11" fill="none" stroke="url(#cpBrand)" '
'stroke-width="0.5" stroke-opacity=".55"/>'
f'<g fill="none" stroke="url(#cpBrand)" stroke-width="2.5" '
f'stroke-linecap="round" stroke-linejoin="round">{_PROMPT_PATHS}</g>'
"</svg>"
)
# ── Favicon (ICO, 32×32 光栅回退) ─────────────────────────────────────────
def _build_favicon() -> bytes:
"""程序化生成 32×32 ICO:全透明底 + 青绿渐变 prompt 笔划(旧浏览器/Safari 回退).
项目无 Pillow/cairosvg 等图像库,故以纯 Python 按像素光栅化:全透明底 + 青绿渐变
(#22d3ee -> #2dd4bf)``>`` 折线与 ``_`` 下划线。沿用「全零 AND-mask + per-pixel
alpha」透明方案(现代渲染器按 alpha 通道处理透明)。方案 d05 的细圆环(0.5px)在
32px 下不足 1 像素、无法渲染,故 ICO 省略圆环、仅保留饱和 ``>_`` 笔划(符合「图标
为主角、环极弱」的设计意图),完整外观由 SVG 主版承载。
"""
import math
import struct
width = height = 32
scale = width / 24.0 # SVG 24 单位 -> 像素
# 图标笔划青绿渐变:#22d3ee -> #2dd4bf(与 _LOGO_DEFS 同源)
r0, g0, b0 = 0x22, 0xD3, 0xEE
r1, g1, b1 = 0x2D, 0xD4, 0xBF
# 像素缓冲:[B, G, R, A],默认全透明(全透底,无容器填充)
buf: list[list[list[int]]] = [
[[0, 0, 0, 0] for _ in range(width)] for _ in range(height)
]
def brand_at(px: float, py: float) -> tuple[int, int, int]:
"""按对角参数 t 返回 (px,py) 处的青绿渐变 RGB(与 SVG url(#cpBrand) 同向)."""
t = (px + py) / (width + height - 2)
return (
int(r0 + (r1 - r0) * t),
int(g0 + (g1 - g0) * t),
int(b0 + (b1 - b0) * t),
)
def stamp(px: float, py: float) -> None:
"""以 (px, py) 为中心盖 ~3px 青绿渐变方块(笔划加粗,保证小尺寸可辨识)."""
ix, iy = int(round(px)), int(round(py))
cr, cg, cb = brand_at(px, py)
for oy in (-1, 0, 1):
for ox in (-1, 0, 1):
nx, ny = ix + ox, iy + oy
if 0 <= nx < width and 0 <= ny < height:
buf[ny][nx] = [cb, cg, cr, 255]
def line(x0: float, y0: float, x1: float, y1: float) -> None:
"""稠密采样 + stamp 形成青绿渐变粗线段."""
dist = math.hypot(x1 - x0, y1 - y0)
steps = max(1, int(dist * 3))
for i in range(steps + 1):
s = i / steps
stamp(x0 + (x1 - x0) * s, y0 + (y1 - y0) * s)
# prompt 笔划(SVG 24 单位 -> 像素)
# > 折线 (5,7)->(10,12)->(5,17);_ 下划线 (13,17)->(19,17)
line(5 * scale, 7 * scale, 10 * scale, 12 * scale)
line(10 * scale, 12 * scale, 5 * scale, 17 * scale)
line(13 * scale, 17 * scale, 19 * scale, 17 * scale)
# 3) 打包 ICO(BMP bottom-up;全零 AND-mask,信任 per-pixel alpha 实现圆角透明)
pixel_rows: list[bytes] = []
for y in range(height - 1, -1, -1): # BMP bottom-up
row = bytearray()
for x in range(width):
b, g, r, a = buf[y][x]
row.extend([b, g, r, a]) # BGRA
pixel_rows.append(bytes(row))
bmp_hdr = struct.pack(
"<IIIHHIIIIII", 40, width, height * 2, 1, 32, 0, 0, 0, 0, 0, 0
)
px_data = b"".join(pixel_rows)
mask_data = b"\x00\x00\x00\x00" * height
image_data = bmp_hdr + px_data + mask_data
ico_hdr = struct.pack("<HHH", 0, 1, 1)
dir_entry = struct.pack(
"<BBBBHHII", width, height, 0, 0, 1, 32, len(image_data), 22
)
return ico_hdr + dir_entry + image_data
_FAVICON_ICO: bytes = _build_favicon()
_FAVICON_SVG: str = _build_favicon_svg()
logger = logging.getLogger(__name__)
# ── 静态资源与安全头 ───────────────────────────────────────────────────────
_STATIC_DIR = Path(__file__).parent / "static"
def _asset_url(rel: str) -> str:
"""``/static/<rel>?v=<sha256[:8]>``:内容变化即换 URL(含 editable 安装)."""
digest = hashlib.sha256((_STATIC_DIR / rel).read_bytes()).hexdigest()[:8]
return f"/static/{rel}?v={digest}"
# 精确版本 + SRI:哈希取自 npm registry tarball(dist.integrity 校验通过)中的
# dist/chart.umd.js,jsDelivr 同路径文件逐字节一致(.min.js 为 CDN 动态生成,不可用 SRI)
_CHART_JS_URL = "https://cdn.jsdelivr.net/npm/chart.js@4.4.3/dist/chart.umd.js"
_CHART_JS_SRI = (
"sha384-tgbB5AKnszdcfwcZtTfuhR3Ko1XZdlDfsLtkxiiAZiVkkXCkFmp+FQFh+V/UTo54"
)
_DASHBOARD_CSP = (
"default-src 'self'; "
"script-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net; "
"style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; "
"font-src https://fonts.gstatic.com; img-src 'self' data:; connect-src 'self'; "
"frame-ancestors 'none'; object-src 'none'; base-uri 'none'"
)
def _inner_model(annotation: Any) -> type[BaseModel] | None:
"""``M`` / ``M | None`` / ``list[M]`` → ``M``."""
for arg in (annotation, *get_args(annotation)):
if isinstance(arg, type) and issubclass(arg, BaseModel):
return arg
return None
def _schema_field(path: str) -> Any:
"""registry 路径(``*`` 为 vendor 类型 / 列表下标)→ Pydantic FieldInfo."""
parts = path.split(".")
model: type[BaseModel] | None = ProxyConfig
if parts[0] == "vendors":
model, parts = VendorConfig, parts[2:]
info = None
for part in (p for p in parts if p != "*"):
info = model.model_fields.get(part) if model is not None else None
if info is None:
return None
model = _inner_model(info.annotation)
return info
def _schema_defaults_json() -> str:
"""可编辑字段的 schema 缺省值(前端据此补齐未显式设置的键);转义 ``<`` 以嵌入 script."""
fields: dict[str, Any] = {}
groups: dict[str, Any] = {}
for spec in REGISTRY:
info = _schema_field(spec.path)
if spec.readonly or spec.widget in ("secret", "list_section") or info is None:
continue
if spec.widget == "optional_group":
groups[spec.path] = _inner_model(info.annotation)().model_dump(mode="json")
elif not info.is_required():
value = info.get_default(call_default_factory=True)
if value is not PydanticUndefined:
fields[spec.path] = to_jsonable_python(value)
payload = json.dumps({"fields": fields, "groups": groups}, ensure_ascii=False)
return payload.replace("<", "\\u003c")
class _StaticAssets(StaticFiles):
"""静态资源:URL 带内容哈希,响应 ``no-cache``(ETag 协商,304 无 body)."""
def file_response(self, *args: Any, **kwargs: Any) -> Response:
response = super().file_response(*args, **kwargs)
response.headers["Cache-Control"] = "no-cache"
response.headers["X-Content-Type-Options"] = "nosniff"
return response
# ── HTML 模板 ──────────────────────────────────────────────────────────────
_DASHBOARD_HTML = """<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Coding Proxy Dashboard</title>
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600;700&display=swap" rel="stylesheet" />
<script src="{{CHART_JS_URL}}" integrity="{{CHART_JS_SRI}}" crossorigin="anonymous"></script>
<style>
:root {
--bg: #0a0e14;
--bg-card: #12161e;
--bg-card-hover: #181d27;
--bg-secondary: #161b24;
--border: rgba(255,255,255,.06);
--border-subtle: rgba(255,255,255,.04);
--text-primary: #e6edf3;
--text-secondary: #8b949e;
--text-tertiary: #6e7681;
--accent-blue: #58a6ff;
--accent-green: #3fb950;
--accent-yellow: #d29922;
--accent-red: #f85149;
--accent-purple: #bc8cff;
--accent-teal: #39d353;
--radius: 14px;
--radius-sm: 8px;
--shadow: 0 1px 2px rgba(0,0,0,.3);
--shadow-md: 0 8px 24px rgba(0,0,0,.3);
--gradient-primary: linear-gradient(135deg, #667eea, #764ba2);
--gap-section: 12px;
/* 表格固定列宽 token(Sessions 与 Config 共用:同一属性同一宽度;
宽度 ≥ 大写表头实测宽 + 左右 padding,并容纳典型内容;超长内容省略号 + tooltip;
Sessions 合计 1328px = main 内容区) */
--col-session: 136px;
--col-title: 152px;
--col-time: 112px;
--col-count: 100px;
--col-models: 144px;
--col-vendors: 96px;
--col-latency: 120px;
--col-success: 120px;
--col-client: 128px;
--col-order: 88px;
--col-vendor: 120px;
--col-name: 160px;
--col-model: 240px;
--col-pattern: 240px;
--col-target: 200px;
--col-list: 200px;
--col-state: 128px;
--col-currency: 104px;
--col-price: 96px;
--col-bool: 88px;
--col-actions: 128px;
}
@keyframes fadeInUp {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
background: var(--bg);
color: var(--text-primary);
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
font-size: 15px;
line-height: 1.5;
min-height: 100vh;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-rendering: optimizeLegibility;
}
/* ── 头部 ── */
header {
background: rgba(10,14,20,.9);
backdrop-filter: blur(6px);
-webkit-backdrop-filter: blur(6px);
border-bottom: 1px solid rgba(255,255,255,.04);
padding: 16px 32px;
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
gap: 8px 16px;
position: sticky;
top: 0;
z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.header-left h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo {
width: 32px; height: 32px;
display: flex; align-items: center; justify-content: center;
}
.logo svg { width: 28px; height: 28px; display: block; filter: drop-shadow(0 0 3px rgba(45,212,191,.3)); }
h1 { font-size: 18px; font-weight: 600; color: var(--text-primary); letter-spacing: -.3px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.badge {
font-size: 12px; padding: 2px 8px;
border-radius: 12px;
background: rgba(88,166,255,.1);
color: var(--accent-blue);
border: 1px solid rgba(88,166,255,.2);
font-family: 'JetBrains Mono', monospace;
}
.refresh-time { font-size: 12px; color: var(--text-tertiary); }
.btn-refresh {
padding: 5px 12px; border-radius: var(--radius-sm);
background: rgba(48,54,61,.5);
border: 1px solid var(--border);
color: var(--text-secondary);
font-size: 13px; cursor: pointer;
transition: all .2s ease;
}
.btn-refresh:hover {
background: var(--bg-card-hover);
color: var(--text-primary);
border-color: rgba(88,166,255,.4);
}
/* ── 主内容 ── */
main { padding: 28px 32px; max-width: 1440px; margin: 0 auto; }
/* ── KPI:一条 stat strip ──
六格合成一个表面,格间只留 hairline。数值穿文字色;图标、彩色顶线、hover 光晕这类装饰一概不加 */
.kpi-grid {
display: grid;
gap: 0;
/* 费用可能是双币种长串(¥1,234.56 + $987.65),那一列略宽,其余五列等宽 */
grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.45fr) repeat(2, minmax(0, 1fr));
overflow: hidden;
background: rgba(18,22,30,.7);
border: 1px solid rgba(255,255,255,.05);
border-radius: var(--radius);
box-shadow: var(--shadow);
backdrop-filter: blur(4px);
-webkit-backdrop-filter: blur(4px);
margin-bottom: var(--gap-section);
}
.kpi-card {
position: relative;
min-width: 0;
padding: 16px 20px 14px;
border-left: 1px solid rgba(255,255,255,.06);
animation: fadeInUp .4s ease both;
}
.kpi-card:nth-child(6n+1) { border-left: 0; }
/* 首末两格的外侧内边距取卡片标准内边距:首格文字与其它卡片标题左对齐 */
.kpi-card:first-child { padding-left: 24px; }
.kpi-card:last-child { padding-right: 24px; }
.kpi-label {
font-size: 13px; font-weight: 500; color: var(--text-secondary); letter-spacing: .2px;
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi-value {
margin-top: 6px;
font-size: clamp(22px, 1.95vw, 28px); font-weight: 700; line-height: 1.15; letter-spacing: -.5px;
font-family: 'JetBrains Mono', monospace;
color: var(--text-primary);
white-space: nowrap;
}
/* 费用:updateKPI 按「 + 」拆成两段,每段整体不断开,放不下时在段之间换行;数字比其它格小一号 */
.kpi-cost .kpi-value {
display: flex; flex-wrap: wrap; column-gap: 6px;
font-size: clamp(18px, 1.5vw, 22px); line-height: 1.25; letter-spacing: -.3px;
}
.kpi-cost .kpi-value > span { white-space: nowrap; }
/* 副行 = 区间标签 + 数值:放不下时在两段之间换行,两段各自不断开,不截断 */
.kpi-sub {
display: flex; flex-wrap: wrap; column-gap: 5px;
margin-top: 6px; font-size: 12px; line-height: 1.35; color: var(--text-secondary);
}
.kpi-sub-label, .kpi-sub-val { white-space: nowrap; }
/* ── KPI 响应式:平板横屏及以下转 3 列两行,手机转 2 列三行;分隔线跟着换行位置走 ── */
@media (max-width: 1023px) {
.kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi-card:nth-child(3n+1) { border-left: 0; padding-left: 24px; }
.kpi-card:nth-child(3n) { padding-right: 24px; }
.kpi-card:nth-child(n+4) { border-top: 1px solid rgba(255,255,255,.06); }
}
/* 列内边距规则按「先清 3 列、再排 2 列」的顺序写:同特异性下后写的赢,末列才是 24px */
@media (max-width: 519px) {
.kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi-card { padding: 14px 16px 12px; }
.kpi-card:nth-child(3n+1) { border-left: 1px solid rgba(255,255,255,.06); padding-left: 16px; padding-right: 16px; }
.kpi-card:nth-child(3n) { padding-right: 16px; }
.kpi-card:nth-child(2n+1) { border-left: 0; padding-left: 24px; }
.kpi-card:nth-child(2n) { padding-right: 24px; }
.kpi-card:nth-child(n+3) { border-top: 1px solid rgba(255,255,255,.06); }
}
/* ── 同一水平栏:订阅状态 | 供应商请求分布 ──
右列放甜甜圈与图例;视口不够宽时订阅区会被挤到横向滚动,这一档改为上下堆叠 */
.status-row {
display: grid;
grid-template-columns: minmax(0, 1fr) clamp(280px, 24vw, 360px);
gap: var(--gap-section);
margin-bottom: var(--gap-section);
}
.status-row > .card {
min-width: 0;
margin-bottom: 0;
overflow: hidden;
}
/* 分布卡随左卡等高:标题留在顶上,图形区吃掉余量,甜甜圈与图例在余量里垂直居中。
flex-basis 取 0 而不是 auto:auto 会让图形区的高度钉在 canvas 上一次写下的像素高度上,
左卡变矮后这一行回不去。min-height 只在订阅行很少时保底,须 ≤ 190px(3 行订阅卡 269px 减去
标题与内边距 79px),否则分布卡撑高整行,订阅卡底部留白 */
.dist-card { display: flex; flex-direction: column; }
.dist-card .chart-wrap { flex: 1 1 0; height: auto; min-height: 180px; }
@media (max-width: 1179px) {
.status-row { grid-template-columns: minmax(0, 1fr); }
.dist-card .chart-wrap { flex: none; height: 240px; min-height: 0; }
}
.card {
background: rgba(18,22,30,.7);
border: 1px solid rgba(255,255,255,.05);
border-radius: var(--radius);
padding: 20px 24px;
box-shadow: var(--shadow);
backdrop-filter: blur(4px);
-webkit-backdrop-filter: blur(4px);
transition: box-shadow .2s ease;
animation: fadeInUp .4s ease both;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-title {
font-size: 14px; font-weight: 600;
color: var(--text-secondary);
letter-spacing: .3px;
margin-bottom: 16px;
display: flex; align-items: center; justify-content: space-between;
}
/* 卡片标题栏右侧操作控件(.card-title 的 space-between 自动推至右端) */
.btn-card-action {
padding: 4px 10px; border-radius: 6px;
background: rgba(48,54,61,.4); border: 1px solid rgba(255,255,255,.08);
color: var(--text-secondary); font-size: 12px; font-weight: 500;
letter-spacing: 0; cursor: pointer; white-space: nowrap;
transition: all .15s ease;
}
.btn-card-action:hover:not(:disabled) {
background: var(--bg-card-hover); color: var(--text-primary);
border-color: rgba(88,166,255,.3);
}
.btn-card-action:disabled { opacity: .35; cursor: default; }
.chart-wrap { position: relative; height: 260px; min-width: 0; }
/* 图位高度由外层容器定死;960px 及以下 .chart-with-legend 转为纵向 flex,那里要把图位的 flex-basis 解除(见下方媒体查询) */
.chart-wrap-lg { position: relative; height: 300px; min-width: 0; }
.chart-wrap-xl { position: relative; height: 300px; min-width: 0; }
/* ── HTML Legend(单列可滚动) ── */
.chart-with-legend {
display: flex; align-items: stretch; gap: 0;
}
.chart-with-legend > .chart-wrap-xl { flex: 1 1 0; min-width: 0; }
.html-legend-wrap {
flex: 0 0 200px; max-height: 280px;
overflow-y: auto; overflow-x: hidden;
padding: 4px 0 4px 8px;
scrollbar-width: thin;
scrollbar-color: rgba(255,255,255,.15) transparent;
}
.html-legend-wrap::-webkit-scrollbar { width: 4px; }
.html-legend-wrap::-webkit-scrollbar-track { background: transparent; }
.html-legend-wrap::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }
.html-legend-wrap ul {
list-style: none; margin: 0; padding: 0;
display: flex; flex-direction: column; gap: 4px;
}
.html-legend-wrap li {
display: flex; align-items: center; gap: 6px;
padding: 3px 6px; border-radius: 4px; cursor: pointer;
font-size: 12px; font-weight: 500; color: #8b949e;
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
transition: background .15s ease; user-select: none;
}
.html-legend-wrap li:hover { background: rgba(255,255,255,.06); }
.html-legend-wrap li.legend-hidden { text-decoration: line-through; opacity: 0.4; }
.html-legend-wrap li .legend-color {
display: inline-block; width: 10px; height: 10px;
border-radius: 50%; flex-shrink: 0;
}
@media (max-width: 960px) {
.chart-with-legend { flex-direction: column; }
/* 纵向 flex 下 flex-basis: 0 会让图位高度跟着 canvas 内在高度走、塌成 150px */
.chart-with-legend > .chart-wrap-xl { flex: none; }
.html-legend-wrap { flex: none; max-height: 120px; padding: 8px 0 0 0; }
.html-legend-wrap ul { flex-direction: row; flex-wrap: wrap; gap: 4px 10px; }
.chart-wrap-lg, .chart-wrap-xl { height: 260px; }
}
/* ── 趋势页签:三张图共用一个图位 ──
类名另起 trend- 前缀:.tab-btn / .tab-pane 被页首主页签的状态逻辑按类名全文档匹配,不能借用 */
.trend-head {
display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
margin-bottom: 16px;
border-bottom: 1px solid rgba(255,255,255,.06);
}
.trend-tabs {
display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
/* 负下边距:选中页签的 2px 下划线盖在头部 hairline 上;负左边距抵消首个页签的左内边距,
页签文字与其它卡片标题左对齐,各页签的内边距保持一致 */
margin: 0 0 -1px -12px;
}
/* 区间说明再长也不挤页签(≤600px 页签折行,需保留收缩,见下) */
@media (min-width: 601px) {
.trend-tabs { flex: 0 0 auto; }
}
.trend-tabs::-webkit-scrollbar { display: none; }
.trend-tab {
appearance: none;
background: transparent;
border: 0;
border-bottom: 2px solid transparent;
padding: 8px 12px 10px;
font-family: inherit; font-size: 13px; font-weight: 500;
/* 行高钉死:normal 下含汉字的标签行盒 18px、纯拉丁 16px,页签行高与同排区间说明的基线不能随文案语言变 */
line-height: 18px;
color: var(--text-secondary);
white-space: nowrap; cursor: pointer;
transition: color .15s ease, border-color .15s ease;
}
.trend-tab:hover { color: var(--text-primary); }
.trend-tab[aria-selected="true"] { color: var(--text-primary); border-bottom-color: var(--accent-blue); }
.trend-tab:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: -2px; border-radius: 4px; }
/* 区间说明只有「近 N 天」,不换行 */
.trend-range {
flex: 0 0 auto; padding-bottom: 11px;
font-size: 12px; line-height: 1.35; color: var(--text-secondary);
white-space: nowrap;
}
.trend-panel[hidden] { display: none; }
/* 面板可聚焦(tabpanel 惯例):焦点环画在内侧,与全页 2px 蓝色焦点环一致 */
.trend-panel:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: -2px; border-radius: 4px; }
.trend-panel .html-legend-wrap { max-height: 300px; }
@media (max-width: 960px) {
.trend-panel .html-legend-wrap { max-height: 120px; }
}
/* 手机宽度:页签折成两行而不是横向截断;区间说明收起(上方区间栏已写明当前区间) */
@media (max-width: 600px) {
.trend-tabs { flex-wrap: wrap; overflow-x: visible; row-gap: 2px; }
.trend-range { display: none; }
}
/* ── 订阅状态(订阅档位 / 用量窗口 × 路由 tier 运行状态)── */
.vendor-list { display: flex; flex-direction: column; gap: 8px; }
.vendor-item {
display: flex; align-items: center; justify-content: space-between;
column-gap: 10px;
/* 左内边距为 24px 宽的手柄留位(最小命中区),有无手柄的行头像左缘对齐 */
padding: 12px 14px 12px 38px;
background: rgba(255,255,255,.015);
border: 1px solid rgba(255,255,255,.04);
border-radius: var(--radius-sm);
transition: all .2s ease;
}
.vendor-item:hover { background: rgba(255,255,255,.03); border-color: rgba(255,255,255,.08); }
/* 标识区定宽(容得下最长的行名),各行的订阅区从同一竖线起排;行名不折行 */
.vendor-info { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; min-width: 168px; }
.vendor-avatar {
width: 30px; height: 30px; border-radius: 8px;
background: var(--gradient-primary);
display: flex; align-items: center; justify-content: center;
font-size: 13px; font-weight: 700; color: #fff;
flex-shrink: 0;
}
.vendor-name { font-weight: 600; font-size: 14px; white-space: nowrap; }
/* 分区(订阅区 / 路由区):单行硬约束,放不下时分区内横向滚动而不是折行。滚动条隐藏:
经典滚动条平台(Windows / Linux、macOS 接鼠标)上它会占掉分区的行内高度,让放不下
的那一行文字比行名高出几个像素 */
.vendor-badges {
display: flex; align-items: center; column-gap: 10px;
flex-wrap: nowrap; white-space: nowrap;
min-width: 0; overflow-x: auto;
scrollbar-width: none;
}
.vendor-badges::-webkit-scrollbar { display: none; }
/* 分区标签(tier 名 / 模型族)统一灰字;档位是订阅的关键属性,重一级 */
.zone-label { font-size: 11px; font-weight: 500; color: var(--text-secondary); white-space: nowrap; }
.zone-label.plan { font-size: 12px; font-weight: 600; color: var(--text-primary); }
/* 同一模型族的标签与窗口成组 */
.qg { display: inline-flex; align-items: center; gap: 6px; }
/* 用量格:窗口标签 + 细进度条 + 百分比(订阅窗口再缀重置倒计时)。格底色与进度条按严重度取色,
数值一律穿文字色 */
.quota-group {
display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
border: 1px solid transparent; border-radius: 6px;
}
.quota-group.q-ok { background: rgba(63,185,80,.12); border-color: rgba(63,185,80,.2); }
.quota-group.q-warn { background: rgba(210,153,34,.12); border-color: rgba(210,153,34,.2); }
.quota-group.q-err { background: rgba(248,81,73,.12); border-color: rgba(248,81,73,.2); }
.quota-label { font-size: 11px; color: var(--text-tertiary); min-width: 16px; text-align: right; }
.quota-val { font-size: 11px; color: var(--text-secondary); font-variant-numeric: tabular-nums; min-width: 24px; text-align: right; }
.sub-reset { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; color: var(--text-tertiary); white-space: nowrap; }
.status-badge {
font-size: 11px; padding: 2px 7px;
border-radius: 10px;
font-weight: 500;
}
.sb-warn { background: rgba(210,153,34,.12); color: var(--accent-yellow); border: 1px solid rgba(210,153,34,.2); }
.sb-err { background: rgba(248,81,73,.12); color: var(--accent-red); border: 1px solid rgba(248,81,73,.2); }
.sb-info { background: rgba(88,166,255,.12); color: var(--accent-blue); border: 1px solid rgba(88,166,255,.2); }
.quota-bar-wrap { flex: 0 0 40px; width: 40px; }
.quota-bar-bg {
display: block; height: 4px; border-radius: 2px;
background: rgba(255,255,255,.08);
overflow: hidden;
}
.quota-bar-fill {
display: block; height: 100%; border-radius: 2px;
transition: width .6s cubic-bezier(.4,0,.2,1);
}
.quota-group.q-ok .quota-bar-fill { background: var(--accent-green); }
.quota-group.q-warn .quota-bar-fill { background: var(--accent-yellow); }
.quota-group.q-err .quota-bar-fill { background: var(--accent-red); }
/* ── 订阅状态:拖拽排序(Pointer Events,手柄发起) ── */
.vendor-item.dragging { opacity: .4; }
.drag-handle {
display: flex; align-items: center; justify-content: center;
position: absolute; left: 14px; top: 0; width: 24px; height: 100%;
padding: 0; border: 0; background: none; font-family: inherit;
color: var(--text-tertiary); font-size: 15px; line-height: 1;
cursor: grab; user-select: none; touch-action: none;
opacity: 0; transition: opacity .2s ease;
}
.drag-handle:active { cursor: grabbing; }
.vendor-item:hover .drag-handle { opacity: .55; }
.drag-handle:hover, .drag-handle:focus-visible { opacity: 1 !important; color: var(--text-secondary); }
/* 键盘焦点环不做淡入:调整优先级后行节点会被重建,淡入会让焦点环闪烁 */
.drag-handle:focus-visible { transition: none; }
/* 同一实体一行:[标识] [订阅区] [路由区]。订阅区吃掉余宽,路由区不收缩、靠行尾右对齐成一列;
余量不足时只由订阅区内横向滚动(单行硬约束)。手柄脱离文档流落在行左内边距里 */
.vendor-item[data-vendor] { position: relative; }
.has-sub > .sub-zone { flex: 1 1 auto; }
.tier-zone { flex: 0 0 auto; justify-content: flex-end; }
/* 路由区只剩可用状态:无异常是「圆点 + 正常」,异常才是彩色胶囊(.status-badge) */
.tier-avail { display: inline-flex; align-items: center; column-gap: 6px; white-space: nowrap; }
.avail-ok { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); white-space: nowrap; padding: 2px 0; }
.avail-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-green); }
.zone-note { font-size: 11px; color: var(--text-tertiary); white-space: nowrap; }
.list-note { padding: 0 14px 0 38px; font-size: 12px; }
.subscription-card .vendor-list + .vendor-list { margin-top: 8px; }
.subscription-card .vendor-list + .vendor-list:empty { display: none; }
/* 放不下的行仍在订阅区内横向滚动(单行硬约束不变):右缘渐隐提示「后面还有」,滚到头提示消失
(.has-more 由 syncZoneCues 在行重绘、滚动、窗口缩放时同步) */
.vendor-badges.has-more {
-webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
}
@media (max-width: 960px) {
/* 窄屏:标识与路由区占首行,订阅区独占次行(整行放不下才折行,分区内仍不折行) */
.subscription-card .vendor-item { flex-wrap: wrap; row-gap: 6px; }
.subscription-card .vendor-info { flex: 1 1 auto; min-width: 0; }
.subscription-card .has-sub > .sub-zone { order: 3; flex: 1 1 100%; }
.subscription-card .has-sub > .tier-zone,
.subscription-card .has-sub > .sub-only { order: 2; flex: 0 1 auto; }
}
/* ── 故障转移表 ── */
.ft-table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { position: sticky; top: 0; background: var(--bg-card); z-index: 1; }
th {
text-align: left; font-size: 12px; color: var(--text-tertiary);
font-weight: 600; padding: 6px 10px;
border-bottom: 1px solid var(--border);
letter-spacing: .4px; text-transform: uppercase;
}
td { padding: 8px 10px; font-size: 14px; border-bottom: 1px solid var(--border-subtle); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }
.tag-vendor {
display: inline-block;
font-size: 12px; padding: 2px 8px;
border-radius: 10px;
background: rgba(188,140,255,.1);
color: var(--accent-purple);
border: 1px solid rgba(188,140,255,.2);
font-weight: 500;
}
.arrow { color: var(--text-tertiary); margin: 0 4px; }
/* ── 时间区间选择栏 ── */
.time-range-bar {
display: flex; align-items: center; gap: 8px;
margin-bottom: var(--gap-section); flex-wrap: wrap;
padding: 8px 16px;
background: rgba(18,22,30,.5);
border: 1px solid rgba(255,255,255,.04);
border-radius: var(--radius);
backdrop-filter: blur(4px);
}
.time-range-label { font-size: 13px; color: var(--text-tertiary); font-weight: 600; }
.range-btn {
padding: 6px 16px; border-radius: 20px;
background: transparent;
border: 1px solid transparent;
color: var(--text-secondary);
font-size: 14px; cursor: pointer;
transition: all .25s ease;
}
.range-btn:hover { background: rgba(255,255,255,.05); color: var(--text-primary); }
.range-btn.active {
background: rgba(88,166,255,.08);
border-color: rgba(88,166,255,.2);
color: var(--accent-blue);
font-weight: 500;
}
.range-custom { display: none; align-items: center; gap: 6px; }
.range-custom.visible { display: flex; }
.range-date {
padding: 3px 10px; border-radius: var(--radius-sm);
background: rgba(48,54,61,.4); border: 1px solid var(--border);
color: var(--text-primary); font-size: 13px;
color-scheme: dark;
transition: border-color .2s;
}
.range-date:focus { outline: none; border-color: rgba(88,166,255,.5); }
.range-sep { font-size: 13px; color: var(--text-tertiary); }
/* ── 空态 ── */
.empty {
text-align: center; padding: 32px;
color: var(--text-tertiary); font-size: 14px;
}
.empty-icon { font-size: 32px; margin-bottom: 8px; opacity: .5; }
/* ── Sessions Panel ── */
.sessions-card { grid-column: 1 / -1; animation-delay: .1s; }
.session-table-wrap { overflow-x: auto; }
.session-table { min-width: max-content; }
.session-table th { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
.session-table th {
position: sticky; top: 0; z-index: 1;
background: var(--bg-card); padding: 10px 12px;
text-align: left; font-weight: 600; font-size: 12px;
color: var(--text-secondary); text-transform: uppercase; letter-spacing: .5px;
border-bottom: 1px solid var(--border);
}
.session-table td { padding: 8px 12px; border-bottom: 1px solid var(--border-subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-table td.cell-tags { white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.8; vertical-align: middle; }
.session-table tr:hover td { background: var(--bg-card-hover); }
.session-table .session-key { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--accent-blue); cursor: default; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-table .session-title { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 0; }
.session-id { display: flex; align-items: center; gap: 4px; }
.session-id-text { overflow: hidden; text-overflow: ellipsis; }
.copy-btn { background: none; border: none; color: var(--text-tertiary); cursor: pointer; padding: 2px; border-radius: 4px; font-size: 12px; line-height: 1; opacity: .5; flex-shrink: 0; }
.copy-btn:hover { opacity: 1; color: var(--accent-blue); background: rgba(88,166,255,.1); }
.copy-btn.copied { color: var(--accent-green); opacity: 1; }
.session-meta { font-size: 10px; color: var(--text-tertiary); line-height: 1.2; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-tag {
display: inline-block; font-size: 11px; padding: 2px 7px;
border-radius: 8px; margin: 1px 2px;
background: rgba(88,166,255,.08); border: 1px solid rgba(88,166,255,.15);
color: var(--text-secondary);
}
.session-tag-cc {
background: rgba(63,185,80,.08); border-color: rgba(63,185,80,.15);
}
.session-table td.cell-success { overflow: visible; text-overflow: clip; }
/* ── 展开行 ── */
.session-table tr.row-detail { display: none; }
.session-table tr.row-detail.open { display: table-row; }
.session-table tr.row-detail td { padding: 0; }
.detail-card {
padding: 16px 24px; margin: 6px 0;
background: linear-gradient(135deg, rgba(30,37,54,.95), rgba(22,28,40,.95));
border: 1px solid rgba(88,166,255,.15); border-radius: 12px;
font-size: 13px;
white-space: normal; overflow: hidden;
box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
.detail-card .detail-item { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.detail-card .detail-label { font-size: 11px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .3px; }
.detail-card .detail-value { color: var(--text-primary); line-height: 1.4; word-break: break-all; overflow-wrap: break-word; }
.detail-title-row {
padding-bottom: 10px; margin-bottom: 10px;
border-bottom: 1px solid var(--border);
}
.detail-title-row .detail-value {
white-space: normal;
word-break: break-word;
overflow-wrap: break-word;
line-height: 1.5;
max-height: 4.5em;
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
}
.detail-identity-row {
display: flex; gap: 16px;
padding-bottom: 10px; margin-bottom: 10px;
border-bottom: 1px solid var(--border);
}
.detail-identity-row .detail-item { flex: 3 1 0; }
.detail-identity-row .detail-item:first-child { flex: 2 1 0; }
.detail-identity-row .detail-value { font-family: 'JetBrains Mono', monospace; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; word-break: normal; }
.detail-metrics-grid {
display: grid;
grid-template-columns: repeat(8, 1fr);
gap: 10px 16px;
}
.detail-inline-pair { display: flex; gap: 16px; }
.detail-inline-pair > div { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.session-table tbody tr[data-row]:not(.row-detail) { cursor: pointer; }
.success-bar { width: 56px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.12); display: inline-block; vertical-align: middle; margin-left: 6px; }
.success-bar-fill { height: 100%; border-radius: 2px; display: block; }
/* ── Model Bind 选择器 ── */
.bind-select {
padding: 3px 6px; border-radius: 6px;
background: rgba(48,54,61,.6); border: 1px solid rgba(255,255,255,.1);
color: var(--text-secondary); font-size: 12px;
font-family: 'JetBrains Mono', monospace;
cursor: pointer; outline: none;
transition: all .2s ease;
max-width: 100%;
}
.bind-select:hover { border-color: rgba(88,166,255,.4); color: var(--text-primary); }
.bind-select:focus { border-color: rgba(88,166,255,.6); box-shadow: 0 0 0 2px rgba(88,166,255,.1); }
.bind-select option { background: var(--bg-card); color: var(--text-primary); }
/* ── 分页 ── */
.session-pagination {
display: flex; align-items: center; justify-content: space-between;
padding: 10px 12px; border-top: 1px solid var(--border-subtle);
font-size: 12px; color: var(--text-secondary);
}
.page-btn {
padding: 4px 10px; border-radius: 6px;
background: rgba(48,54,61,.4); border: 1px solid rgba(255,255,255,.08);
color: var(--text-secondary); font-size: 12px; cursor: pointer;
transition: all .15s ease;
}
.page-btn:hover:not(:disabled) { background: var(--bg-card-hover); color: var(--text-primary); border-color: rgba(88,166,255,.3); }
.page-btn:disabled { opacity: .35; cursor: default; }
.page-info { font-family: 'JetBrains Mono', monospace; font-size: 12px; }
/* ── 加载态 ── */
.loading { opacity: .4; pointer-events: none; }
/* ── 图表标签截断 ── */
.chart-legend-note { font-size: 12px; color: var(--text-tertiary); margin-top: 4px; text-align: center; }
/* ── 外部 Tooltip ── */
#chart-tooltip {
position: fixed;
pointer-events: none;
background: rgba(10,14,20,.95);
border: 1px solid rgba(255,255,255,.08);
border-radius: 12px;
padding: 12px 16px;
font-size: 13px;
color: var(--text-primary);
box-shadow: 0 12px 40px rgba(0,0,0,.5);
backdrop-filter: blur(4px);
-webkit-backdrop-filter: blur(4px);
z-index: 1000;
opacity: 0;
transition: opacity .15s ease;
max-width: 520px;
max-height: 60vh;
overflow-y: auto;
backdrop-filter: blur(8px);
-webkit-backdrop-filter: blur(8px);
}
#chart-tooltip.active { opacity: 1; }
#chart-tooltip-title {
font-weight: 600; margin-bottom: 6px; padding-bottom: 6px;
border-bottom: 1px solid var(--border-subtle); color: var(--text-secondary); font-size: 12px;
}
#chart-tooltip-items { display: flex; flex-direction: column; gap: 3px; }
.tt-item { display: flex; align-items: center; gap: 8px; line-height: 1.4; }
.tt-color { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.tt-label { flex: 1; color: var(--text-primary); white-space: nowrap; }
.tt-value { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
#chart-tooltip-footer {
margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border-subtle);
font-weight: 500; font-size: 12px; color: var(--text-secondary);
}
/* ── Tabs ─────────────────────────────────────────────────── */
.tabs {
display: flex;
gap: 2px;
padding: 0;
}
.tab-btn {
appearance: none;
background: transparent;
border: 1px solid transparent;
color: var(--text-secondary);
cursor: pointer;
font-family: inherit;
font-size: 13px;
font-weight: 500;
padding: 4px 12px;
transition: color .15s ease, background .15s ease, border-color .15s ease;
border-radius: var(--radius-sm);
}
.tab-btn:hover { color: var(--text-primary); background: var(--bg-card-hover); }
.tab-btn.active {
color: var(--text-primary);
background: rgba(88,166,255,.1);
border-color: rgba(88,166,255,.2);
}
.tab-btn:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; }
.range-btn:focus-visible,
.btn-refresh:focus-visible,
.page-btn:focus-visible,
.btn-card-action:focus-visible,
.drag-handle:focus-visible,
.copy-btn:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }
/* ── Model Calling 实时状态:对齐成列的 meter list ─────
一个表面内按行列出:vendor | 模型 | 并行度条 | 在途/上限 | 排队,五列逐行对齐 */
.model-calling-card,
.timeline-card {
margin-bottom: var(--gap-section);
}
.card-note { font-size: 12px; font-weight: 400; color: var(--text-secondary); letter-spacing: 0; white-space: nowrap; }
/* 仅供读屏的文本 */
.sr-only {
position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.mc-empty {
text-align: center;
color: var(--text-secondary);
padding: 16px 0;
font-size: 13px;
}
.mc-list {
display: grid;
grid-template-columns: minmax(0, 1fr);
border: 1px solid var(--border-subtle);
border-radius: var(--radius-sm);
background: var(--bg-secondary);
overflow: hidden;
}
.mc-row {
display: grid;
/* 计数列定宽并右对齐:条形终点逐行对齐,不随「4/10」「5/8」的字数变化 */
grid-template-columns: minmax(72px, 96px) minmax(0, 1.5fr) minmax(80px, 1fr) 64px minmax(80px, auto);
align-items: center;
column-gap: 12px;
min-height: 38px;
padding: 6px 16px;
}
.mc-row + .mc-row { border-top: 1px solid rgba(255,255,255,.04); }
/* 视口不少于 1280px 且不少于 3 行时排两列(更窄时模型名列连常见的带日期后缀的模型 ID 都要折行):列间竖线,行间横线 */
@media (min-width: 1280px) {
.mc-list.mc-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mc-list.mc-cols-2 .mc-row + .mc-row { border-top: 0; }
.mc-list.mc-cols-2 .mc-row:nth-child(n+3) { border-top: 1px solid rgba(255,255,255,.04); }
.mc-list.mc-cols-2 .mc-row:nth-child(even) { border-left: 1px solid rgba(255,255,255,.04); }
}
.mc-vendor,
.mc-model-name {
font-family: 'JetBrains Mono', monospace;
overflow: hidden; min-width: 0;
}
.mc-vendor { font-size: 11px; color: var(--text-secondary); white-space: nowrap; text-overflow: ellipsis; }
/* 模型名最多折成两行:带日期后缀的模型 ID(claude-sonnet-4-5-20250929)在两列布局下放不进一行,
折行后仍完整可读;两行还放不下才省略,全名在 title 里(title 键盘与触屏拿不到,所以不默认截断) */
.mc-model-name {
font-size: 12px; color: var(--text-primary);
display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
white-space: normal; overflow-wrap: anywhere;
}
.mc-meter {
height: 6px; border-radius: 3px; overflow: hidden;
background: rgba(255,255,255,.16);
}
.mc-fill {
display: block; height: 100%; border-radius: 3px;
transition: width .6s cubic-bezier(.4,0,.2,1), background .3s ease;
}
.mc-fill.mc-low { background: var(--accent-green); }
.mc-fill.mc-mid { background: var(--accent-yellow); }