:root {
  --bg: #0a0d11;
  --panel: #11161d;
  --panel-2: #161c24;
  --line: #212a35;
  --line-2: #2c3745;
  --text: #e7ebf0;
  --muted: #8794a5;
  --faint: #566172;
  --accent: #f0b90b;
  --accent-ink: #1a1405;
  --long: #1fbf75;
  --short: #f0475b;
  --warn: #f5a524;
  --warn-bg: rgba(245, 165, 36, 0.1);
  --err: #ff5a6a;
  --err-bg: rgba(255, 90, 106, 0.1);
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 13.5px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-variant-numeric: tabular-nums; min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 20px; }
h2 { font-size: 14px; }
h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin: 16px 0 6px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.error { color: var(--err); margin: 0; font-size: 12.5px; }
.pos { color: var(--long); }
.neg { color: var(--short); }
[hidden] { display: none !important; }

/* ---------- top */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 18px; background: rgba(10, 13, 17, 0.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(8px); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; white-space: nowrap; }
.brand svg { width: 20px; height: 20px; stroke: var(--accent); stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.stats { display: flex; align-items: center; gap: 18px; }
.stat { display: flex; flex-direction: column; line-height: 1.15; }
.stat span { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); }
.stat b { font-size: 14px; font-weight: 600; }
.badge { padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 800; letter-spacing: 0.06em; }
.badge.paper { background: #263040; color: #b8c4d4; }
.badge.demo { background: rgba(240, 185, 11, 0.15); color: var(--accent); }
.badge.live { background: var(--short); color: #fff; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.dot.ok { background: var(--long); box-shadow: 0 0 0 3px rgba(31, 191, 117, 0.16); }
.dot.bad { background: var(--err); }

/* ---------- layout */
.layout { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 14px; padding: 14px 18px 40px; max-width: 1500px; margin: 0 auto; align-items: start; }
.side, .main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.side { position: sticky; top: 62px; }
@media (max-width: 980px) { .layout { grid-template-columns: 1fr; padding: 10px 12px 32px; } .side { position: static; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.row.end { justify-content: flex-end; }
.h3row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.h3row h3 { margin-bottom: 6px; }

/* ---------- inputs */
textarea, input, select { width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; outline: none; min-width: 0; }
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; margin-top: 8px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input:disabled { opacity: 0.45; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--muted); }
label.inline { flex-direction: row; align-items: center; gap: 8px; }
label.inline select { width: auto; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 13px; padding-top: 16px; }
label.check input { width: auto; accent-color: var(--accent); }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 560px) { .grid3, .grid2 { grid-template-columns: 1fr 1fr; } }
.uncertain input, .uncertain select, .uncertain .seg { border-color: var(--warn); background: var(--warn-bg); }
h3.uncertain { color: var(--warn); }
h3.uncertain::after { content: " · zkontroluj"; text-transform: none; letter-spacing: 0; }

button { cursor: pointer; border-radius: 7px; padding: 7px 12px; border: 1px solid var(--line); background: var(--panel-2); }
button:hover:not(:disabled) { border-color: var(--line-2); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
button.primary:hover:not(:disabled) { filter: brightness(1.07); }
button.big { padding: 10px 22px; font-size: 14.5px; }
button.ghost { background: transparent; }
button.small { padding: 4px 9px; font-size: 12px; }
button.danger { border-color: rgba(255, 90, 106, 0.45); color: var(--err); background: transparent; }
button.icon { background: transparent; border: 0; padding: 4px 6px; color: var(--muted); font-size: 15px; line-height: 1; }
button.icon:hover { color: var(--text); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: var(--panel-2); }
.seg button { border: 0; border-radius: 0; padding: 6px 12px; background: transparent; color: var(--muted); }
.seg button.on { background: #2a3442; color: var(--text); font-weight: 650; }
#segSide button.on[data-v="LONG"] { background: var(--long); color: #04140c; }
#segSide button.on[data-v="SHORT"] { background: var(--short); color: #fff; }
.seg.wide { display: flex; }
.seg.wide button { flex: 1; }
#segMode button.on[data-v="live"] { background: var(--short); color: #fff; }
#segMode button.on[data-v="demo"] { background: rgba(240, 185, 11, 0.22); color: var(--accent); }

/* ---------- inbox */
.inbox { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 52vh; overflow: auto; }
.inbox li { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 8px 10px; border-radius: 8px; background: var(--panel-2); border: 1px solid transparent; cursor: pointer; }
.inbox li:hover { border-color: var(--line-2); }
.inbox li.active { border-color: var(--accent); }
.inbox li.taken, .inbox li.bad { opacity: 0.55; }
.inbox .sym { font-weight: 700; }
.inbox .meta { grid-column: 1 / -1; font-size: 11.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox .x { padding: 0 4px; font-size: 13px; }
.pill { display: inline-block; font-size: 10.5px; font-weight: 800; padding: 1px 6px; border-radius: 4px; margin-left: 5px; vertical-align: 1px; letter-spacing: 0.03em; }
.pill.LONG { background: rgba(31, 191, 117, 0.14); color: var(--long); }
.pill.SHORT { background: rgba(240, 71, 91, 0.14); color: var(--short); }
.pill.dim { background: #222b36; color: var(--muted); font-weight: 600; }
.empty { color: var(--faint); padding: 10px 2px; font-size: 12.5px; }
details.paste { margin-top: 10px; }
details.paste summary, details.history-card summary { cursor: pointer; color: var(--muted); font-size: 12.5px; list-style: none; }
details.paste summary::before, details.history-card summary::before { content: "+ "; }
details[open].paste summary::before, details[open].history-card summary::before { content: "− "; }
details.history-card summary h2 { display: inline; font-size: 14px; color: var(--text); }

/* ---------- draft */
.draft { border-color: var(--line-2); }
.notes { margin: 0 0 6px; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 3px; }
.notes li { color: var(--warn); font-size: 12.5px; padding-left: 14px; position: relative; }
.notes li::before { content: "!"; position: absolute; left: 2px; font-weight: 800; }
.quick { display: grid; grid-template-columns: minmax(70px, 110px) auto auto; justify-content: start; gap: 10px 14px; align-items: end; }
.quick > .q:first-child { grid-column: 1 / -1; }
.q { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--muted); }
.q-row { display: grid; grid-template-columns: 140px 96px 150px; justify-content: start; gap: 6px; }
.q-row:has(#pctWrap[hidden]) { grid-template-columns: 140px 150px; }
.suffix { position: relative; }
.suffix input { padding-right: 44px; font-weight: 600; }
.suffix span { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); color: var(--faint); font-size: 12px; pointer-events: none; }
@media (max-width: 480px) { .q-row { grid-template-columns: 1fr 80px 1fr; } .quick { grid-template-columns: 1fr auto; } }
.sizing-info { margin-top: 6px; }
.sizing-info b { color: var(--text); font-weight: 600; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 1px; margin-top: 12px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.fact { background: var(--panel-2); padding: 8px 10px; }
.fact span { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); }
.fact b { font-weight: 600; font-size: 13.5px; }
.msgs { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.msgs li { padding: 6px 9px; border-radius: 7px; font-size: 12.5px; }
.msgs li.warn { background: var(--warn-bg); color: #f7c873; }
.msgs li.err { background: var(--err-bg); color: #ff9aa4; }
.send-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th { text-align: left; color: var(--faint); font-weight: 500; font-size: 11px; padding: 4px 5px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 3px 5px; border-bottom: 1px solid rgba(33, 42, 53, 0.7); vertical-align: middle; }
.tbl td input, .tbl td select { padding: 4px 7px; }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl tr.off td { opacity: 0.45; }
.tbl tr.off td:has(input) { opacity: 1; }
@media (max-width: 640px) { .tbl { display: block; overflow-x: auto; } }
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; margin-top: 14px; }
.scn { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; }
.scn h4 { margin: 0 0 5px; font-size: 12.5px; }
.kv { display: grid; grid-template-columns: auto auto; justify-content: space-between; gap: 2px 12px; font-size: 12.5px; }
.kv span:nth-child(odd) { color: var(--muted); }
.kv span:nth-child(even) { text-align: right; }

/* ---------- positions */
.positions { display: flex; flex-direction: column; container-type: inline-size; }
.prow { border-top: 1px solid var(--line); }
.prow:first-child { border-top: 0; }
.pmain { display: grid; grid-template-columns: minmax(120px, 1.2fr) minmax(90px, 1fr) minmax(120px, 1.2fr) minmax(100px, 1fr) minmax(80px, 0.8fr) auto; gap: 10px; align-items: center; padding: 9px 4px; cursor: pointer; }
.pmain:hover { background: rgba(255, 255, 255, 0.015); }
.pcell { min-width: 0; }
.pcell small { display: block; color: var(--faint); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcell .sym { font-weight: 700; }
.pnl b { font-size: 14px; }
.tpbar { display: flex; gap: 2px; margin-top: 3px; }
.tpbar i { flex: 1; height: 4px; border-radius: 2px; background: #273140; }
.tpbar i.set { background: #3c4b5e; }
.tpbar i.hit { background: var(--long); }
.pact { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
.pact button { padding: 4px 8px; font-size: 12px; white-space: nowrap; }
.pstatus { font-size: 11.5px; color: var(--muted); }
.pstatus.att { color: var(--warn); }
.pdetail { padding: 2px 4px 12px; }
.only-sm { display: none !important; }
@container (max-width: 700px) {
  .only-sm { display: block !important; }
  .pmain { grid-template-columns: minmax(0, 1fr) auto; }
  .pmain .hide-sm { display: none; }
  .pact { grid-column: 1 / -1; justify-content: flex-start; }
}
@container (min-width: 701px) and (max-width: 860px) {
  .pmain { grid-template-columns: minmax(110px, 1.2fr) minmax(110px, 1.2fr) minmax(90px, 1fr) auto; }
  .pmain .hide-md { display: none; }
}
.steps { list-style: none; padding: 0; margin: 4px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 3px 16px; }
.steps li { display: grid; grid-template-columns: 18px 105px 1fr; gap: 6px; align-items: baseline; font-size: 12.5px; }
.steps .ic { width: 16px; height: 16px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 10px; font-weight: 800; transform: translateY(2px); }
.steps .done .ic { background: rgba(31, 191, 117, 0.18); color: var(--long); }
.steps .active .ic { background: rgba(240, 185, 11, 0.16); color: var(--accent); }
.steps .wait .ic { background: #222a35; color: var(--muted); }
.steps .skip .ic { background: #1a2029; color: var(--faint); }
.steps .fail .ic { background: var(--err-bg); color: var(--err); }
.steps .det { color: var(--muted); overflow-wrap: anywhere; }
.steps .skip .lbl, .steps .skip .det { color: var(--faint); }
.attention { margin-top: 8px; padding: 6px 9px; border-radius: 7px; background: var(--warn-bg); color: #f7c873; font-size: 12.5px; }
details.journal { margin-top: 8px; }
details.journal summary { cursor: pointer; color: var(--faint); font-size: 12px; }
.journal ol { list-style: none; padding: 0; margin: 6px 0 0; max-height: 220px; overflow: auto; font-size: 12px; }
.journal li { padding: 2px 0; border-bottom: 1px solid rgba(33, 42, 53, 0.6); color: var(--muted); }
.journal time { color: var(--faint); margin-right: 6px; }

.history { display: flex; flex-direction: column; margin-top: 8px; }
.hist { display: grid; grid-template-columns: 1fr auto; gap: 1px 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.hist .why { grid-column: 1 / -1; color: var(--faint); font-size: 11.5px; }

/* ---------- auth, dialog, toast */
.auth { display: grid; place-items: center; min-height: calc(100vh - 60px); padding: 16px; }
.auth-card { width: min(360px, 100%); display: flex; flex-direction: column; gap: 12px; }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 0; width: min(620px, calc(100vw - 24px)); max-height: calc(100vh - 32px); }
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.settings { padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.settings > label { margin-top: 8px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #1d2631; border: 1px solid var(--line-2); padding: 9px 14px; border-radius: 9px; max-width: calc(100vw - 24px); z-index: 20; }
.toast.err { border-color: var(--err); color: #ffb3ba; }

@media (max-width: 760px) {
  .top { flex-wrap: wrap; padding: 8px 12px; }
  .stats { width: 100%; gap: 10px; justify-content: space-between; }
  .stat b { font-size: 13px; }
}

/* ---------- puvodni zprava se zvyraznenim */
details.source { margin-top: 10px; }
details.source summary { cursor: pointer; color: var(--muted); font-size: 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.legend { display: inline-flex; gap: 4px; }
.legend mark { font-size: 10.5px; }
.source-text { margin: 6px 0 0; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; white-space: pre-wrap; word-break: break-word; font: 12.5px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; color: #c3ccd8; max-height: 320px; overflow: auto; }
mark { border-radius: 3px; padding: 0 2px; color: var(--text); }
.hl-pair { background: rgba(88, 166, 255, 0.22); }
.hl-entry { background: rgba(240, 185, 11, 0.25); }
.hl-tp { background: rgba(31, 191, 117, 0.22); }
.hl-stop { background: rgba(240, 71, 91, 0.25); }
.hl-lev { background: rgba(170, 120, 255, 0.25); }

/* ---------- podily */
.row.tight { margin-top: 0; gap: 6px; }
.ftbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ftbl th { text-align: right; color: var(--faint); font-weight: 500; font-size: 11px; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.ftbl th:first-child, .ftbl td:first-child { text-align: left; }
.ftbl td { text-align: right; padding: 6px; border-bottom: 1px solid rgba(33, 42, 53, 0.7); white-space: nowrap; }
.ftbl tr.total td { font-weight: 650; border-bottom: 0; }
.ftbl tr.inactive td { opacity: 0.5; }
.share { display: inline-block; width: 46px; height: 5px; border-radius: 3px; background: #273140; vertical-align: middle; margin-right: 6px; overflow: hidden; }
.share i { display: block; height: 100%; width: 0; background: var(--accent); }
.addr { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.addr code { flex: 1; padding: 8px 10px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; font-size: 12.5px; word-break: break-all; }
.deposits { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.deposits li { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 7px 9px; background: var(--panel-2); border-radius: 7px; font-size: 12.5px; flex-wrap: wrap; }
.deposits li select { width: auto; }
.deposits .dim { color: var(--faint); }
@container (max-width: 560px) { .ftbl .hide-xs { display: none; } }
#fundCard { container-type: inline-size; }
.q .seg { align-self: flex-start; }

/* ---------- ucet: podily a historie */
button.icon.person svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; display: block; }
dialog.wide { width: min(780px, calc(100vw - 24px)); }
#accountDlg .settings { min-height: 320px; }
#historyCard .history { margin-top: 0; }
.w120 { max-width: 120px; }

/* ---------- vklady a zaznam cinnosti */
.deposits li { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.deposits .assign { display: flex; gap: 6px; align-items: center; }
.deposits .assign input { width: 150px; padding: 5px 8px; }
.deposits .who { color: var(--muted); }
.activity { list-style: none; margin: 0; padding: 0; max-height: 60vh; overflow: auto; font-size: 12.5px; }
.activity li { display: grid; grid-template-columns: 92px 1fr; gap: 10px; padding: 6px 2px; border-bottom: 1px solid var(--line); }
.activity time { color: var(--faint); white-space: nowrap; }
.activity .k { display: inline-block; min-width: 54px; margin-right: 6px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--faint); }
.activity .k.fund { color: var(--accent); }
.activity .k.trade { color: #6fb4ff; }
.activity .k.alert { color: var(--long); }
