:root {
  /* paper palette */
  --bg: #ede5d0;         /* page */
  --bg1: #f4ecd8;        /* panel */
  --bg2: #e8dec8;        /* sunken / chips */
  --bg3: #e2d7bf;
  --bg4: #faf6ed;        /* raised: inputs, menus */
  --line: #d4cbba;
  --line2: #c3b9a3;
  --fg: #2a2520;         /* ink */
  --fg2: #7a7060;        /* muted */
  --fg3: #9a907f;        /* faint labels */
  --on-acc: #f4ecd8;
  --up: #2d5f3a;
  --up-bg: rgba(45,95,58,.15);
  --dn: #8b2020;
  --dn-bg: rgba(139,32,32,.12);
  --acc: #7a6235;        /* warm accent */
  --acc-bg: rgba(122,98,53,.14);
  --radius: 6px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--fg); font: 13px/1.4 Inter, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
.mono, .num, input, td.num { font-family: "JetBrains Mono", ui-monospace, Menlo, monospace; font-variant-numeric: tabular-nums; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { color: var(--fg); background: var(--bg4); border: 1px solid var(--line2); border-radius: var(--radius); padding: 7px 10px; outline: none; }
input:focus { border-color: var(--acc); }
.up { color: var(--up); } .dn { color: var(--dn); } .acc { color: var(--acc); }
.hidden { display: none !important; }
.k { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--fg3); font-weight: 500; }
.dim { color: var(--fg2); }
.tag { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; padding: 2px 7px; border-radius: 3px; background: var(--bg3); color: var(--fg2); font-weight: 600; }
.tag.up { background: var(--up-bg); color: var(--up); } .tag.dn { background: var(--dn-bg); color: var(--dn); } .tag.acc { background: var(--acc-bg); color: var(--acc); }

/* ---------- top bar */
.top { height: 48px; display: grid; grid-template-columns: 220px 1fr auto; align-items: center; border-bottom: 1px solid var(--line); background: var(--bg1); position: sticky; top: 0; z-index: 20; }
.logo { display: flex; align-items: baseline; gap: 6px; padding: 0 16px; font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
.logo small { font-weight: 500; color: var(--fg2); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }
.navl { display: flex; gap: 4px; padding-left: 8px; }
.navl button { padding: 6px 12px; border-radius: var(--radius); color: var(--fg2); font-weight: 500; }
.navl button.active { color: var(--fg); background: var(--bg3); }
.top .r { display: flex; align-items: center; gap: 8px; padding-right: 12px; }
.clock { display: flex; align-items: center; gap: 8px; padding: 0 12px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); height: 48px; }
.clock .sess { font-weight: 700; }
.clock .et { color: var(--fg3); }
.btn { border: 1px solid var(--line2); border-radius: var(--radius); padding: 6px 12px; font-weight: 600; background: var(--bg2); }
.btn:hover { border-color: var(--fg3); }
.btn.pri { background: var(--acc); color: var(--on-acc); border-color: var(--acc); }
.btn.pri:hover { filter: brightness(1.08); }
.btn.up { background: var(--up); color: var(--on-acc); border-color: var(--up); }
.btn.dn { background: var(--dn); color: var(--on-acc); border-color: var(--dn); }
.btn.sm { padding: 3px 8px; font-size: 11px; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- layout */
.page { display: none; } .page.active { display: block; }
.trade { display: grid; grid-template-columns: 220px 1fr 300px; height: calc(100vh - 48px); }
.rail { border-right: 1px solid var(--line); overflow: auto; background: var(--bg1); }
.rail .hd { padding: 10px 12px 6px; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: var(--bg1); }
.mrow { display: grid; grid-template-columns: 1fr 64px; grid-template-rows: auto auto; gap: 0 8px; padding: 7px 12px; cursor: pointer; border-left: 2px solid transparent; }
.mrow:hover { background: var(--bg2); }
.mrow.active { background: var(--bg2); border-left-color: var(--acc); }
.mrow .s { font-weight: 700; display: flex; gap: 6px; align-items: center; }
.mrow .s .tag { font-size: 9px; padding: 1px 5px; }
.mrow .p { font-size: 12px; text-align: right; }
.mrow .c { font-size: 11px; color: var(--fg3); }
.mrow .ch { font-size: 11px; text-align: right; }
.mrow canvas { grid-column: 1 / span 2; width: 100%; height: 22px; margin-top: 2px; }
.center { display: flex; flex-direction: column; min-width: 0; }
.head { display: flex; align-items: center; gap: 20px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.head .sym { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.head .px { font-size: 20px; font-weight: 600; }
.head .st { display: flex; flex-direction: column; gap: 1px; }
.head .st b { font-weight: 600; font-size: 12px; }
.head .tf { margin-left: auto; display: flex; gap: 2px; background: var(--bg2); padding: 2px; border-radius: var(--radius); }
.head .tf button { padding: 4px 9px; border-radius: 4px; color: var(--fg2); font-size: 11px; font-weight: 600; }
.head .tf button.active { background: var(--bg3); color: var(--fg); }
.feed { display: flex; align-items: center; gap: 6px; font-size: 10px; color: var(--fg3); letter-spacing: .1em; text-transform: uppercase; }
.feed i { width: 6px; height: 6px; border-radius: 50%; background: var(--up); box-shadow: 0 0 8px var(--up); animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: .2 } }
.chartwrap { flex: 1; position: relative; min-height: 220px; }
#chart { position: absolute; inset: 0; }
.edge-markers { position: absolute; left: 0; right: 60px; top: 0; bottom: 26px; pointer-events: none; z-index: 3; }
.edge-markers .edge { position: absolute; right: 8px; font: 10px "JetBrains Mono", monospace; color: #fff; background: #8b2020; padding: 2px 7px; border-radius: 3px; white-space: nowrap; opacity: .92; }
.edge-markers .edge.top { top: 6px; } .edge-markers .edge.bottom { bottom: 6px; }
.edge-markers .edge.top + .edge.top { top: 26px; } .edge-markers .edge.bottom + .edge.bottom { bottom: 26px; }
.bottom { height: 230px; border-top: 1px solid var(--line); display: flex; flex-direction: column; background: var(--bg1); }
.tabs { display: flex; gap: 2px; padding: 6px 10px 0; border-bottom: 1px solid var(--line); }
.tabs button { padding: 7px 10px; color: var(--fg2); font-weight: 600; border-bottom: 2px solid transparent; font-size: 12px; }
.tabs button.active { color: var(--fg); border-color: var(--acc); }
.tabpane { flex: 1; overflow: auto; }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--fg3); text-align: right; padding: 7px 12px; border-bottom: 1px solid var(--line); font-weight: 500; white-space: nowrap; position: sticky; top: 0; background: var(--bg1); }
table.grid td { padding: 7px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.grid th:first-child, table.grid td:first-child { text-align: left; }
table.grid tr:hover td { background: var(--bg2); }
.empty { text-align: center; color: var(--fg3); padding: 28px; }

/* ---------- ticket */
.ticket { border-left: 1px solid var(--line); background: var(--bg1); display: flex; flex-direction: column; overflow: auto; }
.acct { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); }
.acct > div { padding: 10px 14px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.acct > div:nth-child(2n) { border-right: 0; }
.acct .v { font-size: 14px; font-weight: 600; margin-top: 2px; }
.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 12px 14px 4px; }
.sides button { padding: 9px; border-radius: var(--radius); border: 1px solid var(--line2); font-weight: 700; color: var(--fg2); background: var(--bg2); }
.sides button.active.l { background: var(--up-bg); border-color: var(--up); color: var(--up); }
.sides button.active.s { background: var(--dn-bg); border-color: var(--dn); color: var(--dn); }
.f { padding: 8px 14px 0; }
.f .row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.f input[type=text] { width: 100%; font-size: 15px; font-weight: 600; }
.chips { display: flex; gap: 4px; }
.chips button { font-size: 11px; padding: 2px 8px; border-radius: 4px; background: var(--bg3); color: var(--fg2); font-weight: 600; }
.chips button.active { background: var(--acc); color: var(--on-acc); }
.chips button:disabled { opacity: .3; }
.eq { margin: 12px 14px 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.eq-hd { display: flex; justify-content: space-between; font-weight: 600; padding-bottom: 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.eq-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--fg2); padding: 2px 0; }
.eq-row b { color: var(--fg); font-weight: 500; }
.inrow { display: flex; gap: 6px; align-items: stretch; }
.inrow .chips { flex: 0 0 auto; align-items: stretch; }
.inrow .chips button { padding: 0 9px; border: 1px solid var(--line2); background: var(--bg2); }
.inrow .chips button.active { background: var(--acc); border-color: var(--acc); color: var(--on-acc); }
.inrow input[type=text] { flex: 1; min-width: 0; text-align: right; font-size: 15px; font-weight: 600; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 4px; margin: 14px 0 6px; border-radius: 2px; background: linear-gradient(90deg, var(--up), var(--fg2), var(--dn)); outline: 0; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--fg); border: 3px solid var(--bg1); box-shadow: 0 0 0 1px var(--line2); cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 10px; height: 10px; border-radius: 50%; background: var(--fg); border: 3px solid var(--bg1); cursor: pointer; }
.sl-lab { display: flex; justify-content: space-between; font-size: 10px; color: var(--fg3); }
.sl-lab span:last-child { color: var(--dn); }
.sum { margin: 10px 14px 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.sum div { display: flex; justify-content: space-between; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.sum div:last-child { border-bottom: 0; }
.sum b { font-weight: 600; }
.balhint { margin: 8px 14px 0; padding: 6px 10px; border-radius: var(--radius); background: var(--up-bg); color: var(--up); font-size: 11px; font-weight: 600; }
.cta { margin: 12px 14px 6px; padding: 12px; border-radius: var(--radius); font-weight: 700; font-size: 14px; }
.msg { font-size: 11px; color: var(--fg2); padding: 0 14px 10px; min-height: 16px; }
.plist { border-top: 1px solid var(--line); padding: 10px 14px; }
.plist .hd { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.prow { background: var(--bg2); border-radius: var(--radius); padding: 8px 10px; margin-bottom: 6px; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; }
.prow .s { font-weight: 700; }
.prow .m { font-size: 11px; color: var(--fg2); }

/* ---------- dashboards */
.dash { padding: 16px; display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px; }
.card { background: var(--bg1); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.card h3 { margin: 0 0 12px; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--fg3); font-weight: 500; display: flex; align-items: center; gap: 8px; }
.card h3 .r { margin-left: auto; display: flex; gap: 6px; }
.kvs div { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.kvs div:last-child { border-bottom: 0; }
.kvs div span:first-child { color: var(--fg2); }
.kvs b { font-weight: 600; }
.c3 { grid-column: span 3; } .c4 { grid-column: span 4; } .c6 { grid-column: span 6; } .c8 { grid-column: span 8; } .c12 { grid-column: span 12; }
.mini { height: 220px; position: relative; } .mini > div { position: absolute; inset: 0; }
.big { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
.foot { padding: 20px 16px 40px; font-size: 11px; color: var(--fg3); line-height: 1.5; border-top: 1px solid var(--line); margin-top: 20px; }
.banner { background: var(--acc-bg); border-bottom: 1px solid var(--line); padding: 8px 16px; font-size: 12px; color: var(--acc); }
.toast { position: fixed; right: 16px; bottom: 16px; background: var(--fg); color: var(--bg); padding: 10px 14px; border-radius: var(--radius); font-size: 12px; max-width: 360px; z-index: 50; font-weight: 600; }
@media (max-width: 1100px) { .trade { grid-template-columns: 1fr; height: auto; } .rail { max-height: 200px; } .chartwrap { height: 50vh; } .c3,.c4,.c6,.c8 { grid-column: span 12; } .top { grid-template-columns: auto 1fr auto; } .clock { display: none; } }

/* ---------- v3 additions */
.clock i { width: 7px; height: 7px; border-radius: 50%; background: var(--fg3); display: inline-block; }
.clock i.up { background: var(--up); box-shadow: 0 0 8px var(--up); } .clock i.acc { background: var(--acc); }
.bal { display: flex; flex-direction: column; align-items: flex-end; padding: 0 10px; line-height: 1.1; }
.bal b { font-size: 13px; }
.tabs .cnt { color: var(--fg3); font-weight: 500; margin-left: 2px; }
.note { font-size: 11px; color: var(--fg3); padding: 0 14px 12px; line-height: 1.5; }
.note b { color: var(--fg2); font-weight: 600; }
.c5 { grid-column: span 5; } .c7 { grid-column: span 7; }
.modal { position: fixed; inset: 0; background: rgba(42,37,32,.35); display: flex; align-items: center; justify-content: center; z-index: 60; }
.modal .box { background: var(--bg1); border: 1px solid var(--line2); border-radius: 8px; padding: 18px 20px; width: min(720px, 92vw); max-height: 80vh; overflow: auto; }
.modal h3 { margin: 0 0 12px; font-size: 14px; display: flex; justify-content: space-between; align-items: center; }
.modal .kvs div { font-size: 12px; } .modal .kvs b { font-weight: 500; max-width: 70%; text-align: right; word-break: break-all; }
.modal .wbox { width: min(420px, 92vw); }
.wlist { display: flex; flex-direction: column; gap: 8px; }
.wopt { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line2); border-radius: var(--radius); background: var(--bg2); text-align: left; width: 100%; }
.wopt:hover { border-color: var(--fg3); }
.wopt img, .wopt .wico { width: 28px; height: 28px; border-radius: 6px; flex: none; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; background: var(--acc); color: var(--on-acc); }
.wopt .wico.rh { background: #00c805; }
.wopt .wtxt { display: flex; flex-direction: column; gap: 2px; }
.wopt .wtxt b { font-size: 13px; }
.wopt .wtxt span { font-size: 11px; color: var(--fg2); }
.wqr { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.wqr canvas { background: #fff; border-radius: 8px; padding: 10px; width: 280px; height: 280px; }
.wqr-txt { font-size: 12px; color: var(--fg2); text-align: center; }
@media (max-width: 1100px) { .c5, .c7 { grid-column: span 12; } .bal { display: none; } }
#chart a[href*='tradingview'],#h-chart a[href*='tradingview']{display:none!important}
