:root {
  /* HKStock.AI Logo Core Tri-Color: Blue, Red, Green */
  --brand-blue: #0e4c9d;       /* Logo Navy Blue (PENG LENG JENG & hkstock.ai) */
  --brand-blue-hover: #093874; /* Logo Darker Blue Hover */
  --brand-blue-light: #f0f6ff; /* Soft Brand Blue Tint */
  --brand-red: #e71e25;        /* Logo Red (平靚正) */
  --brand-red-light: rgba(231, 30, 37, 0.10);
  --brand-green: #2baf7e;      /* Logo Green (Ai) */
  --brand-green-light: rgba(43, 175, 126, 0.12);
  
  /* Layout & System Tokens */
  --bg: #f8fafc;
  --bg2: #ffffff;
  --bg3: #f1f5f9;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text2: #64748b;
  --muted: #64748b;
  --radius: 12px;

  /* Semantic Color Mapping: Strictly Logo Green & Logo Red */
  --bull: #2baf7e;             /* Logo Green */
  --bull-bg: rgba(43, 175, 126, 0.12);
  --bear: #e71e25;             /* Logo Red */
  --bear-bg: rgba(231, 30, 37, 0.10);
  --neutral: #94a3b8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft JhengHei", sans-serif;
  line-height: 1.5;
}

/* Official Logo Tri-Color Top Accent Border (Blue -> Green -> Red) */
body::before {
  content: "";
  display: block;
  height: 3.5px;
  background: linear-gradient(90deg, #0e4c9d 0%, #0e4c9d 48%, #36afb7 72%, #2baf7e 86%, #e71e25 100%);
  width: 100%;
}

/* Brand Navigation Header */
.site-header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
}
.site-header-inner {
  max-width: 1600px;
  margin: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.brand-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}
.brand-link img {
  height: 42px;
  display: block;
}
.header-nav {
  display: flex;
  align-items: center;
  gap: 14px;
}
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--brand-blue);
  text-decoration: none;
  padding: 7px 14px;
  border-radius: 8px;
  background: var(--brand-blue-light);
  border: 1px solid #bfdbfe;
  transition: all 0.15s;
}
.back-btn:hover {
  background: #dbeafe;
  color: var(--brand-blue-hover);
}
.nav-badge {
  font-size: 11px;
  letter-spacing: 1.5px;
  font-weight: 700;
  color: var(--brand-blue);
  text-transform: uppercase;
}

/* App Layout: Container and Left Sidebar Navigation */
.container {
  display: flex;
  min-height: calc(100vh - 71px);
}
.sidebar {
  width: 250px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.nav-section {
  padding: 20px 20px 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
}
.nav-item {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text2);
  cursor: pointer;
  transition: 0.2s;
  border-left: 4px solid transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-decoration: none;
}
.nav-item:hover {
  background: #f0f6ff;
  color: var(--brand-blue);
  border-left: 4px solid var(--brand-blue);
}
.nav-item.active {
  background: #f0f6ff;
  color: var(--brand-blue);
  border-left: 4px solid var(--brand-red);
  font-weight: 700;
}
.sidebar-collapsible summary {
  list-style: none;
}
.sidebar-collapsible summary::-webkit-details-marker {
  display: none;
}
.sidebar-collapsible[open] .details-arrow {
  transform: rotate(180deg);
}
.badge {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  display: inline-block;
}
.b-green { background: rgba(43,175,126,0.12); color: #1b7a54; border: 1px solid rgba(43,175,126,0.35); }
.b-red { background: rgba(231,30,37,0.12); color: #d0141b; border: 1px solid rgba(231,30,37,0.35); }
.b-gold { background: rgba(245,158,11,0.15); color: #d97706; border: 1px solid rgba(245,158,11,0.3); }
.b-blue { background: rgba(14,76,157,0.12); color: var(--brand-blue); border: 1px solid rgba(14,76,157,0.35); }

.breadth-page {
  flex: 1;
  min-width: 0;
  max-width: 1360px;
  padding: 24px 28px 48px;
}

@media (max-width: 900px) {
  .container {
    flex-direction: column !important;
  }
  .sidebar {
    width: 100% !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border) !important;
  }
  .breadth-page {
    padding: 16px 14px 32px !important;
  }
}

header.page-intro { padding: 20px 0 16px; }
.eyebrow {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--brand-blue);
  text-transform: uppercase;
}
h1 {
  font-size: clamp(26px, 4vw, 38px);
  margin: 6px 0 10px;
  font-weight: 800;
  color: var(--brand-blue);
}
h2 {
  font-size: 20px;
  margin: 0;
  font-weight: 700;
  color: var(--text);
}
p { margin: 6px 0; color: #334e59; }
.muted, footer { color: var(--muted); font-size: 13px; }

.section-header {
  margin: 32px 0 14px;
}
.section-header h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--brand-blue);
}
.section-header p {
  margin-top: 4px;
}

/* Controls & Buttons in Logo Blue */
button, input, select {
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  background: white;
  color: var(--text);
  transition: all 0.15s ease;
}
button { cursor: pointer; }
button:hover {
  background: var(--brand-blue-light);
  border-color: #bfdbfe;
  color: var(--brand-blue);
}
button[aria-pressed=true], button.active {
  background: var(--brand-blue);
  color: white;
  border-color: var(--brand-blue);
  box-shadow: 0 1px 3px rgba(14, 76, 157, 0.25);
}
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid var(--brand-blue);
  outline-offset: 2px;
}

.toolbar { margin: 16px 0; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.market-toggle-group button { font-weight: 600; font-size: 13.5px; }
.date-ctrls { display: flex; align-items: center; gap: 8px; font-size: 13px; }

#breadth-status {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
  padding: 4px 0;
}

/* 1. Overview Dashboard Section */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
  margin-top: 12px;
}

.overview-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 3px rgba(14, 76, 157, 0.04);
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: box-shadow 0.2s;
}
.overview-card:hover {
  box-shadow: 0 4px 14px rgba(14, 76, 157, 0.08);
}

.ov-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ov-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--brand-blue);
  display: flex;
  align-items: center;
  gap: 6px;
}
.ov-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
}
.ov-badge-bull { background: var(--bull-bg); color: #1b7a54; border: 1px solid rgba(43, 175, 126, 0.35); }
.ov-badge-bear { background: var(--bear-bg); color: #d0141b; border: 1px solid rgba(231, 30, 37, 0.35); }
.ov-badge-neutral { background: var(--brand-blue-light); color: var(--brand-blue); border: 1px solid #bfdbfe; }

.ov-body {
  display: flex;
  gap: 18px;
  align-items: center;
}

/* Circular Radial Meter (Green for Bullish, Red for Bearish) */
.radial-meter {
  position: relative;
  width: 96px;
  height: 96px;
  flex-shrink: 0;
}
.radial-meter svg {
  transform: rotate(-90deg);
  width: 96px;
  height: 96px;
}
.radial-bg {
  fill: none;
  stroke: #e2e8f0;
  stroke-width: 8;
}
.radial-fill {
  fill: none;
  stroke: var(--brand-green);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s ease;
}
.radial-fill.is-bear { stroke: var(--brand-red); }
.radial-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}
.radial-val {
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}
.radial-label {
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}

.ov-metrics {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.metric-bar-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.metric-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}
.metric-bar-label strong {
  color: var(--text);
}

/* Advance / Decline Segmented Momentum Bar (Green / Gray / Red) */
.ad-momentum-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ad-stacked-bar {
  display: flex;
  height: 10px;
  border-radius: 6px;
  overflow: hidden;
  background: #e2e8f0;
  width: 100%;
}
.ad-seg-adv { background: var(--brand-green); transition: width 0.3s; }
.ad-seg-unch { background: var(--neutral); transition: width 0.3s; }
.ad-seg-dec { background: var(--brand-red); transition: width 0.3s; }

.ad-legend {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--muted);
}
.ad-legend span { display: inline-flex; align-items: center; gap: 3px; }
.ad-adv-txt { color: #1b7a54; font-weight: 600; }
.ad-dec-txt { color: #d0141b; font-weight: 600; }

/* 2. Eight Basket Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.breadth-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 3px rgba(14, 76, 157, 0.04);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.breadth-card:hover {
  box-shadow: 0 4px 14px rgba(14, 76, 157, 0.08);
  border-color: #bfdbfe;
}
.breadth-card.card-expanded {
  grid-column: span 2;
  box-shadow: 0 4px 20px rgba(14, 76, 157, 0.12);
  border-color: #93c5fd;
}
@media (max-width: 900px) {
  .breadth-card.card-expanded {
    grid-column: 1 / -1;
  }
}

.breadth-card .card-head {
  margin-bottom: 12px;
}
.breadth-card .subtitle {
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.breadth-card h3 {
  margin: 6px 0 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--brand-blue);
  min-height: 40px;
  line-height: 1.35;
}

/* Gauge comparisons inside basket cards */
.card-gauges {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 10px 0 14px;
}
.gauge-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.gauge-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}
.gauge-pct {
  font-weight: 700;
  color: var(--text);
}
.gauge-pct.is-bull { color: #1b7a54; }
.gauge-pct.is-bear { color: #d0141b; }

.gauge-track {
  position: relative;
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: visible;
}
.gauge-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--brand-green);
  transition: width 0.4s ease;
}
.gauge-fill.is-bear { background: var(--brand-red); }
.gauge-fill.is-ma200 { background: var(--brand-blue); }

/* Center 50% benchmark tick */
.gauge-tick-50 {
  position: absolute;
  left: 50%;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: rgba(14, 76, 157, 0.4);
  border-radius: 1px;
}

.breadth-card .pending-box {
  background: #fffbeb;
  border: 1px dashed #fcd34d;
  border-radius: 8px;
  padding: 16px 12px;
  margin: 12px 0;
  text-align: center;
}
.breadth-card .pending-title {
  color: var(--brand-blue);
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
}

.card-footer {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.5;
}
.card-footer a {
  color: var(--brand-blue);
  text-decoration: none;
}
.card-footer a:hover {
  text-decoration: underline;
  color: var(--brand-red);
}

/* 3. History Chart Section */
.history-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.history-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(14, 76, 157, 0.04);
}
.history-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.history-card h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--brand-blue);
}
.history-current-pill {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 6px;
  background: var(--brand-blue-light);
  color: var(--brand-blue);
  border: 1px solid #bfdbfe;
}

.chart-svg-wrap {
  position: relative;
  width: 100%;
}
.history-card svg {
  width: 100%;
  height: auto;
  overflow: visible;
}
.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(14, 76, 157, 0.95);
  color: white;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 11.5px;
  line-height: 1.4;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  transform: translate(-50%, -120%);
  display: none;
  z-index: 10;
  border: 1px solid rgba(255,255,255,0.2);
}

/* 4. Sectors & Industries Visual Views */
.groups-toolbar {
  margin: 0 0 12px;
}
.view-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.view-switch-group {
  display: flex;
  background: #e2e8f0;
  padding: 3px;
  border-radius: 8px;
  gap: 2px;
}
.view-btn {
  border: none;
  background: transparent;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  color: #475569;
}
.view-btn.active {
  background: white;
  color: var(--brand-blue);
  box-shadow: 0 1px 3px rgba(14, 76, 157, 0.15);
}

.filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  background: #f1f5f9;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.sort-ctrls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.sort-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  background: white;
  border: 1px solid var(--border);
  color: var(--muted);
}
.sort-pill.active {
  background: var(--brand-blue);
  color: white;
  border-color: var(--brand-blue);
}
.search-ctrls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.search-ctrls input {
  padding: 6px 12px;
  font-size: 13px;
  min-width: 240px;
}

/* Visual Horizontal Bar Chart View (Green for >=50%, Red for <50%) */
.groups-chart-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.group-bar-row {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: 200px 1fr 180px;
  align-items: center;
  gap: 16px;
  box-shadow: 0 1px 3px rgba(14, 76, 157, 0.03);
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.group-bar-row:hover {
  border-color: #bfdbfe;
  box-shadow: 0 4px 12px rgba(14, 76, 157, 0.08);
  transform: translateY(-1px);
}

.bar-row-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.bar-row-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 14.5px;
  color: var(--brand-blue);
}
.bar-row-en {
  font-size: 11px;
  color: var(--muted);
}
.bar-row-count {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}

/* Center Dual Bar Graphic */
.bar-row-visual {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bar-track-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.bar-metric-track {
  position: relative;
  width: 100%;
  height: 18px;
  background: #e2e8f0;
  border-radius: 6px;
  overflow: hidden;
}
.bar-metric-fill {
  height: 100%;
  background: var(--brand-green);
  border-radius: 6px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  color: white;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  transition: width 0.4s ease;
}
.bar-metric-fill.is-bear {
  background: var(--brand-red);
}

.bar-track-50mark {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(14, 76, 157, 0.35);
  z-index: 2;
}

.bar-sub-track {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}
.mini-line-track {
  flex: 1;
  height: 4px;
  background: #e2e8f0;
  border-radius: 2px;
  overflow: hidden;
}
.mini-line-fill {
  height: 100%;
  background: var(--brand-blue);
  border-radius: 2px;
}

/* Right Column: A/D & Net in Logo Green and Red */
.bar-row-ad {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.bar-ad-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
}
.bar-ad-badge.pos { background: var(--bull-bg); color: #1b7a54; border: 1px solid rgba(43, 175, 126, 0.35); }
.bar-ad-badge.neg { background: var(--bear-bg); color: #d0141b; border: 1px solid rgba(231, 30, 37, 0.35); }
.bar-ad-mini-bar {
  width: 120px;
  height: 6px;
  display: flex;
  border-radius: 3px;
  overflow: hidden;
  background: #e2e8f0;
}

/* Matrix Tiles View in Logo Colors */
.groups-matrix-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.matrix-quadrant {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: 0 1px 3px rgba(14, 76, 157, 0.04);
}
.quadrant-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.quadrant-title {
  font-size: 14.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--brand-blue);
}
.quadrant-cards-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.quadrant-item {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.15s;
}
.quadrant-item:hover {
  background: var(--brand-blue-light);
  border-color: #bfdbfe;
}

/* Data Table View */
.table-wrap {
  overflow-x: auto;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
table {
  border-collapse: collapse;
  width: 100%;
  white-space: nowrap;
  text-align: left;
}
th, td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
th {
  background: var(--bg3);
  color: var(--text2);
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { background: #e2e8f0; color: var(--brand-blue); }
th.sortable.active { background: #e0e7ff; color: var(--brand-blue); font-weight: 700; }
th.sortable.active .sort-icon { color: var(--brand-blue); }

.cell-metric { display: flex; align-items: center; gap: 8px; }
.pct-val { font-weight: 700; min-width: 48px; }
.pct-val.is-bull { color: #1b7a54; }
.pct-val.is-bear { color: #d0141b; }
.mini-track { flex: 1; min-width: 45px; max-width: 75px; height: 6px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
.mini-fill { height: 100%; background: var(--brand-green); border-radius: 4px; }
.mini-fill.is-bear { background: var(--brand-red); }

.mkt-tag { font-size: 10.5px; font-weight: 700; padding: 2px 5px; border-radius: 4px; line-height: 1; }
.tag-hk { background: rgba(14, 76, 157, 0.12); color: #0e4c9d; }
.tag-us { background: rgba(231, 30, 37, 0.10); color: #d0141b; }

.net-pos { color: #1b7a54; font-weight: 700; }
.net-neg { color: #d0141b; font-weight: 700; }

details {
  background: #f1f5f9;
  border: 1px solid var(--border);
  padding: 18px;
  margin-top: 30px;
  border-radius: var(--radius);
}
footer { padding: 24px 0; }

/* Responsive adjustments */
@media (max-width: 1050px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-grid { grid-template-columns: 1fr; }
  .groups-matrix-container { grid-template-columns: 1fr; }
  .group-bar-row { grid-template-columns: 160px 1fr 140px; }
}

@media (max-width: 640px) {
  .breadth-page { padding: 16px 12px; }
  .site-header { padding: 10px 14px; }
  .cards { grid-template-columns: 1fr; }
  .overview-grid { grid-template-columns: 1fr; }
  .group-bar-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .bar-row-ad { align-items: flex-start; }
  .search-ctrls input { min-width: 100%; }
}

/* ==========================================================================
   Day-Night Volume-Price Direction Monitor Styles
   ========================================================================== */

/* Mode Switcher Group */
.mode-toggle-group {
  display: inline-flex;
  background: var(--bg3);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border);
  gap: 4px;
}
.mode-btn {
  border: none;
  background: transparent;
  color: var(--text2);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.mode-btn.active {
  background: var(--brand-blue);
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(14, 76, 157, 0.25);
}

/* 3-Segment Direction Stacked Bar */
.dir-stacked-bar {
  display: flex;
  width: 100%;
  flex: 1;
  min-width: 160px;
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  background: #e2e8f0;
  margin: 6px 0;
}
.dir-seg-up {
  background: var(--brand-green);
  transition: width 0.4s ease;
}
.dir-seg-flat {
  background: #94a3b8;
  transition: width 0.4s ease;
}
.dir-seg-down {
  background: var(--brand-red);
  transition: width 0.4s ease;
}

/* Direction Legend */
.dir-legend {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.dir-txt-up { color: var(--brand-green); font-weight: 700; }
.dir-txt-flat { color: #64748b; font-weight: 700; }
.dir-txt-down { color: var(--brand-red); font-weight: 700; }

/* Recent Change Badge Row */
.dir-change-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  padding: 6px 10px;
  background: var(--bg3);
  border-radius: 6px;
  margin-top: 6px;
  border: 1px solid rgba(0,0,0,0.04);
}
.dir-pp-badge {
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}
.dir-pp-pos { background: var(--bull-bg); color: var(--brand-green); }
.dir-pp-neg { background: var(--bear-bg); color: var(--brand-red); }

/* Extreme Observation Banner */
.extreme-alert-card {
  background: linear-gradient(135deg, rgba(231,30,37,0.06) 0%, rgba(14,76,157,0.04) 100%);
  border: 1px solid rgba(231,30,37,0.25);
  border-radius: var(--radius);
  padding: 12px 18px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.extreme-alert-title {
  font-weight: 700;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.extreme-alert-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 12px;
}
.extreme-badge-danger { background: var(--bear-bg); color: var(--brand-red); border: 1px solid rgba(231,30,37,0.4); }
.extreme-badge-warning { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.extreme-badge-success { background: var(--bull-bg); color: var(--brand-green); border: 1px solid rgba(43,175,126,0.4); }

/* Drill-Down Collapsible Drawer */
.drilldown-btn {
  width: 100%;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--brand-blue);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.15s ease;
}
.drilldown-btn:hover {
  background: var(--brand-blue-light);
  border-color: #bfdbfe;
}
.drilldown-content {
  display: none;
  margin-top: 8px;
  padding: 8px 10px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11.5px;
  overflow-x: auto;
  max-width: 100%;
}
.drilldown-content.active {
  display: block;
}
.drilldown-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 4px;
  min-width: 440px;
}
.drilldown-table th {
  text-align: left;
  font-size: 10.5px;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  padding: 5px 6px;
  white-space: nowrap;
}
.drilldown-table td {
  padding: 5px 6px;
  border-bottom: 1px solid rgba(0,0,0,0.03);
  font-size: 11px;
  white-space: nowrap;
}

/* ─────────────────────────────────────────────────────────────
   SIGNAL TRACKER & HISTORICAL VERIFICATION RADAR
   ───────────────────────────────────────────────────────────── */
#signal-tracker-section {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-top: 20px;
}
.tracker-intro-card {
  background: linear-gradient(135deg, #f8fafc 0%, #edf4fc 100%);
  border: 1px solid #cbd5e1;
  border-left: 5px solid var(--brand-blue);
  border-radius: var(--radius);
  padding: 18px 22px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.tracker-intro-card h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--brand-blue);
  margin: 0 0 6px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tracker-intro-card p {
  margin: 0;
  font-size: 13.5px;
  color: #334155;
  line-height: 1.6;
}

/* 4 Scorecards Grid */
.tracker-scorecards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.tracker-sc-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.03);
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
}
.tracker-sc-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}
.tracker-sc-card.card-5d::before { background: var(--brand-blue); }
.tracker-sc-card.card-10d::before { background: #0284c7; }
.tracker-sc-card.card-20d::before { background: var(--bull); }
.tracker-sc-card.card-lead::before { background: #f59e0b; }

.tracker-sc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.tracker-sc-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text2);
}
.tracker-sc-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #475569;
}
.tracker-sc-main-metric {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.tracker-sc-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.tracker-sc-value.pos { color: var(--bull); }
.tracker-sc-value.lead { color: #d97706; }
.tracker-sc-label {
  font-size: 13px;
  color: var(--text2);
  font-weight: 600;
}
.tracker-sc-submetrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  border-top: 1px dashed var(--border);
  padding-top: 10px;
  font-size: 11.5px;
}
.tracker-sc-sub-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tracker-sc-sub-title {
  color: #64748b;
  font-size: 10.5px;
}
.tracker-sc-sub-val {
  font-weight: 700;
  color: #1e293b;
}

/* Comparison Table Card */
.tracker-panel-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}
.tracker-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}
.tracker-panel-title {
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tracker-comp-table {
  width: 100%;
  border-collapse: collapse;
}
.tracker-comp-table th {
  background: #f8fafc;
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  text-align: left;
  padding: 10px 14px;
  border-bottom: 2px solid var(--border);
}
.tracker-comp-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  color: #1e293b;
}
.tracker-comp-table tr.highlight-row {
  background: rgba(14, 76, 157, 0.03);
  font-weight: 600;
}
.tracker-comp-table tr.highlight-row td:first-child {
  border-left: 4px solid var(--brand-blue);
  color: var(--brand-blue);
  font-weight: 700;
}

/* Active Signals Table */
.tracker-table-ctrls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.tracker-tabs {
  display: flex;
  gap: 6px;
}
.tracker-tab-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #475569;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.tracker-tab-btn:hover { background: #e2e8f0; }
.tracker-tab-btn.active {
  background: var(--brand-blue);
  color: #ffffff;
  border-color: var(--brand-blue);
}
.tracker-search-input {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  width: 240px;
}
.tracker-progress-wrap {
  width: 90px;
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 3px;
}
.tracker-progress-bar {
  height: 100%;
  background: var(--brand-blue);
  border-radius: 3px;
}

/* ─────────────────────────────────────────────────────────────
   VISUAL CHARTS STYLES FOR DAY-NIGHT DIRECTION MONITOR
   ───────────────────────────────────────────────────────────── */

/* Donut Chart Component */
.donut-chart-wrap {
  position: relative;
  width: 104px;
  height: 104px;
  flex-shrink: 0;
}
.donut-chart-wrap svg {
  transform: rotate(-90deg);
  width: 104px;
  height: 104px;
  display: block;
}
.donut-bg {
  fill: none;
  stroke: #f1f5f9;
  stroke-width: 12;
}
.donut-seg {
  fill: none;
  stroke-width: 12;
  transition: stroke-dasharray 0.6s ease, stroke-dashoffset 0.6s ease;
}
.donut-seg.donut-up { stroke: var(--brand-green); }
.donut-seg.donut-flat { stroke: #94a3b8; }
.donut-seg.donut-down { stroke: var(--brand-red); }
.donut-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}
.donut-val {
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}
.donut-sub {
  font-size: 10.5px;
  font-weight: 700;
  margin-top: 3px;
}

/* 5-Day Delta Divergence Bar */
.delta-chart-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  margin-top: 2px;
}
.delta-bar-track {
  flex: 1;
  height: 7px;
  background: #f1f5f9;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}
.delta-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

/* Grouped Comparative Horizontal Bar Chart (Card 3) */
.comp-chart-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}
.comp-chart-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.comp-row-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
}
.comp-bars-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.comp-single-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}
.comp-mkt-label {
  width: 46px;
  flex-shrink: 0;
  font-weight: 600;
  color: #475569;
}
.comp-bar-track {
  flex: 1;
  height: 10px;
  background: #f1f5f9;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.comp-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}
.comp-bar-val {
  width: 44px;
  text-align: right;
  font-weight: 700;
  font-size: 11.5px;
  flex-shrink: 0;
}

/* Top 10 Stocks Visual Mini Return Bar & Badges */
.mini-return-cell {
  position: relative;
  width: 90px;
  height: 22px;
  background: #f8fafc;
  border: 1px solid #f1f5f9;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  padding: 0 6px;
}
.mini-return-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  border-radius: 3px;
  opacity: 0.22;
}
.mini-return-fill.pos { background: var(--brand-green); }
.mini-return-fill.neg { background: var(--brand-red); }
.mini-return-val {
  position: relative;
  font-weight: 700;
  font-size: 11.5px;
  z-index: 1;
}

.on-day-split-bar {
  display: flex;
  width: 90px;
  height: 6px;
  border-radius: 3px;
  background: #e2e8f0;
  overflow: hidden;
  margin-top: 3px;
}
.on-split-seg { background: #3b82f6; transition: width 0.3s; }
.day-split-seg { background: #10b981; transition: width 0.3s; }

.rvol-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}
.rvol-badge.rvol-high {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}
.rvol-badge.rvol-mid {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #e2e8f0;
}
.rvol-badge.rvol-low {
  background: #f8fafc;
  color: #94a3b8;
  border: 1px solid #f1f5f9;
}

/* Section 3: Cross-Market Multi-Basket Direction Comparison Chart */
.basket-comp-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: 0 1px 3px rgba(14, 76, 157, 0.04);
}
.basket-comp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
}
.basket-comp-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--brand-blue);
  display: flex;
  align-items: center;
  gap: 8px;
}
.basket-comp-tabs {
  display: flex;
  gap: 6px;
}
.basket-comp-tab-btn {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #475569;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.basket-comp-tab-btn.active {
  background: var(--brand-blue);
  color: #ffffff;
  border-color: var(--brand-blue);
}
.basket-comp-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.basket-comp-row {
  display: grid;
  grid-template-columns: 220px 1fr 150px;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid #f1f5f9;
  transition: background 0.15s, border-color 0.15s;
}
.basket-comp-row:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}
.basket-comp-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.basket-comp-name {
  font-weight: 700;
  font-size: 13.5px;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 6px;
}
.basket-comp-sub {
  font-size: 11px;
  color: #64748b;
}
.basket-comp-bar-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.basket-comp-stacked {
  position: relative;
  height: 16px;
  border-radius: 6px;
  overflow: hidden;
  background: #e2e8f0;
  display: flex;
  width: 100%;
}
.basket-comp-tick-50 {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(14, 76, 157, 0.45);
  z-index: 2;
}
.basket-comp-stats-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-size: 12px;
}
@media (max-width: 820px) {
  .basket-comp-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .basket-comp-stats-col {
    align-items: flex-start;
  }
}

/* ─────────────────────────────────────────────────────────────
   UNIFIED COMPASS (三合一全景綜合羅盤)
   大市宏觀體質（健康水位） ｜ 莊家力量動能（即時轉向） ｜ 訊號審計檢驗（勝率與盈虧比）
   ───────────────────────────────────────────────────────────── */
.unified-compass-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 16px 0 28px;
}
@media (max-width: 960px) {
  .unified-compass-grid {
    grid-template-columns: 1fr;
  }
}
.compass-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}
.compass-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(14, 76, 157, 0.08);
  border-color: #cbd5e1;
}
.compass-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.compass-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--brand-blue);
  display: flex;
  align-items: center;
  gap: 6px;
}
.compass-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
}
.compass-tag.tag-blue { background: rgba(14, 76, 157, 0.08); color: var(--brand-blue); border: 1px solid rgba(14, 76, 157, 0.2); }
.compass-tag.tag-green { background: rgba(43, 175, 126, 0.12); color: #15803d; border: 1px solid rgba(43, 175, 126, 0.3); }
.compass-tag.tag-amber { background: rgba(245, 158, 11, 0.12); color: #b45309; border: 1px solid rgba(245, 158, 11, 0.3); }
.compass-tag.tag-purple { background: rgba(99, 102, 241, 0.12); color: #4f46e5; border: 1px solid rgba(99, 102, 241, 0.3); }

.compass-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}
.compass-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.compass-row-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}
.compass-row-title {
  font-weight: 600;
  color: #475569;
}
.compass-row-val {
  font-weight: 700;
  color: var(--text);
}
.compass-track {
  position: relative;
  height: 8px;
  background: #f1f5f9;
  border-radius: 4px;
  overflow: visible;
}
.compass-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--brand-green);
  transition: width 0.4s ease;
}
.compass-fill.is-bear { background: var(--brand-red); }
.compass-tick-50 {
  position: absolute;
  left: 50%;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: rgba(14, 76, 157, 0.4);
  border-radius: 1px;
}
.compass-summary {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.5;
  color: #334155;
  background: #f8fafc;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #f1f5f9;
}



