:root {
  color-scheme: dark;
  --bg: #080d0c;
  --surface: #0d1412;
  --surface-2: #111b18;
  --surface-3: #16221e;
  --line: #20312c;
  --line-soft: #172420;
  --text: #edf6f1;
  --muted: #7f948c;
  --muted-2: #51655d;
  --green: #29e38d;
  --green-soft: rgba(41, 227, 141, 0.1);
  --red: #ff5f6d;
  --red-soft: rgba(255, 95, 109, 0.1);
  --amber: #ffbd59;
  --sidebar: 128px;
  --radius: 16px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { min-width: 320px; font-size: 24px; }
button, input, select { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) 1fr; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); padding: 22px 14px;
  border-right: 1px solid var(--line-soft); background: #090f0e; z-index: 10;
  display: flex; flex-direction: column;
}
.logo { display: flex; flex-direction: column; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .05em; }
.logo-mark {
  width: 42px; height: 42px; display: grid; place-items: center; color: #07100c;
  border-radius: 13px; background: linear-gradient(145deg, #5ef0a8, #20c87a); font-size: 30px;
  box-shadow: 0 0 24px rgba(41,227,141,.16);
}
.logo-text { font-size: 21px; }
.side-nav { margin-top: 42px; display: grid; gap: 8px; }
.nav-item {
  border: 0; background: transparent; padding: 13px 8px; border-radius: 12px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--muted);
}
.nav-item span { font-size: 31.5px; line-height: 1; }
.nav-item b { font-size: 18px; font-weight: 600; }
.nav-item:hover, .nav-item.active { color: var(--green); background: var(--green-soft); }
.sidebar-foot { margin-top: auto; text-align: center; color: var(--muted-2); }
.sidebar-foot p { font-size: 15px; margin: 7px 0; }
.shield { font-size: 16.5px; color: var(--green); border: 1px solid rgba(41,227,141,.22); padding: 6px; border-radius: 20px; }

.workspace { grid-column: 2; min-width: 0; }
.topbar {
  height: 74px; display: flex; align-items: center; gap: 24px; padding: 0 24px;
  position: sticky; top: 0; z-index: 8; background: rgba(8,13,12,.92); backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line-soft);
}
.mobile-brand { display: none; font-weight: 800; }
.market-switch, .segmented { display: flex; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.market-button, .chart-mode {
  border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 7px; padding: 7px 14px; font-size: 18px;
}
.market-button.active, .chart-mode.active { background: var(--surface-3); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.search-wrap { position: relative; flex: 1; max-width: 480px; margin: 0 auto; }
.search-wrap input {
  width: 100%; height: 40px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 0 42px; color: var(--text); outline: none;
}
.search-wrap input:focus { border-color: rgba(41,227,141,.55); box-shadow: 0 0 0 3px rgba(41,227,141,.07); }
.search-icon { position: absolute; left: 15px; top: 8px; color: var(--muted); font-size: 30px; }
.search-results {
  position: absolute; left: 0; right: 0; top: 47px; max-height: 360px; overflow: auto; padding: 7px;
  background: #101815; border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 20px 50px rgba(0,0,0,.45); z-index: 20;
}
.search-result { display: flex; align-items: center; padding: 10px; border-radius: 9px; cursor: pointer; }
.search-result:hover { background: var(--surface-3); }
.search-result b { font-size: 19.5px; }
.search-result span { margin-left: 8px; color: var(--muted); font-size: 18px; }
.search-result em { margin-left: auto; color: var(--green); font-style: normal; font-size: 16.5px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.connection-pill { display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--surface); border-radius: 20px; padding: 7px 12px; font-size: 16.5px; color: var(--muted); }
.connection-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 9px currentColor; }
.connection-pill.live i { background: var(--green); }
.connection-pill.demo i { background: var(--amber); }
.connection-pill.error i { background: var(--red); }
.icon-button, .small-add { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; cursor: pointer; }
.icon-button { width: 38px; height: 38px; font-size: 28.5px; }
.icon-button:hover, .small-add:hover { border-color: var(--green); }
.notification-button { position: relative; }
.notification-button em { position: absolute; right: -5px; top: -5px; min-width: 17px; height: 17px; border-radius: 10px; background: var(--red); color: white; font-size: 13.5px; display: grid; place-items: center; font-style: normal; }

.market-directory {
  margin: 14px; min-height: calc(100vh - 102px); background: var(--surface);
  border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 18px 60px rgba(0,0,0,.2);
}
.directory-heading {
  min-height: 118px; padding: 23px 25px; display: flex; align-items: flex-start;
  justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line-soft);
  background: radial-gradient(circle at 12% 0%, rgba(41,227,141,.08), transparent 32%);
}
.directory-title-line { display: flex; align-items: center; gap: 12px; }
.directory-title-line h1 { margin: 0; font-size: 34.5px; }
.directory-count { color: var(--green); background: var(--green-soft); border: 1px solid rgba(41,227,141,.18); border-radius: 20px; padding: 5px 10px; font-size: 15px; }
.directory-heading p { margin: 9px 0 0; color: var(--muted); font-size: 16.5px; }
.directory-close { border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); border-radius: 9px; padding: 8px 11px; cursor: pointer; font-size: 15px; }
.directory-close:hover { color: var(--text); border-color: var(--green); }
.directory-tools { padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line-soft); }
.directory-search { position: relative; width: min(480px, 100%); }
.directory-search span { position: absolute; left: 13px; top: 8px; color: var(--muted); font-size: 27px; }
.directory-search input { width: 100%; padding-left: 39px; }
.directory-legend { display: flex; gap: 17px; color: var(--muted); font-size: 13.5px; }
.directory-legend span { display: flex; align-items: center; gap: 6px; }
.live-dot { width: 6px; height: 6px; background: var(--green); border-radius: 50%; box-shadow: 0 0 8px var(--green); }
.directory-refresh { border: 0; background: transparent; color: var(--green); cursor: pointer; padding: 4px 6px; font-size: 13.5px; }
.directory-refresh:hover { text-decoration: underline; }
.directory-refresh:disabled { color: var(--muted-2); cursor: wait; text-decoration: none; }
.directory-table-wrap { overflow-x: auto; }
.directory-table-head, .directory-row {
  display: grid;
  grid-template-columns: minmax(190px, 1.2fr) 150px 90px 84px 84px 100px 115px 72px 96px;
  align-items: center; min-width: 1120px; column-gap: 12px;
}
.directory-table-head { min-height: 40px; padding: 0 24px; color: var(--muted-2); font-size: 13.5px; text-transform: uppercase; background: #0b1210; }
.directory-row { min-height: 58px; padding: 0 24px; border-top: 1px solid var(--line-soft); transition: background .15s; }
.directory-row:hover { background: rgba(41,227,141,.025); }
.directory-code { display: flex; align-items: center; gap: 9px; min-width: 0; }
.market-flag { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 8px; color: var(--green); background: var(--green-soft); font-size: 13.5px; font-weight: 800; }
.directory-identity { min-width: 0; }
.directory-stock-link { display: block; max-width: 100%; border: 0; padding: 0; background: transparent; color: var(--text); font-size: 16.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; text-align: left; }
.directory-stock-link:hover { color: var(--green); text-decoration: underline; text-underline-offset: 3px; }
.directory-identity small { display: block; color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.directory-price, .directory-change, .directory-volume { font-size: 16.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.directory-volume, .directory-lot { color: var(--muted); font-weight: 500; }
.range-chart { width: 138px; display: grid; gap: 5px; }
.range-track { position: relative; height: 3px; border-radius: 3px; background: #25332f; }
.range-fill { position: absolute; inset: 0; border-radius: inherit; opacity: .38; }
.range-marker { position: absolute; top: 50%; width: 7px; height: 7px; border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 8px currentColor; }
.range-labels { display: flex; justify-content: space-between; color: var(--muted-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.day-range-values { font-size: 13.5px; line-height: 1.45; color: var(--muted); font-variant-numeric: tabular-nums; }
.day-range-values b { color: var(--text); font-weight: 600; }
.no-quote { color: var(--muted-2); font-size: 13.5px; }
.watch-action { width: 84px; height: 30px; border-radius: 8px; cursor: pointer; border: 1px solid rgba(41,227,141,.32); color: var(--green); background: var(--green-soft); font-size: 15px; font-weight: 700; }
.watch-action:hover { background: rgba(41,227,141,.17); }
.watch-action.added, .watch-action:disabled { color: var(--muted); background: transparent; border-color: var(--line); cursor: default; }
.directory-footer { min-height: 66px; display: flex; align-items: center; justify-content: space-between; padding: 12px 24px; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 15px; }
.load-more { border: 1px solid rgba(41,227,141,.3); background: var(--green-soft); color: var(--green); border-radius: 9px; padding: 8px 16px; cursor: pointer; font-size: 15px; }
.directory-loading { min-height: 360px; display: grid; place-items: center; color: var(--muted); font-size: 16.5px; }
.directory-spinner { width: 28px; height: 28px; border: 2px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: spin .75s linear infinite; margin: 0 auto 10px; }
@keyframes spin { to { transform: rotate(360deg); } }
.market-insights { padding: 4px 24px 26px; border-top: 1px solid var(--line-soft); background: linear-gradient(180deg, rgba(41,227,141,.018), transparent 55%); }
.insights-heading { display: flex; justify-content: space-between; align-items: center; padding: 20px 0 14px; }
.insights-heading h2 { margin: 0; font-size: 22.5px; }
.insights-heading > span { color: var(--muted); font-size: 13.5px; }
.market-stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.market-stat { min-height: 92px; padding: 14px 15px; border: 1px solid var(--line); border-radius: 12px; background: #0f1815; }
.market-stat span, .market-stat small { display: block; color: var(--muted); font-size: 13.5px; }
.market-stat strong { display: block; margin: 7px 0 5px; font-size: 28.5px; font-variant-numeric: tabular-nums; }
.ranking-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.ranking-card { border: 1px solid var(--line); border-radius: 12px; background: #0d1513; overflow: hidden; }
.ranking-title { display: flex; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line-soft); }
.ranking-title b { font-size: 15px; }
.ranking-title span { color: var(--muted-2); font-size: 12px; }
.ranking-list { min-height: 108px; }
.ranking-item { width: 100%; min-height: 36px; display: grid; grid-template-columns: 18px 1fr auto; align-items: center; gap: 8px; padding: 7px 13px; border: 0; border-top: 1px solid var(--line-soft); background: transparent; color: var(--text); cursor: pointer; text-align: left; }
.ranking-item:first-child { border-top: 0; }
.ranking-item:hover { background: var(--green-soft); }
.ranking-number { color: var(--muted-2); font-size: 13.5px; }
.ranking-name { min-width: 0; }
.ranking-name b { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13.5px; }
.ranking-name small { color: var(--muted); font-size: 12px; }
.ranking-value { font-size: 15px; font-weight: 750; font-variant-numeric: tabular-nums; }
.ranking-empty { min-height: 108px; display: grid; place-items: center; color: var(--muted-2); font-size: 13.5px; }

.dashboard-grid { display: grid; grid-template-columns: 290px minmax(520px, 1fr) 330px; gap: 14px; padding: 14px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); box-shadow: 0 14px 40px rgba(0,0,0,.12); }
.watch-panel { min-height: calc(100vh - 102px); position: sticky; top: 88px; overflow: hidden; display: flex; flex-direction: column; }
.panel-heading { padding: 18px; display: flex; justify-content: space-between; align-items: center; }
.eyebrow { display: block; color: var(--green); font-size: 13.5px; font-weight: 800; letter-spacing: .16em; margin-bottom: 6px; }
.panel-heading h2, .modal h2 { margin: 0; font-size: 24px; }
.small-add { width: 31px; height: 31px; color: var(--green); font-size: 27px; }
.watch-summary { display: flex; justify-content: space-between; padding: 0 18px 13px; color: var(--muted); font-size: 16.5px; border-bottom: 1px solid var(--line-soft); }
.watch-summary b { color: var(--text); }
.watch-table-head, .watch-row { display: grid; grid-template-columns: 1fr 75px 64px; align-items: center; gap: 7px; }
.watch-table-head { padding: 11px 14px; color: var(--muted-2); text-transform: uppercase; font-size: 13.5px; }
.watch-table-head span:not(:first-child), .watch-row > span { text-align: right; }
.watch-list { flex: 1; overflow: auto; max-height: calc(100vh - 315px); }
.watch-row { position: relative; width: 100%; border: 0; border-top: 1px solid transparent; border-bottom: 1px solid var(--line-soft); background: transparent; text-align: left; padding: 13px 14px; cursor: pointer; }
.watch-row:hover { background: #111a17; }
.watch-row.active { background: linear-gradient(90deg, rgba(41,227,141,.10), transparent); border-left: 2px solid var(--green); padding-left: 12px; }
.watch-identity b { display: block; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.watch-identity small { color: var(--muted); font-size: 15px; }
.watch-price { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 18px; }
.change-chip { font-size: 16.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }
.scanner-status { margin: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; display: flex; gap: 11px; align-items: center; background: rgba(41,227,141,.025); }
.scanner-status b { font-size: 16.5px; display: block; }
.scanner-status small { font-size: 13.5px; color: var(--muted); }
.scan-orb { width: 27px; height: 27px; border: 1px solid rgba(41,227,141,.4); border-radius: 50%; display: grid; place-items: center; animation: radar 2s infinite; }
.scan-orb span { width: 7px; height: 7px; background: var(--green); border-radius: 50%; box-shadow: 0 0 10px var(--green); }
@keyframes radar { 50% { box-shadow: 0 0 0 8px rgba(41,227,141,0); } }

.center-column, .right-column { min-width: 0; display: grid; gap: 14px; }
.chart-panel { overflow: hidden; }
.stock-heading { padding: 20px 22px 12px; display: flex; justify-content: space-between; gap: 18px; align-items: center; }
.stock-title-line, .price-line { display: flex; align-items: baseline; gap: 10px; }
.stock-title-line h1 { margin: 0 0 7px; font-size: 27px; }
.code-chip, .paper-badge { color: var(--muted); font-size: 15px; border: 1px solid var(--line); padding: 3px 7px; border-radius: 6px; }
.price-line strong { font-size: 45px; letter-spacing: -.04em; }
.price-line span { font-size: 18px; font-weight: 700; }
.stock-actions { display: flex; gap: 7px; }
.trade-button { border: 1px solid; background: transparent; border-radius: 9px; padding: 9px 13px; cursor: pointer; font-size: 16.5px; font-weight: 700; }
.back-directory-button { border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); border-radius: 9px; padding: 9px 11px; cursor: pointer; font-size: 15px; }
.back-directory-button:hover { color: var(--text); border-color: var(--green); }
.trade-button.buy { color: var(--green); border-color: rgba(41,227,141,.38); background: var(--green-soft); }
.trade-button.sell { color: var(--red); border-color: rgba(255,95,109,.35); background: var(--red-soft); }
.trade-button:disabled { color: var(--muted-2); border-color: var(--line); background: transparent; cursor: not-allowed; opacity: .7; }
.chart-toolbar { min-height: 49px; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); padding: 8px 17px; display: flex; align-items: center; gap: 18px; }
.periods { display: flex; gap: 5px; }
.period { border: 0; background: transparent; color: var(--muted); padding: 6px 8px; cursor: pointer; font-size: 16.5px; border-radius: 6px; }
.period.active { color: var(--green); background: var(--green-soft); }
.chart-range { margin-left: auto; color: var(--muted-2); font-size: 15px; }
.data-source-badge {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  border: 1px solid var(--line); border-radius: 14px; padding: 4px 9px;
  font-size: 13.5px; font-weight: 700;
}
.data-source-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; }
.data-source-badge.live { color: var(--green); border-color: rgba(41,227,141,.28); background: var(--green-soft); }
.data-source-badge.live::before { background: var(--green); box-shadow: 0 0 8px var(--green); }
.data-source-badge.waiting { color: var(--amber); border-color: rgba(255,189,89,.25); background: rgba(255,189,89,.06); }
.data-source-badge.waiting::before { background: var(--amber); }
.chart-wrap { position: relative; padding: 8px 10px 0; min-height: 370px; }
#priceChart { width: 100%; height: 370px; display: block; overflow: visible; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 18px; }
.ohlc-row { border-top: 1px solid var(--line-soft); display: flex; gap: 20px; padding: 12px 20px; color: var(--muted); font-size: 15px; overflow-x: auto; }
.ohlc-row b { color: var(--text); margin-left: 3px; }
.depth-panel { position: relative; border-top: 1px solid var(--line-soft); background: #0b1214; padding: 15px 16px 17px; }
.depth-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.depth-heading h2 { margin: 3px 0 0; font-size: 21px; }
.depth-controls { display: flex; align-items: center; gap: 10px; }
.depth-controls label { display: flex; grid-template-columns: none; align-items: center; gap: 6px; font-size: 13.5px; }
.depth-controls select { width: 75px; height: 31px; padding: 0 7px; font-size: 13.5px; }
.depth-status { border: 1px solid var(--line); border-radius: 14px; padding: 4px 9px; color: var(--muted); font-size: 13.5px; font-weight: 700; white-space: nowrap; }
.depth-status.live { color: var(--green); border-color: rgba(41,227,141,.3); background: var(--green-soft); }
.depth-status.limited { color: var(--amber); border-color: rgba(255,189,89,.3); background: rgba(255,189,89,.07); }
.depth-status.error { color: var(--red); border-color: rgba(255,95,109,.3); background: var(--red-soft); }
.depth-metrics { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; margin: 13px 0 10px; color: var(--muted); font-size: 13.5px; }
.depth-metrics b { color: var(--text); margin-left: 4px; font-variant-numeric: tabular-nums; }
#depthUpdatedAt { margin-left: auto; color: var(--muted-2); }
.depth-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.depth-book { overflow: hidden; border: 1px solid var(--line-soft); border-radius: 7px; background: #0e1618; }
.depth-column-head, .depth-row { display: grid; grid-template-columns: 48px minmax(70px,1fr) minmax(70px,1fr) 48px; align-items: center; gap: 7px; }
.depth-column-head { min-height: 33px; padding: 0 9px; border-bottom: 1px solid var(--line-soft); color: var(--muted-2); font-size: 12px; }
.depth-column-head span:not(:first-child) { text-align: right; }
.depth-column-head b { color: var(--muted); }
.depth-list { min-height: 30px; }
.depth-row { position: relative; min-height: 29px; padding: 0 9px; border-top: 1px solid rgba(31,49,44,.36); font-size: 13.5px; font-variant-numeric: tabular-nums; overflow: hidden; }
.depth-row:first-child { border-top: 0; }
.depth-row > * { position: relative; z-index: 1; }
.depth-row b, .depth-row span:not(:first-of-type) { text-align: right; }
.depth-row .depth-bar { position: absolute; z-index: 0; right: 0; top: 2px; bottom: 2px; opacity: .12; }
.depth-row.ask .depth-side-label, .depth-row.ask b { color: var(--red); }
.depth-row.bid .depth-side-label, .depth-row.bid b { color: var(--green); }
.depth-row.ask .depth-bar { background: var(--red); }
.depth-row.bid .depth-bar { background: var(--green); }
.depth-row .depth-orders { color: var(--muted); }
.depth-empty { min-height: 54px; display: grid; place-items: center; color: var(--muted); font-size: 13.5px; }
.depth-empty.hidden { display: none; }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.metric-card { padding: 14px 15px; border: 1px solid var(--line-soft); background: var(--surface); border-radius: 13px; }
.metric-card.featured { border-color: rgba(41,227,141,.22); background: linear-gradient(145deg, rgba(41,227,141,.07), var(--surface)); }
.metric-card span, .metric-card small { display: block; color: var(--muted); font-size: 13.5px; }
.metric-card strong { display: block; font-size: 28.5px; margin: 6px 0 4px; }
.signal-neutral { color: var(--amber); }
.ledger-panel { min-height: 190px; overflow: hidden; }
.ledger-tabs { display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--line-soft); }
.ledger-tab { border: 0; background: transparent; padding: 7px 9px; color: var(--muted); cursor: pointer; font-size: 16.5px; }
.ledger-tab.active { color: var(--text); }
.paper-badge { margin-left: auto; color: var(--amber); }
.ledger-content { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.data-table th { color: var(--muted-2); font-weight: 500; text-align: left; padding: 10px 13px; }
.data-table td { padding: 11px 13px; border-top: 1px solid var(--line-soft); white-space: nowrap; }
.empty-state { min-height: 125px; display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 16.5px; padding: 20px; }

.right-column { position: sticky; top: 88px; max-height: calc(100vh - 102px); }
.rules-panel, .alerts-panel { overflow: hidden; }
.panel-copy { margin: -5px 18px 10px; color: var(--muted); font-size: 15px; line-height: 1.55; }
.text-button { border: 0; background: transparent; color: var(--green); cursor: pointer; font-size: 16.5px; }
.text-button.muted { color: var(--muted); }
.rule-list { padding: 0 10px 10px; max-height: 280px; overflow: auto; }
.rule-card { padding: 12px; margin-top: 7px; border: 1px solid var(--line); border-radius: 11px; background: #101815; }
.rule-top { display: flex; align-items: center; gap: 8px; }
.rule-icon { width: 27px; height: 27px; border-radius: 8px; background: var(--green-soft); color: var(--green); display: grid; place-items: center; }
.rule-top b { font-size: 16.5px; }
.rule-top small { display: block; color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.switch { margin-left: auto; width: 31px; height: 18px; border: 0; border-radius: 10px; background: #26332f; padding: 2px; cursor: pointer; }
.switch::after { content: ""; display: block; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: .2s; }
.switch.on { background: rgba(41,227,141,.3); }
.switch.on::after { transform: translateX(13px); background: var(--green); }
.rule-expression { margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 13.5px; display: flex; justify-content: space-between; }
.rule-expression em { color: var(--text); font-style: normal; }
.alerts-panel { min-height: 240px; }
.alert-list { max-height: calc(100vh - 520px); min-height: 150px; overflow: auto; padding: 0 10px 10px; }
.alert-item { position: relative; border-top: 1px solid var(--line-soft); padding: 12px 8px 12px 22px; }
.alert-item::before { content: ""; position: absolute; left: 7px; top: 18px; width: 6px; height: 6px; background: var(--green); border-radius: 50%; box-shadow: 0 0 8px var(--green); }
.alert-item.sell::before { background: var(--red); box-shadow: 0 0 8px var(--red); }
.alert-item.read { opacity: .5; }
.alert-item b { display: block; font-size: 16.5px; }
.alert-item p { margin: 4px 0; color: var(--muted); font-size: 13.5px; line-height: 1.4; }
.alert-meta { display: flex; align-items: center; gap: 8px; color: var(--muted-2); font-size: 12px; }
.alert-action { margin-left: auto; border: 0; color: var(--green); background: transparent; cursor: pointer; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(2,6,5,.76); backdrop-filter: blur(7px); display: grid; place-items: center; padding: 20px; }
.modal { position: relative; width: min(520px, 100%); max-height: 92vh; overflow: auto; background: #101815; border: 1px solid #2a3d36; border-radius: 18px; padding: 24px; box-shadow: 0 30px 100px rgba(0,0,0,.65); }
.modal.compact { width: min(400px, 100%); }
.modal-close { position: absolute; right: 15px; top: 13px; border: 0; background: transparent; color: var(--muted); font-size: 36px; cursor: pointer; }
.order-quote { margin: 16px 0; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; display: flex; justify-content: space-between; }
.order-quote span { color: var(--muted); }
form { display: grid; gap: 13px; margin-top: 17px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 15px; }
input, select { height: 39px; padding: 0 11px; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 9px; outline: none; }
input:focus, select:focus { border-color: rgba(41,227,141,.55); }
.form-row { display: grid; gap: 10px; }
.form-row.two { grid-template-columns: repeat(2, 1fr); }
.form-row.three { grid-template-columns: repeat(3, 1fr); }
.safety-note { padding: 10px; color: var(--amber); background: rgba(255,189,89,.06); border: 1px solid rgba(255,189,89,.18); border-radius: 9px; font-size: 13.5px; line-height: 1.5; }
.primary-button { height: 42px; border: 0; border-radius: 10px; color: #06110c; font-weight: 800; cursor: pointer; background: linear-gradient(135deg, #54efa7, #23d381); }
.primary-button:hover { filter: brightness(1.08); }
.toast-stack { position: fixed; z-index: 120; right: 22px; bottom: 22px; display: grid; gap: 9px; }
.toast { width: min(340px, calc(100vw - 44px)); padding: 12px 14px; background: #14201c; border: 1px solid var(--line); border-left: 3px solid var(--green); border-radius: 10px; box-shadow: 0 16px 40px rgba(0,0,0,.4); font-size: 16.5px; animation: toast-in .25s ease; }
.toast.error { border-left-color: var(--red); }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }

@media (max-width: 1280px) {
  :root { --sidebar: 82px; }
  .logo-text, .nav-item b, .sidebar-foot p { display: none; }
  .dashboard-grid { grid-template-columns: 255px minmax(480px, 1fr); }
  .right-column { grid-column: 1 / -1; position: static; grid-template-columns: 1fr 1fr; max-height: none; }
  .alert-list { max-height: 280px; }
}

@media (max-width: 900px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .workspace { display: block; }
  .topbar { padding: 0 12px; gap: 10px; }
  .mobile-brand { display: block; font-size: 19.5px; }
  .market-switch, .connection-pill, #refreshButton { display: none; }
  .search-wrap { max-width: none; }
  .dashboard-grid { grid-template-columns: 1fr; padding: 9px; }
  .market-directory { margin: 9px; }
  .directory-heading { padding: 18px; }
  .directory-tools { align-items: stretch; flex-direction: column; }
  .directory-search { width: 100%; }
  .market-stat-grid { grid-template-columns: repeat(2, 1fr); }
  .ranking-grid { grid-template-columns: 1fr; }
  .watch-panel { min-height: 0; position: static; }
  .watch-list { max-height: 280px; }
  .scanner-status { display: none; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .right-column { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .mobile-brand { display: none; }
  .stock-heading { align-items: flex-start; }
  .stock-actions { flex-direction: column; }
  .trade-button { padding: 7px 9px; }
  .chart-toolbar { gap: 8px; overflow-x: auto; }
  .chart-range { display: none; }
  .directory-heading { flex-direction: column; }
  .directory-close { align-self: flex-start; }
  .directory-legend { display: none; }
  .market-stat-grid { grid-template-columns: 1fr; }
  .chart-wrap, #priceChart { min-height: 300px; height: 300px; }
  .form-row.two, .form-row.three { grid-template-columns: 1fr; }
  .depth-heading { align-items: flex-start; flex-direction: column; }
  .depth-grid { grid-template-columns: 1fr; }
  #depthUpdatedAt { margin-left: 0; width: 100%; }
}

/* Trading-terminal layout: market list on the left, chart workspace on the right. */
:root { --terminal-topbar: 64px; }
.app-shell { display: block; min-height: 100vh; }
.sidebar { display: none; }
.workspace { display: block; min-width: 0; }
.topbar {
  height: var(--terminal-topbar); padding: 0 18px; gap: 18px;
  border-bottom-color: #26342f; background: rgba(10, 15, 18, .97);
}
.mobile-brand { display: block; min-width: 118px; color: var(--text); font-size: 21px; letter-spacing: .06em; }
.search-wrap { max-width: 520px; }
.market-switch { order: 2; }
.search-wrap { order: 3; }
.route-tabs { order: 4; margin-left: auto; display: flex; align-items: center; gap: 8px; }
.top-route-link {
  min-height: 38px; display: inline-flex; align-items: center; justify-content: center; padding: 0 18px;
  border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: #10181a;
  font-size: 16.5px; font-weight: 720; text-decoration: none; white-space: nowrap;
}
.top-route-link:hover, .top-route-link.active { color: var(--green); border-color: rgba(41,227,141,.38); background: var(--green-soft); }
.route-count {
  min-width: 22px; height: 22px; margin-left: 8px; padding: 0 6px; display: inline-flex; align-items: center;
  justify-content: center; border-radius: 999px; color: #06110c; background: var(--green); font-size: 12px;
  font-style: normal; font-weight: 850; font-variant-numeric: tabular-nums;
}
.top-actions { order: 5; margin-left: 0; }

.dashboard-grid {
  display: grid; grid-template-columns: minmax(900px, 1.62fr) minmax(520px, .88fr);
  grid-template-areas: "watch detail";
  gap: 10px; padding: 10px; align-items: start; min-height: calc(100vh - var(--terminal-topbar));
}
.watch-panel {
  grid-area: watch;
  min-height: calc(100vh - var(--terminal-topbar) - 20px); height: calc(100vh - var(--terminal-topbar) - 20px);
  position: sticky; top: calc(var(--terminal-topbar) + 10px); border-radius: 5px;
  overflow-x: auto; overflow-y: hidden; background: #0d1316;
}
.watch-panel .panel-heading { min-width: 880px; padding: 16px 18px 12px; }
.watch-panel .watch-summary { min-width: 880px; padding: 0 18px 12px; }
.watch-table-head, .watch-row {
  grid-template-columns: minmax(180px, 1.35fr) 125px 82px 82px 84px 86px 98px 78px;
  gap: 12px; min-width: 880px;
}
.watch-table-head {
  min-height: 42px; padding: 0 16px; background: #10171a; border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft); align-items: center;
}
.watch-table-head span:not(:first-child) { text-align: right; }
.watch-list {
  flex: 1; max-height: calc(100vh - 300px); min-height: 300px;
  overflow-y: auto; overflow-x: hidden; scrollbar-color: #31453e transparent;
}
.watch-row {
  min-height: 72px; padding: 9px 16px; border: 0; border-bottom: 1px solid var(--line-soft);
  transition: background .14s ease, box-shadow .14s ease;
}
.watch-row:hover { background: #121c1f; }
.watch-row.active {
  background: linear-gradient(90deg, rgba(41,227,141,.11), rgba(41,227,141,.018));
  box-shadow: inset 3px 0 0 var(--green); padding-left: 16px;
}
.watch-stock-button {
  min-width: 0; display: flex; align-items: center; gap: 10px; padding: 0; border: 0;
  background: transparent; color: var(--text); text-align: left; cursor: pointer;
}
.watch-stock-button:hover .watch-identity b { color: var(--green); }
.watch-stock-button .market-flag { flex: 0 0 auto; }
.watch-identity { min-width: 0; }
.watch-identity b { font-size: 18px; }
.watch-identity small { display: block; margin-top: 3px; font-size: 13.5px; }
.watch-row .range-chart { width: 115px; margin-left: auto; }
.watch-row > span { text-align: right; font-variant-numeric: tabular-nums; }
.watch-price, .change-chip, .watch-change { font-size: 16.5px; font-weight: 750; }
.watch-volume { color: var(--muted); font-size: 15px; }
.watch-high-low { color: var(--muted); font-size: 13.5px; line-height: 1.45; }
.watch-high-low b { color: var(--text); }
.watch-quick-add {
  width: 76px; height: 31px; border: 1px solid rgba(41,227,141,.32); border-radius: 7px;
  background: var(--green-soft); color: var(--green); font-size: 13.5px; font-weight: 700; cursor: pointer;
}
.watch-quick-add.added, .watch-quick-add:disabled { color: var(--muted); border-color: var(--line); background: transparent; cursor: default; }
.watch-panel .scanner-status { min-width: 850px; margin-top: auto; }

.center-column { grid-area: detail; min-width: 0; gap: 10px; position: static; }
.chart-panel { border-radius: 5px; background: #0d1316; }
.stock-heading { min-height: 112px; padding: 16px 18px 12px; }
.stock-title-line { flex-wrap: wrap; }
.price-line strong { font-size: 45px; }
.chart-toolbar { min-height: 52px; padding: 7px 14px; gap: 12px; background: #10171a; }
.chart-wrap { min-height: 430px; padding: 8px 8px 0; }
#priceChart { height: 430px; }
.ohlc-row { gap: 14px; padding: 10px 14px; flex-wrap: wrap; }
.metric-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
.metric-card { min-height: 104px; border-radius: 5px; }
.ledger-panel { min-height: 168px; border-radius: 5px; }

.right-column {
  grid-area: signals; position: static; max-height: none; min-width: 0; display: grid;
  grid-template-columns: minmax(0, 1fr); gap: 10px;
}
.rules-panel, .alerts-panel { min-height: 260px; border-radius: 5px; }
.rule-list, .alert-list { max-height: 300px; }

@media (max-width: 1480px) {
  .dashboard-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "watch"
      "detail";
  }
  .watch-panel { grid-area: watch; position: static; height: auto; min-height: 620px; }
  .watch-list { max-height: 520px; }
  .center-column { grid-area: detail; position: static; }
}

@media (max-width: 900px) {
  .topbar { min-height: 64px; height: auto; flex-wrap: wrap; padding: 10px 12px; }
  .mobile-brand { min-width: auto; }
  .market-switch { display: flex; }
  .route-tabs { margin-left: 0; }
  .dashboard-grid { padding: 7px; }
  .watch-panel { min-height: 560px; }
  .right-column { grid-template-columns: 1fr; }
}

/* Dedicated trading-alert workspace. Rules and signals live here instead of competing with charts. */
.brand-link { text-decoration: none; }
.alerts-page { min-width: 320px; }
.alerts-page .topbar { position: sticky; top: 0; z-index: 40; }
.alerts-page .route-tabs { order: 2; margin-left: 4px; }
.alerts-page .alerts-topline {
  order: 3; margin: 0 auto; color: var(--muted); font-size: 15px; letter-spacing: .04em;
}
.alerts-page .top-actions { order: 4; }
.alerts-workspace { width: min(1720px, 100%); margin: 0 auto; padding: 22px; }
.alerts-hero {
  min-height: 118px; padding: 22px 24px; display: flex; align-items: flex-end; justify-content: space-between;
  gap: 22px; border: 1px solid var(--line); border-radius: 10px;
  background: radial-gradient(circle at 15% 0, rgba(41,227,141,.11), transparent 40%), #0d1515;
}
.alerts-hero h1 { margin: 5px 0 4px; font-size: 34px; line-height: 1.05; }
.alerts-hero p { margin: 0; color: var(--muted); font-size: 15px; }
.alerts-create-button { min-width: 142px; padding: 0 20px; }
.alerts-summary {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 12px 0;
}
.alerts-summary article {
  min-height: 112px; padding: 16px 18px; display: grid; align-content: center; gap: 5px;
  border: 1px solid var(--line); border-radius: 8px; background: #0d1515;
}
.alerts-summary span, .alerts-summary small { color: var(--muted); }
.alerts-summary span { font-size: 14px; }
.alerts-summary strong { font-size: 29px; line-height: 1.08; color: var(--text); font-variant-numeric: tabular-nums; }
.alerts-summary small { font-size: 12.5px; }
.alerts-page-grid {
  display: grid; grid-template-columns: minmax(360px, .82fr) minmax(620px, 1.55fr); gap: 12px; align-items: start;
}
.alerts-page-grid .panel { border-radius: 8px; overflow: hidden; }
.alerts-page-grid .panel-heading { min-height: 82px; padding: 17px 20px 10px; }
.alerts-page-grid .panel-copy { min-height: 42px; margin: 0; padding: 0 20px 13px; color: var(--muted); }
.alerts-page-grid .rule-list, .alerts-page-grid .alert-list {
  max-height: calc(100vh - 386px); min-height: 420px; overflow-y: auto; scrollbar-color: #31453e transparent;
}
.alerts-page-grid .rule-list { padding: 0 12px 12px; }
.alerts-page-grid .alert-list { padding: 0 16px 16px; }
.alerts-page-grid .rule-card { margin-bottom: 10px; }
.alerts-page-grid .alert-item { padding: 16px 4px; }
.alerts-filter-row {
  min-height: 42px; padding: 0 20px; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; color: var(--muted); border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}
.alerts-filter-row > span:first-child { display: inline-flex; align-items: center; gap: 8px; }

@media (max-width: 1120px) {
  .alerts-page .alerts-topline { display: none; }
  .alerts-page .top-actions { margin-left: auto; }
  .alerts-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .alerts-page-grid { grid-template-columns: 1fr; }
  .alerts-page-grid .rule-list, .alerts-page-grid .alert-list { max-height: 520px; min-height: 280px; }
}

@media (max-width: 700px) {
  .alerts-page .topbar { align-items: center; }
  .alerts-page .mobile-brand { display: block; }
  .alerts-page .route-tabs { order: 5; width: 100%; margin: 0; }
  .alerts-page .top-route-link { flex: 1; }
  .alerts-workspace { padding: 10px; }
  .alerts-hero { min-height: 0; align-items: stretch; flex-direction: column; padding: 18px; }
  .alerts-hero h1 { font-size: 29px; }
  .alerts-create-button { width: 100%; }
  .alerts-summary { grid-template-columns: 1fr; }
  .alerts-summary article { min-height: 92px; }
  .alerts-page-grid .panel-heading { min-height: 72px; }
  .alerts-filter-row { align-items: flex-start; flex-direction: column; padding: 10px 16px; gap: 4px; }
}

/* Alert terminal: actionable stocks on the left, the selected stock's OpenD K-line on the right. */
.alert-trading-grid {
  display: grid; grid-template-columns: minmax(350px, .72fr) minmax(640px, 1.55fr); gap: 12px; align-items: stretch;
}
.alerts-signal-panel, .alert-chart-panel { min-height: 620px; height: 620px; border-radius: 8px; overflow: hidden; }
.alerts-signal-panel { display: flex; flex-direction: column; }
.alerts-signal-panel .panel-heading { min-height: 76px; padding: 15px 18px 8px; }
.alert-kind-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 0 14px 10px; }
.alert-kind-tab {
  min-height: 38px; border: 1px solid var(--line); border-radius: 7px; color: var(--muted);
  background: #10181a; font-size: 15px; font-weight: 720; cursor: pointer;
}
.alert-kind-tab:hover, .alert-kind-tab.active { color: var(--green); border-color: rgba(41,227,141,.36); background: var(--green-soft); }
.alerts-signal-panel .alerts-filter-row { min-height: 38px; padding: 0 16px; }
.alerts-signal-panel .alert-list {
  flex: 1; min-height: 0; max-height: none; padding: 0; overflow-y: auto; scrollbar-color: #31453e transparent;
}
.alert-stock-item {
  position: relative; min-height: 114px; border-bottom: 1px solid var(--line-soft); background: transparent;
  transition: background .15s ease, box-shadow .15s ease;
}
.alert-stock-item:hover { background: #121c1f; }
.alert-stock-item.active {
  background: linear-gradient(90deg, rgba(41,227,141,.12), rgba(41,227,141,.02));
  box-shadow: inset 3px 0 0 var(--green);
}
.alert-stock-item.sell.active { background: linear-gradient(90deg, rgba(255,95,109,.11), rgba(255,95,109,.015)); box-shadow: inset 3px 0 0 var(--red); }
.alert-stock-select {
  width: 100%; min-height: 114px; padding: 13px 16px 35px; display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px; border: 0; color: var(--text); background: transparent; text-align: left; cursor: pointer;
}
.alert-stock-main { min-width: 0; }
.alert-stock-main b, .alert-stock-main small { display: block; }
.alert-stock-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; }
.alert-stock-main small { margin-top: 2px; color: var(--muted); font-size: 12.5px; }
.alert-stock-quote { text-align: right; font-variant-numeric: tabular-nums; }
.alert-stock-quote strong, .alert-stock-quote em { display: block; }
.alert-stock-quote strong { font-size: 17px; }
.alert-stock-quote em { margin-top: 2px; font-size: 12.5px; font-style: normal; }
.alert-stock-note {
  grid-column: 1 / -1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12.5px;
}
.alert-stock-count { position: absolute; left: 16px; bottom: 11px; color: var(--muted-2); font-size: 11.5px; }
.alert-stock-item .alert-action { position: absolute; right: 14px; bottom: 8px; padding: 4px 7px; font-size: 12.5px; }
.alert-chart-panel { background: #0d1316; }
.alert-stock-heading { min-height: 128px; padding: 16px 20px 12px; }
.alert-stock-heading .stock-title-line h1 { font-size: 26px; }
.alert-stock-heading .price-line strong { font-size: 38px; }
.alert-chart-signal { max-width: 720px; margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.alert-chart-toolbar { min-height: 50px; padding: 7px 16px; background: #10171a; }
.alert-chart-modes { flex: 0 0 auto; }
.alert-chart-modes .chart-mode { padding: 6px 11px; font-size: 15px; }
.alert-period {
  border: 0; border-radius: 6px; padding: 6px 9px; color: var(--muted); background: transparent; font-size: 15px; cursor: pointer;
}
.alert-period:hover, .alert-period.active { color: var(--green); background: var(--green-soft); }
.alert-chart-wrap { min-height: 390px; height: 390px; padding: 8px 9px 0; }
#alertPriceChart { width: 100%; height: 390px; display: block; overflow: visible; cursor: crosshair; user-select: none; }
.alerts-rules-panel { margin-top: 12px; border-radius: 8px; }
.alerts-rules-panel .panel-heading { min-height: 76px; padding: 15px 20px 8px; }
.alerts-rules-panel .panel-copy { margin: 0; padding: 0 20px 13px; color: var(--muted); }
.alerts-rules-panel .rule-list {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; min-height: 0; max-height: none; padding: 0 14px 14px;
}
.alerts-rules-panel .rule-card { margin: 0; }

@media (max-width: 980px) {
  .alert-trading-grid { grid-template-columns: 1fr; }
  .alerts-signal-panel { height: 480px; min-height: 480px; }
  .alert-chart-panel { height: auto; min-height: 590px; }
  .alerts-rules-panel .rule-list { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .alert-chart-panel { min-height: 520px; }
  .alert-stock-heading { min-height: 154px; align-items: flex-start; }
  .alert-stock-heading .stock-actions { width: 100%; }
  .alert-stock-heading .trade-button { width: 100%; }
  .alert-chart-toolbar { overflow-x: auto; }
  .alert-chart-wrap, #alertPriceChart { min-height: 300px; height: 300px; }
}
