:root {
  color-scheme: dark;
  --bg: #0b141f;
  --bg-deep: #080f18;
  --panel: #111e2d;
  --panel-2: #101b29;
  --line: #26374b;
  --line-soft: rgba(106, 137, 174, .14);
  --text: #e8edf6;
  --muted: #a1b0c4;
  --quiet: #7f91aa;
  --blue: #4c8dff;
  --blue-dim: rgba(56, 127, 247, .16);
  --gold: #efb94b;
  --gold-dim: rgba(239, 185, 75, .1);
  --rise: #ff5d68;
  --fall: #2dcc98;
  --rise-wick: #ff8990;
  --fall-wick: #56d9b0;
  --rise-volume: rgba(255, 93, 104, .64);
  --fall-volume: rgba(45, 204, 152, .64);
  --up: var(--rise);
  --down: var(--fall);
  --chart-grid: rgba(95, 130, 171, .12);
  --chart-crosshair: rgba(157, 178, 206, .48);
  --shadow: 0 16px 48px rgba(0, 0, 0, .4);
  --sidebar-width: 320px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg-deep); color: var(--text); overflow: hidden; -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button, input { transition: background-color .16s ease, border-color .16s ease, color .16s ease; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
[hidden] { display: none !important; }
button:active { filter: brightness(1.12); }
svg { flex-shrink: 0; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { border-radius: 5px; background: #304158; }
::-webkit-scrollbar-thumb:hover { background: #48607e; }
.app { height: 100%; height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }

.top {
  display: grid; grid-template-columns: calc(var(--sidebar-width) - 34px) minmax(180px, 270px) auto minmax(200px, 1fr) auto;
  grid-template-areas: "brand symbol tfs stats tools";
  align-items: center; gap: 18px; min-height: 76px; padding: 14px 20px; border-bottom: 1px solid var(--line);
  background: linear-gradient(100deg, #0e1b2a, #0b1521 72%);
}
.brand { grid-area: brand; display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { display: flex; width: 40px; height: 40px; color: var(--blue); }
.logo svg { width: 100%; height: 100%; }
.brand h1 { font-size: 19px; font-weight: 650; letter-spacing: .08em; line-height: 1.35; }
.brand p { font-size: 11px; color: var(--muted); margin-top: 3px; letter-spacing: .035em; white-space: nowrap; }
.symbol-box { grid-area: symbol; position: relative; min-width: 0; }
.symbol-btn, .search-input {
  width: 100%; height: 44px; border: 1px solid #344b67; background: linear-gradient(110deg, #142438, #101c2b);
  color: var(--text); border-radius: 8px; padding: 0 14px; font-size: 14px;
}
.symbol-btn { display: flex; align-items: center; gap: 12px; text-align: left; }
.symbol-btn:hover, .symbol-btn[aria-expanded="true"] { border-color: var(--blue); background: #182b44; }
.search-icon { width: 18px; height: 18px; color: #99b5d6; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.symbol-value { display: flex; align-items: baseline; gap: 10px; flex: 1; min-width: 0; white-space: nowrap; }
.symbol-value b { font-size: 17px; letter-spacing: .015em; font-weight: 650; }
.symbol-value span { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.chevron-icon { width: 14px; height: 14px; stroke: var(--muted); stroke-width: 1.5; }
.search-pop {
  display: none; position: absolute; top: calc(100% + 10px); left: 0; width: 360px; max-width: calc(100vw - 32px);
  max-height: min(480px, 70vh); overflow: auto; background: #111f30; border: 1px solid #3b526d;
  border-radius: 10px; box-shadow: var(--shadow); z-index: 20; padding: 10px;
}
.search-pop.open { display: block; }
.search-input { background: #0c1725; font-size: 13px; margin-bottom: 8px; }
input::placeholder { color: var(--quiet); }
.hit { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.hit:hover, .hit.active { background: var(--blue-dim); }
.hit .code { font-weight: 600; }
.hit .name { color: var(--muted); margin-left: 10px; }
.hit > div:last-child { font-variant-numeric: tabular-nums; }
.tfs { grid-area: tfs; display: flex; gap: 2px; padding: 3px; border: 1px solid #30465f; background: #0c1826; border-radius: 8px; }
.tfs button { border: 1px solid transparent; background: transparent; color: var(--muted); height: 36px; min-width: 48px; border-radius: 5px; font-size: 12px; }
.tfs button:hover { color: var(--text); background: rgba(84, 134, 196, .1); }
.tfs button.on, .side-tabs button.on, .sorts button.on {
  background: linear-gradient(110deg, #18417c, #22579d); border-color: #478ef5; color: #f0f5ff;
  box-shadow: inset 0 1px 0 rgba(180, 211, 255, .08); font-weight: 600;
}
.stats { grid-area: stats; display: flex; align-items: center; justify-content: flex-end; gap: 20px; min-width: 0; font-size: 11px; color: var(--muted); }
.stat { display: flex; align-items: baseline; gap: 7px; white-space: nowrap; }
.stat b { color: var(--text); font-size: 13px; font-weight: 550; font-variant-numeric: tabular-nums; }
.stat-last b { font-size: 19px; font-weight: 650; letter-spacing: -.015em; }
.up { color: var(--up) !important; }
.down { color: var(--down) !important; }
.tools { grid-area: tools; display: flex; align-items: center; gap: 8px; }
.tools button { height: 42px; padding: 0 12px; border-radius: 7px; border: 1px solid #324963; background: linear-gradient(120deg, #142436, #0e1a29); color: #c5d2e5; font-size: 12px; white-space: nowrap; }
.tools button:hover { border-color: var(--blue); color: #edf4ff; background: #173053; }
.tools button.is-favorite { color: #bcd5ff; border-color: #416796; }
.tools #tradeToggle { display: flex; align-items: center; gap: 7px; color: #e5efff; }
#tradeToggle svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; }
.tools #tradeToggle.on { border-color: #478ef5; background: #1d4b8e; }

.main { position: relative; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 0; }
.main.trade-open { grid-template-columns: var(--sidebar-width) minmax(0, 1fr) 348px; }
.side { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid #31445d; background: linear-gradient(165deg, #142437, #0e1927 70%); }
.side-controls { flex-shrink: 0; padding: 18px 12px 0; }
.side h2 { padding: 0 2px 12px; font-size: 15px; font-weight: 600; letter-spacing: .035em; }
.filter-wrap { position: relative; margin-bottom: 10px; }
.filter-wrap svg { position: absolute; left: 12px; top: 11px; width: 16px; height: 16px; pointer-events: none; }
.side-filter { width: 100%; height: 38px; border: 1px solid #314862; background: #0c1928; color: var(--text); border-radius: 7px; padding: 0 12px 0 37px; font-size: 12px; }
.side-tabs, .sorts { display: flex; gap: 3px; padding: 3px; background: #0c1826; border: 1px solid #23374d; border-radius: 7px; }
.side-tabs { margin-bottom: 12px; }
.side-tabs button, .sorts button { flex: 1; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--muted); height: 30px; font-size: 12px; }
.side-tabs button:hover:not(.on), .sorts button:hover:not(.on) { color: var(--text); background: #182b40; }
.industries { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.industries button { border: 1px solid #354c67; background: rgba(11, 24, 38, .48); color: #b0bfd3; height: 26px; padding: 0 9px; border-radius: 9px; font-size: 11px; white-space: nowrap; }
.industries button:hover { border-color: #688ab6; background: #1b3049; }
.industries button.on { border-color: #5798ff; color: #d7e7ff; background: #17385f; }
.sorts { margin-bottom: 9px; }
.sorts button { height: 27px; font-size: 11px; }
#watch { flex: 1; min-height: 0; overflow: auto; padding: 0 10px 12px; scrollbar-width: thin; scrollbar-color: #304158 transparent; }
.row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; width: 100%; min-height: 66px; padding: 10px 12px; border: 1px solid transparent; border-bottom-color: var(--line-soft); border-radius: 0; color: var(--text); background: transparent; text-align: left; }
.row:hover { background: rgba(62, 112, 178, .12); border-radius: 6px; }
.row.on { background: linear-gradient(110deg, #173962, #132d50); border-color: #3c6eaf; border-radius: 7px; box-shadow: inset 0 1px 0 rgba(142, 185, 245, .06); }
.row.on::before { content: ""; position: absolute; inset: 0 auto 0 -1px; width: 4px; border-radius: 7px 0 0 7px; background: var(--blue); }
.row .code { font-size: 14px; font-weight: 600; letter-spacing: .02em; }
.stock-meta { display: flex; gap: 10px; min-width: 0; align-items: baseline; margin-top: 5px; }
.row .cname { font-size: 11px; color: #b6c3d6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .ind { font-size: 10px; color: var(--quiet); white-space: nowrap; }
.stock-values { text-align: right; font-variant-numeric: tabular-nums; line-height: 1.35; }
.row .last-price { color: #e5edf9; font-size: 14px; font-weight: 550; }
.row .px { font-size: 11px; }
.row .d5 { font-size: 10px; color: #a6b7cd; margin-top: 1px; }
.d5-label { color: var(--quiet); margin-right: 7px; }
.empty-list { padding: 24px 12px; color: var(--muted); font-size: 12px; text-align: center; }

.chart-wrap { position: relative; min-width: 0; min-height: 0; background: var(--bg); }
#chart { width: 100%; height: 100%; }
.legend { position: absolute; top: 17px; left: 20px; right: 84px; display: flex; align-items: center; flex-wrap: wrap; gap: 9px 14px; z-index: 5; pointer-events: none; font-size: 12px; color: var(--muted); line-height: 1.6; }
.legend strong { color: var(--text); font-size: 15px; font-weight: 600; letter-spacing: .02em; }
.source-badge { display: inline-flex; align-items: center; padding: 1px 7px; border: 1px solid #344b65; border-radius: 5px; font-size: 11px; color: #a9bbd0; background: rgba(18, 35, 53, .85); white-space: nowrap; }
.source-badge.yahoo_aligned, .source-badge.mixed { color: var(--gold); border-color: #786035; background: rgba(85, 66, 25, .12); }
.source-badge.legacy_unknown { color: #ffa28f; border-color: #835648; }
.ohlc { display: inline-flex; gap: 13px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.ohlc i { font-style: normal; }
.ohlc i > span { margin-left: 6px; }
.ma5 { color: var(--gold); font-variant-numeric: tabular-nums; }
.ma5 b { margin-left: 5px; font-weight: 500; }
.legend-change { font-variant-numeric: tabular-nums; }
.chart-boundary { display: none; position: absolute; top: 58px; bottom: calc(18% + 28px); width: 0; border-left: 1px dashed rgba(239, 185, 75, .6); z-index: 3; pointer-events: none; }
.chart-tooltip { display: none; position: absolute; z-index: 5; width: 190px; padding: 12px; border: 1px solid #344960; border-radius: 7px; background: rgba(14, 27, 42, .97); box-shadow: 0 8px 24px rgba(0, 0, 0, .25); pointer-events: none; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.tooltip-date { margin-bottom: 8px; color: #d0dbee; font-size: 12px; }
.chart-tooltip .source-badge { margin-bottom: 8px; font-size: 10px; }
.tooltip-row { display: flex; justify-content: space-between; gap: 12px; line-height: 1.9; }
.tooltip-row b { color: var(--text); font-weight: 500; }
.tooltip-row.ma5 b { color: var(--gold); }
.mask { position: absolute; inset: 0; display: none; place-items: center; background: rgba(11, 20, 31, .7); backdrop-filter: blur(3px); z-index: 6; color: #b2c4dc; font-size: 13px; }
.mask.show { display: grid; }

.drawing-layer { position: absolute; top: 0; left: 0; overflow: hidden; z-index: 4; pointer-events: none; }
.drawing-line { stroke: var(--drawing-color, #9dbef3); stroke-width: var(--drawing-width, 1.5px); fill: none; vector-effect: non-scaling-stroke; }
.drawing-midline { stroke-dasharray: 5 5; stroke-opacity: .7; }
.drawing-fill { fill: var(--drawing-color, #79a9ef); fill-opacity: var(--drawing-fill, .045); }
.drawing.selected .drawing-line, .drawing.selected .drawing-rect { filter: brightness(1.15); }
.drawing.preview .drawing-line { stroke-dasharray: 5 4; stroke-opacity: .85; }
.drawing-arrow-path, .drawing-arrowhead { stroke-linecap: round; stroke-linejoin: round; }
.drawing.preview .drawing-arrowhead { stroke-dasharray: none; }
.drawing-rect { fill: var(--drawing-color); fill-opacity: var(--drawing-fill); stroke: var(--drawing-color); stroke-width: var(--drawing-width); vector-effect: non-scaling-stroke; }
.drawing-baseline { stroke-dasharray: 4 5; stroke-opacity: .5; }
.drawing-fib-label { font-size: 11px; font-variant-numeric: tabular-nums; paint-order: stroke; stroke: var(--bg); stroke-width: 3px; stroke-linejoin: round; }
.drawing-price-label rect { fill: var(--bg); stroke: var(--drawing-color); stroke-width: 1; }
.drawing-price-label text { fill: var(--drawing-color); font-size: 11px; font-variant-numeric: tabular-nums; }
.drawing-anchor { fill: #14253b; stroke: #c0d7fa; stroke-width: 1.5; }
.drawing-cursor line { stroke: var(--chart-crosshair); stroke-width: 1; stroke-dasharray: 5 5; }
.chart-wrap.is-drawing, .chart-wrap.is-drawing #chart { cursor: crosshair; }
.chart-wrap.over-drawing, .chart-wrap.over-drawing #chart { cursor: move; }
.drawing-palette {
  position: absolute; top: 0; left: 0; display: flex; align-items: center; gap: 2px; padding: 4px;
  z-index: 7; flex-wrap: wrap; width: min(376px, calc(100% - 84px)); min-height: 52px; border: 1px solid #3b3e45; border-radius: 10px;
  background: #242528; box-shadow: 0 5px 18px rgba(0, 0, 0, .32); user-select: none;
}
.drawing-palette button {
  display: grid; place-items: center; width: 44px; height: 44px; padding: 4px; border: 1px solid transparent; flex-shrink: 0;
  border-radius: 6px; color: #e5e6e8; background: transparent;
}
.drawing-palette button:hover { background: #37393d; }
.drawing-palette button.on { background: #3c414a; border-color: #647b9d; color: #c8ddff; }
.drawing-palette button:disabled { cursor: default; opacity: .4; background: transparent; }
.drawing-palette button svg { width: 32px; height: 30px; stroke: currentColor; stroke-width: 1.35; stroke-linecap: round; stroke-linejoin: round; }
.drawing-palette .drawing-config-btn svg { width: 23px; height: 23px; }
.drawing-palette button circle { fill: #242528; }
.drawing-palette .drawing-grip { width: 44px; flex-shrink: 0; padding: 8px 12px; color: #8b8e94; cursor: grab; touch-action: none; }
.drawing-palette .drawing-grip svg { width: 18px; height: 28px; stroke: none; }
.drawing-palette .drawing-grip circle { fill: currentColor; }
.drawing-palette.dragging .drawing-grip { cursor: grabbing; background: #37393d; }
.drawing-hint {
  position: absolute; z-index: 7; display: flex; align-items: center; gap: 8px; padding: 5px 10px;
  border: 1px solid #3b3e45; border-radius: 6px; background: #242528; color: #c7cbd2;
  font-size: 11px; line-height: 1.5; box-shadow: 0 3px 12px rgba(0, 0, 0, .22); user-select: none;
}
.drawing-hint button { display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 5px; background: transparent; color: #c7cbd2; flex-shrink: 0; }
.drawing-hint button:hover { color: #ff9299; background: #443036; }
.drawing-hint svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
@media (pointer: coarse) { .drawing-hint button { width: 44px; height: 44px; } }

.drawing-settings { margin: auto; width: min(440px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); padding: 20px; overflow: auto; border: 1px solid #414955; border-radius: 12px; background: #24272c; color: var(--text); box-shadow: var(--shadow); }
.drawing-settings::backdrop { background: rgba(3, 8, 14, .6); }
.drawing-settings-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.drawing-settings h2 { font-size: 17px; font-weight: 600; }
.drawing-settings button { border: 1px solid #46505e; border-radius: 6px; background: #30363e; color: #dbe4f3; padding: 7px 10px; font-size: 12px; min-height: 34px; }
.drawing-settings button:hover { background: #414955; }
.drawing-settings button:disabled { opacity: .4; cursor: default; }
.drawing-settings-heading button { border: none; background: transparent; width: 36px; height: 36px; padding: 8px; }
.drawing-settings svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; }
.drawing-settings-note { color: #aeb7c5; font-size: 11px; line-height: 1.7; margin: 4px 0 10px; }
.drawing-setting-section { border: 0; border-top: 1px solid #3c424c; margin-top: 16px; padding-top: 12px; min-width: 0; }
.drawing-setting-section legend { font-size: 12px; font-weight: 600; padding-right: 10px; color: #d5ddeb; }
.drawing-settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.drawing-setting-field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: #b8c2d1; min-width: 0; }
.drawing-settings input:not([type="checkbox"]):not([type="range"]), .drawing-settings select { width: 100%; height: 36px; padding: 6px 9px; border: 1px solid #46505e; border-radius: 5px; background: #191e26; color: #e4ebf5; font-size: 13px; font-variant-numeric: tabular-nums; min-width: 0; }
.drawing-settings input[type="color"] { cursor: pointer; padding: 3px !important; }
.drawing-settings input[type="range"] { width: 100%; accent-color: #8fb7f7; height: 18px; margin-top: 2px; }
.drawing-setting-field output { color: #dce5f5; font-size: 11px; margin-top: -4px; }
.drawing-setting-checks { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 12px; }
.drawing-setting-checks label, .drawing-save-default { display: flex; align-items: center; gap: 7px; font-size: 12px; color: #c2ccda; }
.drawing-settings input[type="checkbox"] { accent-color: var(--blue); width: 16px; height: 16px; cursor: pointer; flex-shrink: 0; }
.drawing-fib-levels { display: flex; flex-direction: column; gap: 7px; }
.drawing-level-row { display: grid; grid-template-columns: 20px minmax(0, 1fr) 44px 34px; align-items: center; gap: 8px; }
.drawing-level-row button { padding: 6px; width: 34px; height: 36px; }
.drawing-level-actions { display: flex; gap: 8px; margin-top: 10px; }
.drawing-save-default { margin-top: 16px; }
.drawing-settings-error { color: #ffb0b6; font-size: 12px; margin-top: 12px; line-height: 1.6; }
.drawing-settings-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid #3c424c; }
.drawing-settings-actions button:last-child { border-color: #6099ef; background: #22518c; color: #f0f6ff; }
@media (max-width: 480px) {
  .drawing-settings { padding: 16px; }
  .drawing-settings input:not([type="checkbox"]):not([type="range"]), .drawing-settings select { font-size: 16px; height: 44px; }
  .drawing-settings button { min-height: 44px; }
  .drawing-level-row { grid-template-columns: 20px minmax(0, 1fr) 44px 44px; }
  .drawing-level-row button { width: 44px; height: 44px; }
}

.trade-panel { min-height: 0; overflow-y: auto; border-left: 1px solid var(--line); padding: 14px 12px; background: linear-gradient(160deg, #111f30, #0c1724 70%); }
.trade-card { border: 1px solid #324961; border-radius: 9px; padding: 14px; background: #101d2c; }
.trade-heading { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; background: #101d2c; box-shadow: 0 -16px 0 #101d2c; }
.trade-heading h2 { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 600; }
.trade-heading h2 span { border: 1px solid #4172a9; border-radius: 5px; padding: 2px 6px; color: #a9cfff; background: var(--blue-dim); font-size: 11px; font-weight: 500; }
.trade-close { display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); }
.trade-close:hover { color: var(--text); background: #203650; }
.trade-close svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.trade-symbol { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; margin-bottom: 14px; }
.trade-symbol strong { font-size: 13px; font-weight: 600; }
.trade-symbol > span { font-size: 12px; color: var(--muted); }
.trade-segment { display: flex; gap: 3px; padding: 3px; border: 1px solid #30465f; background: #0c1826; border-radius: 7px; }
.trade-segment button { flex: 1; min-width: 0; min-height: 34px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--muted); font-size: 12px; white-space: nowrap; }
.trade-segment button:hover { color: var(--text); background: #182b40; }
.trade-segment button.on { border-color: #478ef5; background: #1b4986; color: #f0f5ff; font-weight: 600; }
.trade-section-label { color: var(--muted); font-size: 11px; margin: 14px 0 7px; }
.trade-units button { font-size: 11px; }
#tradeForm { margin-top: 16px; }
.trade-field { display: grid; grid-template-columns: 72px minmax(0, 1fr); align-items: center; gap: 8px; margin-top: 12px; }
.trade-field label { color: #b5c6dc; font-size: 12px; }
.trade-input-wrap { position: relative; min-width: 0; }
.trade-input-wrap input { width: 100%; min-height: 40px; border: 1px solid #385471; border-radius: 6px; padding: 9px 53px 9px 11px; outline: none; background: #0c1827; color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.trade-input-wrap input::-webkit-inner-spin-button, .trade-input-wrap input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.trade-input-wrap input:focus { border-color: var(--blue); }
.trade-input-wrap input[aria-invalid="true"] { border-color: var(--rise); }
.trade-input-wrap > span { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: #8fa4c0; font-size: 10px; pointer-events: none; }
.trade-field select { justify-self: start; min-width: 86px; height: 38px; padding: 0 9px; border: 1px solid #385471; border-radius: 6px; background: #0c1827; color: var(--text); font-size: 13px; }
.trade-hint { color: var(--quiet); font-size: 10px; line-height: 1.6; margin: 5px 0 0 80px; }
.trade-latest { grid-column: 2; justify-self: end; margin-top: -5px; border: 0; min-height: 25px; background: transparent; color: #8bbbff; font-size: 11px; }
.trade-latest:hover { color: #d5e6ff; }
.trade-latest:disabled { opacity: .4; cursor: default; }
.trade-profit-input::before, .trade-loss-input::before { content: ""; position: absolute; top: 1px; bottom: 1px; left: 1px; width: 3px; border-radius: 5px 0 0 5px; background: var(--up); }
.trade-loss-input::before { background: var(--down); }
.trade-error { margin-top: 12px; padding: 9px 10px; border: 1px solid #79514f; border-radius: 6px; color: #ffb6ad; background: rgba(255, 112, 91, .06); font-size: 11px; line-height: 1.6; }
.trade-results { margin-top: 16px; font-variant-numeric: tabular-nums; }
.trade-results[aria-busy="true"] { opacity: .5; }
.trade-position { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; padding: 12px 10px; border: 1px solid #2d4865; border-radius: 7px; background: #102237; }
.trade-position > div { min-width: 0; }
.trade-position > div:nth-child(2) { padding-left: 10px; border-left: 1px solid #2d4865; }
.trade-position span { display: block; color: #9db4ce; font-size: 10px; margin-bottom: 5px; }
.trade-position strong { display: block; overflow-wrap: anywhere; font-size: 12px; font-weight: 550; }
.trade-position p { grid-column: 1 / -1; text-align: right; color: #93aeca; font-size: 10px; line-height: 1.6; margin-top: 3px; }
.trade-position p b { font-weight: 400; }
.trade-pnl { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 5px 10px; margin-top: 16px; }
.trade-pnl > span { color: #b5c6dc; font-size: 12px; }
.trade-pnl strong { font-size: 19px; font-weight: 600; letter-spacing: -.025em; }
.trade-note { margin-top: 15px; font-size: 10px; line-height: 1.6; color: var(--quiet); }
.trade-data-status { font-size: 10px; color: var(--gold); line-height: 1.6; margin-top: 5px; }
.trade-data-status:empty { display: none; }
a#tv-attr-logo, #tv-attr-logo { display: none !important; }
.foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 34px; padding: 7px 18px; border-top: 1px solid var(--line); color: #a5b6ce; font-size: 11px; background: #0c1724; }
.source-info { display: flex; align-items: center; gap: 9px; min-width: 0; }
.source-info svg { width: 15px; height: 15px; stroke: #719edc; stroke-width: 1.4; stroke-linecap: round; }
.foot #clock { flex-shrink: 0; font-variant-numeric: tabular-nums; color: var(--quiet); }

@media (max-width: 1740px) {
  :root { --sidebar-width: 300px; }
  .top { grid-template-columns: 180px minmax(160px, 230px) auto minmax(200px, 1fr) auto; gap: 14px; padding-inline: 16px; }
  .stats { gap: 12px; }
  .tfs button { min-width: 43px; }
}
@media (max-width: 1440px) {
  .top { grid-template-columns: 180px minmax(190px, 1fr) auto auto; grid-template-areas: "brand symbol tfs tools" "brand stats stats stats"; gap: 10px 16px; padding-block: 12px; }
  .stats { justify-content: flex-start; gap: 24px; }
  .stat-last b { font-size: 17px; }
}
@media (max-width: 1100px) {
  :root { --sidebar-width: 270px; }
  .top { grid-template-columns: 160px minmax(160px, 1fr) auto; grid-template-areas: "brand symbol tools" "tfs tfs stats"; gap: 10px 12px; }
  .tfs { justify-self: start; }
  .stats { justify-content: flex-end; }
  .stat:not(.stat-last) { display: none; }
  .side-controls { padding-inline: 10px; }
  .stock-meta { gap: 6px; }
  .row { padding-inline: 10px; }
}
@media (max-width: 1200px) {
  .main.trade-open { grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
  .trade-panel { position: absolute; right: 0; top: 0; bottom: 0; width: min(348px, 100%); z-index: 10; box-shadow: -12px 0 30px rgba(0, 0, 0, .3); }
}
@media (min-width: 801px) and (max-height: 820px) {
  .trade-panel { padding: 10px 12px; }
  .trade-card { padding: 10px 14px; }
  .trade-heading { margin-bottom: 8px; }
  .trade-symbol { margin-bottom: 8px; }
  .trade-segment button { min-height: 30px; }
  .trade-section-label, .trade-hint { display: none; }
  .trade-units { margin-top: 8px; }
  #tradeForm { margin-top: 10px; }
  .trade-field { margin-top: 6px; }
  .trade-input-wrap input { min-height: 34px; padding-block: 7px; }
  .trade-field select { height: 32px; }
  .trade-entry-field { grid-template-rows: 17px 17px; row-gap: 2px; }
  .trade-entry-field > label { grid-column: 1; grid-row: 1; }
  .trade-entry-field > .trade-input-wrap { grid-column: 2; grid-row: 1 / span 2; }
  .trade-entry-field > .trade-latest { grid-column: 1; grid-row: 2; justify-self: start; min-height: 18px; margin-top: 0; font-size: 10px; }
  .trade-results { margin-top: 10px; }
  .trade-position { padding-block: 8px; }
  .trade-position span { margin-bottom: 3px; }
  .trade-pnl { margin-top: 10px; }
  .trade-pnl strong { font-size: 18px; }
  .trade-note { margin-top: 9px; }
}
@media (max-width: 800px) {
  .main, .main.trade-open { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .top { grid-template-columns: minmax(140px, 1fr) minmax(160px, 1fr); grid-template-areas: "brand tools" "symbol stats" "tfs tfs"; }
  .tools { justify-content: flex-end; }
  .tfs { width: 100%; justify-self: stretch; }
  .tfs button { flex: 1; min-width: 0; }
  .legend { top: 12px; left: 12px; right: 68px; gap: 5px 10px; font-size: 11px; }
  .legend strong { font-size: 13px; }
  .ohlc { gap: 5px 9px; }
  .foot { flex-wrap: wrap; gap: 5px; padding-inline: 12px; font-size: 10px; }
  .chart-tooltip { width: 172px; padding: 10px; }
  .trade-close { width: 44px; height: 44px; }
  .trade-segment button { min-height: 40px; }
  .trade-input-wrap input { font-size: 16px; min-height: 44px; }
  .trade-field select { min-height: 44px; }
}
@media (max-width: 480px) {
  .top { padding: 10px 12px; gap: 10px; }
  .brand { gap: 8px; }
  .brand h1 { font-size: 16px; }
  .brand p { font-size: 9px; }
  .logo { width: 30px; height: 34px; }
  .tools { gap: 5px; }
  .tools button { padding-inline: 8px; height: 36px; font-size: 11px; }
  .tools #tradeToggle { gap: 4px; }
  #tradeToggle svg { display: none; }
  .trade-panel { width: 100%; padding: 10px 12px; }
  .symbol-btn { gap: 8px; padding-inline: 10px; }
  .symbol-value { gap: 6px; }
  .symbol-value b { font-size: 14px; }
  .symbol-value span { font-size: 11px; }
  .stat-last { flex-direction: column; align-items: flex-end; gap: 1px; }
  .stat-last b { font-size: 16px; }
  .legend-change { display: none; }
}
@media (max-width: 360px) {
  .top { grid-template-columns: minmax(0, 1fr) auto; }
  .tools { gap: 4px; }
  .tools button { padding-inline: 6px; font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
