:root {
  --bg: #0b0e13; --panel: #171d26; --panel2: #222a37; --line: #334052; --line2: #475872; --text: #dde3ea; --muted: #8b96a6;
  --accent: #f0b429; --long: #26a69a; --short: #ef5350; --res: #e91e63; --sup: #2196f3; --setup: #ff9800;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 17px/1.4 var(--font); }
button, input, select { font: inherit; color: inherit; }
button { background: var(--accent); color: #111; border: 0; border-radius: 6px; padding: 6px 12px; cursor: pointer; font-weight: 600; }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 500; }
button.ghost:hover { border-color: var(--muted); }
button.danger { background: var(--short); color: #fff; }
button.ghost.danger { background: transparent; color: var(--short); border-color: rgba(239, 83, 80, .55); }
button:disabled { opacity: .45; cursor: default; }
.closeall { display: inline-flex; gap: 6px; align-items: center; }
input, select { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; outline: none; }
input:focus, select:focus { border-color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 15.5px; margin: 8px 0; }
.err { color: var(--short); min-height: 1.2em; margin-top: 4px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
h3 { font-size: 15.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 0 8px; }

.brand { font-weight: 800; letter-spacing: .12em; color: var(--accent); }
.brand span { margin-left: 8px; font-weight: 500; letter-spacing: .02em; color: var(--muted); font-size: 15.5px; }

header { display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
header .spacer { flex: 1; }
.tf-status { display: flex; gap: 6px; flex-wrap: wrap; }
.tf-pill { font: 14.5px var(--mono); padding: 2px 7px; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); }
.tf-pill.run { border-color: var(--accent); color: var(--accent); }
.tf-pill b { color: var(--text); font-weight: 600; }
.conn { font-size: 18px; } .conn.on { color: var(--long); } .conn.off { color: var(--short); }

main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); height: calc(100% - 60px); }
.left { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.right { display: flex; flex-direction: column; min-height: 0; padding: 10px 12px; }
.tabs { display: flex; gap: 2px; padding: 8px 10px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { background: none; color: var(--muted); border-radius: 6px 6px 0 0; font-weight: 500; padding: 7px 12px; white-space: nowrap; }
.tabs button.active { color: var(--text); background: var(--panel2); }
.tabs b { background: var(--setup); color: #111; border-radius: 8px; padding: 0 6px; font-size: 14.5px; margin-left: 4px; }
.tab { padding: 10px; overflow: auto; flex: 1; min-height: 0; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; align-items: center; }
div.more { margin: 6px 0 14px; display: flex; gap: 10px; align-items: center; }   /* «Загрузить ещё» под таблицами счетов */
div.more:empty { display: none; }
.lists h3 { margin-top: 36px; }            /* 16px обычного отступа + 20px */
.grid tr.detail, .grid tr.detail:hover { background: var(--panel); cursor: default; }
.grid tr.detail > td { padding: 10px; white-space: normal; }
.dwrap { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 14px; }
.dchart { height: 400px; min-width: 0; }
.dinfo { font-size: 14.5px; max-height: 400px; overflow: auto; }
.dinfo h4 { margin: 10px 0 4px; }
.dhead { margin-bottom: 6px; }
.dinfo table.kv { border-collapse: collapse; margin-bottom: 4px; }
.dinfo table.kv td, .dinfo table.kv th { padding: 1px 10px 1px 0; text-align: left; vertical-align: top; }
.dinfo table.kv td:first-child { color: var(--muted); white-space: nowrap; }
.dcomment { white-space: pre-wrap; margin-top: 4px; }
.dinfo pre { white-space: pre-wrap; font-size: 13px; color: var(--muted); margin: 4px 0; }
.devents div { margin-bottom: 2px; }
@media (max-width: 900px) { .dwrap { grid-template-columns: 1fr; } .dinfo { max-height: none; } }
.filters input { width: 140px; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { background: var(--panel2); color: var(--muted); border: 1px solid var(--line); border-radius: 12px; padding: 2px 9px; font: 14.5px var(--mono); cursor: pointer; font-weight: 500; }
.chip.on { color: var(--text); border-color: var(--accent); }

.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 15.5px; }
.grid th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); white-space: nowrap; }
.grid td { padding: 5px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid tbody tr { cursor: pointer; }
.grid tbody tr:hover { background: var(--panel); }
.grid tbody tr.sel { background: var(--panel2); }
.grid tbody tr.fresh { animation: flash 2.5s ease-out; }
.grid tbody tr.unread td { font-weight: 700; }
#unreadCount:empty, #watchCount:empty { display: none; }
.grid td.eye { opacity: .25; cursor: pointer; padding-right: 2px; }
.grid td.eye:hover { opacity: .7; }
.grid td.eye.on { opacity: 1; }
.grid td.note input { width: 180px; background: transparent; border: 1px solid transparent; color: inherit; font: inherit; padding: 2px 4px; }
.grid td.note input:hover, .grid td.note input:focus { border-color: var(--line); background: var(--panel); }
@keyframes flash { from { background: rgba(240, 180, 41, .25); } to { background: transparent; } }
.num { font-family: var(--mono); text-align: right; }
.sym { font-weight: 600; }
.badge { font-size: 13px; font-weight: 700; padding: 1px 6px; border-radius: 4px; letter-spacing: .04em; }
.badge.SETUP { background: rgba(255, 152, 0, .15); color: var(--setup); }
.badge.BREAKOUT { background: rgba(156, 39, 176, .2); color: #ce93d8; }
.LONG { color: var(--long); } .SHORT { color: var(--short); }
.tag { display: inline-block; font-size: 13.5px; padding: 0 5px; border-radius: 4px; margin-right: 3px; border: 1px solid var(--line); color: var(--muted); }
.tag.ok { color: var(--long); border-color: rgba(38, 166, 154, .5); }
.tag.bad { color: var(--short); border-color: rgba(239, 83, 80, .45); }
.tag.req { font-weight: 700; }
button.more { margin: 10px auto; display: block; }   /* «Загрузить ещё» скринера */

.ticker-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tk { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; font: 15.5px var(--mono); cursor: pointer; }
.tk:hover { border-color: var(--muted); }
.tk small { color: var(--muted); margin-left: 6px; }
.tk .x { color: var(--short); margin-left: 8px; font-weight: 700; }

#settingsForm fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 12px; padding: 8px 12px 12px; }
#settingsForm legend { color: var(--accent); font-weight: 600; padding: 0 6px; }
.field { display: grid; grid-template-columns: 1fr 220px; gap: 10px; align-items: center; padding: 4px 0; }
.field label { color: var(--text); }
.field.sub label { color: var(--muted); padding-left: 14px; }
.field input[type=number] { width: 100%; }
.field .seg { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.field .seg button { flex: 1; background: transparent; color: var(--muted); border-radius: 0; padding: 4px 4px; font-weight: 500; font-size: 15px; }
.field .seg button.on { background: var(--panel2); color: var(--text); }
.field .seg button.on.req { color: var(--accent); }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 8px 0; }

.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.chart-head b { font-size: 19.5px; }
.links a { color: var(--muted); margin-left: 10px; text-decoration: none; font-size: 15.5px; }
.links a:hover { color: var(--accent); }
#chart { flex: 1; min-height: 360px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.ch-info { padding: 8px 2px; color: var(--muted); font-size: 15.5px; min-height: 40px; }
.ch-info b { color: var(--text); font-weight: 600; }

.login-body { display: grid; place-items: center; }
.login { display: flex; flex-direction: column; gap: 12px; width: 340px; padding: 28px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.login .brand { font-size: 26px; margin-bottom: 8px; }
.login input, .login button { padding: 9px 12px; }

@media (max-width: 1000px) {
  main { grid-template-columns: 1fr; height: auto; }
  .left { border-right: 0; border-bottom: 1px solid var(--line); max-height: 60vh; }
  #chart { min-height: 420px; }
  .field { grid-template-columns: 1fr 180px; }
}

/* бэктест */
.progress { position: relative; height: 20px; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; margin: 8px 0; overflow: hidden; }
.progress .bar { position: absolute; inset: 0 auto 0 0; width: 0; background: rgba(240, 180, 41, .35); transition: width .4s; }
.progress span { position: relative; display: block; text-align: center; font: 14.5px/26px var(--mono); }
details { margin: 8px 0; }
details summary { cursor: pointer; color: var(--muted); }
details[open] summary { margin-bottom: 8px; }
.bt-runs select { flex: 1; min-width: 0; }
.bt-block { margin: 12px 0; }
.bt-block h4 { margin: 0 0 6px; font-size: 15.5px; color: var(--accent); font-weight: 600; }
.pos { color: var(--long); } .neg { color: var(--short); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin: 8px 0; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.kpi .k { color: var(--muted); font-size: 14.5px; }
.kpi .v { font: 600 21px var(--mono); margin-top: 2px; }
.pager { justify-content: center; margin: 8px 0; }
.grid td.link { cursor: pointer; text-decoration: underline dotted; }
.filters input[type=checkbox] { width: auto; vertical-align: middle; margin: 0 4px 0 0; }
.filters label { display: inline-flex; align-items: center; white-space: nowrap; font-size: 15.5px; }

/* шапка: переключатель стратегии и ссылки между страницами */
.strat-sel { font-weight: 600; font-size: 15.5px; padding: 4px 8px; color: var(--accent); background: var(--panel2);
  border: 1px solid var(--line); border-radius: 6px; }
a.navlink { color: var(--text); text-decoration: none; border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; }
a.navlink:hover { background: var(--panel2); }

/* общая шапка (nav.js): строка 1 — PROBOI, раздел, стратегия … меню; строка 2 (.hsub) — мелкий текст страницы */
header[data-nav] { display: block; padding: 7px 14px 5px; }
header[data-nav] .brand span { color: var(--text); font-size: 16.5px; font-weight: 600; }
.hrow { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hrow .spacer { flex: 1; }
.hnav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.hnav a.navlink, .hnav button { padding: 5px 11px; font-size: 15px; }
.hnav a.navlink.active { border-color: var(--accent); color: var(--accent); background: var(--panel2); }
.hnav .conn { font-size: 13px; vertical-align: 1px; }
.hnav .navdot { font-size: 13px; vertical-align: 1px; color: var(--accent); cursor: pointer; }
.hsub { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 22px; margin-top: 5px;
  font-size: 13.5px; color: var(--muted); }
.hsub .tf-pill { font-size: 13px; padding: 1px 6px; }
.hsub button { padding: 1px 9px; font-size: 13.5px; }
.hsub .neg { color: var(--short); }
/* строка «Рынок» под шапкой (nav.js, header[data-market]) */
.mkt-line { margin-top: 4px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.mkt-line .mkt-title { color: var(--text); font-weight: 600; }
.mkt-line b { font-weight: 600; color: var(--text); }
.mkt-line .up { color: var(--long); }
.mkt-line .dn { color: var(--short); }
.htabs { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.htabs a { color: var(--muted); text-decoration: none; padding: 1px 10px; }
.htabs a + a { border-left: 1px solid var(--line); }
.htabs a.active { color: var(--accent); background: var(--panel2); }
.htabs a:hover { color: var(--text); }

/* контраст: группы, вкладки, секции отделены от фона страницы */
header { box-shadow: 0 1px 0 var(--line), 0 4px 12px rgba(0, 0, 0, .35); position: sticky; top: 0; z-index: 50; }
.tabs { background: var(--panel); }
.tabs button:hover { color: var(--text); background: var(--panel2); }
.tabs button.active { color: var(--accent); background: var(--bg); border: 1px solid var(--line); border-bottom-color: var(--bg);
  box-shadow: inset 0 2px 0 var(--accent); margin-bottom: -1px; font-weight: 600; }
h3 { color: var(--text); border-bottom: 1px solid var(--line); padding: 0 0 5px 8px; border-left: 3px solid var(--accent); }
#settingsForm fieldset { background: var(--panel); border-color: var(--line2); }
#settingsForm legend { background: var(--bg); border: 1px solid var(--line2); border-radius: 6px; padding: 1px 10px; }
.field { border-bottom: 1px dotted var(--line); }
.field:last-child { border-bottom: 0; }
.bt-block { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.bt-block h4 { border-bottom: 1px solid var(--line); padding-bottom: 5px; margin-bottom: 8px; }
.grid th { background: var(--panel2); color: var(--text); border-bottom: 1px solid var(--line2); }
.grid tbody tr:nth-child(even) { background: rgba(255, 255, 255, .025); }
.grid tbody tr:hover { background: var(--panel2); }
.grid tbody tr.sel { background: rgba(240, 180, 41, .12); box-shadow: inset 3px 0 0 var(--accent); }
details summary { color: var(--text); }
details[open] > summary { color: var(--accent); }
input, select { border-color: var(--line2); }
button.ghost { border-color: var(--line2); }
.kpi { border-color: var(--line2); }
.chip { border-color: var(--line2); }
.filters { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
/* карточки и блоки страниц (перекрывают стили в <style> страниц) */
body .box, body .card, body .prop, body .arow, body .kpi { border-color: var(--line2); box-shadow: 0 2px 10px rgba(0, 0, 0, .35); }
body .box h4, body .card h2 { border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-bottom: 10px; }
body .sg { background: var(--bg); border-color: var(--line2); }
body .sgt { border-bottom: 1px solid var(--line); padding-bottom: 4px; }
body .arow-det { background: rgba(0, 0, 0, .18); }
body .atabs { border-bottom-color: var(--line2); }
body .atabs button:hover { color: var(--text); }
body .atabs button.active { color: var(--accent); background: var(--panel); border-color: var(--line2); box-shadow: inset 0 2px 0 var(--accent); }
body details.settings[open] { background: rgba(0, 0, 0, .15); border-radius: 8px; padding: 6px 8px; }
body .arow { border-left-color: var(--c, #999); }
body .sf select { width: 100%; padding: 3px 6px; }

/* правила отбора на карточке счёта */
.rules-box { margin: 8px 0; font-size: 15px; }
.rules-list { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.rules-list .rule { padding: 2px 8px; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line); }
.rules-list .rule.yes { color: var(--long); }
.rules-list .rule.no { color: var(--short); }
.rules-list .rule small { color: var(--muted); }
button.small { padding: 2px 10px; font-size: 14px; }
.rules-ed { margin-top: 8px; }
.rules-t { width: 100%; border-collapse: collapse; font-size: 15px; }
.rules-t td, .rules-t th { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.rules-t th { color: var(--muted); font-weight: 500; }
.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 1000; max-width: calc(100% - 32px);
  background: var(--panel2); border: 1px solid var(--short); color: var(--text); padding: 8px 14px; border-radius: 8px; }
