/* Wefx Bookmap web — the WPF palette (App.xaml) as tokens. */
:root {
  --bg: #0E1116;
  --surface: #161B22;
  --surface-alt: #1C232C;
  --border: #2A313C;
  --text: #E6EAF0;
  --muted: #8B95A7;
  --accent: #E0B030;
  --buy: #27C08A;
  --sell: #F05252;
  --warn: #E0A500;
  --grey: #6B7280;
  --sel: #3A3220;
  --hover: #232B36;
  --ui: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --mono: Consolas, "Cascadia Mono", "SFMono-Regular", Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--ui); font-size: 13px; }
button, input, select { font-family: inherit; font-size: 13px; }

.h1 { font-size: 18px; font-weight: 600; }
.label { color: var(--muted); font-size: 11px; font-weight: 600; margin: 0 0 4px; display: block; }
.muted { color: var(--muted); }
.small { font-size: 11px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.buy { color: var(--buy); } .sell { color: var(--sell); } .accent { color: var(--accent); }
.hidden { display: none !important; }
.noperm { display: none !important; }
.wrap { white-space: pre-wrap; word-break: break-word; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }

/* buttons (Btn / Ghost) */
.btn { background: var(--accent); color: #0E1116; border: 0; border-radius: 8px; padding: 8px 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { opacity: .88; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.ghost { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover { background: var(--hover); opacity: 1; }
.btn.ghost:disabled:hover { background: var(--surface-alt); }
.btn.danger { background: var(--sell); color: #fff; }
.btn.block { width: 100%; }

/* inputs */
input[type=text], input[type=password], input[type=email], input:not([type]), select {
  width: 100%; background: var(--surface-alt); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 7px 8px; caret-color: var(--accent); outline: none; min-height: 34px;
}
input:focus, select:focus { border-color: var(--accent); }
select { appearance: none; padding-right: 30px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
select:hover { border-color: var(--accent); }
select:disabled { opacity: .45; }
option { background: var(--surface-alt); color: var(--text); }
label.check { display: flex; gap: 8px; align-items: center; color: var(--muted); cursor: pointer; }
label.check input { accent-color: var(--accent); width: 15px; height: 15px; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.field { margin-bottom: 8px; }

/* ---------- main window ---------- */
.app { height: 100vh; display: flex; flex-direction: column; padding: 16px; gap: 14px; }
.topbar { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: #0E1116; font-weight: 900; font-size: 14px; display: grid; place-items: center; flex: none; }
.conn { display: flex; align-items: center; justify-content: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--sell); flex: none; }
.actions { display: flex; gap: 8px; align-items: center; }
.user { display: flex; gap: 6px; align-items: center; margin-left: 8px; padding-left: 12px; border-left: 1px solid var(--border); }
.user .btn { padding: 6px 10px; font-size: 12px; }

.body { flex: 1; min-height: 0; display: grid; grid-template-columns: 340px 1fr; gap: 14px; }
.left { overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-right: 2px; }
.right { min-height: 0; display: grid; grid-template-rows: auto auto 1fr; gap: 12px; }

.strip { display: grid; grid-template-columns: 1.2fr 1fr 1.15fr 1.15fr .8fr; gap: 12px; }
.strip .card { display: flex; flex-direction: column; justify-content: center; }
.kv { display: flex; justify-content: space-between; gap: 8px; margin-top: 2px; }
.kv > :last-child { font-family: var(--mono); text-align: right; }
.big { font-weight: 900; font-size: 26px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.state { font-weight: 900; font-size: 30px; color: var(--muted); }

.gauge { position: relative; height: 18px; margin-top: 14px; }
.gauge .track { position: absolute; left: 0; right: 0; top: 4px; height: 10px; border-radius: 5px; background: var(--surface-alt); }
.gauge .mid { position: absolute; left: calc(50% - 1px); top: 0; width: 2px; height: 18px; background: var(--muted); opacity: .6; }
.gauge .marker { position: absolute; top: 2px; left: 0; width: 14px; height: 14px; border-radius: 7px; background: var(--accent); }

.brokers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.broker { background: var(--surface-alt); }
.broker .head { display: flex; align-items: center; gap: 8px; }
.broker .head .name { font-weight: 600; font-size: 14px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.broker .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 0; margin-top: 10px; }
.broker .px { font-family: var(--mono); font-size: 15px; }

.lower { min-height: 0; display: grid; grid-template-columns: 1fr 1.6fr; gap: 12px; }
.lower .card { min-height: 0; display: flex; flex-direction: column; }
.scroll { overflow-y: auto; min-height: 0; flex: 1; }
.pos-row { display: grid; grid-template-columns: 1fr 60px 60px 80px 80px; gap: 4px; padding: 3px 0; align-items: center; }
.pos-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.pos-row.kept > * { opacity: .55; }
.pos-row > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-line { font-family: var(--mono); font-size: 13px; margin: 2px 0; white-space: pre-wrap; word-break: break-word; }

/* account card */
.ip-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.ping { background: var(--surface-alt); border: 1px solid var(--border); border-radius: 8px; padding: 3px 10px; min-width: 78px; text-align: center; }
.ping .v { font-family: var(--mono); font-size: 18px; font-weight: 700; color: var(--muted); }
.ping .l { font-size: 9px; color: var(--muted); }
details.exp > summary { cursor: pointer; color: var(--muted); list-style: none; padding: 4px 0; user-select: none; }
details.exp > summary::before { content: "▸ "; }
details.exp[open] > summary::before { content: "▾ "; }
details.exp > div { margin-top: 8px; }
.find-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 6px; }

/* symbol type-ahead (editable ComboBox) */
.combo { position: relative; }
.combo .list { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); max-height: 260px; overflow-y: auto;
  background: var(--surface-alt); border: 1px solid var(--border); border-radius: 6px; padding: 2px; }
.combo .ctog { position: absolute; right: 1px; top: 1px; bottom: 1px; width: 26px; background: none; border: 0; color: var(--muted); cursor: pointer; }
.combo .ctog:hover { color: var(--accent); }
.combo .item { padding: 6px 10px; border-radius: 4px; margin: 1px 2px; cursor: pointer; }
.combo .item.hl { background: var(--border); }
.combo .item.sel { background: var(--sel); }

/* modal (MessageBox) */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 18px; width: min(460px, 100%); }
.modal .t { font-weight: 600; font-size: 15px; margin-bottom: 10px; }
.modal .m { white-space: pre-wrap; line-height: 1.45; margin-bottom: 16px; }
.modal .b { display: flex; justify-content: flex-end; gap: 8px; }
.modal input, .modal select { margin-bottom: 8px; }
.modal.wide { width: min(540px, 100%); }
.modal .m.muted { color: var(--muted); font-size: 12.5px; }
.modal .label { margin-top: 4px; }
/* live Apply (left column, stays in view) */
.apply-bar { position: sticky; bottom: 0; z-index: 5; display: flex; flex-direction: column; gap: 6px; padding: 12px 14px;
  background: var(--sel); border: 1px solid var(--accent); border-radius: 10px; box-shadow: 0 -8px 18px rgba(0,0,0,.45); }
.apply-bar > div:first-child { font-weight: 600; }
.apply-act { display: flex; gap: 8px; }
.apply-act .btn:first-child { flex: 1; }

/* the engine asks for a decision */
.approval { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 12px 14px;
  border: 1px solid var(--accent); background: var(--sel); border-radius: 10px; }
.approval b { color: var(--accent); }
.approval .wrap { margin-top: 4px; font-size: 12.5px; }
.approval-act { display: flex; gap: 8px; flex-wrap: wrap; }
.acct .approval { padding: 10px 12px; }

/* Trading accounts window */
.modal.accts { width: min(700px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; }
.accts-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.accts-head .btn { padding: 4px 10px; }
.acc-list { display: flex; flex-direction: column; gap: 8px; }
.acc { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-alt); }
.acc-main { flex: 1; min-width: 0; }
.acc-main .n { font-weight: 600; font-size: 14px; margin-bottom: 2px; overflow-wrap: anywhere; }
.acc-act { display: flex; gap: 6px; flex: none; }
.acc-act .btn { padding: 5px 10px; font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; font-size: 11.5px; }
.chip { padding: 1px 8px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); }
.chip.running { color: var(--buy); border-color: var(--buy); }
.chip.starting, .chip.stopping { color: var(--accent); border-color: var(--accent); }
.acc-form { display: flex; flex-direction: column; gap: 2px; }
.acc-form .row2 { margin-bottom: 4px; }
.acc-form input { margin-bottom: 4px; }
.pick.srv { max-height: 210px; margin-bottom: 8px; }
.pick.srv:empty { display: none; }
@media (max-width: 640px) { .acc { flex-direction: column; } .acc-form .row2 { grid-template-columns: 1fr; } }

.pick { display: flex; flex-direction: column; gap: 6px; max-height: 250px; overflow-y: auto; padding-right: 2px; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-alt); cursor: pointer; transition: border-color .12s, background .12s; }
.opt:hover { border-color: var(--muted); }
.opt.on { border-color: var(--accent); background: var(--sel); }
.opt input { accent-color: var(--accent); margin: 2px 0 0; flex: none; }
.opt b { display: block; font-weight: 600; margin-bottom: 2px; }
.opt span { color: var(--muted); font-size: 11.5px; overflow-wrap: anywhere; }

/* ---------- services window ---------- */
.svc { min-height: 100vh; display: flex; flex-direction: column; padding: 16px; gap: 12px; }
.svc-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 4px 12px; padding: 10px 12px; }
.filters .f { margin-bottom: 4px; }
.filters .btn { margin-bottom: 4px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 8px 14px; font-weight: 600; font-size: 12.5px; cursor: pointer; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.tiles { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.tile { min-width: 190px; padding: 10px 14px; }
.tile .v { font-family: var(--mono); font-size: 22px; font-weight: 700; }
.tile .v.sm { font-size: 16px; }
.tile .s { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* DataGrid */
.grid-wrap { border: 1px solid var(--border); background: var(--surface); overflow: auto; }
table.dg { border-collapse: collapse; font-size: 12.5px; table-layout: fixed; min-width: 100%; }
table.dg th { background: var(--surface-alt); color: var(--muted); font-weight: 600; font-size: 11px; text-align: left; padding: 7px 10px;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; cursor: pointer; user-select: none; white-space: nowrap; overflow: hidden; }
table.dg th .rz { position: absolute; right: 0; top: 0; bottom: 0; width: 6px; cursor: col-resize; }
table.dg th.drop { box-shadow: inset 2px 0 0 var(--accent); }
table.dg td { height: 26px; padding: 0 10px; border-bottom: 1px solid #222A34; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.dg tbody tr:nth-child(even) td { background: #19202A; }
table.dg tbody tr.sel td { background: var(--sel); }
table.dg td.num { font-family: var(--mono); text-align: right; }
table.dg td.side { font-weight: 600; }

.bot-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.bot-row .btn { padding: 6px 12px; }

/* ---------- Bots board ---------- */
.app.board { height: auto; min-height: 100vh; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(380px, 100%), 1fr)); gap: 12px; align-items: start; }
.acct { display: flex; flex-direction: column; gap: 10px; }
.acct.off { opacity: .72; }
.acct-head { display: flex; align-items: center; gap: 10px; }
.acct-name { flex: 1; min-width: 0; }
.acct-name .n { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-name .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 5px; background: var(--surface-alt); border: 1px solid var(--border); white-space: nowrap; }
.badge.live { color: var(--sell); border-color: var(--sell); }
.badge.dry { color: var(--muted); }
.acct-live { display: flex; flex-direction: column; gap: 8px; }
.acct-top { display: grid; grid-template-columns: 1fr 1.2fr 1.3fr; gap: 8px; }
.acct-top .st { font-weight: 900; font-size: 18px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-top .eq { font-weight: 800; font-size: 18px; white-space: nowrap; }
.acct-top .ch { font-size: 13px; padding-top: 3px; }
.acct-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 8px; background: var(--surface-alt); border-radius: 8px; padding: 8px 10px; }
.acct-grid .mono { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-log { font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-tail { background: var(--surface-alt); border-radius: 8px; padding: 8px 10px; }
.acct-tail .log-line { font-size: 11.5px; margin: 1px 0; color: #C9D1DC; }
.acct-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.acct-actions .btn { padding: 6px 10px; font-size: 12px; }

/* login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: min(380px, 100%); padding: 22px; }
.auth .brand { margin-bottom: 18px; }
.auth .err { color: var(--sell); font-size: 12px; min-height: 16px; margin: 4px 0 10px; }

@media (max-width: 1100px) {
  .app { height: auto; min-height: 100vh; }
  .body { grid-template-columns: 1fr; }
  .left { overflow: visible; }
  .strip { grid-template-columns: 1fr 1fr; }
  .lower { grid-template-columns: 1fr; }
  .lower .card { max-height: 420px; }
}
@media (max-width: 640px) {
  .app, .svc { padding: 12px; }
  .topbar { grid-template-columns: 1fr; }
  .conn { justify-content: flex-start; }
  .actions { flex-wrap: wrap; }
  .user { margin-left: 0; padding-left: 0; border-left: 0; }
  .strip, .brokers { grid-template-columns: 1fr; }
  .board .tile { flex: 1 1 calc(50% - 5px); }
  .acct-top { grid-template-columns: 1fr 1fr; }
  .acct-grid { grid-template-columns: repeat(2, 1fr); }
  .tile { min-width: 0; flex: 1 1 100%; }
}

/* spread monitor (bot window, next to the broker card) */
.sprmon { display: flex; flex-direction: column; min-width: 0; }
.sprt { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 12.5px; margin-top: 8px; }
.sprt th { text-align: right; font: 600 10.5px var(--sans, inherit); color: var(--muted); letter-spacing: .04em; padding: 2px 6px; }
.sprt td { text-align: right; padding: 2px 6px; white-space: nowrap; }
.sprt th:first-child, .sprt td:first-child { text-align: left; padding-left: 0; }
.sprt tr.bot td { color: var(--text); font-weight: 600; }
.sprtape { margin-top: 6px; max-height: 120px; overflow: auto; border-top: 1px solid var(--border, rgba(255,255,255,.08)); }
.sprtape .sprt { margin-top: 2px; font-size: 11.5px; }
.sprtape .sprt th { position: sticky; top: 0; background: var(--surface-alt); }

/* protection card */
.guardbox { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.guardbox:empty { display: none; }
.guardev { margin-top: 4px; background: var(--surface-alt); border-radius: 8px; padding: 8px 10px; font-size: 11.5px; max-height: 140px; overflow: auto; }

/* ADMIN-ONLY Quote -> Trade */
.card.qt.on { border-color: #E0A030; box-shadow: 0 0 0 1px rgba(224,160,48,.35) inset; }
.card.qt #btnQt { min-width: 64px; }

/* BOT PROFIT: this bot's own result */
.card.botpnl { position: relative; overflow: hidden; }
.card.botpnl::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--line, #2a2f3a); transition: background .4s; }
.card.botpnl.up::before { background: #27C08A; box-shadow: 0 0 14px rgba(39,192,138,.55); }
.card.botpnl.dn::before { background: #F05252; box-shadow: 0 0 14px rgba(240,82,82,.5); }
.card.botpnl.up { background-image: linear-gradient(100deg, rgba(39,192,138,.07), transparent 55%); }
.card.botpnl.dn { background-image: linear-gradient(100deg, rgba(240,82,82,.07), transparent 55%); }
.bp-tag { margin-left: 6px; padding: 1px 6px; border: 1px solid currentColor; border-radius: 9px; font-size: 9px; letter-spacing: .06em; opacity: .6; text-transform: uppercase; }
.bp-bar { display: flex; gap: 2px; height: 3px; margin-top: 8px; border-radius: 2px; background: rgba(255,255,255,.05); overflow: hidden; }
.bp-bar i { display: block; height: 100%; width: 0; transition: width .5s ease, background .4s; }
.bp-bar i + i { opacity: .55; }
@media (max-width: 1400px) and (min-width: 1101px) { .strip { grid-template-columns: 1fr 1fr 1fr; } }

/* two brokers: per broker rows in the strip (A, B, total) */
.duo { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 12px; margin: 6px 0 2px; }
.duo th { text-align: right; font: 600 9.5px var(--sans, inherit); color: var(--muted); letter-spacing: .05em; padding: 1px 0 3px 6px; }
.duo td { text-align: right; padding: 2px 0 2px 6px; white-space: nowrap; }
.duo th:first-child, .duo td:first-child { text-align: left; padding-left: 0; }
.duo td.who { font: 600 11px var(--sans, inherit); letter-spacing: .03em; }
.duo tr.tot td { border-top: 1px solid var(--border, rgba(255,255,255,.08)); font-weight: 600; }
.card.b2 { border-left: 3px solid var(--accent); }
.brokers.two .broker .who { font-weight: 700; letter-spacing: .04em; }
