-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstyles.py
More file actions
1415 lines (1265 loc) · 51.8 KB
/
styles.py
File metadata and controls
1415 lines (1265 loc) · 51.8 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
def load_css():
return """
<style>
/* 主要顏色配置 */
:root {
--primary-blue: #2563eb;
--light-blue: #3b82f6;
--dark-blue: #1e40af;
--bg-white: #ffffff;
--bg-light: #f8fafc;
--text-dark: #1e293b;
--text-gray: #64748b;
--border-color: #e2e8f0;
}
/* 整體背景 */
.stApp {
background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}
/* 側邊欄樣式 - 重新設計:豐富的漸變背景與視覺層次 */
[data-testid="stSidebar"] {
background:
linear-gradient(135deg, #1e3a8a 0%, #1e40af 25%, #2563eb 50%, #3b82f6 75%, #60a5fa 100%) !important;
background-size: 400% 400% !important;
animation: gradientShift 15s ease infinite !important;
border-right: 3px solid rgba(255, 255, 255, 0.1) !important;
box-shadow:
inset -10px 0 30px rgba(0, 0, 0, 0.2),
4px 0 20px rgba(30, 64, 175, 0.3) !important;
min-width: 320px !important;
max-width: 320px !important;
position: relative !important;
overflow: visible !important; /* 改為 visible,讓按鈕可以顯示在側邊欄外部 */
}
/* 側邊欄背景動畫效果 */
@keyframes gradientShift {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
/* 側邊欄裝飾性圖案(微妙的幾何圖形) */
[data-testid="stSidebar"]::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background:
radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.08) 0%, transparent 50%),
linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.03) 50%, transparent 70%);
pointer-events: none;
z-index: 0;
}
/* 確保側邊欄內容在裝飾層之上 */
[data-testid="stSidebar"] > * {
position: relative;
z-index: 1;
}
/* 確保滑桿在裝飾層之上,但不干擾互動 */
[data-testid="stSidebar"] .stSlider {
position: relative !important;
z-index: 10 !important;
}
[data-testid="stSidebar"][aria-expanded="false"] {
min-width: 0 !important;
max-width: 0 !important;
padding: 0 !important;
border: none !important;
}
[data-testid="stSidebar"][aria-expanded="false"] * {
display: none;
}
/* 隱藏側邊欄調整大小的手柄 (Resize Handle) */
[data-testid="stSidebar"] ~ div[role="separator"] {
display: none !important;
}
/* 強制側邊欄收合按鈕始終可見 */
/* 針對 Streamlit 側邊欄切換按鈕的所有可能選擇器 */
button[data-testid="baseButton-header"],
button[data-testid="baseButton-header"]:not(:hover),
[data-testid="stHeader"] button,
[data-testid="stHeader"] button:not(:hover),
.stApp button[aria-label*="Close"],
.stApp button[aria-label*="close"],
button[aria-label*="Close sidebar"],
button[aria-label*="close sidebar"],
button[aria-label*="Open sidebar"],
button[aria-label*="open sidebar"],
[data-testid="stSidebar"] + div button,
[data-testid="stSidebar"] + div button:not(:hover),
header button,
header button:not(:hover),
/* 針對可能的 SVG 圖標容器 */
[data-testid="stSidebar"] + div svg,
[data-testid="stSidebar"] + div svg:not(:hover),
header svg,
header svg:not(:hover),
/* 通用規則:所有可能隱藏的側邊欄相關按鈕 */
button[class*="sidebar"],
button[class*="collapse"],
button[class*="toggle"] {
opacity: 1 !important;
visibility: visible !important;
display: block !important;
}
/* 確保按鈕內的 SVG 圖標也始終可見 */
button[data-testid="baseButton-header"] svg,
[data-testid="stHeader"] button svg,
header button svg,
[data-testid="stSidebar"] + div button svg {
opacity: 1 !important;
visibility: visible !important;
display: block !important;
}
/* 將側邊欄收合按鈕移動到右下角 - 使用多種選擇器確保覆蓋 */
/* 針對側邊欄內部的按鈕 - 使用 absolute 定位 */
[data-testid="stSidebar"] button[kind="header"],
[data-testid="stSidebar"] [data-testid="baseButton-header"],
[data-testid="stSidebar"] button[aria-label*="Close"],
[data-testid="stSidebar"] button[aria-label*="close"],
[data-testid="stSidebar"] button[aria-label*="sidebar"],
[data-testid="stSidebar"] button[aria-label*="Open"],
[data-testid="stSidebar"] button[aria-label*="open"] {
position: absolute !important; /* 相對於側邊欄定位 */
bottom: 20px !important;
right: 20px !important;
top: auto !important;
left: auto !important;
z-index: 99999 !important;
background-color: rgba(255, 255, 255, 0.15) !important;
border-radius: 50% !important;
width: 40px !important;
height: 40px !important;
min-width: 40px !important;
min-height: 40px !important;
display: flex !important;
align-items: center !important;
justify-content: center !important;
backdrop-filter: blur(4px) !important;
border: 1px solid rgba(255, 255, 255, 0.2) !important;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1) !important;
transition: all 0.3s ease !important;
margin: 0 !important;
padding: 0 !important;
}
/* 針對側邊欄外部的按鈕(如果 Streamlit 將按鈕放在側邊欄外部) */
[data-testid="stSidebar"] + div button[kind="header"],
[data-testid="stSidebar"] + div [data-testid="baseButton-header"],
[data-testid="stSidebar"] + div button[aria-label*="Close"],
[data-testid="stSidebar"] + div button[aria-label*="close"],
[data-testid="stSidebar"] + div button[aria-label*="sidebar"],
[data-testid="stSidebar"] + div button[aria-label*="Open"],
[data-testid="stSidebar"] + div button[aria-label*="open"] {
position: fixed !important; /* 使用 fixed 定位,相對於視窗 */
bottom: 20px !important;
right: calc(320px + 20px) !important; /* 側邊欄寬度 320px + 間距 20px */
top: auto !important;
left: auto !important;
z-index: 99999 !important;
background-color: rgba(255, 255, 255, 0.15) !important;
border-radius: 50% !important;
width: 40px !important;
height: 40px !important;
min-width: 40px !important;
min-height: 40px !important;
display: flex !important;
align-items: center !important;
justify-content: center !important;
backdrop-filter: blur(4px) !important;
border: 1px solid rgba(255, 255, 255, 0.2) !important;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1) !important;
transition: all 0.3s ease !important;
margin: 0 !important;
padding: 0 !important;
}
/* 當側邊欄收合時,外部按鈕位置調整到右側 */
[data-testid="stSidebar"][aria-expanded="false"] + div button[kind="header"],
[data-testid="stSidebar"][aria-expanded="false"] + div [data-testid="baseButton-header"],
[data-testid="stSidebar"][aria-expanded="false"] + div button[aria-label*="Open"],
[data-testid="stSidebar"][aria-expanded="false"] + div button[aria-label*="open"] {
right: 20px !important; /* 側邊欄收合時,按鈕貼近右側 */
}
/* 通用選擇器:所有可能的側邊欄切換按鈕(作為備用) */
button[data-testid="baseButton-header"]:not([data-testid="stSidebar"] button):not([data-testid="stSidebar"] + div button),
header button[aria-label*="Close"]:not([data-testid="stSidebar"] button):not([data-testid="stSidebar"] + div button),
header button[aria-label*="close"]:not([data-testid="stSidebar"] button):not([data-testid="stSidebar"] + div button),
header button[aria-label*="sidebar"]:not([data-testid="stSidebar"] button):not([data-testid="stSidebar"] + div button) {
position: fixed !important;
bottom: 20px !important;
right: calc(320px + 20px) !important;
top: auto !important;
left: auto !important;
z-index: 99999 !important;
background-color: rgba(255, 255, 255, 0.15) !important;
border-radius: 50% !important;
width: 40px !important;
height: 40px !important;
min-width: 40px !important;
min-height: 40px !important;
display: flex !important;
align-items: center !important;
justify-content: center !important;
backdrop-filter: blur(4px) !important;
border: 1px solid rgba(255, 255, 255, 0.2) !important;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1) !important;
transition: all 0.3s ease !important;
margin: 0 !important;
padding: 0 !important;
}
/* Hover 效果 */
[data-testid="stSidebar"] button[kind="header"]:hover,
[data-testid="stSidebar"] [data-testid="baseButton-header"]:hover,
[data-testid="stSidebar"] button[aria-label*="Close"]:hover,
[data-testid="stSidebar"] button[aria-label*="close"]:hover,
[data-testid="stSidebar"] + div button:hover,
button[data-testid="baseButton-header"]:hover,
header button[aria-label*="Close"]:hover,
header button[aria-label*="close"]:hover {
background-color: rgba(255, 255, 255, 0.3) !important;
transform: scale(1.1) !important;
}
/* 側邊欄內所有文字改為白色 - 但排除展開器標題、Radio Button 和輸入框 */
[data-testid="stSidebar"] *:not(.streamlit-expanderHeader):not(.streamlit-expanderHeader *):not(details):not(details *):not(summary):not(summary *):not([data-testid="stExpander"] *):not([data-testid="stExpander"] button *):not([data-testid="stExpander"] > div:first-child *):not([role="radiogroup"] *):not(.stRadio *):not(.stRadio):not(.stTextInput *):not(.stNumberInput *):not(.stSelectbox *):not(input):not(select):not(option) {
color: #ffffff !important;
}
[data-testid="stSidebar"] h1,
[data-testid="stSidebar"] h2,
[data-testid="stSidebar"] h3,
[data-testid="stSidebar"] h4,
[data-testid="stSidebar"] p,
[data-testid="stSidebar"] label,
[data-testid="stSidebar"] span,
[data-testid="stSidebar"] div,
[data-testid="stSidebar"] .stMarkdown,
[data-testid="stSidebar"] .stCaption {
color: #ffffff !important;
}
/* 明確排除 selectbox 相關元素,確保不被白色文字規則覆蓋 */
/* 注意:排除 label,因為 label 需要保持白色 */
[data-testid="stSidebar"] .stSelectbox,
[data-testid="stSidebar"] .stSelectbox *:not(label):not(label *),
[data-testid="stSidebar"] .stSelectbox select,
[data-testid="stSidebar"] .stSelectbox option,
[data-testid="stSidebar"] .stSelectbox > div,
[data-testid="stSidebar"] .stSelectbox > div > div,
[data-testid="stSidebar"] .stSelectbox > div > div > select,
[data-testid="stSidebar"] select,
[data-testid="stSidebar"] option {
color: #1e293b !important;
-webkit-text-fill-color: #1e293b !important;
}
/* 側邊欄標題顏色 - 重新設計:添加特殊效果 */
[data-testid="stSidebar"] h1 {
color: #ffffff !important;
text-shadow:
0 2px 8px rgba(0, 0, 0, 0.3),
0 0 20px rgba(255, 255, 255, 0.2) !important;
font-weight: 800 !important;
letter-spacing: 0.05em !important;
position: relative !important;
padding: 0.75rem 1rem !important;
background: rgba(255, 255, 255, 0.1) !important;
border-radius: 12px !important;
border: 1px solid rgba(255, 255, 255, 0.2) !important;
box-shadow:
0 4px 12px rgba(0, 0, 0, 0.2),
inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
margin-bottom: 1rem !important;
backdrop-filter: blur(10px) !important;
}
[data-testid="stSidebar"] h2,
[data-testid="stSidebar"] h3 {
color: #ffffff !important;
text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2) !important;
}
/* 側邊欄 caption 和說明文字 */
[data-testid="stSidebar"] .stCaption,
[data-testid="stSidebar"] small {
color: rgba(255, 255, 255, 0.9) !important;
}
/* 側邊欄 radio button 文字 - 移除強制白色 */
/* [data-testid="stSidebar"] .stRadio label {
color: #ffffff !important;
} */
/* 強制修正:針對 Sidebar Radio Group 內的所有文字元素,無論層級,一律設為黑色 */
[data-testid="stSidebar"] .stRadio div[role="radiogroup"] * {
color: #000000 !important;
}
/* 側邊欄 Radio Button 樣式優化 - 白底按鈕風格,寬度與展開器一致 */
/* 確保 Radio Button 的父容器寬度與展開器一致 */
[data-testid="stSidebar"] .element-container {
width: 100% !important;
max-width: 100% !important;
box-sizing: border-box !important;
}
[data-testid="stSidebar"] .stRadio {
width: 100% !important;
max-width: 100% !important;
box-sizing: border-box !important;
}
[data-testid="stSidebar"] .stRadio > div[role="radiogroup"] {
gap: 0.75rem !important;
width: 100% !important;
max-width: 100% !important;
display: flex !important;
flex-direction: column !important;
padding: 0 !important;
margin: 0 !important;
box-sizing: border-box !important;
}
/* 選項容器 (Label) 樣式 - 寬度與展開器一致,高度與展開器一致 */
[data-testid="stSidebar"] .stRadio div[role="radiogroup"] label {
background-color: rgba(248, 250, 252, 0.96) !important;
border: 1px solid rgba(148, 163, 184, 0.65) !important;
border-radius: 10px !important;
padding: 0.45rem 0.9rem !important; /* 與展開器相同的 padding */
width: 100% !important;
max-width: 100% !important;
box-sizing: border-box !important;
display: flex !important;
align-items: center !important;
justify-content: flex-start !important;
cursor: pointer !important;
transition: all 0.2s ease !important;
box-shadow: 0 6px 20px rgba(15, 23, 42, 0.25) !important; /* 與展開器相同的陰影 */
color: #000000 !important; /* 按鈕本體文字顏色 */
font-weight: 700 !important; /* 字體加粗,與展開器一致 */
letter-spacing: 0.02em !important; /* 與展開器相同的字間距 */
font-size: 0.95rem !important; /* 與展開器相同的字體大小 */
}
/* 隱藏 Radio 圓圈 */
[data-testid="stSidebar"] .stRadio div[role="radiogroup"] label > div:first-child {
display: none !important;
}
/* Hover 效果 */
[data-testid="stSidebar"] .stRadio div[role="radiogroup"] label:hover {
background-color: #ffffff !important;
transform: translateY(-2px);
box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1) !important;
border-color: #ffffff !important;
}
/* Selected 狀態 */
[data-testid="stSidebar"] .stRadio div[role="radiogroup"] label:has(input:checked) {
background-color: #ffffff !important;
border-color: #3b82f6 !important;
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3), 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}
/* 側邊欄 selectbox 標籤文字 - 必須為白色,使用最高優先級 */
[data-testid="stSidebar"] .stSelectbox label,
[data-testid="stSidebar"] .stSelectbox > label,
[data-testid="stSidebar"] .stSelectbox label p,
[data-testid="stSidebar"] .stSelectbox label span,
[data-testid="stSidebar"] .stSelectbox label div,
[data-testid="stSidebar"] .stSelectbox label *,
[data-testid="stSidebar"] .streamlit-expanderContent .stSelectbox label,
[data-testid="stSidebar"] .streamlit-expanderContent .stSelectbox label *,
[data-testid="stSidebar"] [data-testid="stExpander"] .stSelectbox label,
[data-testid="stSidebar"] [data-testid="stExpander"] .stSelectbox label *,
[data-testid="stSidebar"] details .stSelectbox label,
[data-testid="stSidebar"] details .stSelectbox label * {
color: #ffffff !important;
-webkit-text-fill-color: #ffffff !important;
}
/* 側邊欄 number input 標籤 */
[data-testid="stSidebar"] .stNumberInput label {
color: #ffffff !important;
}
/* 側邊欄 text input 標籤 */
[data-testid="stSidebar"] .stTextInput label {
color: #ffffff !important;
}
/* 主內容區域標題顏色 - 白底黑字 */
.main .block-container h1,
.main .block-container h2,
.main .block-container h3 {
color: #1e293b !important;
}
/* 主內容區域文字顏色 - 強制深色 */
.main .block-container {
color: #1e293b !important;
}
/* 強制主畫面所有標題為黑色 */
.main h1, .main h2, .main h3, .main h4, .main h5, .main h6,
.main .stMarkdown h1, .main .stMarkdown h2, .main .stMarkdown h3,
.main .stMarkdown h4, .main .stMarkdown h5, .main .stMarkdown h6,
.main [data-testid="stMarkdownContainer"] h1,
.main [data-testid="stMarkdownContainer"] h2,
.main [data-testid="stMarkdownContainer"] h3,
.main [data-testid="stMarkdownContainer"] h4,
.main [data-testid="stMarkdownContainer"] h5,
.main [data-testid="stMarkdownContainer"] h6 {
color: #000000 !important;
}
/* 強制主畫面一般文字為黑色 */
.main p, .main li, .main .stMarkdown p,
.main [data-testid="stMarkdownContainer"] p,
.main [data-testid="stMarkdownContainer"] li {
color: #000000 !important;
}
/* 強制主畫面 Caption 為黑色 */
.main .stCaption, .main .stCaption p,
.main [data-testid="stCaptionContainer"],
.main [data-testid="stCaptionContainer"] p {
color: #000000 !important;
opacity: 1 !important; /* 確保不透明 */
}
/* 針對 Streamlit 標題元素的特殊處理 (st.subheader, st.title) */
.main [data-testid="stHeader"], .main [data-testid="stSubHeader"] {
color: #000000 !important;
}
/* 強制主畫面指標標籤 (Metric Label) 為黑色 */
.main [data-testid="stMetricLabel"] {
color: #000000 !important;
}
/* 強制主畫面指標數值 (Metric Value) 為黑色 */
.main [data-testid="stMetricValue"] {
color: #000000 !important;
}
/* 強制主畫面指標標籤 (Metric Label) 為深灰色 */
.main [data-testid="stMetricLabel"] {
color: #475569 !important;
}
/* 強制主畫面指標數值 (Metric Value) 為深藍色 */
.main [data-testid="stMetricValue"] {
color: #1e40af !important;
}
/* 確保側邊欄文字不受影響(保持白色) */
[data-testid="stSidebar"] h1, [data-testid="stSidebar"] h2, [data-testid="stSidebar"] h3,
[data-testid="stSidebar"] p, [data-testid="stSidebar"] span, [data-testid="stSidebar"] div,
[data-testid="stSidebar"] label, [data-testid="stSidebar"] .stMarkdown,
[data-testid="stSidebar"] .stCaption {
color: #ffffff !important;
}
/* 按鈕樣式 - 確保可點擊 */
.stButton > button {
background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
color: white;
border: none;
border-radius: 8px;
font-weight: 600;
transition: all 0.3s;
cursor: pointer !important;
pointer-events: auto !important;
z-index: 1;
}
.stButton > button:hover {
background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}
.stButton > button:active {
transform: translateY(0);
}
/* 下載按鈕樣式 */
.stDownloadButton > button {
background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
color: white;
border: none;
border-radius: 8px;
font-weight: 600;
cursor: pointer !important;
pointer-events: auto !important;
}
.stDownloadButton > button:hover {
background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
}
/* 主內容區域輸入框樣式 - 白底,確保可互動 */
.main .stTextInput > div > div > input,
.main .stNumberInput > div > div > input,
.main .stSelectbox > div > div > select {
border: 2px solid #e2e8f0;
border-radius: 8px;
background: white;
color: #1e293b;
cursor: text !important;
pointer-events: auto !important;
}
.main .stTextInput input,
.main .stNumberInput input,
.main textarea {
color: #0f172a !important;
background: #ffffff !important;
caret-color: #1e293b !important;
}
.stTextInput input,
.stNumberInput input,
textarea {
color: #0f172a !important;
-webkit-text-fill-color: #0f172a !important;
background: #ffffff !important;
}
.main .stTextInput input::placeholder,
.main .stNumberInput input::placeholder {
color: #475569 !important;
opacity: 0.85;
}
.main .stTextInput > div > div > input:focus,
.main .stNumberInput > div > div > input:focus,
.main .stSelectbox > div > div > select:focus {
border-color: #2563eb;
box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
outline: none;
}
/* 側邊欄輸入框樣式 - 重新設計:更精緻的視覺效果 */
[data-testid="stSidebar"] .stTextInput > div > div > input,
[data-testid="stSidebar"] .stNumberInput > div > div > input,
[data-testid="stSidebar"] .stSelectbox > div > div > select {
border: 2px solid rgba(255, 255, 255, 0.3) !important;
border-radius: 8px !important;
background: rgba(255, 255, 255, 0.95) !important;
color: #1e293b !important;
caret-color: #1e293b !important;
cursor: text !important;
min-height: 40px !important;
padding: 0.5rem 0.75rem !important;
z-index: 10 !important;
box-shadow:
0 2px 4px rgba(0, 0, 0, 0.1) inset,
0 1px 2px rgba(255, 255, 255, 0.3) !important;
transition: all 0.2s ease !important;
}
/* 強制側邊欄 selectbox 文字顏色為深色 - 使用最強力的選擇器 */
[data-testid="stSidebar"] .stSelectbox > div > div > select,
[data-testid="stSidebar"] .stSelectbox > div > div > select option,
[data-testid="stSidebar"] .stSelectbox select,
[data-testid="stSidebar"] .stSelectbox select option,
[data-testid="stSidebar"] .stSelectbox > div > div > select *,
[data-testid="stSidebar"] .stSelectbox * select,
[data-testid="stSidebar"] select,
[data-testid="stSidebar"] select option {
color: #1e293b !important;
-webkit-text-fill-color: #1e293b !important;
background-color: #ffffff !important;
}
/* 確保選中的文字可見 - 所有可能的狀態 */
[data-testid="stSidebar"] .stSelectbox > div > div > select:not([multiple]),
[data-testid="stSidebar"] .stSelectbox > div > div > select[value],
[data-testid="stSidebar"] .stSelectbox > div > div > select:focus,
[data-testid="stSidebar"] .stSelectbox > div > div > select:active,
[data-testid="stSidebar"] .stSelectbox > div > div > select:hover {
color: #1e293b !important;
-webkit-text-fill-color: #1e293b !important;
background-color: #ffffff !important;
}
/* 針對 Streamlit BaseWeb 的 selectbox 內部結構 */
[data-testid="stSidebar"] [data-baseweb="select"] input,
[data-testid="stSidebar"] [data-baseweb="select"] > div,
[data-testid="stSidebar"] [data-baseweb="select"] > div > div {
color: #1e293b !important;
-webkit-text-fill-color: #1e293b !important;
}
[data-testid="stSidebar"] .stTextInput > div > div > input:focus,
[data-testid="stSidebar"] .stNumberInput > div > div > input:focus,
[data-testid="stSidebar"] .stSelectbox > div > div > select:focus {
border-color: rgba(255, 255, 255, 0.8) !important;
background: #ffffff !important;
color: #1e293b !important;
-webkit-text-fill-color: #1e293b !important;
box-shadow:
0 0 0 3px rgba(255, 255, 255, 0.3),
0 4px 12px rgba(0, 0, 0, 0.15) !important;
outline: none !important;
transform: translateY(-1px) !important;
}
[data-testid="stSidebar"] .stTextInput > div > div > input:hover,
[data-testid="stSidebar"] .stNumberInput > div > div > input:hover,
[data-testid="stSidebar"] .stSelectbox > div > div > select:hover {
border-color: rgba(255, 255, 255, 0.5) !important;
box-shadow:
0 2px 6px rgba(0, 0, 0, 0.12) inset,
0 2px 4px rgba(255, 255, 255, 0.2) !important;
}
/* 強制下拉選單箭頭為深色 (SVG fill) - 與文字顏色一致 */
[data-testid="stSidebar"] .stSelectbox svg {
fill: #1e293b !important;
}
/* 針對 BaseWeb Select 組件的所有可能結構 */
[data-testid="stSidebar"] [data-baseweb="select"],
[data-testid="stSidebar"] [data-baseweb="select"] input,
[data-testid="stSidebar"] [data-baseweb="select"] > div,
[data-testid="stSidebar"] [data-baseweb="select"] > div > div,
[data-testid="stSidebar"] [data-baseweb="select"] > div > div > div,
[data-testid="stSidebar"] [data-baseweb="select"] span,
[data-testid="stSidebar"] [data-baseweb="select"] p {
color: #1e293b !important;
-webkit-text-fill-color: #1e293b !important;
}
/* 確保 selectbox 的顯示值文字可見 */
[data-testid="stSidebar"] .stSelectbox [role="combobox"],
[data-testid="stSidebar"] .stSelectbox [aria-expanded],
[data-testid="stSidebar"] .stSelectbox [aria-haspopup] {
color: #1e293b !important;
-webkit-text-fill-color: #1e293b !important;
}
/* 側邊欄輸入框 placeholder 顏色 */
[data-testid="stSidebar"] .stTextInput > div > div > input::placeholder,
[data-testid="stSidebar"] .stNumberInput > div > div > input::placeholder {
color: #94a3b8 !important;
}
/* 卡片和容器 - 移除 .element-container 的背景,避免不必要的白底 */
/* 僅對特定容器應用背景 */
/* 確保側邊欄的輸入框標籤可見 */
[data-testid="stSidebar"] label {
color: #ffffff !important;
}
/* 確保主內容區域的文字顏色 */
.main p, .main label, .main span, .main div {
color: #1e293b;
}
/* 強制修正 Metric 標籤顏色 */
[data-testid="stMetricLabel"] {
color: #64748b !important;
}
/* 修正 Streamlit 預設的白色背景容器 */
[data-testid="stSidebar"] [data-testid="stVerticalBlock"] > div {
background-color: transparent !important;
}
/* 修正展開器內部文字顏色 */
[data-testid="stSidebar"] .streamlit-expanderContent p,
[data-testid="stSidebar"] .streamlit-expanderContent label,
[data-testid="stSidebar"] .streamlit-expanderContent span,
[data-testid="stSidebar"] .streamlit-expanderContent div {
color: #ffffff !important;
}
/* 修正側邊欄 Radio Button 選項文字 - 改為黑色 */
[data-testid="stSidebar"] .stRadio div[role="radiogroup"] label div p {
color: #000000 !important;
}
/* 修正側邊欄 Checkbox 選項文字 */
[data-testid="stSidebar"] .stCheckbox label span p {
color: #ffffff !important;
}
/* 標籤頁樣式,確保可點擊 */
.stTabs [data-baseweb="tab-list"] {
gap: 8px;
}
.stTabs [data-baseweb="tab"] {
background: white;
border: 2px solid #e2e8f0;
color: #64748b;
border-radius: 8px 8px 0 0;
cursor: pointer !important;
pointer-events: auto !important;
transition: all 0.3s;
padding-left: 32px;
padding-right: 32px;
min-width: 180px;
display: flex;
justify-content: center;
font-size: 1.05rem;
font-weight: 600;
line-height: 1.6;
}
.stTabs [data-baseweb="tab"] p {
font-size: 1.05rem !important;
font-weight: 600 !important;
margin: 0;
display: flex;
align-items: center;
gap: 0.4rem;
}
.gauge-wrapper {
width: 440px;
margin: 0 auto;
}
.gauge-block {
width: 440px;
margin: 0 auto;
}
.gauge-title {
text-align: center;
margin-bottom: 0.3rem;
}
.gauge-title h3 {
color: #1e40af;
margin-bottom: 0;
display: inline-block;
}
.gauge-title p {
color: #64748b;
font-size: 0.9rem;
margin-top: 0.1rem;
margin-bottom: 0;
}
/* Tooltip (help icon) styling */
.stTooltipIcon {
background: #2151CC !important;
color: #94a3b8 !important;
border: none !important;
box-shadow: none !important;
width: 18px !important;
height: 18px !important;
border-radius: 999px !important;
display: inline-flex !important;
align-items: center;
justify-content: center;
}
.stTooltipIcon *,
.stTooltipIcon svg,
.stTooltipIcon svg * {
display: none !important;
}
.stTooltipIcon:after {
content: "?";
color: #5f6b7c;
font-weight: 700;
font-size: 0.85rem;
line-height: 1;
}
.stTabs [data-baseweb="tab"]:hover {
background: #f8fafc;
color: #2563eb;
border-color: #2563eb;
}
.stTabs [aria-selected="true"],
.stTabs [aria-selected="true"]:hover {
background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
color: white;
border-color: #2563eb;
position: relative;
overflow: visible;
}
.stTabs [aria-selected="true"]::after {
content: "";
position: absolute;
bottom: -4px;
left: 0;
width: 100%;
height: 4px;
background: #f43f5e;
border-radius: 0 0 6px 6px;
box-shadow: none;
}
/* 進度條 */
.stProgress > div > div > div {
background: linear-gradient(90deg, #3b82f6 0%, #2563eb 100%);
}
/* 成功/警告/錯誤訊息 */
.stSuccess {
background: #dbeafe;
border-left: 4px solid #2563eb;
color: #1e40af;
}
.stWarning {
background: #fef3c7;
border-left: 4px solid #f59e0b;
color: #92400e;
}
.stError {
background: #fee2e2;
border-left: 4px solid #dc2626;
color: #991b1b;
}
.stInfo {
background: #dbeafe;
border-left: 4px solid #2563eb;
color: #1e40af;
}
/* 指標卡片 */
[data-testid="stMetricValue"] {
color: #1e40af;
font-weight: 700;
}
/* 主內容區域分隔線 */
.main hr {
border-color: #e2e8f0;
}
/* 側邊欄分隔線 - 重新設計:更精緻的分隔效果 */
[data-testid="stSidebar"] hr {
border: none !important;
height: 2px !important;
background: linear-gradient(90deg,
transparent 0%,
rgba(255, 255, 255, 0.3) 20%,
rgba(255, 255, 255, 0.5) 50%,
rgba(255, 255, 255, 0.3) 80%,
transparent 100%) !important;
margin: 1.5rem 0 !important;
box-shadow: 0 1px 3px rgba(255, 255, 255, 0.2) !important;
}
/* 主內容區域展開器樣式 - 白底,確保可點擊 */
.main .streamlit-expanderHeader {
background: #f8fafc;
border: 1px solid #e2e8f0;
border-radius: 8px;
color: #1e40af;
font-weight: 600;
cursor: pointer !important;
pointer-events: auto !important;
transition: all 0.3s;
}
.main .streamlit-expanderHeader:hover {
background: #e2e8f0;
border-color: #2563eb;
}
/* 側邊欄展開器 summary 樣式 */
/* 側邊欄展開器標題 - 調高對比與字重,改善中英文可讀性 */
/* Streamlit 1.32+ Expander 實際為 button,需額外強制 */
/* 展開器容器寬度設定,與按鈕一致 */
[data-testid="stSidebar"] [data-testid="stExpander"] {
width: 100% !important;
max-width: 100% !important;
box-sizing: border-box !important;
}
[data-testid="stSidebar"] summary,
[data-testid="stSidebar"] .streamlit-expanderHeader,
[data-testid="stSidebar"] [data-testid="stExpander"] > div:first-child,
[data-testid="stSidebar"] [data-testid="stExpander"] > div:first-child button,
[data-testid="stSidebar"] [data-testid="stExpander"] button {
background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.95) 100%) !important;
border: 2px solid rgba(255, 255, 255, 0.4) !important;
border-radius: 12px !important;
color: #0f172a !important;
padding: 0.5rem 1rem !important;
font-weight: 700 !important;
letter-spacing: 0.02em !important;
font-size: 0.95rem !important;
text-shadow: none !important;
box-shadow:
0 4px 12px rgba(0, 0, 0, 0.15),
0 2px 4px rgba(255, 255, 255, 0.3) inset,
0 0 0 1px rgba(255, 255, 255, 0.2) !important;
width: 100% !important;
max-width: 100% !important;
box-sizing: border-box !important;
transition: all 0.3s ease !important;
position: relative !important;
overflow: hidden !important;
}
/* 展開器按鈕的裝飾性光澤效果 */
[data-testid="stSidebar"] [data-testid="stExpander"] button::before {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg,
transparent,
rgba(255, 255, 255, 0.4),
transparent);
transition: left 0.5s ease;
}
[data-testid="stSidebar"] [data-testid="stExpander"] button:hover::before {
left: 100%;
}
[data-testid="stSidebar"] summary *,
[data-testid="stSidebar"] .streamlit-expanderHeader *,
[data-testid="stSidebar"] [data-testid="stExpander"] > div:first-child *,
[data-testid="stSidebar"] [data-testid="stExpander"] button *,
[data-testid="stSidebar"] [data-testid="stExpander"] button *::before,
[data-testid="stSidebar"] [data-testid="stExpander"] button *::after {
color: #0f172a !important;
fill: #0f172a !important;
stroke: #0f172a !important;
font-weight: 700;
}
[data-testid="stSidebar"] summary svg,
[data-testid="stSidebar"] .streamlit-expanderHeader svg,
[data-testid="stSidebar"] [data-testid="stExpander"] button svg,
[data-testid="stSidebar"] [data-testid="stExpander"] button svg * {
width: 18px;
height: 18px;
flex-shrink: 0;
color: #0f172a !important;
fill: #0f172a !important;
stroke: #0f172a !important;
}
[data-testid="stSidebar"] summary:hover,
[data-testid="stSidebar"] .streamlit-expanderHeader:hover,
[data-testid="stSidebar"] [data-testid="stExpander"] > div:first-child:hover,
[data-testid="stSidebar"] [data-testid="stExpander"] button:hover {
background: linear-gradient(135deg, #ffffff 0%, #f1f5f9 100%) !important;
border-color: rgba(255, 255, 255, 0.6) !important;
color: #0f172a !important;
box-shadow:
0 8px 24px rgba(0, 0, 0, 0.2),
0 4px 8px rgba(255, 255, 255, 0.4) inset,
0 0 0 1px rgba(255, 255, 255, 0.3) !important;
transform: translateY(-1px) !important;
}
[data-testid="stSidebar"] summary:hover *,
[data-testid="stSidebar"] .streamlit-expanderHeader:hover *,
[data-testid="stSidebar"] [data-testid="stExpander"] > div:first-child:hover *,
[data-testid="stSidebar"] [data-testid="stExpander"] button:hover *,
[data-testid="stSidebar"] [data-testid="stExpander"] button:hover *::before,
[data-testid="stSidebar"] [data-testid="stExpander"] button:hover *::after {
color: #0f172a !important;
fill: #0f172a !important;
stroke: #0f172a !important;
}
/* Light 主題下維持一致的高對比淺底設計 */
body[data-theme="light"] [data-testid="stSidebar"] details > summary,
html[data-theme="light"] [data-testid="stSidebar"] details > summary,
.stApp[data-theme="light"] [data-testid="stSidebar"] details > summary,
[data-theme="light"] [data-testid="stSidebar"] details > summary {
background-color: rgba(248, 250, 252, 0.96) !important;
color: #0f172a !important;
border: 1px solid rgba(148, 163, 184, 0.65) !important;
box-shadow: 0 6px 20px rgba(15, 23, 42, 0.25);
}