:root {
  --bg-body: #090d14;
  --bg-card: #111722;
  --bg-card-2: #161e2c;
  --bg-elevated: #1c2638;
  --border: #232f45;
  --border-subtle: rgba(148, 163, 184, 0.12);

  --text-primary: #eef2f8;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* Authentic Chinese A-share convention: Red = Up, Green = Down */
  --up: #f23645;
  --up-bright: #ff4d5a;
  --up-bg: rgba(242, 54, 69, 0.14);
  --up-border: rgba(242, 54, 69, 0.35);

  --down: #00b87c;
  --down-bright: #10d696;
  --down-bg: rgba(0, 184, 124, 0.14);
  --down-border: rgba(0, 184, 124, 0.35);

  --flat: #94a3b8;
  --accent: #3b82f6;
  --accent-bg: rgba(59, 130, 246, 0.16);
  --gold: #f59e0b;

  --radius: 10px;
  --radius-sm: 6px;
  --mono: "JetBrains Mono", "Cascadia Code", "Consolas", "SFMono-Regular", monospace;
  --sans: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  background: var(--bg-body);
  color: var(--text-primary);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.45;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.num, .big-pct, .big-nav, .detail-price, .detail-change, .detail-pct, .update-time, .code-tag {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.up { color: var(--up-bright) !important; }
.down { color: var(--down-bright) !important; }
.flat { color: var(--flat) !important; }
.hidden { display: none !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: #0c111a; }
::-webkit-scrollbar-thumb { background: #263248; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #364766; }

/* ==================== TOP BAR ==================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  background: rgba(11, 15, 24, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--down-bright);
  box-shadow: 0 0 10px var(--down-bright);
  animation: pulse 2s infinite;
}

.brand-dot.paused {
  background: var(--gold);
  box-shadow: none;
  animation: none;
}

.brand-dot.error {
  background: var(--up);
  box-shadow: 0 0 10px var(--up);
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.brand-badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.main-nav {
  display: flex;
  gap: 6px;
  background: var(--bg-card);
  padding: 3px;
  border-radius: 9px;
  border: 1px solid var(--border);
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 15px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
}

.nav-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.nav-tab.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.35);
}

.topbar-right {
  display: flex;
  align-items: center;
}

.refresh-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.update-time {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
}

.select-control {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  outline: none;
}

.select-control:focus {
  border-color: var(--accent);
}

.btn {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-ghost {
  background: var(--bg-card);
  color: var(--text-primary);
}

.btn-ghost:hover {
  background: var(--bg-elevated);
  border-color: #3b4f73;
}

.btn-xs {
  padding: 3px 8px;
  font-size: 11px;
}

.btn-add {
  background: var(--accent-bg);
  color: #7cc0ff;
  border-color: rgba(59, 130, 246, 0.4);
}

.btn-add:hover {
  background: var(--accent);
  color: #fff;
}

.btn-added {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-muted);
  border-color: transparent;
  cursor: default;
}

/* ==================== INDICES STRIP ==================== */
.indices-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 8px;
  padding: 8px 20px;
  background: #0c1019;
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
}

.index-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 11px;
  border-radius: 7px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.index-chip:hover {
  border-color: var(--accent);
  background: var(--bg-card-2);
}

.index-chip-left {
  display: flex;
  flex-direction: column;
}

.index-chip-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.index-chip-price {
  font-size: 12px;
  font-family: var(--mono);
  font-weight: 600;
}

.index-chip-right {
  text-align: right;
}

.index-chip-pct {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
}

.index-chip-chg {
  font-family: var(--mono);
  font-size: 11px;
  opacity: 0.85;
}

/* ==================== MAIN CONTAINER ==================== */
.main-container {
  max-width: 1760px;
  margin: 0 auto;
  padding: 14px 20px 36px;
}

.view-panel {
  display: none;
}

.view-panel.active {
  display: block;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ==================== VIEW 1: SECTORS ==================== */
.panel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.sector-type-tabs {
  display: flex;
  gap: 8px;
}

.sub-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.sub-tab:hover {
  color: var(--text-primary);
  border-color: #3a4c6e;
}

.sub-tab.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--accent);
}

.count-pill {
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 99px;
  background: rgba(148, 163, 184, 0.14);
  color: var(--text-secondary);
}

.sub-tab.active .count-pill {
  background: var(--accent-bg);
  color: #7cc0ff;
}

.sector-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 8px;
  width: 240px;
}

.search-box.full-width {
  width: 100%;
}

.search-box:focus-within {
  border-color: var(--accent);
}

.search-icon {
  color: var(--text-muted);
  font-size: 14px;
  margin-right: 6px;
}

.search-box input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  padding: 6px 2px;
  font-size: 12px;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.clear-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  padding: 0 3px;
}

.clear-btn:hover { color: var(--text-primary); }

.segmented {
  display: inline-flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.segmented.small .seg-btn {
  padding: 3px 8px;
  font-size: 11px;
}

.seg-btn.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

/* Breadth Bar */
.breadth-bar-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.breadth-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 280px;
}

.breadth-item {
  display: flex;
  align-items: baseline;
  gap: 5px;
  white-space: nowrap;
}

.breadth-item .label {
  color: var(--text-secondary);
  font-size: 12px;
}

.breadth-item strong {
  font-family: var(--mono);
  font-size: 15px;
}

.breadth-visual {
  flex: 1;
  min-width: 120px;
  max-width: 320px;
}

.breadth-track {
  display: flex;
  height: 8px;
  border-radius: 99px;
  overflow: hidden;
  background: #1e293b;
}

.breadth-fill-up { background: var(--up); transition: width 0.3s ease; }
.breadth-fill-flat { background: #64748b; transition: width 0.3s ease; }
.breadth-fill-down { background: var(--down); transition: width 0.3s ease; }

.filter-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pill {
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.pill:hover { color: var(--text-primary); border-color: #3f5175; }
.pill.active {
  background: var(--accent-bg);
  color: #7cc0ff;
  border-color: rgba(59, 130, 246, 0.5);
}

.status-banner {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fbbf24;
  font-size: 12px;
}

/* Sector Heatmap Grid */
.sector-heatmap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(146px, 1fr));
  gap: 7px;
}

.sector-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease, border-color 0.15s;
  min-height: 76px;
  overflow: hidden;
}

.sector-tile:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  z-index: 2;
}

.tile-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 4px;
}

.tile-name {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-pct {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  margin: 3px 0 2px;
  letter-spacing: -0.3px;
}

.tile-sub {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.82);
  white-space: nowrap;
  overflow: hidden;
}

.tile-lead {
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-inflow {
  font-family: var(--mono);
  opacity: 0.9;
  flex-shrink: 0;
}

/* Full Table View */
.table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead th {
  position: sticky;
  top: 0;
  background: #141c2b;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table thead th.num { text-align: right; }
.data-table thead th.sortable { cursor: pointer; }
.data-table thead th.sortable:hover { color: var(--text-primary); }

.data-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background 0.12s;
}

.data-table tbody tr:hover {
  background: rgba(59, 130, 246, 0.08);
}

.data-table tbody td {
  padding: 9px 12px;
  white-space: nowrap;
}

.data-table tbody td.num { text-align: right; font-family: var(--mono); }

.col-rank { width: 42px; color: var(--text-muted); font-family: var(--mono); }

.sector-name-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sector-name-main { font-weight: 600; color: var(--text-primary); }
.sector-code-sub { font-family: var(--mono); font-size: 11px; color: var(--text-muted); }

.pct-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 5px;
  font-family: var(--mono);
  font-weight: 700;
  min-width: 68px;
  text-align: right;
}

.pct-badge.up { background: var(--up-bg); color: var(--up-bright); }
.pct-badge.down { background: var(--down-bg); color: var(--down-bright); }
.pct-badge.flat { background: rgba(148, 163, 184, 0.12); color: var(--flat); }

.ratio-mini-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
}

.ratio-bar-track {
  width: 72px;
  height: 6px;
  border-radius: 99px;
  overflow: hidden;
  background: #1f2937;
  display: flex;
}

.ratio-bar-up { background: var(--up); }
.ratio-bar-down { background: var(--down); }

/* ==================== VIEW 2: 017470 HERO & WATCHLIST ==================== */
.chip-hero-card {
  background: linear-gradient(145deg, #131b2c 0%, #101623 55%, #121826 100%);
  border: 1px solid #293856;
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

.chip-hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.chip-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.chip-title-row h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.code-tag {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(148, 163, 184, 0.14);
  color: #cbd5e1;
}

.meta-tag {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}

.meta-tag.accent {
  background: var(--accent-bg);
  color: #7cc0ff;
}

.chip-subtitle {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

.chip-subtitle strong {
  color: #cbd5e1;
}

.ratio-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ratio-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.chip-metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(210px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.hero-metric-box {
  background: rgba(10, 14, 23, 0.65);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 12px 14px;
  transition: border-color 0.16s, background 0.16s;
}

.hero-metric-box.primary-box {
  border-color: rgba(59, 130, 246, 0.42);
  background: linear-gradient(160deg, rgba(59, 130, 246, 0.09), rgba(10, 14, 23, 0.8));
}

.hero-metric-box.clickable {
  cursor: pointer;
}

.hero-metric-box.clickable:hover {
  border-color: var(--accent);
  background: rgba(28, 38, 56, 0.65);
}

.metric-box-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.metric-box-label em {
  font-style: normal;
  color: #93c5fd;
  font-family: var(--mono);
}

.live-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 99px;
  background: rgba(16, 185, 129, 0.16);
  color: #34d399;
  font-weight: 600;
}

.sub-time, .click-hint {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--mono);
}

.click-hint {
  color: #7cc0ff;
}

.metric-big-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}

.big-pct {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.big-nav {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.metric-foot {
  font-size: 11px;
  color: var(--text-muted);
}

.metric-foot strong {
  color: var(--text-secondary);
  font-family: var(--mono);
}

/* Chip Leaders Strip */
.chip-leaders-section {
  border-top: 1px solid var(--border-subtle);
  padding-top: 10px;
}

.chip-leaders-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.section-mini-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.section-mini-title small {
  font-weight: 400;
  color: var(--text-muted);
}

.recent-nav-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-hist-pill {
  font-size: 11px;
  font-family: var(--mono);
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.chip-leaders-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 6px;
}

.leader-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 7px;
  background: rgba(11, 16, 26, 0.75);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.leader-pill:hover {
  border-color: var(--accent);
  background: var(--bg-elevated);
}

.leader-info {
  min-width: 0;
}

.leader-name {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leader-price {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

.leader-right {
  display: flex;
  align-items: center;
  gap: 5px;
}

.leader-pct {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
}

.mini-add-btn {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mini-add-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ==================== WATCHLIST SPLIT WORKSPACE ==================== */
.watchlist-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.38fr) minmax(350px, 1fr);
  gap: 14px;
  align-items: start;
}

/* Detail Pane (Left) */
.detail-pane {
  padding: 14px 16px;
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 12px;
}

.detail-name-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.detail-name-line h3 {
  font-size: 17px;
  font-weight: 700;
}

.detail-price-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.detail-price {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.detail-change, .detail-pct {
  font-size: 14px;
  font-weight: 700;
}

.detail-kv-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(78px, 1fr));
  gap: 6px 14px;
}

.kv {
  display: flex;
  flex-direction: column;
}

.kv span {
  font-size: 11px;
  color: var(--text-muted);
}

.kv strong {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
}

.detail-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  gap: 14px;
}

.chart-box {
  display: flex;
  flex-direction: column;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.leg-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.price-dot { background: #38bdf8; }
.avg-dot { background: #f59e0b; }

#chartHoverInfo {
  margin-left: auto;
  font-family: var(--mono);
  color: var(--text-primary);
}

.canvas-wrap {
  position: relative;
  width: 100%;
  height: 330px;
  background: #0c111b;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
}

#intradayCanvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

/* Order Book */
.orderbook-box {
  background: #0c111b;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.orderbook-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.ob-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3.5px 4px;
  font-family: var(--mono);
  font-size: 12px;
  border-radius: 4px;
  overflow: hidden;
}

.ob-bar {
  position: absolute;
  top: 1px;
  bottom: 1px;
  right: 0;
  opacity: 0.16;
  pointer-events: none;
}

.ob-bar.ask { background: var(--down); }
.ob-bar.bid { background: var(--up); }

.ob-lbl { color: var(--text-muted); font-size: 11px; width: 28px; position: relative; }
.ob-price { font-weight: 600; position: relative; }
.ob-vol { color: var(--text-secondary); font-size: 11px; position: relative; }

.ob-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

/* Watchlist Pane (Right) */
.watchlist-pane {
  padding: 14px;
}

.watchlist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.wl-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wl-title-row h3 {
  font-size: 15px;
  font-weight: 700;
}

.wl-hint {
  font-size: 11px;
  color: var(--text-muted);
}

.add-stock-wrap {
  position: relative;
  margin-bottom: 8px;
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 30;
  background: #141c2c;
  border: 1px solid #354769;
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  max-height: 290px;
  overflow-y: auto;
}

.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 11px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: rgba(59, 130, 246, 0.12); }

.sr-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.sr-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sr-code {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

.sr-tag {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(148, 163, 184, 0.14);
  color: var(--text-secondary);
  flex-shrink: 0;
}

.quick-add-row {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.quick-label {
  font-size: 11px;
  color: var(--text-muted);
}

.quick-chip {
  padding: 2px 7px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}

.quick-chip:hover {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent-bg);
}

.watchlist-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 440px;
  overflow-y: auto;
  padding-right: 2px;
}

.wl-item {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) 76px 82px 26px;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 8px;
  background: #0d131f;
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: border-color 0.14s, background 0.14s;
}

.wl-item:hover {
  background: #141d2e;
  border-color: #354769;
}

.wl-item.selected {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.11);
}

.wl-item.flash-up { animation: flashUp 0.75s ease; }
.wl-item.flash-down { animation: flashDown 0.75s ease; }

@keyframes flashUp {
  0% { background: rgba(242, 54, 69, 0.28); }
  100% { background: #0d131f; }
}

@keyframes flashDown {
  0% { background: rgba(0, 184, 124, 0.28); }
  100% { background: #0d131f; }
}

.wl-name-col {
  min-width: 0;
}

.wl-name-top {
  display: flex;
  align-items: center;
  gap: 5px;
}

.wl-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wl-sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  gap: 6px;
}

.wl-price-col {
  text-align: right;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
}

.wl-pct-col {
  text-align: right;
}

.wl-del-btn {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wl-del-btn:hover {
  background: rgba(242, 54, 69, 0.18);
  color: var(--up-bright);
}

/* ==================== SECTOR CONSTITUENTS DRAWER ==================== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(2px);
}

.sector-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(560px, 94vw);
  z-index: 70;
  background: #0e1420;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.5);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: #121a29;
}

.drawer-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.drawer-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  font-family: var(--mono);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
}

.drawer-stock-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) 74px 78px 74px 82px;
  align-items: center;
  gap: 8px;
  padding: 8px 8px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px;
}

.drawer-stock-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.drawer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 5px;
}

/* ==================== TOAST & MISC ==================== */
.loading-inline, .indices-loading {
  padding: 14px;
  color: var(--text-muted);
  text-align: center;
}

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  padding: 9px 18px;
  border-radius: 8px;
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #3b82f6;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  font-size: 13px;
  font-weight: 500;
}

/* Responsive */
@media (max-width: 1220px) {
  .chip-metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .watchlist-workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 780px) {
  .indices-strip {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }
  .detail-body {
    grid-template-columns: 1fr;
  }
  .chip-metrics-grid {
    grid-template-columns: 1fr;
  }
}
