:root {
  color-scheme: light;
  --bg: #f3f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --line: #dbe3e8;
  --text: #172231;
  --muted: #687686;
  --navy: #091523;
  --navy-soft: #122437;
  --cyan: #168dcc;
  --cyan-dark: #0874ad;
  --green: #139267;
  --red: #ce4650;
  --orange: #ca791d;
  --sidebar-width: 258px;
  --sidebar-compact: 78px;
  font-family: "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; letter-spacing: 0; }
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button { border: 1px solid #c6d0d8; background: white; color: var(--text); min-height: 38px; padding: 8px 13px; cursor: pointer; border-radius: 6px; }
button:hover { background: #f1f6f8; }
button.primary { border-color: var(--cyan-dark); background: var(--cyan-dark); color: white; font-weight: 650; }
button.primary:hover { background: #075f8e; }
button.danger, button.sell { border-color: var(--red); background: var(--red); color: white; }
button.buy { border-color: var(--green); background: var(--green); color: white; }
button.full { width: 100%; margin-top: 16px; }
.hidden { display: none !important; }
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }

.login-screen { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(430px, .75fr); background: var(--navy); }
.login-brand { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; padding: 7vw; color: white; }
.login-brand::before { content: ""; position: absolute; inset: 0; background: linear-gradient(135deg, #07111d 10%, #082641 58%, #07111d 100%); opacity: .92; }
.login-brand::after { content: ""; position: absolute; inset: 0; background-image: linear-gradient(#29a9e910 1px, transparent 1px), linear-gradient(90deg, #29a9e910 1px, transparent 1px); background-size: 52px 52px; mask-image: linear-gradient(to bottom, transparent, black 25%, transparent); }
.login-brand img { position: absolute; width: min(58vw, 720px); opacity: .26; filter: saturate(.9); transform: translate(-9%, -2%); z-index: 1; }
.login-brand > div { position: relative; z-index: 2; width: min(560px, 100%); margin-top: 52vh; }
.login-brand h1 { margin: 5px 0 12px; font-size: clamp(34px, 4vw, 60px); line-height: 1; }
.login-brand p:not(.eyebrow) { color: #bdd0df; font-size: 17px; max-width: 500px; }
.eyebrow { margin: 0; color: #56c5f4; font-size: 12px; font-weight: 700; text-transform: uppercase; }
.login-panel { background: var(--surface); display: flex; flex-direction: column; justify-content: center; padding: clamp(36px, 6vw, 90px); box-shadow: -20px 0 60px #0003; }
.login-heading { display: flex; gap: 14px; align-items: center; margin-bottom: 28px; }
.brand-mark { width: 54px; height: 54px; border-radius: 8px; background: var(--navy); display: grid; place-items: center; overflow: hidden; }
.brand-mark img { width: 56px; height: 56px; object-fit: contain; }
.login-heading h2 { margin: 0; font-size: 27px; }
.login-heading p, .settings-title p, .panel-toolbar p { margin: 3px 0 0; color: var(--muted); }
label { display: block; color: #465463; margin-bottom: 14px; font-weight: 600; }
label small { display: block; color: var(--muted); font-weight: 400; margin-top: 4px; }
input, textarea, select { width: 100%; border: 1px solid #bcc8d1; border-radius: 5px; padding: 10px 11px; margin-top: 5px; color: var(--text); background: white; }
input:focus, textarea:focus, select:focus { outline: 2px solid #168dcc30; border-color: var(--cyan); }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 48px; }
.field-icon { position: absolute; right: 2px; top: 7px; border: 0; background: transparent; width: 42px; padding: 0; min-height: 38px; }
.login-submit { width: 100%; margin-top: 7px; display: flex; justify-content: space-between; font-size: 15px; }
.form-error { color: var(--red); margin: -5px 0 10px; }
.secure-note { margin: 24px 0 0; color: var(--muted); text-align: center; font-size: 12px; }
.secure-note span { color: var(--green); }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-width); background: var(--navy); color: white; z-index: 30; display: flex; flex-direction: column; transition: width .2s ease, transform .2s ease; }
.sidebar-head { height: 76px; padding: 12px 13px; display: grid; grid-template-columns: 48px 1fr 38px; align-items: center; gap: 9px; border-bottom: 1px solid #ffffff12; }
.sidebar-head img { width: 48px; height: 48px; object-fit: contain; }
.brand-copy strong, .brand-copy span { display: block; line-height: 1.05; }
.brand-copy strong { font-size: 16px; }
.brand-copy span { color: #55bdea; margin-top: 4px; font-size: 12px; text-transform: uppercase; }
.icon-button { border: 0; background: transparent; min-width: 38px; min-height: 38px; padding: 6px; font-size: 20px; }
.sidebar .icon-button { color: #c9d6df; }
.side-nav { padding: 17px 10px; flex: 1; }
.nav-item { width: 100%; border: 0; background: transparent; color: #aebdca; display: grid; grid-template-columns: 36px minmax(0, 1fr) 16px auto; gap: 5px; align-items: center; text-align: left; padding: 10px 9px; margin-bottom: 5px; }
.nav-item:hover { background: #ffffff0c; color: white; }
.nav-item.active { background: #168dcc20; color: white; box-shadow: inset 3px 0 var(--cyan); }
.nav-icon { font-size: 18px; text-align: center; }
.nav-label { white-space: nowrap; overflow: hidden; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: block; background: #70808c; }
.status-dot.ok { background: #27c98d; box-shadow: 0 0 0 4px #27c98d18; }
.status-dot.warning { background: #f29a35; }
.status-dot.error { background: #ee5963; }
.nav-count { border-radius: 9px; min-width: 18px; padding: 1px 5px; background: var(--red); color: white; font-size: 11px; text-align: center; }
.sidebar-foot { padding: 10px; border-top: 1px solid #ffffff12; }
.install-button, .logout-button { width: 100%; border: 0; color: #aebdca; background: transparent; display: grid; grid-template-columns: 36px 1fr; text-align: left; align-items: center; }
.install-button:hover, .logout-button:hover { color: white; background: #ffffff0c; }
.profile-wrap { position: relative; }
.profile-button { width: 100%; border: 0; padding: 9px; background: var(--navy-soft); color: white; display: grid; grid-template-columns: 38px 1fr 18px; align-items: center; gap: 8px; text-align: left; margin: 7px 0; }
.profile-button:hover { background: #18314a; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--cyan); font-size: 12px; font-weight: 700; }
.profile-copy strong, .profile-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-copy small { color: #92a9b9; font-size: 11px; margin-top: 2px; }
.profile-menu { position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); padding: 6px; background: white; border: 1px solid var(--line); box-shadow: 0 12px 30px #0004; border-radius: 7px; }
.profile-menu button { border: 0; width: 100%; text-align: left; min-height: 34px; }
.workspace { min-height: 100vh; margin-left: var(--sidebar-width); transition: margin-left .2s ease; }
.sidebar-collapsed .sidebar { width: var(--sidebar-compact); }
.sidebar-collapsed .workspace { margin-left: var(--sidebar-compact); }
.sidebar-collapsed .brand-copy, .sidebar-collapsed .nav-label, .sidebar-collapsed .profile-copy, .sidebar-collapsed .profile-chevron { display: none; }
.sidebar-collapsed .sidebar-head { grid-template-columns: 48px; height: 126px; justify-content: center; }
.sidebar-collapsed .sidebar-head .icon-button { grid-row: 2; }
.sidebar-collapsed .nav-item { grid-template-columns: 36px; justify-content: center; position: relative; }
.sidebar-collapsed .nav-item .status-dot { position: absolute; right: 7px; top: 7px; }
.sidebar-collapsed .nav-count { position: absolute; right: 4px; bottom: 4px; }
.sidebar-collapsed .profile-button { grid-template-columns: 38px; justify-content: center; }
.sidebar-collapsed .install-button, .sidebar-collapsed .logout-button { grid-template-columns: 36px; justify-content: center; }
.sidebar-collapsed .profile-menu { left: 67px; right: auto; width: 220px; bottom: 0; }
.topbar { height: 76px; background: white; border-bottom: 1px solid var(--line); padding: 11px 24px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 20; }
.topbar h1 { font-size: 21px; margin: 1px 0 0; }
.topbar p { margin: 0; color: var(--muted); font-size: 11px; text-transform: uppercase; font-weight: 700; }
.top-status { display: flex; gap: 8px; }
.badge { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 5px 9px; border-radius: 5px; font-size: 12px; font-weight: 650; }
.badge i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.warning { background: #fff1dd; color: #9b5811; }
.badge.ok { background: #e3f6ef; color: #087653; }
.badge.neutral { background: #edf1f4; color: #657382; }
.mobile-menu { display: none; }
.mobile-card-list, .mobile-bottom-nav { display: none; }
main { padding: 20px; }
.view { display: none; }
.view.active { display: block; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.metrics > div { padding: 15px 17px; min-height: 100px; background: white; border: 1px solid var(--line); border-radius: 7px; }
.metrics span, .metrics small { display: block; color: var(--muted); }
.metrics span { font-size: 12px; text-transform: uppercase; font-weight: 650; }
.metrics strong { display: block; margin: 6px 0 3px; font-size: 22px; }
.metrics small { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content-panel, .message-list-panel { background: white; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.history-panel { margin-top: 14px; }
.panel-toolbar { min-height: 69px; padding: 13px 16px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); }
.panel-toolbar.compact { min-height: 54px; padding-left: 0; padding-right: 0; }
.panel-toolbar h2, .panel-toolbar h3 { margin: 0; font-size: 16px; }
.panel-toolbar p { font-size: 12px; }
.toolbar-actions { display: flex; align-items: center; gap: 8px; }
.bordered { border: 1px solid #c6d0d8; font-size: 18px; }
.toggle { display: inline-flex; align-items: center; gap: 7px; margin: 0; font-weight: 500; white-space: nowrap; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; padding: 0; }
.toggle span { width: 32px; height: 18px; border-radius: 9px; background: #aeb9c1; position: relative; transition: .15s; }
.toggle span::after { content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%; left: 2px; top: 2px; background: white; transition: .15s; }
.toggle input:checked + span { background: var(--green); }
.toggle input:checked + span::after { transform: translateX(14px); }
.selection-bar { display: none; min-height: 46px; padding: 7px 16px; background: #edf8fd; align-items: center; gap: 8px; border-bottom: 1px solid #cce5f1; }
.selection-bar.visible { display: flex; }
.selection-bar span { margin-right: auto; color: #315b70; }
.danger.ghost { color: var(--red); background: white; }
.table-wrap { overflow: auto; max-height: 48vh; }
.table-wrap.history { max-height: 32vh; }
table { width: 100%; border-collapse: collapse; min-width: 930px; }
th { position: sticky; top: 0; z-index: 1; background: var(--surface-soft); color: #526170; text-align: left; font-size: 11px; text-transform: uppercase; padding: 10px 12px; border-bottom: 1px solid var(--line); }
td { padding: 10px 12px; border-bottom: 1px solid #e8edf0; white-space: nowrap; }
tbody tr:hover { background: #f7fafb; }
.position-row { cursor: pointer; }
.position-row.selected { background: #eaf7fd; box-shadow: inset 3px 0 var(--cyan); }
td.actions { display: flex; gap: 6px; min-width: 255px; }
button:disabled { opacity: .48; cursor: not-allowed; }
.empty-cell { text-align: center; color: var(--muted); padding: 30px; }
.message-layout { display: grid; grid-template-columns: minmax(300px, .72fr) minmax(440px, 1.28fr); gap: 14px; min-height: calc(100vh - 117px); }
.message-view-tabs { background: white; border: 1px solid var(--line); border-radius: 7px 7px 0 0; margin-bottom: 10px; }
.message-list-panel, .message-detail { min-height: 0; }
.message-list-head { height: 69px; display: flex; justify-content: space-between; align-items: center; padding: 0 15px; border-bottom: 1px solid var(--line); }
.message-list-head h2 { font-size: 16px; margin: 0; }
.message-list-head span { background: #eaf1f5; color: var(--muted); padding: 2px 7px; border-radius: 10px; font-size: 11px; }
.message-list { max-height: calc(100vh - 187px); overflow: auto; }
.message-item { width: 100%; min-height: 70px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; text-align: left; padding: 11px 14px; background: white; }
.message-item.active { background: #edf8fd; box-shadow: inset 3px 0 var(--cyan); }
.message-item strong, .message-item span { display: block; }
.message-item span { color: var(--muted); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.message-item small { display: block; color: #6b7884; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-item-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.message-item-title strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.execution-status { display: inline-flex; flex: 0 0 auto; align-items: center; min-height: 22px; padding: 3px 7px; border-radius: 4px; font-size: 10px; font-style: normal; font-weight: 750; }
.execution-status.ok { color: #087653; background: #e3f6ef; }
.execution-status.warning { color: #94540f; background: #fff1dd; }
.execution-status.error { color: #ad2733; background: #fde8eb; }
.execution-status.neutral { color: #657382; background: #edf1f4; }
.execution-summary { margin: 14px 15px 0; padding: 13px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); }
.execution-summary > div { display: flex; align-items: center; gap: 9px; }
.execution-summary p { margin: 8px 0 4px; color: #344351; }
.execution-summary small { color: var(--muted); }
.message-detail textarea { width: calc(100% - 30px); margin: 15px; min-height: 220px; resize: vertical; }
.parser-head { border-top: 1px solid var(--line); }
pre { min-height: 170px; margin: 15px; background: #0d1b29; color: #dce9f1; border-radius: 5px; padding: 13px; overflow: auto; }
.settings-layout { display: grid; grid-template-columns: 220px minmax(0, 820px); gap: 16px; align-items: start; }
.settings-nav { display: flex; flex-direction: column; background: white; border: 1px solid var(--line); border-radius: 7px; padding: 7px; position: sticky; top: 96px; }
.settings-nav button { border: 0; text-align: left; }
.settings-nav button.active { color: var(--cyan-dark); background: #edf8fd; font-weight: 700; }
.settings-content { background: white; border: 1px solid var(--line); border-radius: 7px; padding: 22px; }
.settings-section { display: none; }
.settings-section.active { display: block; }
.settings-title { padding-bottom: 17px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.settings-title h2 { margin: 0; font-size: 20px; }
.settings-form { max-width: 560px; }
.settings-card { border: 1px solid var(--line); background: var(--surface-soft); padding: 16px; border-radius: 6px; margin-bottom: 14px; }
.settings-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.settings-card-head h3 { margin: 0; font-size: 16px; }
.settings-card-head p { color: var(--muted); margin: 2px 0 0; font-size: 12px; }
.notification-settings { margin-top: 18px; }
.notification-settings .settings-card-head { margin-bottom: 10px; }
.button-link { display: inline-flex; min-height: 38px; padding: 8px 13px; align-items: center; border: 1px solid #c6d0d8; border-radius: 6px; color: var(--text); text-decoration: none; background: white; }
.button-link:hover { background: #f1f6f8; }
.certificate-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.field-help { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 12px 0 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid.three { grid-template-columns: repeat(3, 1fr); }
.setting-toggle { min-height: 42px; }
.account-summary { color: var(--muted); }
.account-summary strong { color: var(--text); }
.market-workspace { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 14px; align-items: start; }
.market-watchlist { height: calc(100vh - 220px); min-height: 570px; background: white; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; display: flex; flex-direction: column; }
.market-search { padding: 11px; border-bottom: 1px solid var(--line); }
.market-search input { margin: 0; }
#marketList { min-height: 0; overflow: auto; }
.market-item { width: 100%; min-height: 62px; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; text-align: left; }
.market-item.active { background: #edf8fd; box-shadow: inset 3px 0 var(--cyan); }
.market-item span, .market-item strong, .market-item small { display: block; min-width: 0; }
.market-item small { margin-top: 3px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.market-item b { font-size: 11px; }
.market-main { min-width: 0; display: grid; gap: 14px; }
.chart-panel { margin: 0; }
.chart-title-line { display: flex; align-items: center; gap: 9px; }
.live-status { padding: 3px 7px; border-radius: 4px; font-size: 10px; font-weight: 750; text-transform: uppercase; }
.live-status.online { color: #087653; background: #e3f6ef; }
.live-status.offline { color: #9b5811; background: #fff1dd; }
.chart-canvas-workspace { display: grid; grid-template-columns: 46px minmax(0, 1fr); background: #0b1825; }
.chart-side-tools { padding: 6px; border-right: 1px solid #263746; background: #101f2d; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.chart-side-tools button { width: 34px; min-height: 34px; padding: 5px; color: #c4d1da; background: transparent; border-color: transparent; font-weight: 750; }
.chart-side-tools button:hover { color: white; background: #20384b; }
.chart-side-tools button.active { color: white; background: var(--cyan-dark); }
.tool-separator { width: 25px; height: 1px; background: #385063; margin: 3px 0; }
.tool-spacer { flex: 1; }
.chart-wrap { height: 560px; position: relative; overflow: hidden; background: #0b1825; }
.chart-wrap canvas { display: block; }
#chartEmpty { position: absolute; inset: 0; display: grid; place-items: center; color: #8fa3b3; }
.chart-hint { position: absolute; left: 12px; bottom: 7px; color: #8195a5; font-size: 10px; pointer-events: none; }
.chart-canvas-workspace:fullscreen { width: 100vw; height: 100vh; grid-template-columns: 50px minmax(0, 1fr); background: #0b1825; }
.chart-canvas-workspace:fullscreen .chart-wrap { height: 100vh; }
.chart-canvas-workspace.fullscreen-fallback { position: fixed; inset: 0; z-index: 200; width: 100vw; height: 100vh; grid-template-columns: 50px minmax(0, 1fr); background: #0b1825; }
.chart-canvas-workspace.fullscreen-fallback .chart-wrap { height: 100vh; }
.indicator-settings-list { display: grid; gap: 9px; }
.indicator-setting-row { display: grid; grid-template-columns: minmax(125px, 1fr) 70px 80px 110px 90px; gap: 8px; align-items: end; padding: 11px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 6px; }
.indicator-setting-row strong { align-self: center; }
.indicator-setting-row label { margin: 0; font-size: 11px; }
.indicator-setting-row input, .indicator-setting-row select { margin: 4px 0 0; }
.indicator-setting-row input[type="color"] { padding: 3px; height: 38px; }
.positions-panel { min-width: 0; }
.compact-market-toolbar { min-height: 58px; }
.positions-table-wrap { max-height: 31vh; }
.positions-table-wrap table { min-width: 1180px; }
.segmented { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.segmented button { border: 0; border-right: 1px solid var(--line); border-radius: 0; min-height: 32px; padding: 5px 9px; }
.segmented button:last-child { border-right: 0; }
.segmented button.active { background: var(--cyan-dark); color: white; }
.channel-workspace { display: grid; grid-template-columns: 300px minmax(0, 1fr); height: calc(100vh - 116px); background: white; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.channel-list-panel { min-width: 0; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.channel-search { padding: 12px; border-bottom: 1px solid var(--line); }
.channel-search input { margin: 0; }
.channel-list { flex: 1; min-height: 0; overflow: auto; }
.channel-list-item { width: 100%; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; gap: 9px; align-items: center; padding: 12px; text-align: left; }
.channel-list-item.active { background: #edf8fd; box-shadow: inset 3px 0 var(--cyan); }
.channel-list-item strong, .channel-list-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-list-item small { color: var(--muted); margin-top: 3px; }
.channel-list-item b { border-radius: 10px; background: #e8eef2; color: var(--muted); text-align: center; font-size: 11px; }
.channel-counters { display: flex; align-items: center; gap: 5px; }
.channel-counters b, .channel-counters em { min-width: 22px; padding: 2px 6px; border-radius: 10px; text-align: center; font-size: 11px; font-style: normal; }
.channel-counters em { background: var(--cyan-dark); color: white; font-weight: 750; }
.channel-add { margin: 12px; }
.channel-detail-panel { min-width: 0; overflow: auto; }
.channel-empty { height: 100%; display: grid; place-content: center; text-align: center; color: var(--muted); }
.channel-empty strong, .channel-empty span { display: block; }
.channel-empty strong { color: var(--text); font-size: 17px; margin-bottom: 5px; }
.channel-detail-head { min-height: 78px; padding: 14px 17px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.channel-title-line { display: flex; gap: 9px; align-items: center; }
.channel-title-line h2 { margin: 0; font-size: 18px; }
.channel-detail-head p { margin: 3px 0 0 17px; color: var(--muted); }
.detail-tabs { display: flex; padding: 0 17px; border-bottom: 1px solid var(--line); }
.detail-tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; }
.detail-tabs button.active { color: var(--cyan-dark); border-bottom-color: var(--cyan); font-weight: 700; }
.channel-tab { display: none; padding: 17px; }
.channel-tab.active { display: block; }
.channel-fields { max-width: 720px; }
.channel-rules-table { overflow: auto; border: 1px solid var(--line); }
.channel-rule-head, .detail-rule-row { min-width: 1040px; display: grid; grid-template-columns: 1fr 1fr 64px 88px 2fr 76px 86px 38px; gap: 8px; align-items: center; }
.channel-rule-head { padding: 8px; background: var(--surface-soft); color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.detail-rule-row { padding: 8px; border-top: 1px solid var(--line); }
.detail-rule-row input { margin: 0; padding: 8px; }
.mt5-symbol-field { position: relative; min-width: 0; }
.compact-toggle { justify-content: center; }
.tp-levels { display: flex; gap: 4px; flex-wrap: wrap; }
.tp-levels label { margin: 0; padding: 4px 6px; border: 1px solid var(--line); border-radius: 4px; font-size: 11px; font-weight: 600; }
.tp-levels input { position: static; opacity: 1; width: auto; height: auto; margin-right: 3px; }
.detail-savebar { display: flex; justify-content: flex-end; gap: 8px; margin-top: 15px; }
.channel-messages-layout { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(300px, .72fr); min-height: 520px; border: 1px solid var(--line); }
.channel-chat { min-height: 0; max-height: calc(100vh - 285px); overflow: auto; padding: 18px; background: #eef5f1; border-right: 1px solid var(--line); }
.chat-bubble { display: block; width: 100%; margin: 0 0 12px; padding: 10px 12px; border: 0; border-radius: 7px; background: #dff4df; color: var(--text); text-align: left; box-shadow: 0 1px 2px #15261c18; }
.chat-bubble.active { box-shadow: 0 0 0 2px var(--cyan); }
.chat-bubble small, .chat-bubble span, .chat-bubble i { display: block; }
.chat-bubble small { color: #527060; font-size: 10px; margin-bottom: 6px; }
.chat-bubble span { white-space: pre-wrap; line-height: 1.45; }
.chat-bubble i { margin-top: 7px; color: var(--cyan-dark); font-size: 11px; font-style: normal; font-weight: 750; }
.channel-message-detail { padding: 12px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.channel-message-detail pre { margin: 0; min-height: 280px; flex: 1; }
.channel-order-list { display: grid; gap: 10px; }
.channel-order-card { padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: white; }
.channel-order-card header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.channel-order-card header strong, .channel-order-card header small { display: block; }
.channel-order-card header small { color: var(--muted); margin-top: 3px; }
.channel-order-card p { margin: 10px 0; color: #3f4d59; }
.channel-order-card > div { display: flex; flex-wrap: wrap; gap: 8px; }
.channel-order-card > div span { padding: 6px 8px; background: var(--surface-soft); border-radius: 4px; color: var(--muted); font-size: 11px; }
.channel-order-card > div b { color: var(--text); }
.history-metrics { grid-template-columns: repeat(4, minmax(140px, 1fr)); }

dialog { width: min(660px, calc(100vw - 28px)); max-height: calc(100vh - 30px); overflow: auto; border: 1px solid var(--line); border-radius: 7px; padding: 0; box-shadow: 0 20px 70px #0005; }
#tradeDialog { width: min(780px, calc(100vw - 28px)); }
dialog::backdrop { background: #07111dc0; }
dialog form { padding: 18px; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.dialog-head h2 { margin: 0; font-size: 19px; }
.dialog-head p { color: var(--muted); margin: 3px 0 0; }
.trade-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.trade-actions button { height: 48px; font-weight: 800; }
.order-kind-picker { width: max-content; margin-bottom: 14px; }
.tp-editor-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.trade-tp-list { display: grid; gap: 7px; margin-top: 8px; }
.trade-live-quote { display: grid; grid-template-columns: 1fr .8fr 1fr; gap: 8px; margin-bottom: 12px; }
.trade-live-quote > div { padding: 10px; border: 1px solid var(--line); border-radius: 6px; text-align: center; background: var(--surface-soft); }
.trade-live-quote span, .trade-live-quote strong { display: block; }
.trade-live-quote span { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.trade-live-quote strong { margin-top: 4px; font-size: 17px; }
.trade-live-quote > div:first-child strong { color: var(--red); }
.trade-live-quote > div:last-child strong { color: var(--green); }
.trade-projection-head { margin-left: auto; display: grid; grid-template-columns: 105px 105px; gap: 7px; color: var(--muted); font-size: 10px; text-align: center; }
.trade-projection-head i { font-style: normal; }
.trade-tp-row { display: grid; grid-template-columns: 35px minmax(130px, 1fr) 105px 105px 38px; gap: 7px; align-items: center; }
.trade-tp-row span { color: var(--muted); font-weight: 700; }
.trade-tp-row input { margin: 0; }
.trade-tp-row > strong { padding: 8px 5px; border-radius: 4px; background: var(--surface-soft); text-align: center; font-size: 12px; }
.trade-sl-projection { display: grid; grid-template-columns: 1fr 105px 105px; gap: 7px; align-items: center; margin-top: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 6px; }
.trade-sl-projection span { color: var(--muted); font-size: 12px; }
.trade-sl-projection strong { text-align: center; font-size: 12px; }
.estimate-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 14px 0; }
.estimate-grid > div { padding: 12px; border: 1px solid var(--line); background: var(--surface-soft); border-radius: 6px; }
.estimate-grid span, .estimate-grid strong { display: block; }
.estimate-grid span { color: var(--muted); font-size: 11px; margin-bottom: 5px; }
.estimate-grid strong { font-size: 18px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 15px; }
.attention { box-shadow: 0 0 0 2px #ef596433; }
.partial-percentages { width: 100%; margin-bottom: 14px; }
.partial-percentages button { flex: 1; }
.form-warning { min-height: 18px; margin: 4px 0 12px; color: var(--red); font-size: 12px; }
.symbol-results { max-height: 135px; overflow: auto; border: 1px solid var(--line); margin: -9px 0 13px; }
.symbol-results:empty { display: none; }
.symbol-results button { width: 100%; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; text-align: left; }
.rule-row { display: grid; grid-template-columns: 1.15fr 1.15fr 90px 95px 38px; gap: 7px; align-items: end; margin: 7px 0; }
.rule-row label { margin-bottom: 0; }
.remove-rule { padding: 6px; color: var(--red); }
#toast { position: fixed; right: 18px; bottom: 18px; z-index: 100; max-width: 420px; background: #102131; color: white; padding: 11px 15px; border-radius: 6px; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .18s; box-shadow: 0 10px 30px #0003; }
#toast.show { opacity: 1; transform: translateY(0); }
.sidebar-overlay { display: none; }

.mobile-action-sheet { width: min(470px, calc(100vw - 20px)); margin: auto auto 10px; border: 0; border-radius: 8px 8px 0 0; overflow: hidden; }
.mobile-action-sheet::backdrop { background: #07111da8; }
.action-sheet-head { min-height: 66px; padding: 12px 13px 10px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.action-sheet-head strong, .action-sheet-head span { display: block; }
.action-sheet-head span { color: var(--muted); margin-top: 2px; font-size: 12px; }
.action-sheet-buttons { padding: 7px; }
.action-sheet-buttons button { width: 100%; border: 0; display: grid; grid-template-columns: 34px 1fr; align-items: center; text-align: left; font-weight: 650; }
.action-sheet-buttons button span { color: var(--cyan-dark); font-size: 19px; text-align: center; }
.action-sheet-buttons button.danger { color: white; }
.action-sheet-buttons button.danger span { color: white; }

@media (max-width: 900px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-panel { min-height: 100vh; padding: 36px max(24px, calc((100vw - 480px) / 2)); }
  .sidebar { transform: translateX(-100%); width: min(290px, 86vw); }
  .workspace, .sidebar-collapsed .workspace { margin-left: 0; }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar-collapsed .sidebar { width: min(290px, 86vw); }
  .sidebar-collapsed .brand-copy, .sidebar-collapsed .nav-label, .sidebar-collapsed .profile-copy, .sidebar-collapsed .profile-chevron { display: block; }
  .sidebar-collapsed .sidebar-head { grid-template-columns: 48px 1fr 38px; height: 76px; }
  .sidebar-collapsed .sidebar-head .icon-button { grid-row: auto; }
  .sidebar-collapsed .nav-item { grid-template-columns: 36px 1fr 16px; justify-content: stretch; }
  .sidebar-collapsed .nav-item .status-dot, .sidebar-collapsed .nav-count { position: static; }
  .sidebar-collapsed .profile-button { grid-template-columns: 38px 1fr 18px; justify-content: stretch; }
  .sidebar-collapsed .profile-menu { left: 0; right: 0; width: auto; bottom: calc(100% + 8px); }
  .sidebar-overlay { position: fixed; inset: 0; background: #07111d99; z-index: 25; }
  .sidebar-overlay.visible { display: block; }
  .mobile-menu { display: inline-block; margin-right: 10px; }
  .topbar { justify-content: flex-start; padding: 10px 14px; }
  .top-status { margin-left: auto; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .message-layout { grid-template-columns: 1fr; min-height: auto; }
  .message-list { max-height: 300px; }
  .settings-layout { grid-template-columns: 1fr; }
  .channel-workspace { grid-template-columns: 240px minmax(0, 1fr); }
  .market-workspace { grid-template-columns: 205px minmax(0, 1fr); }
  .settings-nav { position: static; flex-direction: row; overflow-x: auto; }
  .settings-nav button { white-space: nowrap; }
}

@media (max-width: 620px) {
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  main { padding: 10px; }
  .topbar { height: 68px; }
  .topbar h1 { font-size: 18px; }
  .topbar p { display: none; }
  .top-status .badge { padding: 5px 7px; font-size: 0; }
  .top-status .badge::after { font-size: 11px; content: attr(data-short); }
  .metrics, .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .positions-metrics { grid-template-columns: 1fr 1fr; }
  .metrics { gap: 8px; }
  .positions-metrics > div { min-width: 0; min-height: 74px; padding: 9px 11px; }
  .positions-metrics strong { margin: 3px 0 1px; font-size: 18px; }
  .positions-metrics span { font-size: 10px; }
  .positions-metrics small { font-size: 9px; }
  .panel-toolbar { align-items: flex-start; flex-direction: column; }
  .toolbar-actions { width: 100%; flex-wrap: wrap; }
  .toolbar-actions .primary { flex: 1; }
  .rule-row { grid-template-columns: 1fr 1fr; padding: 10px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 5px; }
  .settings-content { padding: 15px; }
  .market-workspace { display: block; }
  .market-watchlist { height: auto; min-height: 0; border: 0; background: transparent; overflow: visible; }
  .market-search { padding: 0 0 9px; border: 0; }
  #marketList, #allMarketsBtn { display: none; }
  .mobile-card-list { display: grid; gap: 9px; }
  .market-main { display: block; }
  #positionsView[data-mobile-tab="positions"] .market-watchlist { display: none; }
  #positionsView[data-mobile-tab="markets"] .market-main { display: none; }
  #positionsView[data-mobile-tab="positions"] #positionChartPanel { display: none; }
  .positions-panel { border: 0; background: transparent; overflow: visible; }
  .positions-panel .compact-market-toolbar, .positions-panel .selection-bar, .positions-table-wrap { display: none !important; }
  .mobile-trade-card, .mobile-market-card { touch-action: pan-y; user-select: none; background: white; border: 1px solid var(--line); border-radius: 7px; padding: 13px; box-shadow: 0 2px 8px #1224370a; transition: transform .12s, border-color .12s; }
  .mobile-trade-card.pressing, .mobile-market-card.pressing { transform: scale(.985); border-color: var(--cyan); }
  .mobile-trade-card.selected, .mobile-market-card.selected { border-color: #79c8eb; box-shadow: inset 3px 0 var(--cyan); }
  .mobile-trade-card header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; }
  .mobile-trade-card header > div { display: flex; align-items: center; gap: 8px; }
  .mobile-trade-card header strong { font-size: 17px; }
  .mobile-trade-card header > b { font-size: 18px; }
  .side-badge { padding: 2px 6px; border-radius: 4px; color: white; font-size: 10px; font-weight: 800; }
  .side-badge.buy { background: var(--green); }
  .side-badge.sell { background: var(--red); }
  .mobile-card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px 6px; padding-top: 10px; border-top: 1px solid #e8edf0; }
  .mobile-card-grid span, .mobile-card-grid small, .mobile-card-grid strong { display: block; min-width: 0; }
  .mobile-card-grid small { color: var(--muted); font-size: 10px; }
  .mobile-card-grid strong { margin-top: 2px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
  .mobile-card-grid i { font-style: normal; }
  .mobile-trade-card footer, .mobile-market-card footer { margin-top: 10px; color: var(--muted); font-size: 10px; text-align: center; }
  .mobile-market-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; }
  .mobile-market-card > div:first-child strong, .mobile-market-card > div:first-child small { display: block; }
  .mobile-market-card > div:first-child strong { font-size: 16px; }
  .mobile-market-card > div:first-child small { color: var(--muted); font-size: 10px; margin-top: 3px; }
  .mobile-market-card > div:nth-child(2) { display: grid; justify-items: end; font-size: 10px; color: var(--muted); }
  .mobile-market-card > div:nth-child(2) b { font-size: 13px; }
  .mobile-market-card footer { grid-column: 1 / -1; margin-top: 2px; }
  .mobile-empty { padding: 35px 15px; color: var(--muted); text-align: center; }
  .mobile-bottom-nav { position: fixed; z-index: 180; left: 0; right: 0; bottom: 0; min-height: 62px; padding: 5px 8px calc(5px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: white; border-top: 1px solid var(--line); box-shadow: 0 -5px 20px #07111d14; }
  .channel-mobile-nav { grid-template-columns: repeat(4, 1fr); }
  .mobile-bottom-nav button { border: 0; min-height: 52px; padding: 3px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; color: var(--muted); font-size: 10px; background: transparent; }
  .mobile-bottom-nav button span { font-size: 19px; line-height: 1; }
  .mobile-bottom-nav button.active { color: var(--cyan-dark); font-weight: 750; }
  #positionChartPanel.mobile-chart-fullscreen { display: block !important; position: fixed; z-index: 160; inset: 0 0 calc(62px + env(safe-area-inset-bottom)); border: 0; border-radius: 0; background: white; overflow: auto; }
  #positionChartPanel.mobile-chart-fullscreen .panel-toolbar { padding: 9px; min-height: 92px; }
  #positionChartPanel.mobile-chart-fullscreen .toolbar-actions { display: block; }
  #positionChartPanel.mobile-chart-fullscreen #newTradeBtn { display: none; }
  #positionChartPanel.mobile-chart-fullscreen .chart-wrap { height: calc(100vh - 170px - env(safe-area-inset-bottom)); }
  body.mobile-chart-visible #positionsMobileNav [data-position-mobile-tab] { opacity: .35; pointer-events: none; }
  .chart-wrap { height: 470px; }
  .chart-wrap { height: 470px; }
  .chart-canvas-workspace { grid-template-columns: 42px minmax(0, 1fr); }
  .chart-side-tools { overflow-y: auto; }
  .indicator-setting-row { grid-template-columns: 1fr 1fr; }
  .indicator-setting-row strong { grid-column: 1 / -1; }
  .channel-workspace { display: block; height: calc(100vh - 98px); border: 0; background: transparent; overflow: visible; }
  .channel-list-panel { height: 100%; border: 1px solid var(--line); border-radius: 7px; background: white; overflow: hidden; }
  .channel-detail-panel { display: none; position: fixed; z-index: 150; inset: 68px 0 calc(62px + env(safe-area-inset-bottom)); min-height: 0; background: white; overflow: auto; }
  #channelsView.mobile-detail-open .channel-list-panel { display: none; }
  #channelsView.mobile-detail-open .channel-detail-panel { display: block; }
  .channel-mobile-nav { display: none; }
  #channelsView.mobile-detail-open .channel-mobile-nav { display: grid; }
  .channel-detail-head { min-height: 76px; padding: 10px 12px; }
  .channel-detail-head { align-items: flex-start; gap: 10px; }
  .channel-detail-head .toolbar-actions { justify-content: flex-end; }
  .channel-detail-head .toggle { width: auto; }
  .detail-tabs { display: none; }
  .channel-tab { padding: 11px; }
  .channel-messages-layout { grid-template-columns: 1fr; height: auto; }
  .channel-chat { max-height: 380px; border-right: 0; border-bottom: 1px solid var(--line); padding: 11px; }
  .chat-bubble { width: 100%; }
  .trade-projection-head { display: none; }
  .trade-tp-row { grid-template-columns: 30px 1fr 1fr 34px; gap: 4px; }
  .trade-tp-row input { grid-column: 2 / 4; }
  .trade-tp-row .tp-buy-profit { grid-column: 2; grid-row: 2; }
  .trade-tp-row .tp-sell-profit { grid-column: 3; grid-row: 2; }
  .trade-tp-row .remove-rule { grid-column: 4; grid-row: 1; }
  .trade-tp-row > strong { padding: 7px 2px; font-size: 10px; }
  .trade-sl-projection { grid-template-columns: 1fr 1fr; gap: 4px; padding: 8px; }
  .trade-sl-projection span { grid-column: 1 / -1; }
  .trade-sl-projection strong { font-size: 10px; }
  .segmented { width: 100%; overflow-x: auto; }
  .history-metrics { grid-template-columns: 1fr 1fr; }
  .mobile-action-sheet { margin-bottom: calc(6px + env(safe-area-inset-bottom)); }
}
