/* Полная версия без WebSocket (B27): базовые стили в духе темы сайта (.streamlit/config.toml). Стили шагов приходят из app.py (st.html). */
@font-face {font-family:'Material Symbols Rounded'; font-style:normal; font-weight:100 700; font-display:block; src:url(fonts/MaterialSymbols-Rounded.woff2) format('woff2');}
@font-face {font-family:'SrcSans'; font-style:normal; font-weight:200 900; font-display:swap; src:url(fonts/SourceSansVF-Upright.woff2) format('woff2');}
:root {--ink:#0F172A; --body:#334155; --muted:#64748B; --faint:#94A3B8; --line:#E6E8EC; --bg:#F7F8FA; --card:#FFFFFF; --field:#E2E6EC;
       --accent:#2563EB; --accent-d:#1D4ED8; --accent-s:#EFF4FF; --ok:#15803D; --bad:#B42318; --r:.6rem; --side:300px;}
* {box-sizing:border-box;}
html, body {margin:0; height:100%; background:var(--bg); color:var(--ink);}
body {font-family:Inter, 'Segoe UI', SrcSans, system-ui, -apple-system, sans-serif; font-size:15px; line-height:1.5; -webkit-font-smoothing:antialiased;}
a {color:var(--accent);}
p {margin:0 0 .5rem;} p:last-child {margin-bottom:0;}
h1, h2, h3 {letter-spacing:-.02em; margin:.2rem 0 .4rem;}
code {font-family:'SF Mono', Consolas, monospace; font-size:.85em; background:#F1F4F8; padding:.05rem .3rem; border-radius:.3rem; color:#0B5394;}
ul, ol {margin:.2rem 0 .5rem; padding-left:1.4rem;}
.mi, .material-symbols-rounded {font-family:'Material Symbols Rounded'; font-weight:400; font-style:normal; font-size:1.15em; line-height:1; letter-spacing:normal;
  text-transform:none; display:inline-block; white-space:nowrap; word-wrap:normal; direction:ltr; font-feature-settings:'liga'; -webkit-font-feature-settings:'liga'; vertical-align:-.18em;}

/* каркас: боковая панель и основная область */
#app {display:flex; height:100vh;}
[data-testid="stSidebar"] {width:var(--side); flex:0 0 var(--side); background:#fff; border-right:1px solid var(--line); height:100vh; overflow-y:auto;}
[data-testid="stSidebarContent"] {padding:1.4rem 1.1rem 2rem;}
[data-testid="stMain"] {flex:1; min-width:0; height:100vh; overflow-y:auto; position:relative;}
.block-container {margin:0 auto; padding:2.4rem 1.6rem 4rem; max-width:1120px;}
#sidetoggle {display:none;}
@media (max-width: 900px) {
  [data-testid="stSidebar"] {position:fixed; z-index:40; left:0; top:0; transform:translateX(-100%); transition:transform .18s; box-shadow:0 0 40px rgba(15,23,42,.15);}
  body.side-open [data-testid="stSidebar"] {transform:none;}
  #sidetoggle {display:flex; position:fixed; z-index:41; left:10px; top:10px; width:38px; height:38px; border-radius:10px; border:1px solid var(--line); background:#fff;
    align-items:center; justify-content:center; cursor:pointer; color:var(--body);}
  .block-container {padding:3.8rem 16px 4rem !important;}
}

/* вертикальные блоки */
.vb {display:flex; flex-direction:column; gap:1rem; min-width:0;}
[data-testid="stSidebar"] .vb {gap:.55rem;}
.el-hidden {display:none !important;}
.iframe-hidden {position:absolute; width:0; height:0; border:0; visibility:hidden;}
.bordered {border:1px solid var(--line); border-radius:12px; padding:1rem; background:#fff;}
.horiz {flex-direction:row; flex-wrap:wrap; align-items:center;}
.cols {display:flex; gap:1rem; width:100%;}
.cols.va-center {align-items:center;} .cols.va-bottom {align-items:flex-end;} .cols.va-top {align-items:flex-start;}
.cols.gap-large {gap:2rem;} .cols.gap-medium {gap:1.5rem;}
.cols > [data-testid="stColumn"] {min-width:0;}
.cols > [data-testid="stColumn"].bordered {padding:1rem;}
@media (max-width: 640px) {.cols {flex-wrap:wrap;} .cols > [data-testid="stColumn"] {flex:1 1 100% !important; width:100%;}}

/* текст */
[data-testid="stMarkdownContainer"] {overflow-wrap:break-word;}
[data-testid="stCaptionContainer"] {font-size:.82rem; color:var(--muted);}
[data-testid="stCaptionContainer"] p {margin:0 0 .2rem;}
pre.txt {font-family:inherit; white-space:pre-wrap; margin:0;}
pre.code {background:#F1F4F8; padding:.7rem .9rem; border-radius:.6rem; overflow:auto; font-size:.82rem;}
hr {border:none; border-top:1px solid var(--line); margin:.6rem 0;}
.latex {font-family:'Times New Roman', Georgia, serif; font-size:1.05rem; color:var(--ink); padding:.2rem 0; overflow-x:auto;}
.help {display:inline-flex; align-items:center; justify-content:center; width:15px; height:15px; border-radius:50%; border:1px solid var(--faint); color:var(--faint);
  font-size:10px; font-weight:600; margin-left:.35rem; cursor:help; flex:0 0 auto; vertical-align:.08rem; line-height:1;}

/* сообщения */
[data-testid="stAlert"] {border-radius:12px; padding:.75rem 1rem; display:flex; gap:.6rem; align-items:flex-start; font-size:.9rem;}
[data-testid="stAlert"] .ai {flex:0 0 auto; font-size:1.15rem; line-height:1.3;}
[data-testid="stAlert"].info {background:#EEF4FF; color:#1E40AF;}
[data-testid="stAlert"].warning {background:#FFF8E6; color:#8A4B00;}
[data-testid="stAlert"].error {background:#FDECEC; color:#9B1C1C;}
[data-testid="stAlert"].success {background:#EAF7EF; color:#14632F;}
.exc {background:#FDECEC; color:#9B1C1C; border-radius:12px; padding:.75rem 1rem; font-size:.85rem;}
.exc pre {white-space:pre-wrap; font-size:.72rem; color:#7F1D1D; max-height:260px; overflow:auto;}

/* поля */
[data-testid="stWidgetLabel"] {display:flex; align-items:center; font-size:.86rem; color:var(--body); margin-bottom:.3rem; min-height:1.3em;}
[data-testid="stWidgetLabel"] p {margin:0; color:var(--body); font-size:.86rem;}
.lv-collapsed > [data-testid="stWidgetLabel"] {display:none !important;}
.lv-hidden > [data-testid="stWidgetLabel"] {visibility:hidden;}
[data-baseweb="input"], [data-baseweb="textarea"] {display:flex; align-items:center; background:#fff; border:1px solid var(--field); border-radius:var(--r); min-height:2.5rem; overflow:hidden;}
[data-baseweb="input"]:focus-within, [data-baseweb="textarea"]:focus-within, [data-baseweb="select"] > div:focus-within {border-color:var(--accent) !important; box-shadow:0 0 0 2px #2563EB22;}
[data-baseweb="base-input"] {flex:1; display:flex; min-width:0; background:transparent;}
input, select, textarea, button {font:inherit; color:inherit;}
[data-baseweb="input"] input, [data-baseweb="textarea"] textarea {flex:1; min-width:0; border:none; outline:none; background:transparent; padding:.5rem .75rem; font-size:.92rem; color:var(--ink);}
[data-baseweb="textarea"] textarea {resize:vertical; min-height:5.5rem;}
[data-baseweb="input"] input::placeholder, textarea::placeholder {color:#A0AEC0;}
[data-baseweb="input"] input:disabled {color:var(--faint);}
.pm {display:flex; align-self:stretch;}
.pm button {border:none; border-left:1px solid var(--field); background:#F7F8FA; width:2.2rem; cursor:pointer; font-size:1.05rem; color:var(--body);}
.pm button:hover {background:#EEF1F5;}
[data-baseweb="select"] > div {position:relative; background:#fff; border:1px solid var(--field); border-radius:var(--r); min-height:2.5rem;}
[data-baseweb="select"] select {width:100%; min-height:2.45rem; border:none; outline:none; background:transparent; padding:.45rem 2rem .45rem .75rem; font-size:.92rem;
  appearance:none; -webkit-appearance:none; cursor:pointer; color:var(--ink);}
[data-baseweb="select"] select.ph {color:#A0AEC0;}
[data-baseweb="select"] > div::after {content:'expand_more'; font-family:'Material Symbols Rounded'; position:absolute; right:.55rem; top:50%; transform:translateY(-50%);
  pointer-events:none; color:var(--muted); font-size:1.2rem; font-feature-settings:'liga';}
.chk {display:flex; align-items:center; gap:.5rem; cursor:pointer; font-size:.9rem; color:var(--body); user-select:none;}
.chk input {width:1rem; height:1rem; accent-color:var(--accent); margin:0;}
.tgl input {appearance:none; -webkit-appearance:none; width:2.1rem; height:1.2rem; border-radius:99px; background:#CBD5E1; position:relative; cursor:pointer; transition:background .12s;}
.tgl input::after {content:''; position:absolute; width:.9rem; height:.9rem; border-radius:50%; background:#fff; top:.15rem; left:.15rem; transition:left .12s;}
.tgl input:checked {background:var(--accent);} .tgl input:checked::after {left:1.05rem;}
[data-testid="stRadio"] [role="radiogroup"] {display:flex; flex-direction:column; gap:.25rem;}
[data-testid="stRadio"] [role="radiogroup"].hz {flex-direction:row; flex-wrap:wrap; gap:.4rem 1.1rem;}
[data-testid="stRadio"] label {display:flex; align-items:center; gap:.45rem; cursor:pointer;}
[data-testid="stRadio"] label input {accent-color:var(--accent); margin:0;}
[data-testid="stRadio"] label p {margin:0; font-size:.9rem;}
[data-testid="stSidebar"] [role="radiogroup"] label input {display:none;}
[data-testid="stSidebar"] [role="radiogroup"] label {display:flex; cursor:pointer;}
[data-testid="stButtonGroup"] .seg {display:flex; flex-wrap:wrap; gap:.3rem;}
.seg button {border:1px solid var(--field); background:#fff; border-radius:var(--r); padding:.38rem .8rem; cursor:pointer; font-size:.88rem; color:var(--body); min-height:2.3rem;}
.seg:not(.pills) {gap:0 !important;}
.seg:not(.pills) button {border-radius:0; margin-left:-1px;}
.seg:not(.pills) button:first-child {border-radius:var(--r) 0 0 var(--r); margin-left:0;}
.seg:not(.pills) button:last-child {border-radius:0 var(--r) var(--r) 0;}
.seg.pills button {border-radius:99px;}
.seg button.on {background:var(--accent-s); border-color:#9DB8F5; color:var(--accent-d); font-weight:600; position:relative; z-index:1;}
.seg button:disabled {opacity:.5; cursor:default;}
.multi {display:flex; flex-wrap:wrap; gap:.3rem .9rem; border:1px solid var(--field); border-radius:var(--r); padding:.5rem .7rem; background:#fff; max-height:12rem; overflow:auto;}
.file {display:flex; align-items:center; gap:.6rem; border:1px dashed #C5CBD6; border-radius:var(--r); padding:.65rem .8rem; background:#fff;}
.file input {font-size:.85rem; max-width:100%;}
.file .fn {font-size:.85rem; color:var(--body);}
.file .x {border:none; background:none; cursor:pointer; color:var(--muted);}

/* кнопки */
.stButton > button, .stDownloadButton > button, .linkbtn {display:inline-flex; align-items:center; justify-content:center; gap:.4rem; border:1px solid var(--field); background:#fff; color:var(--ink);
  border-radius:var(--r); padding:.42rem .9rem; min-height:2.5rem; cursor:pointer; font-size:.9rem; font-weight:550; text-decoration:none; line-height:1.2; text-align:center;}
.stButton > button p, .stDownloadButton > button p {margin:0;}
.stButton > button[kind="primary"], .stDownloadButton > button[kind="primary"] {background:var(--accent); color:#fff; border-color:var(--accent);}
.stButton > button[kind="primary"]:hover, .stDownloadButton > button[kind="primary"]:hover {background:var(--accent-d);}
.stButton > button[kind="secondary"]:hover, .stDownloadButton > button[kind="secondary"]:hover {border-color:#C5CBD6; background:#F7F8FA;}
.stButton > button[kind="tertiary"] {border:none; background:none; color:var(--accent); padding:.2rem .3rem; min-height:0;}
.stButton > button:disabled, .stDownloadButton > button:disabled {opacity:.45; cursor:default;}
.stButton.stretch > button, .stDownloadButton.stretch > button {width:100%;}
.stButton .mi, .stDownloadButton .mi {font-size:1.15rem;}

/* блоки */
[data-testid="stExpander"] details {background:#fff; border:1px solid var(--line); border-radius:12px;}
[data-testid="stExpander"] summary {cursor:pointer; padding:.7rem 1rem; font-size:.92rem; font-weight:500; list-style:none; display:flex; align-items:center; gap:.4rem;}
[data-testid="stExpander"] summary::-webkit-details-marker {display:none;}
[data-testid="stExpander"] summary::after {content:'expand_more'; font-family:'Material Symbols Rounded'; margin-left:auto; color:var(--muted); font-size:1.25rem; font-feature-settings:'liga'; transition:transform .15s;}
[data-testid="stExpander"] details[open] > summary::after {transform:rotate(180deg);}
[data-testid="stExpander"] details > .vb {padding:.2rem 1rem 1rem;}
.tabs [role="tablist"] {display:flex; gap:.2rem; border-bottom:1px solid var(--line); margin-bottom:.8rem; overflow-x:auto;}
.tabs [role="tab"] {border:none; background:none; padding:.5rem .8rem; cursor:pointer; color:var(--muted); font-size:.9rem; border-bottom:2px solid transparent; margin-bottom:-1px; white-space:nowrap;}
.tabs [role="tab"].on {color:var(--accent-d); border-bottom-color:var(--accent); font-weight:600;}
.tabs [role="tabpanel"][hidden] {display:none;}
form.stForm {margin:0;}
form.stForm.bordered {border:1px solid var(--line); border-radius:12px; padding:1rem;}
[data-testid="stMetric"] {background:#fff; border:1px solid var(--line); border-radius:12px; padding:.8rem 1rem;}
[data-testid="stMetricLabel"] {display:flex; align-items:center; color:var(--muted); font-size:.8rem;}
[data-testid="stMetricLabel"] p {margin:0;}
[data-testid="stMetricValue"] {font-size:1.45rem; font-weight:700; letter-spacing:-.02em; color:var(--ink); line-height:1.25;}
[data-testid="stMetricDelta"] {font-size:.8rem; color:var(--ok);}
.prog {height:6px; border-radius:99px; background:#E8ECF2; overflow:hidden;}
.prog > div {height:100%; background:var(--accent);}
.prog-t {font-size:.82rem; color:var(--muted); margin-bottom:.25rem;}

/* таблицы */
.df-wrap {overflow:auto; border:1px solid var(--line); border-radius:10px; background:#fff; max-width:100%;}
table.df {border-collapse:collapse; width:100%; font-size:.84rem;}
table.df th {background:#F7F8FA; font-weight:600; color:var(--muted); text-align:left; padding:.45rem .6rem; border-bottom:1px solid var(--line); position:sticky; top:0; z-index:1; white-space:nowrap;}
table.df td {padding:.38rem .6rem; border-bottom:1px solid #F0F2F5; vertical-align:top;}
table.df td.n {text-align:right; white-space:nowrap; font-variant-numeric:tabular-nums;}
table.df tr:last-child td {border-bottom:none;}
table.df td input[type=text] {width:100%; min-width:5rem; border:1px solid var(--field); border-radius:.4rem; padding:.2rem .4rem; font-size:.84rem;}
table.df td input[type=checkbox] {accent-color:var(--accent); width:1rem; height:1rem;}
table.df td select {border:1px solid var(--field); border-radius:.4rem; padding:.15rem .3rem; font-size:.84rem; background:#fff;}

/* окно */
#dlg .back {position:fixed; inset:0; background:rgba(15,23,42,.38); z-index:60; display:flex; align-items:flex-start; justify-content:center; padding:6vh 16px; overflow-y:auto;}
#dlg .box {background:#fff; border-radius:14px; width:100%; max-width:500px; padding:1.3rem 1.5rem 1.5rem; box-shadow:0 20px 60px rgba(15,23,42,.25);}
#dlg .box.w-medium {max-width:750px;} #dlg .box.w-large {max-width:1100px;}
#dlg .head {display:flex; align-items:center; justify-content:space-between; margin-bottom:.8rem;}
#dlg .head h2 {font-size:1.25rem; margin:0;}
#dlg .head button {border:none; background:none; cursor:pointer; color:var(--muted); font-size:1.4rem; padding:.2rem;}

/* статус прогона, всплывающие сообщения */
#busy {position:fixed; top:0; left:0; right:0; height:3px; z-index:80; pointer-events:none; opacity:0; transition:opacity .2s;}
#busy.on {opacity:1; background:linear-gradient(90deg, transparent, var(--accent), transparent); background-size:40% 100%; background-repeat:no-repeat; animation:busy 1.1s linear infinite;}
@keyframes busy {from {background-position:-40% 0;} to {background-position:140% 0;}}
#status {position:fixed; top:14px; left:50%; transform:translateX(-50%); z-index:81; background:var(--ink); color:#fff; font-size:.86rem; padding:.55rem 1rem; border-radius:10px;
  display:none; align-items:center; gap:.55rem; box-shadow:0 8px 30px rgba(15,23,42,.25); max-width:calc(100vw - 32px);}
#status.on {display:flex;}
#status .spin {width:14px; height:14px; border:2px solid #ffffff55; border-top-color:#fff; border-radius:50%; animation:spin .8s linear infinite; flex:0 0 auto;}
@keyframes spin {to {transform:rotate(360deg);}}
#toasts {position:fixed; right:16px; bottom:16px; z-index:90; display:flex; flex-direction:column; gap:.5rem; max-width:calc(100vw - 32px);}
.toast {background:#fff; border:1px solid var(--line); border-radius:12px; padding:.7rem 1rem; font-size:.88rem; box-shadow:0 10px 30px rgba(15,23,42,.14); display:flex; gap:.5rem; align-items:center; max-width:420px;}
.toast .mi {color:var(--accent);}
#offline {position:fixed; bottom:16px; left:50%; transform:translateX(-50%); z-index:91; background:#9B1C1C; color:#fff; padding:.55rem 1rem; border-radius:10px; font-size:.86rem; display:none;}
#offline.on {display:block;}
.plot {width:100%; min-height:120px;}
iframe.comp {width:100%; border:0; display:block;}
.latex {font-family:'Cambria Math', 'Times New Roman', Georgia, serif; font-size:1.12rem; line-height:2.1; text-align:center; white-space:normal;}
.latex i {font-style:italic;} .latex .up {font-style:normal;} .latex .op {margin:0 .28em;} .latex .big {font-size:1.35em; vertical-align:-.12em; margin:0 .1em;}
.latex .fr {display:inline-flex; flex-direction:column; vertical-align:middle; text-align:center; margin:0 .15em; line-height:1.25;}
.latex .fr .nu {border-bottom:1px solid currentColor; padding:0 .2em .05em;} .latex .fr .de {padding:.05em .2em 0;}
.latex sub, .latex sup {font-size:.72em;} .latex .sp0 {margin-left:.17em;} .latex .sp1 {margin-left:.28em;} .latex .sp2 {margin-left:1em;} .latex .sp4 {margin-left:2em;}
