:root { --bg:#0f1115; --panel:#181b22; --line:#2a2f3a; --text:#e6e8ec; --muted:#8a91a0; --accent:#2f81f7; --bad:#f85149; }
* { box-sizing:border-box; }
body { margin:0; background:var(--bg); color:var(--text); font:14px/1.5 -apple-system,"Segoe UI",Tahoma,sans-serif; }
.center { min-height:100vh; display:flex; align-items:center; justify-content:center; padding:16px; }
.card { width:100%; max-width:360px; background:var(--panel); border:1px solid var(--line); border-radius:10px; padding:24px; }
h1 { font-size:18px; margin:0 0 16px; }
input { width:100%; padding:10px 12px; background:var(--bg); color:var(--text); border:1px solid var(--line); border-radius:6px; font-size:15px; }
button { margin-top:12px; width:100%; padding:10px; border:0; border-radius:6px; background:var(--accent); color:#fff; font-size:15px; cursor:pointer; }
button:disabled { opacity:.6; cursor:default; }
.err { color:var(--bad); min-height:1.5em; margin-top:8px; }
.topbar { display:flex; justify-content:space-between; align-items:center; padding:10px 16px; border-bottom:1px solid var(--line); background:var(--panel); }
.topbar button { width:auto; margin:0; padding:6px 12px; background:transparent; border:1px solid var(--line); }
.muted { color:var(--muted); }
main { padding:16px; }
.row { display:flex; align-items:center; gap:8px; }
.small { font-size:12px; }
.topbar { flex-wrap:wrap; gap:8px; }
select { background:var(--bg); color:var(--text); border:1px solid var(--line); border-radius:6px; padding:4px 8px; }
.badge { font-size:11px; font-weight:700; padding:2px 6px; border-radius:4px; }
.badge.demo { background:#1f6f43; color:#fff; }
.badge.real { background:var(--bad); color:#fff; }
.dot { width:9px; height:9px; border-radius:50%; background:var(--muted); display:inline-block; }
.dot.ok { background:#3fb950; } .dot.bad { background:var(--bad); }
.banner { background:#5a1e1e; color:#fff; padding:8px 16px; font-size:13px; }
.stats { display:grid; grid-template-columns:repeat(auto-fit,minmax(110px,1fr)); gap:8px; margin-bottom:16px; }
.stats div { background:var(--panel); border:1px solid var(--line); border-radius:8px; padding:8px 10px; display:flex; flex-direction:column; }
.stats b { font-variant-numeric:tabular-nums; font-size:16px; }
.panel { background:var(--panel); border:1px solid var(--line); border-radius:8px; margin-bottom:16px; }
.panel-head { display:flex; justify-content:space-between; align-items:center; padding:8px 12px; border-bottom:1px solid var(--line); gap:8px; }
.panel-head h2 { font-size:14px; margin:0; }
.panel-head input { width:140px; padding:4px 8px; font-size:13px; }
.panel-head button, .tbl button { width:auto; margin:0; padding:4px 10px; font-size:13px; }
.tbl button { background:transparent; border:1px solid var(--line); color:var(--muted); }
.scroll { overflow-x:auto; }
.tbl { width:100%; border-collapse:collapse; font-size:13px; font-variant-numeric:tabular-nums; }
.tbl th, .tbl td { padding:6px 10px; border-bottom:1px solid var(--line); text-align:left; white-space:nowrap; }
.tbl th { color:var(--muted); font-weight:500; }
.r { text-align:right !important; }
.up { color:#3fb950; } .down { color:var(--bad); } .stale { color:var(--muted); }
.empty { color:var(--muted); text-align:center !important; }
@media (max-width: 600px) {
  main { padding:12px; }
  .tbl th, .tbl td { padding:6px 6px; }
  .stats { grid-template-columns:repeat(3,1fr); }
  .stats b { font-size:14px; }
}
/* ---------- P2 charts ---------- */
.workspace { display:grid; grid-template-columns:minmax(0,1fr) 340px; gap:16px; margin-bottom:16px; }
.side .stats { grid-template-columns:repeat(2,1fr); }
.charts { background:var(--panel); border:1px solid var(--line); border-radius:8px; display:flex; flex-direction:column; min-width:0; }
.chart-toolbar { display:flex; flex-wrap:wrap; gap:8px; align-items:center; padding:6px 8px; border-bottom:1px solid var(--line); }
.tool-group { display:flex; gap:2px; }
.tool, .tf { width:auto; margin:0; padding:3px 8px; font-size:13px; background:transparent; color:var(--muted); border:1px solid transparent; border-radius:4px; }
.tool:hover, .tf:hover { color:var(--text); border-color:var(--line); }
.tool.on, .tf.on { color:#fff; background:#23324a; border-color:#2f81f7; }
.chart-grid { display:grid; gap:1px; background:var(--line); height:68vh; min-height:380px; }
.chart-grid.grid-1 { grid-template-columns:1fr; }
.chart-grid.grid-2 { grid-template-columns:1fr 1fr; }
.chart-grid.grid-4 { grid-template-columns:1fr 1fr; grid-template-rows:1fr 1fr; }
.chart-panel { display:flex; flex-direction:column; min-width:0; min-height:0; background:var(--bg); outline:1px solid transparent; }
.chart-panel.active { outline-color:#2f81f7; z-index:1; }
.chart-head { display:flex; align-items:center; gap:6px; padding:4px 6px; border-bottom:1px solid var(--line); overflow-x:auto; }
.sym-input { width:100px; padding:3px 6px; font-size:13px; font-weight:600; }
.tf-wrap { display:flex; gap:1px; }
.tf { padding:2px 6px; font-size:12px; }
.chart-msg { white-space:nowrap; }
.chart-body { flex:1; min-height:0; }
tr.clickable { cursor:pointer; }
tr.clickable:hover td { background:#1d212a; }
@media (max-width: 1000px) {
  .workspace { grid-template-columns:1fr; }
  .side .stats { grid-template-columns:repeat(3,1fr); }
}
@media (max-width: 700px) {
  .chart-grid { height:auto; }
  .chart-grid.grid-2, .chart-grid.grid-4 { grid-template-columns:1fr; grid-template-rows:none; }
  .chart-panel { height:60vh; min-height:340px; }
}
/* ---------- P3 trading ---------- */
.ticket .panel-head h2 span { color:var(--muted); font-weight:500; margin-left:4px; }
.chk { display:flex; align-items:center; gap:4px; cursor:pointer; }
.chk input { width:auto; }
.tk-body { padding:10px 12px; display:flex; flex-direction:column; gap:10px; }
.seg { display:flex; border:1px solid var(--line); border-radius:6px; overflow:hidden; }
.seg button { flex:1; width:auto; margin:0; padding:6px 4px; font-size:12px; background:transparent; color:var(--muted); border:0; border-radius:0; }
.seg button.on { background:#23324a; color:#fff; }
.seg.mini { display:inline-flex; margin-left:6px; }
.seg.mini button { padding:1px 6px; font-size:11px; }
.tk-grid { display:grid; grid-template-columns:1fr 1fr; gap:8px; align-items:end; }
.tk-grid label { display:flex; flex-direction:column; gap:3px; font-size:12px; color:var(--muted); }
.tk-grid input { padding:6px 8px; font-size:14px; font-variant-numeric:tabular-nums; }
.tk-grid label[hidden] { display:none; }
.tk-clear { margin:0; padding:7px; font-size:13px; }
.tk-info { font-size:12px; color:var(--muted); min-height:1.4em; }
.tk-info.bad { color:var(--bad); }
.tk-btns { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.tk-btns button { margin:0; display:flex; flex-direction:column; align-items:center; padding:8px; font-variant-numeric:tabular-nums; }
.tk-btns span { font-size:13px; opacity:.9; }
.btn-buy { background:#1f8f5f; } .btn-sell { background:#c93c37; }
.btn-primary { background:var(--accent); } .btn-danger { background:#c93c37; }
.btn-ghost { background:transparent; border:1px solid var(--line); color:var(--text); }
.danger-text { color:var(--bad) !important; }
.panel-head .btn-ghost { font-size:12px; padding:3px 8px; }
.acts { display:flex; gap:4px; justify-content:flex-end; }
.tbl button.act { padding:2px 7px; font-size:12px; color:var(--text); }
.tbl button.act.danger { color:var(--bad); }
dialog#modal { background:var(--panel); color:var(--text); border:1px solid var(--line); border-radius:10px; padding:0; width:min(380px, calc(100vw - 32px)); }
dialog#modal::backdrop { background:rgba(0,0,0,.55); }
dialog#modal form { padding:18px; display:flex; flex-direction:column; gap:10px; }
dialog#modal h3 { margin:0; font-size:16px; }
.modal-line { margin:0; font-variant-numeric:tabular-nums; }
.modal-field { display:flex; flex-direction:column; gap:4px; font-size:12px; color:var(--muted); }
.modal-btns { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-top:6px; }
.modal-btns button { margin:0; }
.toasts { position:fixed; right:16px; bottom:16px; display:flex; flex-direction:column; gap:8px; z-index:50; max-width:calc(100vw - 32px); }
.toast { padding:10px 14px; border-radius:8px; font-size:13px; box-shadow:0 4px 16px rgba(0,0,0,.4); }
.toast.ok { background:#1f6f43; color:#fff; } .toast.bad { background:#8e2b27; color:#fff; }
/* ---------- P3.1 edit mode ---------- */
.est { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.est > div { border-radius:6px; padding:6px 10px; display:flex; flex-direction:column; font-size:11px; }
.est b { font-size:15px; font-variant-numeric:tabular-nums; }
.est-loss { background:rgba(239,83,80,.12); color:#ef5350; }
.est-profit { background:rgba(38,166,154,.12); color:#26a69a; }
.edit-head { display:flex; justify-content:space-between; align-items:center; gap:8px; }
.edit-head b { font-size:13px; }
.edit-head .x { width:auto; margin:0; padding:2px 8px; }
.ed-more { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.ed-more button, .modal-btns button { margin:0; }
.ed-more[hidden], #ed-partial[hidden] { display:none; }
.tool:disabled { opacity:.35; cursor:default; }
.tool:disabled:hover { border-color:transparent; color:var(--muted); }
.tk-body[hidden] { display:none; }
/* ---------- drawing settings ---------- */
dialog#modal:has(form.wide) { width:min(460px, calc(100vw - 32px)); }
dialog#modal form.wide { max-height:calc(100vh - 64px); overflow-y:auto; }
.fib-levels { display:grid; grid-template-columns:1fr 1fr; gap:6px; }
.fib-row { display:flex; align-items:center; gap:6px; }
.fib-row input[type=checkbox] { width:auto; }
.fib-v { width:70px; padding:4px 6px; font-size:13px; }
input[type=color] { width:34px; height:28px; padding:0; border:1px solid var(--line); border-radius:4px; background:none; }
.fib-del { width:auto; margin:0; padding:2px 7px; font-size:12px; }
.opt-grid { display:grid; grid-template-columns:1fr 1fr; gap:8px; font-size:13px; align-items:center; }
.opt-grid input[type=range] { width:90px; }
.swatches { display:flex; gap:6px; flex-wrap:wrap; }
.swatch { width:26px !important; height:26px; margin:0; padding:0; border:1px solid var(--line); border-radius:50%; }
@media (max-width: 420px) { .fib-levels { grid-template-columns:1fr; } }
