:root {
  color-scheme: dark;
  --bg: #080b10;
  --panel: #0d1219;
  --panel-raised: #111923;
  --line: rgba(166, 187, 207, 0.12);
  --line-strong: rgba(166, 187, 207, 0.2);
  --text: #e7edf4;
  --text-soft: #95a5b7;
  --text-dim: #5f7083;
  --accent: #75d9c5;
  --accent-strong: #9af1dc;
  --accent-rgb: 117, 217, 197;
  --up: #ef716d;
  --down: #52c79c;
  --blue: #7ea8e9;
  --blue-rgb: 126, 168, 233;
  --amber: #d9b56f;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
}

:root[data-theme="ocean"] {
  --bg: #080d16;
  --panel: #0d1522;
  --panel-raised: #121d2d;
  --line: rgba(173, 194, 224, .14);
  --line-strong: rgba(173, 194, 224, .24);
  --text: #e7eef8;
  --text-soft: #9eafc5;
  --text-dim: #647994;
  --accent: #6ea8ff;
  --accent-strong: #9bc4ff;
  --accent-rgb: 110, 168, 255;
  --blue: #8bbcff;
  --blue-rgb: 139, 188, 255;
  --amber: #d7b26e;
}

:root[data-theme="amber"] {
  --bg: #0f0d0a;
  --panel: #17130e;
  --panel-raised: #201a12;
  --line: rgba(218, 193, 153, .14);
  --line-strong: rgba(218, 193, 153, .25);
  --text: #f2ede4;
  --text-soft: #bdb09c;
  --text-dim: #827463;
  --accent: #e2b66e;
  --accent-strong: #f4d18d;
  --accent-rgb: 226, 182, 110;
  --blue: #8eb6d9;
  --blue-rgb: 142, 182, 217;
  --amber: #f0c878;
}

:root[data-theme="violet"] {
  --bg: #0d0a13;
  --panel: #151020;
  --panel-raised: #1c1529;
  --line: rgba(194, 173, 231, .14);
  --line-strong: rgba(194, 173, 231, .25);
  --text: #eee9f7;
  --text-soft: #b8abc9;
  --text-dim: #776b89;
  --accent: #b58cff;
  --accent-strong: #d3bbff;
  --accent-rgb: 181, 140, 255;
  --blue: #9aaef0;
  --blue-rgb: 154, 174, 240;
  --amber: #e0bb79;
}

* { box-sizing: border-box; }

html {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  height: 100%;
  min-width: 1040px;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  letter-spacing: 0;
}

button, input { font: inherit; }
button { cursor: pointer; }

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 70% 10%, rgba(var(--accent-rgb), .12), transparent 32%), var(--bg);
}
.auth-view[hidden] { display: none; }
.auth-card {
  width: min(360px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .34);
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}
.auth-card label {
  display: grid;
  gap: 6px;
  color: var(--text-dim);
  font-size: 11px;
}
.auth-card input {
  height: 38px;
  border: 1px solid var(--line-strong);
  background: var(--panel-raised);
  color: var(--text);
  padding: 0 10px;
  outline: none;
}
.auth-card input:focus { border-color: rgba(var(--accent-rgb), .45); }
.auth-card .primary-button { width: 100%; margin-top: 4px; }
.auth-status {
  min-height: 18px;
  color: var(--up);
  font-size: 12px;
}
.app-shell { display: flex; height: 100vh; overflow: hidden; }
.ai-panel { position: relative; flex: 0 0 0; width: 0; overflow: hidden; background: var(--panel); border-left: 0 solid var(--line); transition: flex-basis .22s ease, width .22s ease, border-width .22s ease; }
.ai-panel.open { flex-basis: 360px; width: 360px; border-left-width: 1px; }
.ai-panel.open.fullscreen { position: fixed; z-index: 60; inset: 0 0 0 248px; flex-basis: auto !important; width: auto !important; border-left-width: 1px; box-shadow: -24px 0 46px rgba(0, 0, 0, .34); transition: left .22s ease; }
.ai-resizer { display: none; flex: 0 0 5px; width: 5px; cursor: col-resize; background: transparent; border-left: 1px solid transparent; border-right: 1px solid transparent; }
.ai-resizer:hover, .ai-resizer.dragging { background: rgba(var(--accent-rgb),.12); border-color: rgba(var(--accent-rgb),.28); }
.ai-resizer.open { display: block; }
.ai-resizer.fullscreen { display: none; }
.ai-drawer { position: relative; display: none; height: 100%; margin-left: 0; flex-direction: column; min-width: 0; }
.ai-panel.open .ai-drawer { display: flex; }
.ai-header-button { display: grid; place-items: center; grid-column: -1; grid-row: 1; align-self: start; width: 31px; height: 31px; margin-top: 27px; padding: 0; border: 1px solid var(--line-strong); background: color-mix(in srgb, var(--panel-raised) 78%, transparent); color: var(--text-soft); line-height: 1; transition: background .18s ease, border-color .18s ease, color .18s ease; }
.ai-header-icon { display: block; width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; }
.ai-header-button:hover, .ai-header-button.active { color: var(--accent-strong); background: rgba(var(--accent-rgb),.1); border-color: rgba(var(--accent-rgb),.35); }
.ai-header { flex: 0 0 58px; display: flex; justify-content: space-between; align-items: center; padding: 0 12px; border-bottom: 1px solid var(--line); }
.ai-header strong { display: block; color: var(--text); font-size: 13px; }.ai-header > div:first-child span { display: block; margin-top: 3px; color: var(--text-dim); font-size: 10px; }.ai-header-actions { position: relative; display: flex; gap: 4px; }.ai-header-actions > button { width: 28px; height: 28px; display: grid; place-items: center; border: 0; background: transparent; color: var(--text-soft); font-size: 20px; line-height: 1; }
.ai-header-actions > button:hover, .ai-header-actions > button.active { color: var(--accent-strong); background: rgba(var(--accent-rgb),.1); }
.ai-conversation-trigger { font-size: 0 !important; }
.ai-conversation-trigger .ai-header-icon { width: 16px; height: 16px; }
.ai-conversation-trigger[aria-expanded="true"] { color: var(--accent-strong); background: rgba(var(--accent-rgb),.1); }
.ai-conversation-title { display: -webkit-box; overflow: hidden; color: var(--text-soft); font-size: 12px; font-weight: 600; line-height: 1.25; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.ai-conversation-time { overflow: hidden; color: var(--text-dim); font-size: 10px; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.ai-conversation-menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 12; width: min(360px, calc(100vw - 24px)); max-height: calc(100vh - 86px); max-height: calc(100dvh - 86px); overflow-y: auto; padding: 4px; border: 1px solid var(--line-strong); background: var(--panel); box-shadow: 0 14px 30px rgba(0,0,0,.34); }
.ai-conversation-item { padding: 3px; border-bottom: 1px solid rgba(166,187,207,.08); background: transparent; }
.ai-conversation-item:last-child { border-bottom: 0; }
.ai-conversation-item.is-actions-open { background: rgba(var(--blue-rgb),.045); }
.ai-conversation-item-main { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; gap: 4px; }
.ai-conversation-select { display: grid; width: 100%; gap: 4px; min-height: 62px; padding: 8px 9px; border: 0; background: transparent; color: var(--text-soft); text-align: left; }
.ai-conversation-more { display: grid; width: 28px; height: 28px; align-self: center; place-items: center; padding: 0 0 3px; border: 0; border-radius: 4px; background: transparent; color: var(--text-dim); font-size: 17px; line-height: 1; letter-spacing: 1px; }
.ai-conversation-more:hover, .ai-conversation-more[aria-expanded="true"] { background: rgba(var(--blue-rgb),.12); color: var(--text-soft); }
.ai-conversation-item:hover .ai-conversation-select, .ai-conversation-item.active .ai-conversation-select { background: rgba(var(--accent-rgb),.1); }
.ai-conversation-item.active .ai-conversation-title { color: var(--accent-strong); }
.ai-conversation-actions { display: flex; justify-content: flex-end; margin: 3px 4px 1px; padding: 6px 2px 2px; border-top: 1px solid rgba(166,187,207,.1); }
.ai-conversation-actions button { min-width: 88px; height: 28px; padding: 0 10px; border: 1px solid rgba(239,113,109,.3); border-radius: 4px; background: transparent; color: #ff928e; font-size: 11px; }
.ai-conversation-actions button:hover { border-color: rgba(239,113,109,.55); background: rgba(239,113,109,.12); }
.ai-conversation-empty { padding: 15px 10px; color: var(--text-dim); font-size: 11px; line-height: 1.5; text-align: center; }
.ai-messages { flex: 1; min-height: 0; overflow: auto; padding: 12px; }.ai-empty { color: var(--text-dim); font-size: 12px; line-height: 1.7; }.ai-message { display: flex; margin-bottom: 16px; font-size: 14px; line-height: 1.65; }.ai-message.user { justify-content: flex-end; }.ai-message.user .ai-content { max-width: 80%; padding: 9px 12px; border: 0; border-radius: 14px 14px 3px 14px; background: rgba(var(--accent-rgb),.16); color: var(--text); white-space: pre-wrap; text-align: left; }.ai-message.assistant { justify-content: flex-start; }.ai-message.assistant .ai-content { max-width: 100%; color: var(--text); text-align: left; }.ai-role { display: none; }.ai-content p { margin: 0 0 8px; }.ai-content p:last-child { margin-bottom: 0; }.ai-content h1, .ai-content h2, .ai-content h3 { margin: 12px 0 7px; color: var(--text); line-height: 1.35; }.ai-content h1 { font-size: 18px; }.ai-content h2 { font-size: 16px; }.ai-content h3 { font-size: 14px; }.ai-content ul, .ai-content ol { margin: 6px 0 9px; padding-left: 20px; }.ai-content li { margin: 3px 0; }.ai-content strong { color: #fff09a; }.ai-content em { color: var(--text-soft); }.ai-content blockquote { margin: 8px 0; padding: 5px 9px; border-left: 3px solid var(--blue); color: var(--text-soft); background: rgba(var(--blue-rgb),.08); }.ai-content code { padding: 1px 4px; border-radius: 3px; background: rgba(0,0,0,.28); color: #ffcf8a; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }.ai-content pre { overflow-x: auto; margin: 8px 0; padding: 9px; border: 1px solid var(--line); background: #080d13; }.ai-content pre code { padding: 0; background: transparent; color: var(--text-soft); }.ai-content table { width: 100%; margin: 8px 0; border-collapse: collapse; font-size: 12px; }.ai-content th, .ai-content td { padding: 5px 6px; border: 1px solid var(--line-strong); text-align: left; }.ai-content th { color: var(--text); background: rgba(var(--blue-rgb),.08); }.ai-content td { color: var(--text-soft); }
.ai-composer { position: relative; display: block; padding: 10px; }
.ai-composer textarea { display: block; width: 100%; height: 58px; min-height: 58px; max-height: 180px; overflow-y: auto; scrollbar-width: none; -ms-overflow-style: none; resize: none; border: 1px solid var(--line-strong); border-bottom: 0; border-radius: 8px 8px 0 0; background: var(--panel-raised); color: var(--text); padding: 8px 10px; font-size: 14px; line-height: 1.55; outline: none; }
.ai-composer textarea::-webkit-scrollbar { display: none; }
.ai-composer textarea:focus { border-color: rgba(var(--accent-rgb),.45); }
.ai-composer-actions { display: flex; justify-content: space-between; align-items: center; min-height: 38px; padding: 5px 8px; border: 1px solid var(--line-strong); border-top: 0; border-radius: 0 0 8px 8px; background: var(--panel-raised); }
.ai-composer:focus-within textarea, .ai-composer:focus-within .ai-composer-actions { border-color: rgba(var(--accent-rgb),.45); }
.ai-composer #aiSend { height: 28px; min-width: 48px; padding: 0 9px; border: 0; border-radius: 5px; background: var(--accent); color: #081411; font-size: 14px; font-weight: 700; }
.ai-composer #aiSend:disabled { opacity: .45; cursor: default; }
.ai-quick-question-trigger { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 8px; border: 1px solid rgba(var(--accent-rgb),.32); border-radius: 5px; background: rgba(var(--accent-rgb),.07); color: var(--accent-strong); font-size: 11px; font-weight: 700; }
.ai-quick-question-trigger:hover, .ai-quick-question-trigger[aria-expanded="true"] { border-color: rgba(var(--accent-rgb),.56); background: rgba(var(--accent-rgb),.15); }
.ai-quick-question-menu { position: absolute; right: 10px; bottom: calc(100% + 6px); left: 10px; z-index: 18; display: flex; flex-direction: column; max-height: min(360px, calc(100vh - 240px)); overflow: hidden; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--panel); box-shadow: 0 14px 34px rgba(0,0,0,.42); }
.ai-quick-question-menu[hidden] { display: none !important; }
.ai-quick-question-menu.is-open { display: flex; }
.ai-quick-question-list { min-height: 0; overflow: auto; padding: 4px; }
.ai-quick-question-editing { overflow: visible; }
.ai-quick-question-empty { padding: 18px 10px; color: var(--text-dim); font-size: 11px; line-height: 1.6; text-align: center; }
.ai-quick-question-row { padding: 3px; border-bottom: 1px solid rgba(166,187,207,.08); }
.ai-quick-question-row:last-child { border-bottom: 0; }
.ai-quick-question-row.is-actions-open { background: rgba(var(--blue-rgb),.045); }
.ai-quick-question-row-main { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; gap: 4px; }
.ai-quick-question-ask { min-width: 0; padding: 7px 8px; border: 0; border-radius: 5px; background: transparent; color: var(--text-soft); font-size: 12px; line-height: 1.45; text-align: left; white-space: pre-wrap; }
.ai-quick-question-ask:hover { background: rgba(var(--blue-rgb),.09); color: var(--text); }
.ai-quick-question-more { display: grid; width: 28px; height: 28px; align-self: center; place-items: center; padding: 0 0 3px; border: 0; border-radius: 4px; background: transparent; color: var(--text-dim); font-size: 17px; line-height: 1; letter-spacing: 1px; }
.ai-quick-question-more:hover, .ai-quick-question-more[aria-expanded="true"] { background: rgba(var(--blue-rgb),.12); color: var(--text-soft); }
.ai-quick-question-row-actions { display: flex; justify-content: flex-end; gap: 6px; margin: 3px 4px 1px; padding: 6px 2px 2px; border-top: 1px solid rgba(166,187,207,.1); }
.ai-quick-question-row-actions button { min-width: 58px; height: 28px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 4px; background: transparent; color: var(--text-soft); font-size: 11px; }
.ai-quick-question-row-actions button:hover { border-color: rgba(var(--blue-rgb),.42); background: rgba(var(--blue-rgb),.12); color: var(--text); }
.ai-quick-question-row-actions button.danger { border-color: rgba(239,113,109,.3); color: #ff928e; }
.ai-quick-question-row-actions button.danger:hover { border-color: rgba(239,113,109,.55); background: rgba(239,113,109,.12); }
.ai-quick-question-create { flex: 0 0 auto; display: block; width: calc(100% - 8px); min-height: 32px; margin: 0 4px 4px; padding: 0 8px; border: 0; border-top: 1px solid var(--line); background: transparent; color: var(--text-dim); font-size: 11px; text-align: left; }
.ai-quick-question-create:hover { color: var(--accent-strong); background: rgba(var(--accent-rgb),.06); }
.ai-quick-question-editor { padding: 6px; border-bottom: 1px solid rgba(166,187,207,.08); background: rgba(var(--accent-rgb),.045); }
.ai-quick-question-editor textarea { display: block; width: 100%; min-height: 56px; max-height: 180px; overflow-y: hidden; resize: none; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--panel-raised); color: var(--text); padding: 7px 8px; font-size: 12px; line-height: 1.45; outline: none; }
.ai-quick-question-editor textarea:focus { border-color: rgba(var(--accent-rgb),.48); }
.ai-quick-question-editor-actions { display: flex; justify-content: flex-end; gap: 5px; margin-top: 6px; }
.ai-quick-question-editor-actions button { height: 25px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 4px; background: transparent; color: var(--text-soft); font-size: 11px; }
.ai-quick-question-editor-actions .ai-quick-question-save { border-color: rgba(var(--accent-rgb),.42); background: rgba(var(--accent-rgb),.13); color: var(--accent-strong); }
.ai-quick-question-editor-actions button:hover { border-color: rgba(var(--blue-rgb),.42); color: var(--text); }
.ai-quick-question-editor textarea:disabled, .ai-quick-question-editor-actions button:disabled { cursor: default; opacity: .58; }
.ai-settings button { border: 0; background: var(--accent); color: #081411; padding: 0 12px; font-weight: 700; }
.ai-settings { padding: 10px; border-top: 1px solid var(--line); background: var(--panel-raised); }.ai-settings label { display: block; margin-bottom: 8px; color: var(--text-dim); font-size: 10px; }.ai-settings input { display: block; width: 100%; margin-top: 4px; border: 1px solid var(--line-strong); background: var(--panel); color: var(--text); padding: 7px; font-size: 11px; }.ai-settings-status { color: var(--text-dim); font-size: 10px; }
.ai-clear-key { margin-left: 6px; border: 1px solid rgba(239,113,109,.3) !important; background: transparent !important; color: #ef716d !important; padding: 5px 8px !important; font-size: 10px; }
.ai-thinking { display: inline-flex; align-items: center; gap: 5px; min-height: 20px; padding: 2px 0; }
.ai-thinking span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: .35; animation: aiThinkingPulse 1s ease-in-out infinite; }
.ai-thinking span:nth-child(2) { animation-delay: .16s; }
.ai-thinking span:nth-child(3) { animation-delay: .32s; }
@keyframes aiThinkingPulse { 0%, 80%, 100% { opacity: .32; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.ai-question-nav { position: absolute; right: max(10px, calc((100% - 980px) / 2 + 10px)); bottom: calc(var(--ai-bottom-controls-height, 82px) + 6px); z-index: 3; display: flex; gap: 6px; }
.ai-question-nav[hidden] { display: none; }
.ai-question-nav button { height: 30px; padding: 0 10px; border: 1px solid rgba(var(--accent-rgb),.35); border-radius: 15px; background: var(--panel-raised); color: var(--text); font-size: 12px; font-weight: 600; box-shadow: 0 8px 22px rgba(0,0,0,.32); }
.ai-question-nav button:hover:not(:disabled) { color: #081411; border-color: var(--accent); background: var(--accent); }
.ai-question-nav button:disabled { opacity: .38; cursor: default; color: var(--text-dim); border-color: rgba(166,187,207,.16); background: var(--panel); }
.ai-scroll-bottom { position: absolute; left: 50%; bottom: calc(var(--ai-bottom-controls-height, 82px) + 6px); z-index: 3; width: 30px; height: 30px; border: 1px solid rgba(var(--accent-rgb),.34); border-radius: 50%; background: color-mix(in srgb, var(--panel) 94%, transparent); color: var(--accent-strong); font-size: 16px; line-height: 1; box-shadow: 0 8px 22px rgba(0,0,0,.28); transform: translateX(-50%); }
.ai-scroll-bottom:hover { color: #081411; border-color: var(--accent); background: var(--accent); }
.ai-panel.fullscreen .ai-composer, .ai-panel.fullscreen .ai-settings { width: min(100%, 980px); margin-left: auto; margin-right: auto; }
.ai-panel.fullscreen .ai-header { padding-left: max(18px, calc((100% - 980px) / 2)); padding-right: max(18px, calc((100% - 980px) / 2)); }
.ai-panel.fullscreen .ai-messages { width: 100%; padding: 20px max(18px, calc((100% - 980px) / 2)); }
.ai-panel.fullscreen .ai-message.user .ai-content { max-width: 80%; }
.ai-panel.fullscreen .ai-message.assistant .ai-content { max-width: 100%; }

.sidebar {
  position: relative;
  --sidebar-content-inset: 10px;
  width: 248px;
  height: 100vh;
  padding: 25px 0 12px;
  border-right: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width .22s ease, padding .22s ease;
}

.brand {
  position: relative;
  min-width: 0;
  min-height: 48px;
  padding: 2px 48px 18px 52px;
}
.brand-mark {
  position: absolute;
  left: var(--sidebar-content-inset);
  top: 2px;
  width: 31px; height: 31px; display: grid; place-items: center;
  border: 1px solid rgba(var(--accent-rgb), 0.55);
  color: var(--accent-strong); font-size: 15px; font-weight: 700;
  box-shadow: 0 0 18px rgba(var(--accent-rgb), 0.13);
}
.brand-copy { min-width: 0; transition: opacity .16s ease, transform .2s ease; }
.brand-name { font-size: 14px; letter-spacing: .13em; font-weight: 700; }
.brand-subtitle { margin-top: 3px; color: var(--text-dim); font-size: 8px; letter-spacing: .16em; }
.sidebar-toggle {
  position: absolute;
  right: var(--sidebar-content-inset);
  top: 2px;
  width: 31px;
  height: 31px;
  border: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--panel-raised) 78%, transparent);
  color: var(--text-soft);
  font-size: 20px;
  line-height: 1;
  transition: background .18s ease, border-color .18s ease, color .18s ease, transform .22s ease;
}
.sidebar-toggle:hover { background: rgba(var(--blue-rgb), .09); border-color: rgba(var(--blue-rgb), .35); color: var(--text); }
.sidebar-search { padding: 0 var(--sidebar-content-inset) 12px; }
.brand-mark,
.brand-copy,
.sidebar-search,
.watchlist-head,
.watchlist,
.sidebar-actions,
.account-panel {
  visibility: visible;
}
.sidebar-search { position: relative; }
.sidebar-search .search-wrap { width: 100%; max-width: none; }
.symbol-suggestions { position: absolute; z-index: 30; top: 42px; left: var(--sidebar-content-inset); right: var(--sidebar-content-inset); padding: 4px; border: 1px solid var(--line-strong); background: var(--panel-raised); box-shadow: 0 12px 26px rgba(0, 0, 0, .3); }
.symbol-suggestion { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 0; background: transparent; color: var(--text-soft); text-align: left; cursor: pointer; }
.symbol-suggestion:hover, .symbol-suggestion.active { background: rgba(var(--blue-rgb), .1); color: var(--text); }
.symbol-suggestion-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.symbol-suggestion-meta { flex: 0 0 auto; color: var(--text-dim); font-size: 10px; }
.watchlist-head { padding: 0 var(--sidebar-content-inset) 12px; display: flex; justify-content: space-between; color: var(--text-soft); font-size: 12px; }
.watchlist-head-actions { display: inline-flex; align-items: center; gap: 7px; }
.watchlist-add-divider { width: 20px; height: 20px; padding: 0; border: 1px solid transparent; background: transparent; color: var(--text-dim); font-size: 16px; line-height: 1; }
.watchlist-add-divider:hover { color: var(--accent-strong); border-color: rgba(var(--accent-rgb), .28); background: rgba(var(--accent-rgb), .08); }
.muted { color: var(--text-dim); }
.watchlist {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  overflow: auto;
  padding: 0 var(--sidebar-content-inset);
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.watchlist::-webkit-scrollbar { display: none; }
.watchlist.drag-active { user-select: none; }
.watch-item {
  flex: 0 0 52px;
  width: 100%; height: 52px; padding: 6px 10px 5px; border: 1px solid transparent; background: transparent;
  color: var(--text-soft); text-align: left; display: grid; gap: 4px;
  touch-action: manipulation; min-width: 0;
  transition: background .18s ease, border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.watch-item.menu-open { flex-basis: 84px; height: 84px; }
.watch-item:hover { background: rgba(var(--blue-rgb), .06); border-color: var(--line); transform: translateX(2px); }
.watch-item.active { background: rgba(var(--accent-rgb), .08); border-color: rgba(var(--accent-rgb), .28); color: var(--text); }
.watch-item.dragging {
  background: rgba(var(--accent-rgb), .13);
  border-color: rgba(var(--accent-rgb), .48);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .24);
  color: var(--text);
  cursor: grabbing;
  transform: scale(1.015);
  z-index: 2;
}
.watch-divider { position: relative; flex: 0 0 12px; min-height: 12px; height: 12px; display: flex; align-items: center; padding: 0 8px; color: var(--text-dim); cursor: grab; }
.watch-divider::before, .watch-divider::after { content: ""; height: 1px; flex: 1; background: rgba(var(--accent-rgb), .42); }
.watch-divider.has-title { flex-basis: 20px; min-height: 20px; height: 20px; gap: 6px; }
.watch-divider.is-untitled::before { flex: 1; }
.watch-divider.is-untitled::after { display: none; }
.watch-divider-title { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; letter-spacing: .04em; }
.watch-divider-actions { position: absolute; z-index: 3; right: 6px; top: 50%; display: none; align-items: center; gap: 3px; padding: 2px; transform: translateY(-50%); border: 1px solid var(--line-strong); background: var(--panel); box-shadow: 0 4px 12px rgba(0, 0, 0, .28); }
.watch-divider:hover .watch-divider-actions { display: inline-flex; }
.watch-divider-action { width: 18px; height: 18px; padding: 0; border: 1px solid transparent; background: transparent; color: var(--text-dim); font-size: 11px; }
.watch-divider-action:hover { border-color: var(--line-strong); color: var(--text); background: rgba(var(--blue-rgb), .08); }
.watch-divider.dragging { background: rgba(var(--accent-rgb), .08); cursor: grabbing; }
.watch-row { min-width: 0; display: flex; align-items: center; gap: 8px; }
.watch-main {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  display: grid;
  gap: 2px;
}
.watch-menu-trigger {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--text-dim);
  font-size: 20px;
  line-height: 1;
}
.watch-menu-trigger:hover { background: rgba(var(--blue-rgb), .09); border-color: rgba(var(--blue-rgb), .16); color: var(--text); }
.watch-name { color: #dce6ef; font-size: 16px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.watch-code-line { min-width: 0; display: flex; align-items: center; gap: 5px; }
.watch-code,
.watch-market { color: var(--text-dim); font-size: 11px; font-weight: 500; letter-spacing: .04em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.watch-kdj-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  height: 15px;
  padding: 0 4px;
  border: 1px solid transparent;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 750;
  line-height: 1;
  letter-spacing: .03em;
}
.watch-kdj-badge.is-below { border-color: rgba(91, 157, 255, .58); background: rgba(91, 157, 255, .18); color: #8bbcff; }
.watch-kdj-badge.is-golden { border-color: #f6d64d; background: #f6d64d; color: #081018; }
.watch-menu { display: none; padding: 0 0 1px; }
.watch-item.menu-open .watch-menu { display: block; }
.watch-remove {
  width: 100%;
  height: 28px;
  border: 1px solid rgba(239, 113, 109, .2);
  background: rgba(239, 113, 109, .08);
  color: var(--up);
  font-size: 11px;
  text-align: center;
}
.watch-remove:hover { background: rgba(239, 113, 109, .14); border-color: rgba(239, 113, 109, .32); }
.watch-change { padding: 3px 6px; border: 1px solid rgba(var(--blue-rgb), .2); color: var(--text-dim); font-variant-numeric: tabular-nums; font-size: 10px; white-space: nowrap; }
.empty-list { padding: 14px 10px; color: var(--text-dim); line-height: 1.7; }
.sidebar-actions { margin-top: auto; padding: 12px var(--sidebar-content-inset) 0; }
.sidebar-action-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-action-row > .ghost-button {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.account-menu-group { position: relative; flex: 0 0 38px; }
.account-menu-group .account-menu-trigger {
  width: 38px;
  min-width: 38px;
  padding: 0;
  display: grid;
  place-items: center;
}
.account-menu-trigger svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.account-menu-trigger[aria-expanded="true"] {
  border-color: rgba(var(--accent-rgb), .45);
  background: rgba(var(--accent-rgb), .1);
  color: var(--text);
}
.account-menu {
  position: absolute;
  z-index: 40;
  left: 0;
  bottom: calc(100% + 8px);
  width: 208px;
  padding: 10px;
  border: 1px solid var(--line-strong);
  background: var(--panel-raised);
  box-shadow: 0 14px 30px rgba(0, 0, 0, .34);
}
.account-panel {
  padding: 0 2px 9px;
  border-bottom: 1px solid var(--line);
}
.account-panel span {
  display: block;
  color: var(--text-dim);
  font-size: 10px;
  margin-bottom: 4px;
}
.account-panel strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 600;
}
.account-setting {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  align-items: center;
  gap: 8px;
  padding: 9px 2px 1px;
}
.account-setting label {
  color: var(--text-dim);
  font-size: 11px;
}
.account-setting select {
  width: 100%;
  height: 28px;
  padding: 0 7px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--panel-raised);
  color: var(--text-soft);
  font-size: 11px;
  outline: none;
}
.account-setting select:focus {
  border-color: var(--accent);
}
.account-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}
.account-actions button {
  height: 30px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text-soft);
  font-size: 11px;
}
.account-actions #adminUsersButton,
.account-actions #logoutButton { grid-column: 1 / -1; }
.account-actions button:hover {
  color: var(--text);
  border-color: rgba(var(--blue-rgb), .35);
  background: rgba(var(--blue-rgb), .08);
}

body.sidebar-collapsed .sidebar {
  width: 51px;
  padding: 25px 0 12px;
}
body.sidebar-collapsed .ai-panel.open.fullscreen {
  left: 51px;
}
body.sidebar-collapsed .brand {
  padding: 2px 0 18px 0;
}
body.sidebar-collapsed .brand-mark,
body.sidebar-collapsed .brand-copy,
body.sidebar-collapsed .sidebar-search,
body.sidebar-collapsed .watchlist-head,
body.sidebar-collapsed .watchlist,
body.sidebar-collapsed .sidebar-actions,
body.sidebar-collapsed .account-panel,
body.sidebar-collapsed .account-menu {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-8px);
}
body.sidebar-collapsed .brand-mark,
body.sidebar-collapsed .brand-copy,
body.sidebar-collapsed .sidebar-search,
body.sidebar-collapsed .watchlist-head,
body.sidebar-collapsed .watchlist,
body.sidebar-collapsed .sidebar-actions,
body.sidebar-collapsed .account-panel,
.sidebar-search,
.watchlist-head,
.watchlist,
.sidebar-actions,
.account-panel,
.account-menu {
  transition: opacity .16s ease, transform .2s ease;
}
body.sidebar-collapsed .sidebar-toggle {
  position: absolute;
  left: auto;
  right: var(--sidebar-content-inset);
  top: 2px;
}

.workspace {
  min-width: 0;
  flex: 1;
  height: 100vh;
  padding: 0 10px 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.search-wrap { display: flex; align-items: center; width: 100%; height: 38px; border: 1px solid var(--line-strong); background: color-mix(in srgb, var(--panel-raised) 88%, transparent); }
.search-icon { width: 39px; text-align: center; color: var(--text-dim); font-size: 23px; line-height: 1; transform: rotate(-20deg); }
.search-wrap input { flex: 1; min-width: 0; border: 0; outline: none; color: var(--text); background: transparent; }
.search-wrap input::placeholder { color: var(--text-dim); }
.primary-button, .ghost-button { border: 0; height: 38px; padding: 0 14px; transition: filter .18s ease, background .18s ease, transform .18s ease; }
.primary-button { background: var(--accent); color: #081411; font-weight: 700; }
.primary-button:hover { filter: brightness(1.09); transform: translateY(-1px); }
.ghost-button { border: 1px solid var(--line-strong); color: var(--text-soft); background: transparent; }
.ghost-button:not(:disabled):hover { background: rgba(var(--blue-rgb), .08); border-color: rgba(var(--blue-rgb), .35); color: var(--text); }
.ghost-button:disabled { cursor: default; opacity: .45; }
.button-icon { margin-right: 7px; color: var(--accent); font-size: 16px; }

.instrument-strip {
  min-height: 98px;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(340px, 1.1fr) minmax(0, 2.4fr) 31px;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}
.instrument-primary { min-width: 0; display: flex; align-items: center; gap: 32px; }
.instrument-title { min-width: 0; }
.ticker-line { display: flex; align-items: center; gap: 11px; }
.ticker-line span:first-child { font-size: 22px; letter-spacing: .01em; font-weight: 650; }
.type-tag { padding: 4px 7px; border: 1px solid rgba(var(--blue-rgb), .4); color: var(--blue); font-size: 10px; letter-spacing: .08em; }
.instrument-code { margin-top: 6px; color: var(--text-dim); font-variant-numeric: tabular-nums; letter-spacing: .1em; }
.quote-block { min-width: 130px; }
.last-price { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; }
.daily-change { margin-top: 4px; font-size: 12px; font-variant-numeric: tabular-nums; }
.daily-change.up, .watch-change.up { color: var(--up); }
.daily-change.down, .watch-change.down { color: var(--down); }
.neutral { color: var(--text-dim); }
.metric { min-width: 98px; display: grid; grid-template-rows: 17px 22px 16px; align-content: center; }
.metric span { display: block; color: var(--text-dim); font-size: 11px; line-height: 17px; margin-bottom: 0; }
.metric strong { color: var(--text-soft); font-size: 12px; line-height: 22px; font-weight: 500; font-variant-numeric: tabular-nums; }
.instrument-summary { min-width: 0; display: grid; grid-column: 2; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 16px; align-self: stretch; align-items: center; }
.instrument-summary .insight-card { min-width: 0; display: grid; grid-template-rows: 17px 22px 16px; align-content: center; row-gap: 0; }
.insight-label { line-height: 17px; }
.insight-value { line-height: 22px; }
.market-index-card { grid-template-rows: 17px 22px 16px; }
.market-index-change { min-width: 0; display: flex; align-items: center; gap: 9px; font-size: 10px; line-height: 1.2; font-variant-numeric: tabular-nums; white-space: nowrap; }
.market-index-change > span { min-width: 0; }
.market-index-change.up { color: var(--up); }
.market-index-change.down { color: var(--down); }
#insightDividendYield { color: #ffdf5d; }
.instrument-summary > .metric { min-width: 0; }
#aiToolbarButton { grid-column: 3; grid-row: 1; }

.chart-panel {
  min-height: 0;
  flex: 1;
  margin-top: 12px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 20%, transparent);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chart-toolbar { flex: 0 0 46px; height: 46px; padding: 0 9px 0 16px; display: flex; align-items: center; gap: 13px; border-bottom: 1px solid var(--line); }
.toolbar-group { display: flex; align-items: center; gap: 4px; }
.toolbar-divider { width: 1px; height: 18px; background: var(--line-strong); }
.toolbar-label { color: var(--text-dim); margin-right: 3px; font-size: 11px; }
.period-button, .range-button, .adjust-button, .indicator-button, .overlay-button, .sub-indicator-button, .indicator-menu-trigger, .ma-menu-trigger { border: 0; background: transparent; color: var(--text-dim); padding: 7px 9px; font-size: 11px; }
.period-button:hover, .range-button:hover, .adjust-button:hover, .chart-style-button:hover, .indicator-button:hover, .overlay-button:hover:not(:disabled), .sub-indicator-button:hover:not(:disabled), .indicator-menu-trigger:hover, .ma-menu-trigger:hover:not(:disabled) { color: var(--text-soft); }
.period-button.active, .range-button.active, .adjust-button.active, .chart-style-button.active, .indicator-button.active, .overlay-button.active, .sub-indicator-button.active, .indicator-menu-trigger.active, .ma-menu-trigger.active { background: rgba(var(--accent-rgb), .1); color: var(--accent-strong); }
.chart-style-button, .indicator-button, .overlay-button, .sub-indicator-button, .indicator-menu-trigger, .ma-menu-trigger {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  padding: 7px 9px;
  font-size: 11px;
}
.chart-style-button:disabled, .indicator-button:disabled, .overlay-button:disabled, .sub-indicator-button:disabled, .ma-menu-trigger:disabled { cursor: default; opacity: .38; }
.range-button:disabled { cursor: default; opacity: .28; }
.range-button:disabled:hover { color: var(--text-dim); }
.chart-tools { gap: 5px; }
.chart-tool-button {
  height: 28px;
  min-width: 38px;
  padding: 0 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  font-size: 11px;
  transition: color .18s ease, background .18s ease, border-color .18s ease, opacity .18s ease;
}
.chart-tool-button:hover:not(:disabled) {
  color: var(--text-soft);
  background: rgba(var(--blue-rgb), .09);
  border-color: var(--line);
}
.chart-tool-button.active {
  color: #fff09a;
  background: rgba(246, 214, 77, .12);
  border-color: rgba(246, 214, 77, .34);
}
.trade-marker-tool { position: relative; }
.trade-marker-menu { position: absolute; z-index: 20; top: calc(100% + 6px); right: 0; min-width: 74px; padding: 4px; border: 1px solid var(--line-strong); background: var(--panel-raised); box-shadow: 0 10px 24px rgba(0, 0, 0, .28); }
.trade-marker-option { display: block; width: 100%; padding: 7px 10px; border: 0; background: transparent; color: var(--text-soft); text-align: left; font-size: 11px; cursor: pointer; }
.trade-marker-option:hover { background: rgba(var(--blue-rgb), .1); }
.buy-marker-option { color: #ff9f43; }
.sell-marker-option { color: #7ea8e9; }
.icon-tool-button { min-width: 28px; padding: 0; font-size: 18px; line-height: 1; }
.chart-tool-button:disabled { cursor: default; opacity: .3; }
.toolbar-spacer { flex: 1; }
.indicator-menu-group { position: relative; }
.indicator-menu-trigger {
  min-width: 42px;
  border: 1px solid transparent;
  transition: color .18s ease, background .18s ease, border-color .18s ease;
}
.indicator-menu-trigger.active,
.indicator-menu-trigger[aria-expanded="true"] {
  border-color: rgba(var(--accent-rgb), .28);
}
.indicator-menu {
  position: absolute;
  z-index: 25;
  top: calc(100% + 8px);
  right: 0;
  width: 216px;
  padding: 10px;
  border: 1px solid var(--line-strong);
  background: var(--panel-raised);
  box-shadow: 0 14px 32px rgba(0, 0, 0, .34);
}
.indicator-menu-section + .indicator-menu-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.indicator-menu-label {
  margin-bottom: 7px;
  color: var(--text-dim);
  font-size: 11px;
}
.indicator-menu-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.kdj-watchlist-progress {
  margin-top: 7px;
  color: var(--text-dim);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.indicator-menu .overlay-button,
.indicator-menu .sub-indicator-button {
  min-width: 48px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, .02);
}
.indicator-menu .overlay-button:hover:not(:disabled),
.indicator-menu .sub-indicator-button:hover:not(:disabled) {
  background: rgba(var(--blue-rgb), .09);
  border-color: var(--line);
}
.adjust-group { position: relative; }
.adjust-trigger {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  padding: 7px 9px;
  font-size: 11px;
}
.adjust-trigger:hover { color: var(--text-soft); }
.adjust-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 4;
  display: grid;
  min-width: 92px;
  padding: 4px;
  border: 1px solid var(--line-strong);
  background: #0b1118;
}
.adjust-menu[hidden] {
  display: none;
}
.adjust-menu .adjust-button {
  justify-content: flex-start;
  padding: 7px 9px;
}
.ma-control-group { position: relative; display: flex; align-items: center; gap: 7px; min-width: 0; }
.ma-menu-trigger {
  min-width: 66px;
  border: 1px solid transparent;
  transition: color .18s ease, background .18s ease, border-color .18s ease, opacity .18s ease;
}
.ma-menu-trigger.active,
.ma-menu-trigger[aria-expanded="true"] {
  border-color: rgba(var(--accent-rgb), .28);
}
.ma-menu {
  position: absolute;
  z-index: 25;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  padding: 10px;
  border: 1px solid var(--line-strong);
  background: var(--panel-raised);
  box-shadow: 0 14px 32px rgba(0, 0, 0, .34);
}
.ma-menu[hidden] { display: none; }
.ma-controls { display: grid; gap: 9px; min-width: 0; }
.ma-controls-section { display: grid; gap: 5px; }
.ma-controls-label { color: var(--text-dim); font-size: 10px; letter-spacing: .08em; }
.ma-controls-options { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.ma-toggle {
  height: 25px;
  min-width: 42px;
  padding: 0 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  transition: color .18s ease, background .18s ease, border-color .18s ease, opacity .18s ease;
}
.ma-toggle:hover { color: var(--text-soft); background: rgba(var(--blue-rgb), .08); border-color: var(--line); }
.ma-toggle.active {
  color: var(--ma-color);
  background: color-mix(in srgb, var(--ma-color) 12%, transparent);
  border-color: color-mix(in srgb, var(--ma-color) 42%, transparent);
}
.ma-toggle:disabled {
  cursor: default;
  opacity: .42;
}
.ma-toggle:disabled:hover {
  color: var(--text-dim);
  background: transparent;
  border-color: transparent;
}
.chart-stage { min-height: 0; flex: 1; position: relative; }
#chartCanvas { width: 100%; height: 100%; display: block; touch-action: none; }
#chartCanvas.horizontal-line-mode { cursor: crosshair; }
#chartCanvas.price-range-mode { cursor: crosshair; }
#chartCanvas.trade-marker-mode { cursor: crosshair; }
#chartCanvas:not(.horizontal-line-mode) { cursor: crosshair; }
#chartCanvas.horizontal-line-hover { cursor: row-resize; }
#chartCanvas.horizontal-line-dragging { cursor: row-resize; }
#chartCanvas.price-range-hover { cursor: row-resize; }
#chartCanvas.rsi14-toggle-hover { cursor: pointer; }
#chartCanvas.price-range-dragging { cursor: row-resize; }
.chart-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px; color: var(--text-dim); pointer-events: none; }
.chart-empty strong { color: var(--text-soft); font-size: 14px; font-weight: 500; }
.chart-empty span { font-size: 11px; }
.empty-orbit { width: 42px; height: 42px; margin-bottom: 10px; border: 1px solid rgba(var(--accent-rgb), .22); border-top-color: var(--accent); border-radius: 50%; animation: orbit 3s linear infinite; }
@keyframes orbit { to { transform: rotate(360deg); } }
.chart-tooltip {
  position: absolute;
  left: 58px;
  top: 14px;
  z-index: 3;
  display: none;
  width: min(300px, calc(100% - 88px));
  padding: 14px;
  border: 1px solid rgba(166, 187, 207, .28);
  background: #070b10;
  box-shadow: 0 10px 30px rgba(0,0,0,.28);
  pointer-events: none;
  font-size: 13px;
}
.tooltip-head { color: var(--text-soft); margin-bottom: 11px; font-size: 14px; line-height: 1.3; }
.tooltip-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 20px; row-gap: 9px; color: var(--text-dim); line-height: 1.25; }
.tooltip-grid > span { min-width: 0; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; white-space: nowrap; }
.tooltip-grid b { flex: 0 0 auto; color: var(--text); font-weight: 500; white-space: nowrap; }
.tooltip-magic {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid rgba(166, 187, 207, .12);
}
.tooltip-magic-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--magic-color);
  font-size: 12px;
}
.tooltip-magic-head span { font-weight: 700; }
.tooltip-magic-head b { color: var(--text-soft); font-size: 11px; font-weight: 500; white-space: nowrap; }
.tooltip-magic-reasons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.tooltip-magic-reasons span {
  padding: 4px 6px;
  background: rgba(166, 187, 207, .1);
  color: var(--text-soft);
  font-size: 11px;
  line-height: 1.1;
}
.magic-backtest-panel {
  flex: 0 0 var(--magic-backtest-height, 230px);
  height: var(--magic-backtest-height, 230px);
  min-height: 10px;
  overflow: hidden;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 85%, var(--bg));
  display: flex;
  flex-direction: column;
}
.magic-backtest-panel[hidden] { display: none; }
.magic-backtest-resizer {
  flex: 0 0 8px;
  cursor: row-resize;
  position: relative;
  border-bottom: 1px solid rgba(166, 187, 207, .08);
}
.magic-backtest-resizer::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 3px;
  width: 46px;
  height: 2px;
  transform: translateX(-50%);
  background: rgba(166, 187, 207, .42);
}
.magic-backtest-resizer:hover::before,
.magic-backtest-resizer.dragging::before {
  background: var(--accent-strong);
}
.magic-backtest-content {
  min-height: 0;
  overflow: auto;
}
body.magic-backtest-resizing {
  cursor: row-resize;
  user-select: none;
}
.magic-backtest-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px 8px;
}
.magic-backtest-head strong {
  display: block;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 600;
}
.magic-backtest-head span {
  display: block;
  margin-top: 3px;
  color: var(--text-dim);
  font-size: 10px;
}
.magic-backtest-head p {
  margin: 0;
  color: var(--text-dim);
  font-size: 11px;
  text-align: right;
}
.magic-backtest-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: 14px;
  padding: 0 12px 12px;
}
.magic-backtest-title {
  margin-bottom: 6px;
  color: var(--text-dim);
  font-size: 10px;
}
.magic-backtest-block {
  min-width: 0;
  overflow: auto;
}
.magic-backtest-block table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.magic-backtest-block th,
.magic-backtest-block td {
  padding: 6px 7px;
  border: 1px solid rgba(166, 187, 207, .1);
  color: var(--text-dim);
  text-align: right;
  white-space: nowrap;
}
.magic-backtest-block th:first-child,
.magic-backtest-block td:first-child,
.magic-backtest-block th:nth-child(2),
.magic-backtest-block td:nth-child(2) {
  text-align: left;
}
.magic-backtest-block th {
  color: var(--text-soft);
  background: rgba(var(--blue-rgb), .06);
  font-weight: 500;
}
.magic-recent-table {
  table-layout: fixed;
}
.magic-backtest-block .magic-recent-table th,
.magic-backtest-block .magic-recent-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}
.magic-backtest-block tr.magic-backtest-highlight td {
  background: rgba(255, 240, 154, .04);
  box-shadow: inset 0 1px #fff09a, inset 0 -1px #fff09a;
}
.magic-backtest-block tr.magic-backtest-highlight td:first-child {
  box-shadow: inset 1px 0 #fff09a, inset 0 1px #fff09a, inset 0 -1px #fff09a;
}
.magic-backtest-block tr.magic-backtest-highlight td:last-child {
  box-shadow: inset -1px 0 #fff09a, inset 0 1px #fff09a, inset 0 -1px #fff09a;
}
.magic-signal-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  padding: 2px 6px;
  background: var(--signal-color);
  color: #050807;
  font-weight: 700;
  line-height: 1.1;
}
.magic-backtest-block .positive { color: var(--up); }
.magic-backtest-block .negative { color: var(--down); }
.magic-backtest-empty {
  padding: 8px 12px 12px;
  color: var(--text-dim);
  font-size: 11px;
}

.insight-value { color: var(--text); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.insight-label { color: var(--text-dim); font-size: 11px; white-space: nowrap; }
.toast { position: fixed; right: 30px; bottom: 26px; padding: 12px 15px; border: 1px solid rgba(var(--accent-rgb), .3); background: rgba(11, 19, 23, .96); color: var(--accent-strong); opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

.admin-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(3, 7, 11, .62);
}
.admin-modal[hidden] { display: none; }
.backup-modal {
  position: fixed;
  inset: 0;
  z-index: 82;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(3, 7, 11, .62);
}
.backup-modal[hidden] { display: none; }
.backup-dialog {
  width: min(480px, 100%);
  border: 1px solid var(--line-strong);
  background: var(--panel);
  box-shadow: 0 20px 68px rgba(0, 0, 0, .45);
}
.backup-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px; border-bottom: 1px solid var(--line); }
.backup-head strong { display: block; font-size: 15px; }
.backup-head span { display: block; margin-top: 4px; color: var(--text-dim); font-size: 11px; }
.backup-head button { width: 30px; height: 30px; border: 0; background: transparent; color: var(--text-soft); font-size: 22px; }
.backup-head button:hover { color: var(--accent-strong); background: rgba(var(--accent-rgb), .1); }
.backup-body { padding: 16px; }
.backup-body p { margin: 0; color: var(--text-soft); font-size: 12px; line-height: 1.7; }
.backup-warning { color: var(--text-dim) !important; font-size: 11px !important; }
.backup-primary { width: 100%; height: 36px; margin-top: 16px; border: 1px solid rgba(var(--accent-rgb), .42); background: rgba(var(--accent-rgb), .13); color: var(--accent-strong); font-size: 12px; font-weight: 700; }
.backup-primary:hover:not(:disabled) { border-color: rgba(var(--accent-rgb), .7); background: rgba(var(--accent-rgb), .21); }
.backup-primary:disabled { cursor: default; opacity: .55; }
.backup-source { color: var(--text-dim) !important; font-size: 11px !important; }
.backup-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 12px; }
.backup-summary span { padding: 8px; border: 1px solid rgba(166, 187, 207, .14); background: rgba(var(--blue-rgb), .05); color: var(--text-soft); font-size: 11px; }
.backup-summary strong { display: block; margin-top: 3px; color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }
.admin-dialog {
  width: min(760px, 100%);
  max-height: min(720px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  box-shadow: 0 20px 68px rgba(0, 0, 0, .45);
}
.admin-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}
.admin-head strong { display: block; font-size: 15px; }
.admin-head span { display: block; margin-top: 4px; color: var(--text-dim); font-size: 11px; }
.admin-head button {
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  color: var(--text-soft);
  font-size: 22px;
}
.admin-head button:hover { color: var(--accent-strong); background: rgba(var(--accent-rgb), .1); }
.admin-create {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 112px 70px;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.admin-create input,
.admin-create select,
.admin-user-row input {
  min-width: 0;
  height: 34px;
  border: 1px solid var(--line-strong);
  background: var(--panel-raised);
  color: var(--text);
  padding: 0 9px;
  outline: none;
}
.admin-create button,
.admin-user-row button {
  height: 34px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text-soft);
  font-size: 12px;
}
.admin-create button {
  border-color: rgba(var(--accent-rgb), .34);
  background: rgba(var(--accent-rgb), .12);
  color: var(--accent-strong);
  font-weight: 700;
}
.admin-user-row button:hover,
.admin-create button:hover { border-color: rgba(var(--accent-rgb), .42); color: var(--accent-strong); }
.admin-users-list {
  min-height: 0;
  overflow: auto;
  padding: 8px 16px 16px;
}
.admin-user-row {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) 80px 70px minmax(120px, .8fr) 64px 64px;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(166, 187, 207, .08);
}
.admin-user-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}
.admin-user-main strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 13px;
}
.admin-user-main span,
.admin-user-role,
.admin-user-status {
  color: var(--text-dim);
  font-size: 11px;
}
.admin-user-status.active { color: var(--accent-strong); }
.admin-user-status.inactive { color: var(--up); }

@media (max-width: 1120px) {
  body { min-width: 900px; }
  .sidebar { width: 220px; }
  .workspace { padding-left: 10px; padding-right: 10px; }
  .instrument-strip { grid-template-columns: minmax(290px, 1fr) minmax(0, 2.1fr) 31px; gap: 18px; }
  .instrument-primary { gap: 20px; }
  .instrument-summary { gap: 12px; }
}

@media (max-width: 980px) {
  .instrument-strip { grid-template-columns: minmax(280px, 1fr) minmax(0, 1.9fr) 31px; gap: 18px; }
  .instrument-strip { align-content: center; }
}

@media (max-width: 900px) {
  .instrument-primary { gap: 14px; }
  .instrument-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 12px; }
}

/* AI conversation readability scale */
.ai-empty { font-size: 14px; }
.ai-message { font-size: 16px; }
.ai-content h1 { font-size: 20px; }
.ai-content h2 { font-size: 18px; }
.ai-content h3 { font-size: 16px; }
.ai-content code, .ai-content table { font-size: 14px; }
.ai-composer textarea { font-size: 16px; }
