Spaces:
Sleeping
Sleeping
File size: 8,336 Bytes
0d4a0ba | 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 | import streamlit as st
_CSS = """
<style>
/* ββ Fonts βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
html, body, [class*="css"], [class*="st-"] {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
}
/* ββ Main container βββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
.main .block-container {
padding: 2rem 2.5rem 3rem !important;
max-width: 1200px !important;
}
/* ββ Typography βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
h1 { font-weight: 700 !important; letter-spacing: -0.4px !important; line-height: 1.2 !important; }
h2 { font-weight: 600 !important; color: #2d3748 !important; }
h3 { font-weight: 600 !important; }
[data-testid="stCaptionContainer"] p {
color: #64748b !important;
font-size: 0.85rem !important;
}
/* ββ Sidebar ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
[data-testid="stSidebar"] {
border-right: 1px solid #e2e8f0 !important;
}
[data-testid="stSidebar"] > div:first-child {
padding-top: 1.5rem;
}
[data-testid="stSidebarUserContent"] h1 {
font-size: 1.3rem !important;
}
/* ββ Metric cards βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
[data-testid="stMetric"] {
background: #ffffff;
border: 1px solid #e2e8f0;
border-radius: 12px;
padding: 1.1rem 1.3rem !important;
box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
[data-testid="stMetricValue"] {
font-size: 1.9rem !important;
font-weight: 700 !important;
color: #1e6b3b !important;
}
[data-testid="stMetricLabel"] {
font-size: 0.78rem !important;
font-weight: 500 !important;
color: #64748b !important;
text-transform: uppercase !important;
letter-spacing: 0.4px !important;
}
/* ββ Tabs βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
[data-testid="stTabs"] [role="tablist"] {
gap: 2px;
border-bottom: 2px solid #e2e8f0 !important;
padding-bottom: 0 !important;
}
[data-testid="stTabs"] button[role="tab"] {
border-radius: 8px 8px 0 0 !important;
font-weight: 500 !important;
padding: 0.55rem 1.1rem !important;
color: #64748b !important;
border: 1px solid transparent !important;
border-bottom: none !important;
transition: color 0.15s, background 0.15s;
}
[data-testid="stTabs"] button[role="tab"]:hover {
color: #1e6b3b !important;
background: #f4f7f5 !important;
}
[data-testid="stTabs"] button[role="tab"][aria-selected="true"] {
color: #1e6b3b !important;
font-weight: 600 !important;
background: #ffffff !important;
border-color: #e2e8f0 !important;
border-bottom-color: #ffffff !important;
margin-bottom: -2px;
}
/* ββ Alerts (info / success / warning / error) ββββββββββββββββββββββββββββ */
[data-testid="stAlert"] {
border-radius: 10px !important;
border-left-width: 4px !important;
padding: 0.75rem 1rem !important;
}
/* ββ Buttons ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
[data-testid="stButton"] > button {
border-radius: 8px !important;
font-weight: 500 !important;
transition: filter 0.15s, transform 0.1s !important;
}
[data-testid="stButton"] > button:hover {
filter: brightness(0.92) !important;
transform: translateY(-1px) !important;
}
[data-testid="stButton"] > button[kind="primary"] {
padding: 0.5rem 1.4rem !important;
font-weight: 600 !important;
}
/* ββ Select / Input βββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
[data-testid="stSelectbox"] > div > div,
[data-testid="stTextInput"] > div > div > input {
border-radius: 8px !important;
}
/* ββ Divider ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
hr {
border-color: #e2e8f0 !important;
margin: 0.8rem 0 !important;
}
/* ββ Home page cards ββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
.at-card {
background: #ffffff;
border: 1px solid #e2e8f0;
border-radius: 14px;
padding: 1.5rem 1.75rem;
margin-bottom: 1.25rem;
box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.at-card h3 {
margin-top: 0 !important;
color: #1e6b3b !important;
}
.at-hero {
background: linear-gradient(135deg, #1e6b3b 0%, #2d9c59 100%);
border-radius: 16px;
padding: 2.5rem 2rem;
margin-bottom: 2rem;
color: #ffffff !important;
}
.at-hero h1, .at-hero p {
color: #ffffff !important;
margin: 0 !important;
}
.at-hero h1 { font-size: 2rem !important; margin-bottom: 0.5rem !important; }
.at-hero p { font-size: 1.05rem !important; opacity: 0.92; }
.at-feature-icon { font-size: 1.8rem; margin-bottom: 0.4rem; }
.at-feature-box {
background: #f4f7f5;
border-radius: 12px;
padding: 1.2rem 1rem;
text-align: center;
height: 100%;
}
.at-feature-box p { color: #4a5568 !important; font-size: 0.9rem !important; margin: 0 !important; }
.at-feature-box strong { color: #1a2332 !important; font-size: 0.95rem; }
/* ββ Spinner ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
[data-testid="stSpinner"] > div { border-top-color: #1e6b3b !important; }
/* ββ Mobile responsive ββββββββββββββββββββββββββββββββββββββββββββββββββββ */
@media (max-width: 768px) {
.main .block-container {
padding: 1rem 0.9rem 2rem !important;
}
h1 { font-size: 1.55rem !important; }
h2 { font-size: 1.15rem !important; }
/* Stack the 3-column metric row */
[data-testid="stHorizontalBlock"] {
flex-wrap: wrap !important;
gap: 0.6rem !important;
}
[data-testid="stHorizontalBlock"] > [data-testid="stColumn"] {
min-width: calc(50% - 0.3rem) !important;
flex: 1 1 calc(50% - 0.3rem) !important;
}
/* Smaller tab labels */
[data-testid="stTabs"] button[role="tab"] {
padding: 0.4rem 0.65rem !important;
font-size: 0.82rem !important;
}
/* Map iframe: shorter on phone */
.stFoliumChart iframe, iframe[title*="folium"] {
height: 340px !important;
}
.at-hero { padding: 1.5rem 1.25rem; }
.at-hero h1 { font-size: 1.5rem !important; }
.at-card { padding: 1.1rem 1.2rem; }
}
@media (max-width: 480px) {
[data-testid="stHorizontalBlock"] > [data-testid="stColumn"] {
min-width: 100% !important;
}
}
</style>
"""
_HIDE_SIDEBAR_CSS = """
<style>
[data-testid="stSidebar"] { display: none !important; }
[data-testid="stSidebarCollapsedControl"]{ display: none !important; }
.main .block-container { max-width: 900px !important; margin: 0 auto !important; }
</style>
"""
def inject_css() -> None:
st.markdown(_CSS, unsafe_allow_html=True)
def hide_sidebar() -> None:
st.markdown(_HIDE_SIDEBAR_CSS, unsafe_allow_html=True)
|