/* Trading screen + the top bar it shares with Reports. Colours come from the palette variables only. */
body.terminal { display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100vh; overflow: hidden; }

/* ── Top bar ───────────────────────────────────────────────────── */
.topbar {
  position: relative; z-index: 40; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 60px; padding: 10px 18px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent); box-shadow: var(--shadow-sm);
}
.topbar-left { display: flex; align-items: center; gap: 26px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.mainnav { display: flex; gap: 2px; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; }
.nav-link { display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px; border-radius: 9px; font-weight: 600; font-size: 13.5px; color: var(--muted); transition: color .15s, background .15s; }
.nav-link svg { flex: none; }
.nav-link:hover { color: var(--text); }
.nav-link.on { color: var(--text); background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, .15), 0 0 0 1px color-mix(in srgb, var(--primary) 22%, transparent); }
.nav-link.on svg { color: var(--primary); }

.conn { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; color: var(--amber); background: var(--amber-bg); border: 1px solid color-mix(in srgb, var(--amber) 28%, transparent); }
.conn i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.conn.live { color: var(--buy); background: var(--buy-bg); border-color: color-mix(in srgb, var(--buy) 28%, transparent); }
.conn.live i { animation: pulse 2s infinite; }
.conn.off { color: var(--sell); background: var(--sell-bg); border-color: color-mix(in srgb, var(--sell) 28%, transparent); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--buy) 55%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* user menu */
.menu { position: relative; }
.user-btn { gap: 9px; height: 38px; padding-block: 0; padding-inline: 4px 12px; border-radius: 999px; background: var(--surface-2); font-size: 13.5px; }
.user-btn:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); filter: none; }
.user-btn .chev { color: var(--muted); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 800; box-shadow: 0 0 0 2px var(--surface); }
.menu-pop { position: absolute; inset-inline-end: 0; top: calc(100% + 8px); min-width: 220px; padding: 6px; z-index: 50; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); animation: mpop .14s ease-out; }
@keyframes mpop { from { opacity: 0; transform: translateY(-4px); } }
.menu-head { display: grid; padding: 8px 12px 10px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }
.menu-head b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-head span { font-size: 12px; color: var(--muted); }
.menu-pop button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: start; padding: 9px 12px; border: 0; background: none; border-radius: 9px; cursor: pointer; font-weight: 600; }
.menu-pop button svg { flex: none; color: var(--muted); }
.menu-pop button:hover { background: var(--surface-2); }
.menu-pop #logout-btn, .menu-pop #logout-btn svg { color: var(--sell); }
.menu-pop #logout-btn:hover { background: var(--sell-bg); }

/* ── Account banner ────────────────────────────────────────────── */
/* One row of tiles separated by 1px hairlines (the container's background shows through the gap). */
.banner {
  display: flex; flex-wrap: nowrap; gap: 1px; min-height: 100%;
  background: var(--border); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.banner::-webkit-scrollbar { height: 4px; }
.banner::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }   /* tiles stay on one line; extra ones scroll sideways */
.stat {
  --c: var(--primary); position: relative; flex: 1 1 0; min-width: 124px;
  display: flex; align-items: center; gap: 10px; padding: 6px 14px;
  background: var(--surface); transition: background .3s;
}
/* accent bar: faint by default, solid when the tile carries a state */
.stat::after {
  content: ''; position: absolute; inset-inline: 14px; bottom: 0; height: 2px; border-radius: 2px 2px 0 0;
  background: var(--c); opacity: .22; transition: opacity .3s, background .3s;
}
.stat.is-up::after, .stat.is-down::after, .stat.warn::after, .stat.danger::after { opacity: 1; }
.stat-id { flex: 0 0 auto; min-width: 0; background: color-mix(in srgb, var(--primary) 6%, var(--surface)); }
.stat-id::after { display: none; }
.stat[data-k="balance"] { --c: var(--primary-2); }
.stat[data-k="credit"] { --c: var(--primary); }
.stat[data-k="equity"] { --c: var(--cyan); }
.stat[data-k="upl"] { --c: var(--muted); }
.stat[data-k="used"] { --c: var(--amber); }
.stat[data-k="free"] { --c: var(--buy); }
.stat[data-k="util"], .stat[data-k="liq"] { --c: var(--buy); }
.stat.is-up { --c: var(--buy); background: linear-gradient(90deg, var(--buy-bg), var(--surface) 85%); }
.stat.is-down { --c: var(--sell); background: linear-gradient(90deg, var(--sell-bg), var(--surface) 85%); }
[dir="rtl"] .stat.is-up { background: linear-gradient(-90deg, var(--buy-bg), var(--surface) 85%); }
[dir="rtl"] .stat.is-down { background: linear-gradient(-90deg, var(--sell-bg), var(--surface) 85%); }
.stat.warn { --c: var(--amber); }
.stat.danger { --c: var(--sell); }
.stat-ic {
  flex: none; width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center;
  color: var(--c); background: color-mix(in srgb, var(--c) 15%, transparent); transition: color .3s, background .3s;
}
.stat-t { display: grid; min-width: 0; flex: 1; row-gap: 1px; }
.stat-l {
  font-size: 10.5px; line-height: 1.3; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
[dir="rtl"] .stat-l { text-transform: none; letter-spacing: 0; font-size: 11px; }
.stat-v {
  font-size: 16px; line-height: 1.3; font-weight: 700; font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-inline: -4px; padding-inline: 4px; border-radius: 5px;
}
.stat-v .ccy { margin-inline-start: 4px; font-size: 10px; font-weight: 600; color: var(--muted); letter-spacing: .04em; }
.stat[data-k="login"] .stat-v { color: var(--primary); }
.stat-v.up, .stat-v.down { font-weight: 800; }
/* equity delta, utilisation and liquidation meters sit beside the value */
.stat[data-k="equity"] .stat-t, .stat[data-k="util"] .stat-t, .stat[data-k="liq"] .stat-t { grid-template-columns: auto minmax(20px, 1fr); column-gap: 8px; align-items: center; }
.stat[data-k="equity"] .stat-l, .stat[data-k="util"] .stat-l, .stat[data-k="liq"] .stat-l { grid-column: 1 / -1; }
.stat-d { justify-self: start; font-size: 10.5px; font-weight: 700; line-height: 1.5; padding: 0 5px; border-radius: 5px; white-space: nowrap; color: var(--muted); background: var(--surface-2); font-variant-numeric: tabular-nums; }
.stat-d:empty { display: none; }
.stat-d.up { color: var(--buy); background: var(--buy-bg); }
.stat-d.down { color: var(--sell); background: var(--sell-bg); }
.meter { display: block; height: 5px; border-radius: 5px; overflow: hidden; background: var(--surface-3); }
.meter > i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--c); transition: width .5s ease, background .3s; }
/* value changed since the last poll */
@keyframes stat-flash-up { from { background: var(--buy-bg); color: var(--buy); } to { background: transparent; } }
@keyframes stat-flash-down { from { background: var(--sell-bg); color: var(--sell); } to { background: transparent; } }
.stat-v.flash-up { animation: stat-flash-up .7s ease-out; }
.stat-v.flash-down { animation: stat-flash-down .7s ease-out; }

/* ── Panes ─────────────────────────────────────────────────────── */
.pane {
  display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden;
  background: var(--surface); border: 1px solid color-mix(in srgb, var(--border) 80%, transparent); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.pane-head, .chart-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: var(--pane-head-h); padding: 0 var(--pane-head-px); border-bottom: 1px solid var(--border); }
.pane-head h2 { margin: 0; display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 700; letter-spacing: -.005em; }
.ph-ic { flex: none; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; color: var(--primary); background: color-mix(in srgb, var(--primary) 14%, transparent); }
.input-sm { padding: 7px 10px; font-size: 13px; border-radius: 8px; }

/* friendly empty states */
.pane .empty { padding: 28px 18px; color: var(--muted); font-size: 13.5px; }
.empty-hero { flex: 1; display: grid; place-content: center; justify-items: center; gap: 6px; text-align: center; height: 100%; }
.empty-hero .empty-ic { width: 54px; height: 54px; margin-bottom: 6px; border-radius: 16px; display: grid; place-items: center; color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent); }
.empty-hero b { color: var(--text); font-size: 15px; }
.empty-hero span:last-child { max-width: 260px; }

/* ── Instruments ───────────────────────────────────────────────── */
.pane-instruments { gap: 8px; padding-bottom: 6px; }
.pane-instruments > .search-wrap, .pane-instruments > .chips, .pane-instruments > .inst-head { margin-inline: 10px; }
.pane-instruments > .search-wrap { margin-top: 4px; }
.search-wrap { position: relative; }
.search-wrap .input { border-radius: 999px; padding-block: 8px; padding-inline: 36px 14px; background: var(--surface-2); }
.search-wrap svg { position: absolute; inset-inline-start: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-wrap:focus-within svg { color: var(--primary); }

.chips { display: flex; flex-wrap: nowrap; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid transparent; background: none; border-radius: 999px; padding: 4px 11px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; transition: color .15s, background .15s; }
.chip:hover { color: var(--text); background: var(--surface-2); }
.chip.on { color: var(--primary); background: color-mix(in srgb, var(--primary) 14%, transparent); border-color: color-mix(in srgb, var(--primary) 30%, transparent); }

.inst-head, .inst-row { display: grid; grid-template-columns: 20px minmax(58px, 1fr) minmax(68px, 1.15fr) 38px minmax(68px, 1.15fr) 20px; gap: 5px; align-items: center; }
.inst-head { padding: 4px 6px 6px; border-bottom: 1px solid var(--border); font-size: 10.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.inst-head span:nth-child(n+3) { text-align: center; }
.inst-list { flex: 1; overflow: auto; padding: 0 6px 0 4px; }
.inst-row { position: relative; padding: 7px 6px; margin: 1px 0; border-radius: 10px; cursor: pointer; font-size: 13px; transition: background .12s; }
.inst-row:hover { background: var(--surface-2); }
.inst-row.sel { background: color-mix(in srgb, var(--primary) 10%, var(--surface)); box-shadow: inset 3px 0 0 var(--primary); }
[dir="rtl"] .inst-row.sel { box-shadow: inset -3px 0 0 var(--primary); }
.inst-row.off { opacity: .5; }
.inst-row .ins { display: flex; align-items: center; gap: 6px; min-width: 0; }
.inst-row .sym { font-size: 12.5px; font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inst-row .spr { text-align: center; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.flags { display: inline-flex; flex: none; }
.flag { width: 18px; height: 18px; border-radius: 50%; box-shadow: 0 0 0 2px var(--surface); flex: none; object-fit: cover; }
.flag + .flag { margin-inline-start: -6px; }
.flag.ph { display: inline-grid; place-items: center; color: #fff; font: 700 10px/1 var(--font); font-style: normal; }
.pill { display: block; text-align: center; padding: 6px 2px; border-radius: 7px; background: var(--surface-2); font-size: 12px; font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; direction: ltr; white-space: nowrap; transition: background .3s, color .3s; }
.pill.rise { background: var(--buy-bg); color: var(--buy); }
.pill.fall { background: var(--sell-bg); color: var(--sell); }
.inst-row .flash-up { animation: fu .7s; } .inst-row .flash-dn { animation: fd .7s; }
@keyframes fu { from { color: var(--buy); background: var(--buy-bg); } }
@keyframes fd { from { color: var(--sell); background: var(--sell-bg); } }
.fav, .bolt { width: 22px; height: 22px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.fav svg { fill: none; }
.fav:hover, .bolt:hover { color: var(--text); background: var(--surface-3); }
.bolt:hover { color: var(--primary); }
.fav.on { color: var(--amber); }
.fav.on svg { fill: currentColor; }

/* ── Chart ─────────────────────────────────────────────────────── */
.chart-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chart-title b { font-size: 15px; font-weight: 800; letter-spacing: -.01em; white-space: nowrap; }
.chart-title .muted { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-actions { display: flex; align-items: center; gap: 8px; }

/* full screen: native (Fullscreen API) or the CSS fallback .chart-max (iPhone Safari) */
.chart-full { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--muted); cursor: pointer; transition: color .15s, background .15s, border-color .15s; }
.chart-full:hover { color: var(--text); background: var(--surface-2); }
.chart-full[aria-pressed="true"] { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); background: color-mix(in srgb, var(--primary) 12%, var(--surface)); }
.chart-full .i-compress, .chart-full[aria-pressed="true"] .i-expand { display: none; }
.chart-full[aria-pressed="true"] .i-compress { display: block; }
.chart-head { user-select: none; }
.grid-stack-item-content > .pane-chart:fullscreen, .pane-chart:fullscreen { width: 100%; height: 100%; border: 0; border-radius: 0; box-shadow: none; }
.grid-stack-item-content > .pane-chart.chart-max, .pane-chart.chart-max { position: fixed; inset: 0; z-index: 1000; width: auto; height: 100vh; height: 100dvh; border: 0; border-radius: 0; box-shadow: none; }
html.chart-max-open, html.chart-max-open body { overflow: hidden; }
.chart-body { flex: 1; min-height: 0; position: relative; }

/* multiple charts: the active symbol's full chart + the other open tabs in smaller cells */
.chart-grid { flex: 1; min-height: 0; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
.chart-grid > .chart-body { min-width: 0; }
.chart-grid[data-layout="2v"] { grid-template: minmax(0, 1fr) / minmax(0, 1fr) minmax(0, 1fr); }
.chart-grid[data-layout="2h"] { grid-template: minmax(0, 1fr) minmax(0, 1fr) / minmax(0, 1fr); }
.chart-grid[data-layout="3"] { grid-template: minmax(0, 1fr) minmax(0, 1fr) / minmax(0, 3fr) minmax(0, 2fr); }
.chart-grid[data-layout="3"] > .chart-body { grid-row: 1 / 3; }
.chart-grid[data-layout="4"] { grid-template: minmax(0, 1fr) minmax(0, 1fr) / minmax(0, 1fr) minmax(0, 1fr); }
.chart-grid:not([data-layout="1"]) { gap: 1px; background: var(--border); }
.chart-grid:not([data-layout="1"]) > * { background: var(--surface); }
.chart-grid:not([data-layout="1"]) > .chart-body::after { content: ""; position: absolute; inset: 0; z-index: 30; pointer-events: none; box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--primary) 55%, transparent); }
.chart-cell { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chart-cell-head { flex: none; display: flex; align-items: center; gap: 8px; height: 28px; padding: 0 6px 0 10px; border-bottom: 1px solid var(--border); font-size: 12.5px; cursor: pointer; user-select: none; }
.chart-cell-head b { font-weight: 700; white-space: nowrap; }
.chart-cell-head .num { margin-inline-start: auto; color: var(--muted); }
.chart-cell-head:hover { background: color-mix(in srgb, var(--text) 5%, transparent); }
.chart-cell-body { flex: 1; min-height: 0; position: relative; }
.chart-cell-body > div, .chart-cell-body iframe { width: 100%; height: 100%; }
.chart-lay { position: relative; z-index: 60; }
.chart-lay-menu { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: 50; display: grid; gap: 2px; min-width: 210px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.chart-lay-menu[hidden] { display: none; }
.chart-lay-menu button { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border: 0; border-radius: 6px; background: none; color: var(--text); font: inherit; font-size: 13px; text-align: start; cursor: pointer; }
.chart-lay-menu button:hover { background: var(--surface-2); }
.chart-lay-menu button[aria-checked="true"] { color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, var(--surface)); }
.lay-ic { flex: none; display: grid; gap: 2px; width: 22px; height: 16px; grid-template: 1fr / 1fr; }
.lay-ic > i { border: 1.5px solid currentColor; border-radius: 2px; }
.lay-ic.lay-2v { grid-template: 1fr / 1fr 1fr; }
.lay-ic.lay-2h { grid-template: 1fr 1fr / 1fr; }
.lay-ic.lay-3 { grid-template: 1fr 1fr / 3fr 2fr; }
.lay-ic.lay-3 > i:first-child { grid-row: 1 / 3; }
.lay-ic.lay-4 { grid-template: 1fr 1fr / 1fr 1fr; }
.chart-body > div, .chart-body iframe { width: 100%; height: 100%; }
.chart-msg { display: grid; place-items: center; height: 100%; padding: 24px; text-align: center; color: var(--muted); }

/* KLineChart mode: top bar (timeframes, indicators) + side bar (drawing tools) around the canvas */
.kl-wrap { display: grid; grid-template-columns: 1fr; grid-template-rows: 1fr; grid-template-areas: "chart"; position: relative; }
.kl-wrap.has-top { grid-template-rows: auto 1fr; grid-template-areas: "top" "chart"; }
.kl-wrap.has-side { grid-template-columns: auto 1fr; grid-template-areas: "side chart"; }
.kl-wrap.has-top.has-side { grid-template-areas: "top top" "side chart"; }
.kl-chart { grid-area: chart; min-width: 0; min-height: 0; direction: ltr; }   /* time runs left to right in every language; canvas text would garble under rtl */
.kl-top { grid-area: top; display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-bottom: 1px solid var(--border); min-width: 0; }
.kl-res { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.kl-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border: 0; border-radius: 7px; background: none; color: var(--muted); font-size: 12.5px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.kl-chip:hover { background: var(--surface-2); color: var(--text); }
.kl-tz { max-width: 200px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--muted); font-size: 12.5px; font-weight: 700; cursor: pointer; }
.kl-tz:hover { color: var(--text); }
.kl-chip.on { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }
.kl-trades { border: 1px solid color-mix(in srgb, var(--primary) 45%, transparent); background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); padding: 5px 12px; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.kl-trades:hover { background: color-mix(in srgb, var(--primary) 24%, transparent); color: var(--primary); }
.kl-trades.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.kl-trades[hidden] { display: none; }
.kl-trades-n { display: inline-grid; place-items: center; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: color-mix(in srgb, var(--primary) 25%, transparent); font-size: 11px; }
.kl-trades-n:empty { display: none; }
.kl-trades.on .kl-trades-n { background: rgba(255,255,255,.28); }
.kl-sep { width: 1px; align-self: stretch; margin: 2px 4px; background: var(--border); }
.kl-grow { flex: 1; }
.kl-menu { position: relative; }
.kl-pop { position: absolute; top: calc(100% + 6px); inset-inline-start: 0; z-index: 30; display: grid; grid-template-columns: repeat(3, minmax(92px, 1fr)); gap: 2px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); max-height: min(360px, 60vh); overflow-y: auto; }
.kl-pop button { padding: 7px 10px; border: 0; border-radius: 8px; background: none; color: var(--text); font-weight: 700; font-size: 12.5px; text-align: start; cursor: pointer; }
.kl-pop[hidden] { display: none; }
.kl-pop button:hover { background: var(--surface-2); }
.kl-pop button.on { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }
.kl-ind-item { display: flex; align-items: center; gap: 2px; min-width: 0; }
.kl-pop .kl-ind-item > [data-kl-ind] { flex: 1; min-width: 0; }
.kl-cfg-btn { display: inline-flex; align-items: center; justify-content: center; flex: none; border: 0; background: none; color: var(--muted); cursor: pointer; }
.kl-cfg-btn[hidden] { display: none; }
.kl-pop .kl-cfg-btn { padding: 5px; }
.kl-cfg-btn:not(.on) { opacity: .45; }
.kl-cfg-btn:hover { color: var(--primary); opacity: 1; }
.kl-cfg-btn svg { width: 15px; height: 15px; }
/* indicator settings dialog */
.kl-cfg h4 { margin: 4px 0 8px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.kl-cfg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 0 10px; }
.kl-cfg-lines { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.kl-cfg-line { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border: 1px solid var(--border); border-radius: 8px; font-size: 12.5px; font-weight: 700; cursor: pointer; }
.kl-cfg-line input { width: 26px; height: 22px; padding: 0; border: 0; background: none; cursor: pointer; }
.kl-cfg .row { align-items: center; }
.kl-side { grid-area: side; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; border-inline-end: 1px solid var(--border); overflow-y: auto; scrollbar-width: none; }
.kl-hr { width: 20px; height: 1px; margin: 4px 0; background: var(--border); flex: none; }
.kl-btn { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer; }
.kl-btn:hover { background: var(--surface-2); color: var(--text); }
.kl-btn.on { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }
.kl-nodata { position: absolute; inset: 0; pointer-events: none; }
.kl-nodata[hidden] { display: none; }

/* ── Order ticket ──────────────────────────────────────────────── */
.pane-order { overflow: auto; container: ordercard / inline-size; }
.pane-order > .pane-head { position: sticky; top: 0; z-index: 2; background: var(--surface); }
#order-form:not([hidden]) { flex: 1 0 auto; display: flex; flex-direction: column; }
.order-body { flex: 1; display: grid; align-content: start; gap: 12px; padding: 14px; }
.order-body .field { margin: 0; }
.pane-order .input { padding: 6px 10px; font-size: 13px; line-height: 1.4; }

/* instrument header */
.order-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
}
.order-head .flag { width: 26px; height: 26px; }
.order-head .flag + .flag { margin-inline-start: -9px; }
.order-head .flag.ph { font-size: 12px; }
#o-flags:empty { display: none; }
.order-id { display: grid; min-width: 0; flex: 1; }
.order-id b { font-size: 17px; font-weight: 800; letter-spacing: -.01em; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-id span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-id span:empty { display: none; }
.order-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--buy); box-shadow: 0 0 0 4px var(--buy-bg); }
.order-dot.off { background: var(--amber); box-shadow: 0 0 0 4px var(--amber-bg); }

.order-notice {
  display: flex; align-items: flex-start; gap: 9px; padding: 9px 12px; border-radius: 10px;
  font-size: 12.5px; font-weight: 600; line-height: 1.4;
  color: var(--amber); background: var(--amber-bg); border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent);
}
.order-notice[hidden] { display: none; }
.order-notice svg { flex: none; margin-top: 1px; }

.seg-full { display: flex; width: 100%; } .seg-full .seg-btn { flex: 1; padding: 8px; font-size: 13px; }

/* volume stepper */
.stepper { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: var(--radius-sm, 10px); background: var(--surface-2); overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.stepper:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.stepper .input { flex: 1; min-width: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; text-align: center; font-weight: 700; font-size: 14px; -moz-appearance: textfield; }
.stepper .input:focus { box-shadow: none; }
.stepper .input::-webkit-outer-spin-button, .stepper .input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.step-btn { flex: none; width: 34px; border: 0; background: none; color: var(--muted); font-size: 17px; font-weight: 600; line-height: 1; cursor: pointer; transition: background .12s, color .12s; }
.step-btn:hover { background: var(--surface-3); color: var(--text); }
.step-btn:active { background: color-mix(in srgb, var(--primary) 16%, transparent); color: var(--primary); }

/* stop loss / take profit */
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
/* same label height in both columns (the Stop loss one carries the Trailing switch), so the two inputs line up */
.order-risk .field > label { display: flex; align-items: center; gap: 6px; min-height: 22px; white-space: nowrap; }
.order-risk .field > label::before { content: ''; width: 7px; height: 7px; border-radius: 2px; background: var(--c); }
.field-sl { --c: var(--sell); } .field-tp { --c: var(--buy); }
.order-risk .input { border-inline-start: 3px solid color-mix(in srgb, var(--c) 55%, var(--border)); }
.order-risk .input:focus { border-inline-start-color: var(--c); }
.order-risk .input::placeholder { color: var(--muted); opacity: .6; font-size: 12.5px; }
/* profit / loss estimate under a Stop loss / Take profit field (order ticket and the Edit popup) */
.field .est { display: flex; flex-wrap: wrap; column-gap: 6px; row-gap: 1px; margin-top: 4px; font-size: 11.5px; line-height: 1.3; color: var(--muted); }
.field .est[hidden] { display: none; }
/* .field is a grid: when the other column grows with its estimate, keep label + input at the top instead of spreading them out */
.order-risk .field, .field:has(> .est) { align-content: start; }
/* a warning takes two lines at most (the full text is its tooltip), so it doesn't push Estimated Margin out of the card */
.field .est.bad { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.field .est b { font-weight: 700; font-size: 12px; }
.field .est.up b { color: var(--buy); } .field .est.down b { color: var(--sell); }
.field .est:not(.bad):not([hidden]) { display: grid; justify-items: start; }   /* P/L, Distance, % each on a line, so SL and TP line up */
.field .est.up .pct { color: var(--buy); } .field .est.down .pct { color: var(--sell); }
.field .est .warn { flex-basis: 100%; font-style: normal; color: var(--sell); display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.field .est.bad { color: var(--sell); }
/* Stop loss ⇄ Trailing switch on the Stop loss label (order ticket and the Edit popup) */
.field label:has(.sl-trail) { display: flex; align-items: center; gap: 6px; }
.sl-trail { margin-inline-start: auto; padding: 1px 7px; border: 1px solid var(--border); border-radius: 999px; background: none; color: var(--muted); font: inherit; font-size: 11px; line-height: 1.5; cursor: pointer; }
.sl-trail:hover { color: var(--text); }
.sl-trail.on { color: var(--text); border-color: var(--sell); background: color-mix(in srgb, var(--sell) 16%, transparent); }
.sl-trail:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }
/* the side picked by clicking a Bid / Ask price in the instrument list */
.go-btn.armed { box-shadow: 0 0 0 2px var(--text); }

/* sell / spread / buy action bar, pinned to the bottom of the card */
.order-foot {
  position: sticky; bottom: 0; z-index: 2; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  padding: 12px 14px 14px; background: var(--surface); border-top: 1px solid var(--border);
}
.go-btn {
  display: grid; gap: 2px; justify-items: center; padding: 10px 8px; border: 0; border-radius: 12px; color: #fff; cursor: pointer;
  transition: filter .15s, transform .08s, box-shadow .15s;
}
.go-btn span { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; opacity: .9; }
[dir="rtl"] .go-btn span { text-transform: none; letter-spacing: 0; font-size: 11px; }
.go-btn b { font-size: 13px; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; direction: ltr; padding: 0 6px; border-radius: 6px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.go-sell { background: var(--sell); box-shadow: 0 6px 16px color-mix(in srgb, var(--sell) 28%, transparent); }
.go-buy { background: var(--buy); box-shadow: 0 6px 16px color-mix(in srgb, var(--buy) 28%, transparent); }
.go-btn:hover { filter: brightness(1.08); }
.go-btn:active { transform: translateY(1px); }
.go-btn:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.go-btn:disabled, .pane-order.closed .go-btn { filter: grayscale(.6); opacity: .55; cursor: not-allowed; box-shadow: none; }
.go-btn b.flash-up { animation: go-up .7s ease-out; } .go-btn b.flash-dn { animation: go-dn .7s ease-out; }
@keyframes go-up { from { background: rgba(255, 255, 255, .32); } }
@keyframes go-dn { from { background: rgba(0, 0, 0, .28); } }
.spread-chip { display: grid; justify-items: center; gap: 1px; min-width: 44px; padding: 5px 7px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); }
.spread-chip small { font-size: 9.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
[dir="rtl"] .spread-chip small { text-transform: none; letter-spacing: 0; font-size: 10.5px; }
.spread-chip b { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* narrow card: stack SL/TP, tighten the action bar */
@container ordercard (max-width: 260px) {
  .order-risk { grid-template-columns: 1fr; }
  .order-foot { gap: 6px; padding-inline: 10px; }
  .order-body { padding: 10px; }
  .go-btn b { font-size: 12px; }
  .spread-chip small { display: none; }
  .spread-chip { min-width: 0; padding: 4px 5px; }
  .go-btn { padding-inline: 4px; }
  .go-btn b { padding-inline: 2px; }
}
/* very narrow: spread moves to its own thin line so Sell / Buy get the full width for their prices */
@container ordercard (max-width: 240px) {
  .order-foot { grid-template-columns: 1fr 1fr; row-gap: 6px; }
  .spread-chip { grid-column: 1 / -1; order: -1; display: flex; justify-content: center; align-items: baseline; gap: 6px; padding: 2px 6px; }
  .spread-chip small { display: inline; }
}

/* ── Blotter ───────────────────────────────────────────────────── */
.tabs { flex: none; display: flex; align-items: stretch; gap: 2px; min-height: var(--pane-head-h); padding: 0 calc(var(--pane-head-px) - 4px); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 0 12px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: none; font-weight: 600; font-size: 13.5px; color: var(--muted); cursor: pointer; transition: color .15s; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); border-bottom-color: var(--primary); }
.count { min-width: 20px; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 700; text-align: center; background: var(--surface-3); color: var(--muted); }
.tab.on .count { background: color-mix(in srgb, var(--primary) 18%, transparent); color: var(--primary); }
.tab-tools { margin-inline-start: auto; display: flex; gap: 8px; align-items: center; font-size: 12.5px; position: relative; min-width: 0; padding: 6px 0; }
.tab-tools[hidden] { display: none; }
.seg-sm { padding: 2px; }
.seg-sm .seg-btn { padding: 4px 9px; font-size: 12px; white-space: nowrap; }
#h-presets { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.range-chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); color: var(--text); font-size: 12.5px; font-weight: 600; white-space: nowrap; cursor: pointer; transition: border-color .15s, background .15s; }
.range-chip svg { color: var(--muted); flex: none; }
.range-chip:hover, .range-chip[aria-expanded="true"] { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, var(--surface-2)); }
.range-pop { position: fixed; z-index: 1000; width: 300px; max-width: calc(100vw - 24px); padding: 12px; display: grid; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, .28); }
.range-pop[hidden] { display: none; }
.range-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.range-fields .field { margin: 0; gap: 4px; font-size: 11.5px; color: var(--muted); }
.range-fields .input { width: 100%; min-width: 0; }
.range-acts { display: flex; justify-content: flex-end; gap: 8px; }
@media (max-width: 980px) {
  .tab-tools { flex-basis: 100%; margin-inline-start: 0; flex-wrap: wrap; }
  #h-presets { flex: 1 1 100%; }
}
.pane-blotter .tbl-wrap { flex: 1; min-height: 0; }
/* collapse / expand the trades panel (grid.js) */
.blot-toggle {
  flex: none; align-self: center; margin-inline-start: auto; width: 30px; height: 30px; display: grid; place-items: center;
  border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer; transition: background .15s, color .15s;
}
.tab-tools:not([hidden]) + .blot-toggle { margin-inline-start: 8px; }
.blot-toggle:hover { background: var(--surface-2); color: var(--text); }
.blot-toggle svg { transition: transform .2s; }
.pane-blotter.collapsed .blot-toggle svg { transform: rotate(180deg); }
.pane-blotter.collapsed .tbl-wrap, .pane-blotter.collapsed .tab-tools { display: none; }
.pane-blotter.collapsed .tabs { flex: 1; min-height: 0; border-bottom: 0; flex-wrap: nowrap; }
.pane-blotter.collapsed .tab.on { border-bottom-color: transparent; }
.pane-blotter .tbl th { background: var(--surface); font-size: 11px; padding: 9px 12px; }
.pane-blotter .tbl td { padding: 8px 12px; border-bottom-color: color-mix(in srgb, var(--border) 60%, transparent); }
.tbl td.r, .tbl th:nth-child(n+4) { text-align: end; }
.hist-total { border-top: 1px solid var(--border); }
.acts { text-align: end; white-space: nowrap; }
.ic { width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; transition: background .12s, color .12s; }
.ic:hover { background: var(--surface-3); color: var(--text); }
.ic-x:hover { background: var(--sell-bg); color: var(--sell); }

/* ── Instrument details modal (right-click / long-press a list row) ── */
.inst-info { width: min(480px, 100%); padding: 0; overflow: hidden; }
.inst-info-head { position: relative; display: flex; align-items: center; justify-content: center; padding: 14px 48px; border-bottom: 1px solid var(--border); }
.inst-info-head h3 { margin: 0; font-size: 15px; text-align: center; }
.inst-info-x { position: absolute; inset-inline-end: 10px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 16px; cursor: pointer; }
.inst-info-x:hover { background: var(--surface-3); color: var(--text); }
.inst-info-sym { display: flex; align-items: center; gap: 10px; padding: 18px 22px 4px; font-weight: 600; font-size: 13px; }
.inst-info-sym .flag { width: 26px; height: 26px; }
.inst-info-sym .flag + .flag { margin-inline-start: -9px; margin-top: 10px; }
.inst-info-sym .flag.ph { font-size: 12px; }
.inst-info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px 18px; padding: 16px 22px 22px; }
.inst-info-grid > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.inst-info-grid small { color: var(--muted); font-size: 13px; font-weight: 600; line-height: 1.25; }
.inst-info-grid b { font-size: 13px; overflow-wrap: anywhere; }
.inst-info-grid .muted { grid-column: 1 / -1; margin: 0; color: var(--muted); }
@media (max-width: 400px) { .inst-info-grid { grid-template-columns: repeat(2, 1fr); } }
.m-mk { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

/* ── Profile modal ─────────────────────────────────────────────── */
.modal-wide { width: min(520px, 100%); }
.profile-grid { display: grid; gap: 10px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.kv span:first-child { color: var(--muted); }
.kv b { text-align: end; overflow-wrap: anywhere; }
.prefs { display: grid; gap: 10px; margin-top: 8px; }
.prefs .rowp { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* thin themed scrollbars */
.inst-list, .tbl-wrap, .pane-order { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.inst-list::-webkit-scrollbar, .tbl-wrap::-webkit-scrollbar, .pane-order::-webkit-scrollbar { width: 8px; height: 8px; }
.inst-list::-webkit-scrollbar-thumb, .tbl-wrap::-webkit-scrollbar-thumb, .pane-order::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; border: 2px solid var(--surface); }

/* ── Card grid (GridStack) ─────────────────────────────────────── */
.workspace.grid-stack { display: block; padding: 5px 7px; overflow: hidden; min-height: 0; }
.grid-stack > .grid-stack-item > .grid-stack-item-content { overflow: visible; border-radius: var(--radius); }
.grid-stack-item-content > .pane, .grid-stack-item-content > .banner { height: 100%; }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 980px) {
  body.terminal { height: auto; overflow: auto; display: block; }
  .workspace { display: flex; flex-direction: column; }
  .pane-chart { height: 460px; }
  .pane-instruments { height: 320px; order: 3; }
  .pane-order { order: 2; overflow: visible; }
  .pane-blotter { order: 4; min-height: 260px; }
  .user-name { display: none; }
  .topbar .lang-btn span { display: none; }
}
@media (max-width: 560px) {
  .topbar { padding: 8px 10px; }
}

/* blotter: right-aligned numbers, icon actions (edit / close) */
.tbl td.r, .tbl th:nth-child(n+4) { text-align: end; }
.pane-blotter .tbl td { padding: 7px 12px; }
.acts { text-align: end; white-space: nowrap; }
.ic { width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; }
.ic:hover { background: var(--surface-3); color: var(--text); }
.ic-x:hover { background: var(--sell-bg); color: var(--sell); }

/* ── Instruments list (flags, tinted bid/ask pills, spread, favourites, quick trade) ── */
.workspace { grid-template-columns: 350px minmax(0, 1fr) 310px; }
@media (max-width: 1280px) { .workspace { grid-template-columns: 330px minmax(0, 1fr) 290px; } }
.search-wrap { position: relative; }
.search-wrap .input { padding-inline-end: 34px; }
.search-wrap svg { position: absolute; inset-inline-end: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
/* type tabs: badges that wrap onto new lines instead of scrolling sideways */
.chips { flex-wrap: wrap; overflow: visible; gap: 5px; padding-bottom: 0; }
.chip { flex: none; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; font-size: 11.5px; font-weight: 600; line-height: 1.5; color: var(--muted); }
.chip:hover { color: var(--text); background: var(--surface-3); }
.chip.on { color: var(--primary); font-weight: 700; background: color-mix(in srgb, var(--primary) 14%, transparent); border-color: color-mix(in srgb, var(--primary) 40%, transparent); box-shadow: none; }
.inst-head, .inst-row { grid-template-columns: 22px minmax(0, 1.25fr) minmax(0, 1fr) 34px minmax(0, 1fr) 22px; gap: 6px; }
.inst-head { padding: 6px 6px; align-items: center; }
.inst-head span:nth-child(n+3) { text-align: center; }
.inst-row { padding: 4px 6px; margin: 0; border-radius: 8px; border-bottom: 1px solid transparent; }
.inst-row .ins { display: flex; align-items: center; gap: 6px; min-width: 0; }
.flags { display: inline-flex; flex: none; }
.flag { width: 18px; height: 18px; border-radius: 50%; box-shadow: 0 0 0 2px var(--surface); flex: none; object-fit: cover; }
.flag + .flag { margin-inline-start: -6px; margin-top: 0; }
.flag.ph { display: inline-grid; place-items: center; color: #fff; font: 700 10px/1 var(--font); font-style: normal; }
.inst-row .sym { font-size: 12.5px; font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { display: block; text-align: center; padding: 4px 2px; border-radius: 6px; background: var(--surface-2); font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; direction: ltr; white-space: nowrap; }
.pill.rise { background: var(--buy-bg); color: var(--buy); }
.pill.fall { background: var(--sell-bg); color: var(--sell); }
.inst-row .spr { text-align: center; font-size: 12px; font-weight: 600; color: var(--text); }
.fav, .bolt { background: none; border: 0; padding: 0; cursor: pointer; color: var(--muted); display: grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; }
.fav svg { fill: none; }
.fav:hover, .bolt:hover { color: var(--text); background: var(--surface-3); }
.fav.on { color: var(--amber); }
.fav.on svg { fill: currentColor; }
.inst-list::-webkit-scrollbar { width: 6px; height: 6px; }
.inst-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
@media (max-width: 980px) { .workspace { display: flex; } }
.inst-head, .inst-row { grid-template-columns: 20px minmax(0, 1.3fr) minmax(0, 1fr) 30px minmax(0, 1fr) 20px; gap: 5px; }
.inst-list { overflow-x: hidden; }
.pill { font-size: 12px; padding: 4px 2px; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; }
.inst-row .spr { font-size: 11.5px; }
.pane-instruments { padding: 0 0 6px; }   /* header runs edge to edge like every other card */

/* narrow instruments card (laptops): drop the spread column, then put bid / ask on a second line under the symbol */
body:not(.m-app) .pane-instruments { container: instcard / inline-size; }
@container instcard (max-width: 360px) {
  .inst-head, .inst-row:not(.m-mk) { grid-template-columns: 20px minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr) 20px; }
  .inst-head > span:nth-of-type(3), .inst-row:not(.m-mk) > .spr { display: none; }
}
@container instcard (max-width: 300px) {
  .inst-head, .inst-row:not(.m-mk) {
    grid-template-columns: 20px minmax(0, 1fr) minmax(0, 1fr) 20px; row-gap: 3px;
    grid-template-areas: "fav ins ins bolt" ". b a .";
  }
  .inst-row:not(.m-mk) { padding-block: 6px; }
  .inst-head > .fav, .inst-row:not(.m-mk) > .fav { grid-area: fav; }
  .inst-head > span:nth-of-type(1), .inst-row:not(.m-mk) > .ins { grid-area: ins; }
  .inst-head > span:nth-of-type(2), .inst-row:not(.m-mk) > .b { grid-area: b; }
  .inst-head > span:nth-of-type(4), .inst-row:not(.m-mk) > .a { grid-area: a; }
  .inst-head > span:nth-of-type(5), .inst-row:not(.m-mk) > .bolt { grid-area: bolt; }
  .inst-head { row-gap: 0; }
  .inst-head > span:nth-of-type(2), .inst-head > span:nth-of-type(4) { font-size: 9.5px; }
  .inst-row:not(.m-mk) .sym { font-size: 13px; }
}

/* shared top bar: brand + main navigation */
.topbar-left { display: flex; align-items: center; gap: 26px; min-width: 0; }
.mainnav { display: flex; gap: 4px; }
.nav-link { padding: 8px 14px; border-radius: 10px; font-weight: 700; color: var(--muted); }
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.on { color: var(--text); background: var(--surface-3); box-shadow: inset 0 -3px 0 var(--primary); border-radius: 10px 10px 4px 4px; }
@media (max-width: 700px) { .topbar-left { gap: 8px; } .nav-link { padding: 7px 9px; } .logo-text { display: none; } }

/* ═══ Drag-and-drop layout (GridStack) ═══════════════════════════════════ */
body.terminal { grid-template-rows: auto minmax(0, 1fr); }
.workspace.grid-stack { display: block; padding: 0; margin: 5px; overflow: hidden; min-height: 0; gap: 0; }   /* margin, not padding: GridStack places cards absolutely, so padding would be ignored */
.grid-stack > .grid-stack-item > .grid-stack-item-content { overflow: hidden; border-radius: var(--radius); }
.grid-stack-item-content > .pane { height: 100%; }
/* banner card: tiles compact as the card narrows and only wrap when it is tall enough (h ≥ 2) */
@media (min-width: 981px) {
  .grid-stack-item[gs-id="banner"] > .grid-stack-item-content { container: bannercard / size; }
  @container bannercard (max-width: 1250px) { .stat:not(.stat-id) .stat-ic { display: none; } .stat { padding-inline: 12px; } .stat::after { inset-inline: 12px; } }
  @container bannercard (max-width: 980px) { .stat { min-width: 108px; padding-inline: 10px; } .stat-v { font-size: 14.5px; } .stat-id .stat-ic { display: none; } }
  /* a 1-row banner card can be as short as ~30px: tighten the tiles so nothing is clipped */
  @container bannercard (max-height: 52px) {
    .stat { padding-block: 2px; }
    .stat-ic { width: 24px; height: 24px; border-radius: 7px; }
    .stat-t { row-gap: 0; }
    .stat-l { font-size: 9.5px; line-height: 1.15; }
    .stat-v { font-size: 14px; line-height: 1.15; }
    .stat-d { line-height: 1.3; }
  }
  /* very short card (~30px on laptop screens): still two lines, just tighter */
  @container bannercard (max-height: 38px) {
    .stat { padding-block: 0; }
    .stat-ic { display: none !important; }
    .stat-l { font-size: 9px; line-height: 1.1; }
    .stat-v { font-size: 13px; line-height: 1.1; }
    .stat-v .ccy { font-size: 9px; }
    .stat-d { font-size: 9.5px; line-height: 1.2; }
    .meter { height: 4px; }
  }
}

/* phones / tablets: no dragging, cards simply stack */
@media (max-width: 980px) {
  .workspace.grid-stack { display: flex; flex-direction: column; gap: 10px; height: auto !important; overflow: visible; padding: 10px; margin: 0; }
  .grid-stack > .grid-stack-item, .grid-stack > .grid-stack-item > .grid-stack-item-content { position: static !important; width: auto !important; height: auto !important; inset: auto !important; overflow: visible; }
  .grid-stack > .grid-stack-item { position: relative !important; }   /* anchors the card tools */
  .card-grip, .grid-stack-item > .ui-resizable-handle { display: none !important; }
  .grid-stack-item-content > .pane, .grid-stack-item-content > .banner { height: auto; }
  .grid-stack-item-content > .banner { min-height: 60px; flex-wrap: wrap; overflow: visible; }
  .banner .stat { flex-basis: 170px; padding-block: 9px; }
  .grid-stack-item[gs-id="banner"] { order: 0; } .grid-stack-item[gs-id="chart"] { order: 1; } .grid-stack-item[gs-id="order"] { order: 2; }
  .grid-stack-item[gs-id="inst"] { order: 3; } .grid-stack-item[gs-id="blotter"] { order: 4; }
  .grid-stack-item-content > .pane-chart { height: 460px; }
  .grid-stack-item-content > .pane-instruments { height: 420px; }
  .grid-stack-item-content > .pane-blotter { min-height: 260px; }
  .pane-order { overflow: visible; }
}
@media (max-width: 700px) {
  .topbar-left { gap: 10px; }
  .nav-link { padding: 7px 10px; }
  .nav-link span, .logo-text { display: none; }
}
@media (max-width: 560px) {
  .topbar { padding: 8px 10px; min-height: 54px; }
  .conn { padding: 0 10px; }
  .conn #conn-text { display: none; }
  .banner .stat { flex-basis: calc(50% - 1px); min-width: 0; padding: 10px 12px; }
  .banner .stat-id { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) { .conn.live i, .menu-pop, .stat-v.flash-up, .stat-v.flash-down { animation: none; } }

/* ── Card tools: move grip + close, shown on hover at the top centre of each card (grid.js) ── */
.card-tools {
  position: absolute; top: 0; left: 50%; transform: translate(-50%, -2px); z-index: 20;
  display: flex; align-items: center; gap: 2px; padding: 2px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
.grid-stack-item:hover > .card-tools, .card-tools:focus-within, .grid-stack-item.ui-draggable-dragging > .card-tools { opacity: 1; pointer-events: auto; }
.card-grip, .card-x { width: 22px; height: 20px; display: grid; place-items: center; border: 0; border-radius: 6px; background: none; color: var(--muted); }
.card-grip { cursor: grab; }
.card-grip:active { cursor: grabbing; }
.card-x { cursor: pointer; }
.card-grip:hover { color: var(--text); background: var(--surface-3); }
.card-x:hover { color: var(--sell); background: var(--sell-bg); }
/* resize handles only appear on hover so they never cover content */
.grid-stack-item > .ui-resizable-handle { opacity: 0; transition: opacity .15s; }
.grid-stack-item:hover > .ui-resizable-handle { opacity: 1; }
.grid-stack-item.ui-resizable-resizing > .grid-stack-item-content, .grid-stack-item.ui-draggable-dragging > .grid-stack-item-content { box-shadow: 0 0 0 2px var(--primary); }
.grid-stack-placeholder > .placeholder-content { border: 2px dashed color-mix(in srgb, var(--primary) 60%, transparent); border-radius: var(--radius); background: color-mix(in srgb, var(--primary) 8%, transparent); }

/* top-bar dock: chips that bring closed cards back + reset layout */
.card-dock { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.card-dock[hidden] { display: none; }
.dock-chip {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px 0 5px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  border: 1px solid color-mix(in srgb, var(--primary) 45%, transparent); background: color-mix(in srgb, var(--primary) 14%, var(--surface));
  color: var(--primary); font-size: 12.5px; font-weight: 700; transition: background .15s, transform .15s, box-shadow .15s;
}
.dock-ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: #fff; font-style: normal; }
.dock-chip:hover { background: color-mix(in srgb, var(--primary) 24%, var(--surface)); transform: translateY(-1px); box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 25%, transparent); }
/* the chip of the card just closed pops in, then pulses twice so the eye follows it */
.dock-chip.pop { animation: dock-pop .35s cubic-bezier(.3, 1.6, .5, 1) both, dock-pulse 1.1s .35s ease-out 2; }
@keyframes dock-pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes dock-pulse { from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 55%, transparent); } to { box-shadow: 0 0 0 10px transparent; } }
@media (prefers-reduced-motion: reduce) { .dock-chip.pop { animation: none; } }
.dock-reset { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; border: 1px solid var(--border); background: none; color: var(--muted); cursor: pointer; }
.dock-reset:hover { color: var(--text); background: var(--surface-2); }
@media (max-width: 700px) { .dock-chip span { display: none; } .dock-chip { padding: 0 5px; } }
.grid-stack > [hidden] { display: none !important; }
body.gs-busy iframe { pointer-events: none; }

/* ── Instruments: search + category dropdown share one row; on laptop-sized screens the chips become the dropdown
      and the header matches the other cards, so the list gets more height ── */
.pane-instruments > .inst-bar { display: flex; gap: 6px; margin: 4px 10px 0; }
.inst-bar .search-wrap { flex: 1; min-width: 0; }
.inst-cat { display: none; }
@media (min-width: 981px) and (max-width: 1599px) {
  .pane-instruments { gap: 6px; }
  .pane-instruments > .inst-bar { margin-top: 2px; }
  .inst-bar .input-sm { height: 30px; padding-block: 0; font-size: 12.5px; }
  .inst-bar .search-wrap .input { padding-inline-end: 28px; }
  .inst-bar .search-wrap svg { width: 14px; height: 14px; inset-inline-end: 9px; }
  .inst-cat { display: block; flex: 0 1 42%; min-width: 0; cursor: pointer; text-overflow: ellipsis; }
  .pane-instruments > .chips { display: none; }
}

/* width handles on each card's sides (grid.js): a thin line shows on hover / while dragging */
.grid-stack-item > .edge-h { position: absolute; top: 14px; bottom: 14px; width: 10px; z-index: 15; cursor: col-resize; touch-action: none; }
.edge-h.start { inset-inline-start: 0; }
.edge-h.end { inset-inline-end: 0; }
.edge-h::after { content: ''; position: absolute; top: 0; bottom: 0; left: 4px; width: 2px; border-radius: 2px; background: var(--primary); opacity: 0; transition: opacity .15s; }
.edge-h:hover::after, .edge-h.on::after { opacity: .85; }
body.col-resizing, body.col-resizing * { cursor: col-resize !important; user-select: none; }
.grid-stack-item > .edge-v { position: absolute; left: 14px; right: 14px; height: 10px; z-index: 15; cursor: row-resize; touch-action: none; }
.edge-v.top { top: 0; }
.edge-v.bottom { bottom: 0; }
.edge-v::after { content: ''; position: absolute; left: 0; right: 0; top: 4px; height: 2px; border-radius: 2px; background: var(--primary); opacity: 0; transition: opacity .15s; }
.edge-v:hover::after, .edge-v.on::after { opacity: .85; }
body.row-resizing, body.row-resizing * { cursor: row-resize !important; user-select: none; }
.grid-stack-item:has(.pane-blotter.collapsed) > .edge-v { display: none; }   /* a collapsed trades panel keeps its height */
@media (max-width: 980px) { .edge-h, .edge-v { display: none; } }

/* chart tabs: several symbols open, one chart shown */
.chart-tabs { display: flex; align-items: center; gap: 2px; padding: 4px 8px 0; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border); }
.chart-tabs::-webkit-scrollbar { display: none; }
.ctab { display: inline-flex; align-items: center; gap: 4px; padding: 5px 6px 5px 11px; font-size: 12.5px; font-weight: 600; white-space: nowrap; cursor: pointer; color: var(--muted); border: 1px solid transparent; border-bottom: 0; border-radius: 6px 6px 0 0; }
.ctab:hover { color: var(--text); background: color-mix(in srgb, var(--text) 6%, transparent); }
.ctab.on { color: var(--text); background: var(--surface, var(--bg)); border-color: var(--border); margin-bottom: -1px; }
.ctab-x { appearance: none; background: none; border: 0; color: inherit; cursor: pointer; line-height: 1; border-radius: 4px; }
.ctab-x { width: 18px; height: 18px; font-size: 15px; opacity: .6; }
.ctab-x:hover { opacity: 1; background: color-mix(in srgb, var(--text) 12%, transparent); }

.newtab { flex: none; width: 20px; height: 20px; margin-inline-start: 4px; padding: 0; display: inline-grid; place-items: center; border: 0; border-radius: 5px; background: none; color: var(--muted); cursor: pointer; opacity: .55; }
.inst-row:hover .newtab, .newtab:focus-visible { opacity: 1; }
.newtab:hover { color: var(--primary); background: var(--surface-3); opacity: 1; }
.inst-row .ins { display: flex; align-items: center; min-width: 0; }

/* notification bell */
.bell-btn { padding-inline: 8px; }
.bell-btn .bell-off { display: none; }
.bell-btn[aria-pressed="false"] { color: var(--muted); }
.bell-btn[aria-pressed="false"] .bell-on { display: none; }
.bell-btn[aria-pressed="false"] .bell-off { display: block; }

#go-sell.no-long { opacity: .45; cursor: not-allowed; }

/* stocks-only account: no margin utilisation / liquidation level */
body.no-margin-tiles .stat[data-k="util"], body.no-margin-tiles .stat[data-k="liq"] { display: none; }

/* ── Open trades: the close / edit column stays in view however narrow the panel is ── */
.pane-blotter .tbl td.acts, .pane-blotter .tbl th:last-child {
  position: sticky; inset-inline-end: 0; z-index: 1; background: var(--surface); text-align: center; white-space: nowrap;
  box-shadow: -8px 0 8px -8px rgba(0, 0, 0, .35);
}
[dir="rtl"] .pane-blotter .tbl td.acts, [dir="rtl"] .pane-blotter .tbl th:last-child { box-shadow: 8px 0 8px -8px rgba(0, 0, 0, .35); }
.pane-blotter .tbl tr:hover td.acts { background: var(--surface-2); }
.pane-blotter .tbl th:last-child { z-index: 2; }

/* ── bulk close bar + row checkboxes ── */
.bulk-bar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-bottom: 1px solid var(--border); position: sticky; inset-inline-start: 0; }
.bulk-sp { flex: 1; }
.bulk-all-btn { background: var(--sell-bg); color: var(--sell); border: 1px solid color-mix(in srgb, var(--sell) 40%, transparent); font-weight: 700; }
.bulk-all-btn:hover:not(:disabled) { background: var(--sell); color: #fff; }
.chk { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.chk input { accent-color: var(--primary); width: 15px; height: 15px; margin: 0; cursor: pointer; }
.bulk-all { font-size: 12px; color: var(--muted); font-weight: 600; }
.m-app .bulk-bar { padding: 6px 2px 10px; border-bottom: 0; }

/* ── volume / lots switch ── */
.vol-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.vol-head label { margin: 0; }

/* ── one-click trading switch ── */
.oneclick { display: flex; align-items: center; gap: 10px; margin: 0 14px 8px; cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.oneclick input { position: absolute; opacity: 0; pointer-events: none; }
.oc-sw { flex: none; position: relative; width: 34px; height: 20px; border-radius: 999px; background: color-mix(in srgb, var(--text) 22%, transparent); transition: background .18s; }
.oc-sw::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .35); transition: transform .18s; }
.oneclick input:checked + .oc-sw { background: var(--amber); }
.oneclick input:checked + .oc-sw::after { transform: translateX(14px); }
[dir="rtl"] .oneclick input:checked + .oc-sw::after { transform: translateX(-14px); }
.oneclick input:focus-visible + .oc-sw { outline: 2px solid var(--primary); outline-offset: 2px; }
.oneclick input:checked ~ .oc-t { color: var(--amber); }
.oc-t { display: inline-flex; align-items: center; gap: 4px; }

/* Bid / Ask prices in the instrument list are buttons: Bid sells, Ask buys */
.inst-row .pill.a, .inst-row .pill.b { cursor: pointer; }
.inst-row .pill.a:hover { outline: 1px solid var(--buy); }
.inst-row .pill.b:hover { outline: 1px solid var(--sell); }
body.one-click .inst-row .pill.a:hover, body.one-click .inst-row .pill.b:hover { outline-width: 2px; }

/* one-click trading ON for the selected symbol: clearly yellow */
.oneclick.on { padding: 8px 10px; margin-inline: 10px; border-radius: 10px; background: color-mix(in srgb, var(--amber) 18%, transparent); border: 1px solid var(--amber); color: var(--amber); }
.oneclick.on .oc-sw { background: var(--amber); }
.pane-order.one-click .go-btn { box-shadow: 0 0 0 2px var(--amber); }

/* instrument rows with one-click trading on: yellow bolt */
.inst-row.oc .bolt { color: var(--amber); background: color-mix(in srgb, var(--amber) 20%, transparent); }
.inst-row.oc .bolt svg { filter: drop-shadow(0 0 3px var(--amber)); }

/* ── Product specifications ────────────────────────────────────── */
.specs-btn { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.specs-btn:hover { color: var(--text); }
.specs { width: min(1200px, 100%); max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.specs-bar { flex: none; display: flex; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.specs-bar .search-wrap { flex: 1; min-width: 0; }
.specs-bar select { width: auto; max-width: 45%; }
.specs-wrap { flex: 1; min-height: 0; overflow: auto; }
.specs-msg { margin: 0; padding: 24px; text-align: center; }
.specs-tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.specs-tbl th, .specs-tbl td { padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; text-align: end; }
.specs-tbl thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-2, var(--surface)); color: var(--muted); font-size: 11.5px; font-weight: 700; }
.specs-tbl th:first-child { position: sticky; inset-inline-start: 0; z-index: 1; text-align: start; background: var(--surface); }
.specs-tbl thead th:first-child { z-index: 3; background: var(--surface-2, var(--surface)); }
.specs-tbl tbody tr { cursor: pointer; }
.specs-tbl tbody tr:hover td, .specs-tbl tbody tr:hover th { background: color-mix(in srgb, var(--text) 5%, var(--surface)); }
.specs-sym { display: flex; align-items: center; gap: 8px; }
.specs-sym > span:last-child { display: flex; flex-direction: column; line-height: 1.25; }
.specs-sym small { color: var(--muted); font-weight: 500; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.specs-sym .flag + .flag { margin-inline-start: -8px; }

/* stock logos: square company icons cropped to the same circle as the currency flags */
.flag.logo { background: #fff; object-fit: cover; }
/* indicator menu: short code + full name; the x removes an indicator that is on the chart */
.kl-pop { grid-template-columns: repeat(2, minmax(210px, 1fr)); }
.kl-pop [data-kl-ind], .kl-ind-chip { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; line-height: 1.2; }
.kl-pop [data-kl-ind] small, .kl-ind-chip small { font-size: 11px; font-weight: 500; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.kl-pop [data-kl-ind].on small, .kl-ind-chip.on small { color: inherit; opacity: .8; }
.kl-x-btn { display: inline-flex; align-items: center; justify-content: center; flex: none; padding: 5px; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.kl-x-btn[hidden] { display: none; }
.kl-x-btn:hover { color: #ef5350; background: color-mix(in srgb, #ef5350 12%, transparent); }
.kl-x-btn svg { width: 14px; height: 14px; }
.kl-pop .kl-x-btn { padding: 5px; color: var(--muted); }
.kl-pop .kl-x-btn:hover { color: #ef5350; }

/* order panel: Required Margin for the volume (red when it is more than the free margin) */
.order-margin { display: flex; justify-content: space-between; gap: 12px; padding: 8px 2px 0; }
.order-margin > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.order-margin small { color: var(--muted); font-size: 12px; }
.order-margin b { font-size: 13.5px; font-weight: 700; }
.order-margin.short #o-req-margin { color: var(--red, #ef5350); }
