:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
  --toolbar-h: 38px; --bottom-h: 41px; --gutter: 4px; --sidebar-w: 526px; --row-h: 30px;
  --up: #26a69a; --down: #ef5350; --blue: #2962ff; --orange: #ff9800; --purple: #7e57c2;
}
[data-theme="dark"] {
  --bg: #0f0f0f; --panel: #0f0f0f; --panel2: #141414; --border: #2e2e2e; --border2: #3d3d3d; --hover: #1f1f1f; --active: #2a2a2a;
  --text: #d1d4dc; --text-strong: #ffffff; --muted: #787b86; --muted2: #9598a1; --chart-bg: #131722;
  --btn-bg: #1e1e1e; --btn-fg: #d1d4dc; --sel: rgba(41,98,255,0.18); --news-bg: #2b2438; --card-shadow: 0 8px 24px rgba(0,0,0,.55); --input-bg: #1a1a1a;
}
[data-theme="light"] {
  --bg: #ffffff; --panel: #ffffff; --panel2: #f8f9fd; --border: #e0e3eb; --border2: #d1d4dc; --hover: #f0f3fa; --active: #e0e3eb;
  --text: #131722; --text-strong: #000000; --muted: #787b86; --muted2: #6a6d78; --chart-bg: #ffffff;
  --btn-bg: #f0f3fa; --btn-fg: #131722; --sel: rgba(41,98,255,0.12); --news-bg: #f0eefa; --card-shadow: 0 8px 24px rgba(0,0,0,.18); --input-bg: #ffffff;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font); font-size: 13px; color: var(--text); background: var(--bg); overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font-family: inherit; font-size: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { opacity: .35; cursor: default; }
input, select { font-family: inherit; font-size: inherit; color: var(--text); background: var(--input-bg); border: 1px solid var(--border2); border-radius: 3px; padding: 4px 6px; outline: none; }
input:focus, select:focus { border-color: var(--blue); }
svg { display: block; }
#app { display: grid; grid-template-rows: var(--toolbar-h) 1fr var(--bottom-h); height: 100vh; width: 100vw; background: var(--bg); }

/* ---------- toolbar ---------- */
#toolbar { display: flex; align-items: center; justify-content: space-between; height: var(--toolbar-h); padding: 0 6px; border-bottom: var(--gutter) solid var(--border); background: var(--panel); user-select: none; }
.tb-group { display: flex; align-items: center; gap: 2px; height: 100%; min-width: 0; }
.tb-btn, .tb-icon { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 9px; border-radius: 4px; color: var(--text); font-size: 14px; white-space: nowrap; }
.tb-icon { width: 34px; padding: 0; justify-content: center; }
.tb-btn:hover, .tb-icon:hover, .icon-btn:hover { background: var(--hover); }
.tb-btn.active, .tb-icon.active { background: var(--active); color: var(--text-strong); }
.tb-btn svg, .tb-icon svg, .icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.tb-sep { width: 1px; height: 20px; background: var(--border2); margin: 0 4px; }
.chev { width: 8px; height: 8px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg) translate(-2px,-2px); margin-left: 2px; opacity: .8; }
.symbol-btn { background: var(--btn-bg); font-weight: 600; padding: 0 5px 0 11px; gap: 8px; }
.symbol-btn .fav { display: inline-flex; width: 20px; height: 20px; align-items: center; justify-content: center; border-radius: 50%; border: 1px solid var(--border2); }
.symbol-btn .fav svg { width: 12px; height: 12px; }
.symbol-btn .fav.on { color: #f7b500; border-color: #f7b500; }
.symbol-btn .fav.on svg { fill: #f7b500; }
.interval-btn { font-weight: 600; min-width: 30px; justify-content: center; }
.layout-btn { gap: 6px; }
.layout-text { display: flex; flex-direction: column; line-height: 1; align-items: flex-start; }
#layout-name { font-size: 13px; }
#layout-save { font-size: 10px; color: var(--blue); margin-top: 1px; }
#layout-save.saved { color: var(--up); }
.tb-btn.pill { border: 1px solid var(--border2); border-radius: 14px; padding: 0 11px; font-weight: 600; }
.tb-btn.pill.primary { background: var(--text-strong); color: var(--bg); border-color: var(--text-strong); }
.tb-btn.pill.primary:hover { opacity: .9; }
.badge { position: absolute; top: -3px; right: -3px; min-width: 14px; height: 14px; padding: 0 3px; border-radius: 7px; background: var(--blue); color: #fff; font-size: 9px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.has-badge { position: relative; }

/* ---------- workspace ---------- */
#workspace { display: grid; grid-template-columns: 1fr var(--sidebar-w); min-height: 0; }
#chart-area { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#chart-container { position: relative; flex: 1; min-height: 0; background: var(--chart-bg); overflow: hidden; }
.chart-canvas { position: absolute; inset: 0; }
.chart-overlay { cursor: crosshair; }
.chart-overlay.dragging { cursor: grabbing; }
.chart-overlay.replay-pick { cursor: cell; }
.loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 14px; background: var(--chart-bg); z-index: 5; }
.loading.error { color: var(--down); white-space: pre-wrap; padding: 24px; text-align: center; }

/* legend */
#legend { position: absolute; left: 10px; top: 6px; z-index: 3; user-select: none; pointer-events: none; }
#legend > * { pointer-events: auto; }
.legend-main { display: flex; align-items: center; gap: 4px; height: 24px; font-size: 15px; color: var(--text); white-space: nowrap; }
.sym-icon { display: inline-flex; width: 17px; height: 17px; border-radius: 50%; background: #f7931a; color: #fff; font-size: 11px; font-weight: 700; align-items: center; justify-content: center; margin-right: 3px; }
.legend-title { color: var(--text); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--up); margin: 0 6px 0 8px; box-shadow: 0 0 0 2px rgba(38,166,154,.25); }
.status-dot.paused { background: var(--muted); box-shadow: none; }
.status-dot.sim { background: var(--blue); box-shadow: 0 0 0 2px rgba(41,98,255,.25); }
.status-dot.pending { background: var(--orange); box-shadow: 0 0 0 2px rgba(255,152,0,.25); }
.status-dot.live { animation: live-pulse 2s ease-in-out infinite; }
@keyframes live-pulse { 0%, 100% { box-shadow: 0 0 0 2px rgba(38,166,154,.25); } 50% { box-shadow: 0 0 0 4px rgba(38,166,154,.08); } }
.legend-ohlc { display: inline-flex; gap: 7px; font-size: 14px; }
.legend-ohlc .k { color: var(--muted); margin-right: 1px; }
.legend-ohlc .v { font-variant-numeric: tabular-nums; }
.legend-ohlc .chg { margin-left: 2px; }
.up { color: var(--up) !important; } .down { color: var(--down) !important; }
.trade-row { display: flex; align-items: center; gap: 8px; margin: 5px 0 6px 0; }
.trade-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 88px; height: 31px; border: 1px solid; border-radius: 4px; line-height: 1; background: var(--chart-bg); }
.trade-btn .tp { font-size: 13px; font-variant-numeric: tabular-nums; }
.trade-btn .tl { font-size: 9.5px; letter-spacing: .3px; margin-top: 2px; }
.trade-btn.sell { color: var(--down); border-color: var(--down); }
.trade-btn.buy { color: var(--blue); border-color: var(--blue); }
.trade-btn:hover { filter: brightness(1.15); }
.trade-btn:active { transform: translateY(1px); }
.spread { font-size: 10px; color: var(--muted2); min-width: 22px; text-align: center; }
.qty-wrap { font-size: 10px; color: var(--muted); margin-left: 6px; display: inline-flex; align-items: center; gap: 4px; opacity: 0; transition: opacity .15s; }
.trade-row:hover .qty-wrap, .qty-wrap:focus-within { opacity: 1; }
.qty-wrap input { width: 58px; padding: 1px 4px; font-size: 11px; height: 20px; }
.ind-list { display: flex; flex-direction: column; gap: 0; }
.ind-row { display: flex; align-items: center; gap: 6px; height: 24px; font-size: 14px; color: var(--text); white-space: nowrap; }
.ind-row.off { color: var(--muted); }
.ind-row .ind-val { font-variant-numeric: tabular-nums; }
.ind-row.off .ind-val { display: none; }
.ind-row .eye { display: inline-flex; width: 20px; height: 18px; align-items: center; justify-content: center; border-radius: 3px; color: var(--muted2); opacity: .9; }
.ind-row .eye:hover { background: var(--hover); color: var(--text); }
.ind-row .eye svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.4; }
.ind-row .rm { color: var(--muted); font-size: 12px; padding: 0 3px; }
.ind-row .rm:hover { color: var(--down); }
.legend-collapse { display: flex; width: 22px; height: 16px; align-items: center; justify-content: center; border: 1px solid var(--border2); border-radius: 3px; background: var(--chart-bg); color: var(--muted2); margin-top: 2px; }
.legend-collapse svg { width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 1.6; }
#legend.collapsed .ind-list { display: none; }
#legend.collapsed .legend-collapse svg { transform: rotate(180deg); }
.rsi-legend { position: absolute; left: 10px; z-index: 3; display: flex; align-items: center; gap: 8px; height: 22px; font-size: 14px; color: var(--text); white-space: nowrap; user-select: none; }
.rsi-legend .v1 { color: var(--purple); } .rsi-legend .v2 { color: #f5b942; }
.rsi-legend .eye { display: inline-flex; width: 20px; height: 18px; align-items: center; justify-content: center; color: var(--muted2); border-radius: 3px; }
.rsi-legend .eye:hover { background: var(--hover); color: var(--text); }
.rsi-legend .eye svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.4; }
.currency-wrap { position: absolute; right: 6px; top: 6px; z-index: 3; }
.currency-wrap select { font-size: 12px; padding: 2px 18px 2px 6px; height: 22px; background: var(--chart-bg); border-color: var(--border2); appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted2) 50%), linear-gradient(135deg, var(--muted2) 50%, transparent 50%); background-position: calc(100% - 9px) 9px, calc(100% - 5px) 9px; background-size: 4px 4px; background-repeat: no-repeat; width: 62px; }
.chart-notice { position: absolute; left: 50%; top: 34px; transform: translateX(-50%); z-index: 4; background: rgba(255,152,0,.12); border: 1px solid var(--orange); color: var(--orange); padding: 4px 10px; border-radius: 4px; font-size: 12px; max-width: 70%; text-align: center; pointer-events: none; }
.chart-notice.info { background: rgba(41,98,255,.12); border-color: var(--blue); color: var(--text); }
.reset-chart { position: absolute; right: 90px; bottom: 32px; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; color: var(--muted2); border-radius: 50%; z-index: 3; }
.reset-chart:hover { color: var(--text); background: var(--hover); }
.reset-chart svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.replay-bar { position: absolute; left: 50%; bottom: 40px; transform: translateX(-50%); z-index: 4; display: flex; align-items: center; gap: 4px; background: var(--panel); border: 1px solid var(--border2); border-radius: 6px; padding: 4px 8px; box-shadow: var(--card-shadow); font-size: 12px; }
.replay-bar button { padding: 3px 7px; border-radius: 3px; }
.replay-bar button:hover { background: var(--hover); }
.replay-bar button.active { background: var(--sel); color: var(--blue); }
.replay-bar .rp-time { color: var(--muted2); font-variant-numeric: tabular-nums; margin: 0 6px; }

/* trade panel */
.trade-panel { height: 190px; border-top: 1px solid var(--border); background: var(--panel); display: flex; flex-direction: column; font-size: 12px; }
.trade-panel .tp-head { display: flex; align-items: center; gap: 12px; padding: 4px 10px; border-bottom: 1px solid var(--border); color: var(--muted2); }
.trade-panel .tp-head b { color: var(--text); font-weight: 600; }
.trade-panel .tp-head .sp { flex: 1; }
.trade-panel .tp-head button { padding: 2px 8px; border: 1px solid var(--border2); border-radius: 3px; }
.trade-panel table { width: 100%; border-collapse: collapse; }
.trade-panel th, .trade-panel td { text-align: left; padding: 3px 10px; font-weight: normal; white-space: nowrap; font-variant-numeric: tabular-nums; }
.trade-panel th { color: var(--muted); position: sticky; top: 0; background: var(--panel); border-bottom: 1px solid var(--border); }
.trade-panel .tp-body { overflow: auto; flex: 1; }
.trade-panel .empty { padding: 16px; color: var(--muted); text-align: center; }

/* ---------- sidebar ---------- */
#sidebar { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-left: var(--gutter) solid var(--border); }
.watchlist { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.wl-header { display: flex; align-items: center; justify-content: space-between; height: 49px; padding: 0 8px 0 10px; }
.wl-title { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; color: var(--text); padding: 4px 6px; border-radius: 4px; }
.wl-title:hover { background: var(--hover); }
.wl-actions { display: flex; gap: 2px; }
.icon-btn { display: inline-flex; width: 28px; height: 28px; align-items: center; justify-content: center; border-radius: 4px; color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; }
.wl-cols, .wl-row { display: grid; grid-template-columns: 1fr 96px 84px 70px; align-items: center; padding-right: 12px; }
.wl-cols { height: 29px; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--border2); padding-left: 12px; }
.wl-cols span:not(:first-child), .wl-row > span:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.wl-body { overflow-y: auto; min-height: 0; scrollbar-width: thin; }
.wl-section { display: flex; align-items: center; gap: 8px; height: 40px; border-bottom: 1px solid var(--border); padding-left: 16px; font-size: 11px; letter-spacing: .5px; color: var(--muted); text-transform: uppercase; cursor: pointer; user-select: none; }
.wl-section .chev { transition: transform .15s; }
.wl-section.collapsed .chev { transform: rotate(-45deg) translate(-2px,2px); }
.wl-section:hover { color: var(--text); }
.wl-row { height: var(--row-h); border-bottom: 1px solid var(--border); font-size: 14px; cursor: pointer; position: relative; }
.wl-row:hover { background: var(--hover); }
.wl-row.selected::after { content: ""; position: absolute; inset: -1px 4px 0 2px; border: 1px solid var(--text); border-radius: 4px; pointer-events: none; }
.wl-row .c-sym { display: flex; align-items: center; gap: 8px; min-width: 0; height: 100%; }
.wl-row .flag { width: 12px; height: 16px; flex: 0 0 12px; border-radius: 1px; }
.wl-row .flag.up { background: var(--up); } .wl-row .flag.down { background: var(--down); }
.wl-row .ico { width: 16px; height: 16px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 700; color: #fff; flex: 0 0 16px; }
.wl-row .tk { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wl-row .mdot { width: 6px; height: 6px; border-radius: 50%; background: var(--orange); flex: 0 0 6px; }
.wl-row .c-last { color: var(--text); }
.wl-row .c-last .d { color: inherit; }
.wl-row.hidden-row { display: none; }

.card { border-top: 1px solid var(--border); padding: 12px 16px 12px; height: 258px; overflow-y: auto; scrollbar-width: thin; flex: 0 0 auto; }
.card .c-head { display: flex; align-items: center; justify-content: space-between; }
.card .c-name { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; color: var(--text); }
.card .c-ico { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #fff; }
.card .c-actions { display: flex; gap: 2px; }
.card .c-sub { color: var(--text); font-size: 13px; margin-top: 6px; display: flex; align-items: center; gap: 6px; }
.card .c-sub .ext { color: var(--muted2); display: inline-flex; }
.card .c-sub .ext svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.card .c-type { color: var(--muted2); font-size: 13px; margin-top: 4px; }
.card .c-price { display: flex; align-items: baseline; gap: 8px; margin-top: 14px; }
.card .c-price .big { font-size: 28px; font-weight: 600; color: var(--text); letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.card .c-price .cur { font-size: 12px; color: var(--muted2); font-weight: 500; }
.card .c-price .chg { font-size: 15px; font-weight: 600; }
.card .c-status { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-top: 6px; }
.card .c-status .dot { width: 7px; height: 7px; border-radius: 50%; }
.card .c-status.open { color: var(--up); } .card .c-status.open .dot { background: var(--up); }
.card .c-status.closed { color: var(--muted2); } .card .c-status.closed .dot { background: var(--muted2); }
.card .news { margin-top: 14px; background: var(--news-bg); border-radius: 6px; padding: 8px 10px; font-size: 12.5px; }
.card .news .n-head { display: flex; gap: 6px; align-items: center; color: var(--muted2); font-size: 12px; }
.card .news .n-head b { color: var(--purple); font-weight: 600; }
.card .news .n-title { color: var(--text); margin-top: 4px; line-height: 1.35; }
.card .news .n-more { color: var(--muted2); margin-top: 4px; background: none; font-size: 12px; }
.card .news .n-more:hover { color: var(--text); }
.card .news .n-item { margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(120,123,134,.25); }
.card .stats-title { font-size: 14px; font-weight: 600; color: var(--text); margin-top: 16px; }
.card .stats { display: grid; grid-template-columns: 1fr auto; row-gap: 5px; column-gap: 12px; margin-top: 8px; font-size: 12.5px; }
.card .stats .k { color: var(--muted2); } .card .stats .v { color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- bottom bar ---------- */
#bottombar { display: flex; align-items: center; justify-content: space-between; height: var(--bottom-h); border-top: 1px solid var(--border); padding: 0 12px 0 6px; background: var(--panel); user-select: none; }
.bb-left, .bb-right { display: flex; align-items: center; gap: 4px; }
.ranges { display: flex; gap: 1px; }
.ranges button { padding: 3px 7px; border-radius: 3px; font-size: 13px; color: var(--text); }
.ranges button:hover { background: var(--hover); }
.ranges button.active { color: var(--blue); background: var(--sel); }
.bb-sep { width: 1px; height: 18px; background: var(--border2); margin: 0 6px; }
.data-chip { font-size: 12px; color: var(--muted2); padding: 3px 8px; border-radius: 3px; }
.data-chip:hover { background: var(--hover); color: var(--text); }
.data-chip .ok { color: var(--up); } .data-chip .warn { color: var(--orange); }
.live-controls { display: flex; align-items: center; gap: 2px; font-size: 12px; }
.live-controls .lbl { color: var(--muted2); margin-right: 4px; }
.live-controls button { padding: 3px 7px; border-radius: 3px; color: var(--text); display: inline-flex; align-items: center; gap: 4px; }
.live-controls button:hover { background: var(--hover); }
.live-controls button.active { color: var(--blue); background: var(--sel); }
.live-controls button.rec.active { color: var(--down); background: rgba(239,83,80,.12); }
.live-controls button.feed.active { color: var(--up); background: rgba(38,166,154,.12); }
.live-controls button.feed.pending { color: var(--orange); background: rgba(255,152,0,.12); }
.feed-status { font-size: 11px; color: var(--muted2); margin: 0 4px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.feed-status.connected { color: var(--up); } .feed-status.reconnecting, .feed-status.error { color: var(--orange); }
.live-controls svg { width: 14px; height: 14px; fill: currentColor; }
.fps { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 46px; text-align: right; }
.clock { font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums; margin-left: 10px; }

/* ---------- menus / modals / toasts ---------- */
#menu-layer { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.menu { position: absolute; min-width: 180px; background: var(--panel); border: 1px solid var(--border2); border-radius: 6px; box-shadow: var(--card-shadow); padding: 4px; pointer-events: auto; font-size: 13px; max-height: 70vh; overflow: auto; }
.menu .mi { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 4px; cursor: pointer; white-space: nowrap; color: var(--text); width: 100%; text-align: left; }
.menu .mi:hover { background: var(--hover); }
.menu .mi.active { color: var(--blue); background: var(--sel); }
.menu .mi .sub { color: var(--muted); margin-left: auto; padding-left: 16px; font-size: 12px; }
.menu .mi svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.4; }
.menu .m-title { padding: 6px 10px 4px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.menu .m-sep { height: 1px; background: var(--border); margin: 4px 0; }
.menu input.m-search { width: 100%; margin-bottom: 4px; }
#modal-layer { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; }
.modal { width: 440px; max-width: 92vw; max-height: 86vh; overflow: auto; background: var(--panel); border: 1px solid var(--border2); border-radius: 8px; box-shadow: var(--card-shadow); font-size: 13px; }
.modal.wide { width: 620px; }
.modal .md-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 15px; font-weight: 600; }
.modal .md-close { color: var(--muted2); font-size: 18px; width: 24px; height: 24px; border-radius: 4px; }
.modal .md-close:hover { background: var(--hover); color: var(--text); }
.modal .md-body { padding: 12px 16px; }
.modal .md-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 16px 14px; }
.modal .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; }
.modal .row label { color: var(--text); }
.modal .row .hint { color: var(--muted); font-size: 12px; }
.modal input[type="text"], .modal input[type="number"], .modal input[type="datetime-local"], .modal select, .modal textarea { width: 220px; }
.modal textarea { width: 100%; min-height: 70px; resize: vertical; font-family: inherit; color: var(--text); background: var(--input-bg); border: 1px solid var(--border2); border-radius: 3px; padding: 6px; }
.modal .seg { display: inline-flex; border: 1px solid var(--border2); border-radius: 4px; overflow: hidden; }
.modal .seg button { padding: 4px 10px; }
.modal .seg button.active { background: var(--sel); color: var(--blue); }
.btn { padding: 6px 14px; border-radius: 4px; border: 1px solid var(--border2); color: var(--text); font-weight: 500; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.danger { color: var(--down); }
.modal table { width: 100%; border-collapse: collapse; font-size: 12px; }
.modal th, .modal td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.modal th { color: var(--muted); font-weight: normal; }
.modal pre { background: var(--panel2); border: 1px solid var(--border); padding: 8px; border-radius: 4px; font-size: 11px; overflow: auto; max-height: 240px; }
.modal .list { max-height: 280px; overflow: auto; }
.modal .list .mi { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 4px; cursor: pointer; width: 100%; text-align: left; }
.modal .list .mi:hover { background: var(--hover); }
.modal .list .mi .sub { color: var(--muted); margin-left: auto; font-size: 12px; }
.modal .list .mi.active { background: var(--sel); }
.modal .kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; }
.modal .kv .k { color: var(--muted); }
#toasts { position: fixed; right: 16px; bottom: 52px; z-index: 70; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.toast { background: var(--panel); border: 1px solid var(--border2); border-left: 3px solid var(--blue); color: var(--text); padding: 8px 12px; border-radius: 4px; font-size: 12.5px; box-shadow: var(--card-shadow); max-width: 360px; animation: toast-in .15s ease-out; }
.toast.warn { border-left-color: var(--orange); } .toast.err { border-left-color: var(--down); } .toast.ok { border-left-color: var(--up); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.kbd { font-family: inherit; font-size: 11px; color: var(--muted2); border: 1px solid var(--border2); border-radius: 3px; padding: 0 4px; }

@media (max-width: 1500px) { :root { --sidebar-w: 380px; } .wl-cols, .wl-row { grid-template-columns: 1fr 84px 74px 62px; } }
@media (max-width: 1100px) { :root { --sidebar-w: 300px; } .tb-btn.with-icon > span:not(.ic):not(.chev) { display: none; } }
@media (max-width: 820px) { #workspace { grid-template-columns: 1fr; } #sidebar { display: none; } }
