File size: 4,205 Bytes
7fd88a5
 
 
 
 
7b97ccd
 
 
 
 
 
 
 
 
7fd88a5
 
 
 
7b97ccd
 
 
 
7fd88a5
 
7b97ccd
 
 
 
 
 
 
 
 
 
 
 
7fd88a5
 
 
7b97ccd
 
e28bc7a
 
 
7fd88a5
 
 
 
 
 
 
7b97ccd
 
e28bc7a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2461d8f
 
e28bc7a
 
7b97ccd
 
 
7fd88a5
7b97ccd
 
 
7fd88a5
 
 
 
 
 
7b97ccd
 
 
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
"""Hugging Face Spaces entrypoint (Gradio SDK) — declared as ``app_file`` in README.md.

Why this is not ``app.py``: ``app.py`` is the route-selective system-prompt
builder of the skill (imported by ``tests/test_structure.py`` and
``tests/test_v16.py`` as ``import app``), so the web entrypoint uses a
different file name and the README frontmatter points HF at it.

Launch line (carried over verbatim from the Space that is live at
value.railnexus.io, 2026-09-17): ``ssr_mode=False`` and the absolute
``root_path`` are what let the Cloudflare custom domain reach the app, and
``css=`` on ``launch()`` needs Gradio >= 6 (``sdk_version`` in README.md is
pinned accordingly). ``SPACE_ROOT_PATH`` only exists so the same file can be
run on a laptop (set it to an empty string); on the Space it is unset and the
value is exactly the production one.
"""

from __future__ import annotations

import os

import gradio as gr

from web.ui import build_demo

PRODUCTION_ROOT_PATH = "https://value.railnexus.io"

# Verde Institucional: green accent + warm stone neutral. Gradio 6 takes the
# theme on launch(), not on the Blocks constructor. Serif headings and the
# stone page-ground come from the CSS below.
THEME = gr.themes.Soft(
    primary_hue=gr.themes.colors.emerald,
    secondary_hue=gr.themes.colors.green,
    neutral_hue=gr.themes.colors.stone,
    font=(gr.themes.GoogleFont("Inter"), "system-ui", "sans-serif"),
)

# Branding CSS carried over from the previous production Space (v8): hides the
# HF Space header/footer and applies the RailNexus look. Selectors that do not
# exist in this UI are simply inert.
CSS = """
@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,600;8..60,700&display=swap');
/* Hide the HF Space chrome. The floating badge is #huggingface-space-header —
   an ID, not a class; the March attempt targeting the class never matched it. */
#huggingface-space-header,
.huggingface-space-header,
div[class*="space-header"],
header.container,
div[data-testid="space-header"] {
    display: none !important;
}
footer { display: none !important; }
.gradio-container { max-width: 1040px !important; margin: 0 auto; background: #f4f6f1; }
body, gradio-app { background: #f4f6f1 !important; }

/* Verde Institucional — muted forest-green accent, quiet labels (close to mockup B) */
.gradio-container {
    --button-primary-background-fill: #2f6b43;
    --button-primary-background-fill-hover: #27563a;
    --button-primary-border-color: #2f6b43;
    --button-primary-border-color-hover: #27563a;
    --button-primary-text-color: #ffffff;
    --block-label-background-fill: #ffffff;
    --block-label-text-color: #5b6b5e;
    --block-title-text-color: #17321f;
    --checkbox-background-color-selected: #2f6b43;
    --checkbox-border-color-selected: #2f6b43;
    --slider-color: #2f6b43;
}
/* selected radio/checkbox option: soft green chip with dark ink, not a solid block */
.gradio-container label.selected {
    background: #e8f1e6 !important;
    color: #17321f !important;
}
/* quiet field labels (mockup B): drop the green chip, muted ink */
.gradio-container span[data-testid="block-info"] {
    background: transparent !important;
    color: #5b6b5e !important;
    font-weight: 600;
    padding-left: 0 !important;
}
/* "Tipus d'anàlisi": one route per row (full-width labels wrap in the flex row) */
#route-radio label { width: 100% !important; justify-content: flex-start; }
/* Upload box: two lines, no "- or -" between them (Pablo, v21_3) */
#project-files .or { display: block !important; height: 0; overflow: hidden; visibility: hidden; margin: 0; }

/* serif deep-green headings */
.gradio-container h1 {
    font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif !important;
    font-weight: 700 !important; color: #17321f !important; letter-spacing: -0.01em;
}
.gradio-container h2,
.gradio-container h3 {
    font-family: 'Source Serif 4', Georgia, serif !important; color: #17321f !important;
}
"""

demo = build_demo()
demo.queue()

if __name__ == "__main__":
    root_path = os.environ.get("SPACE_ROOT_PATH", PRODUCTION_ROOT_PATH)
    demo.launch(ssr_mode=False, root_path=root_path or None, css=CSS, theme=THEME)