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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  background-color: #0b0e14;
  color: #e6edf3;
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  height: 56px;
  background-color: #121721;
  border-bottom: 1px solid #1f2636;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  position: relative;
  z-index: 1000;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-badge {
  background: linear-gradient(135deg, #1f6feb, #388bfd);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
}

.date-selector-group {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 0;
  position: relative;
}

.date-selector-group label {
  display: none;
}

.date-select {
  background: transparent;
  color: #e6edf3;
  border: none;
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

.date-select option {
  background-color: #161b22;
  color: #e6edf3;
}

/* ==========================================================================
   Modern Date Legend & Popover DatePicker
   ========================================================================== */
.dp-trigger-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1b2230;
  border: 1px solid #283347;
  border-radius: 6px;
  padding: 4px 10px;
  color: #e6edf3;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  font-family: inherit;
}

.dp-trigger-btn:hover {
  border-color: #388bfd;
  background: #222b3d;
  box-shadow: 0 0 10px rgba(56, 139, 253, 0.2);
}

.dp-icon {
  font-size: 13px;
}

.dp-label {
  font-size: 12px;
  color: #8b949e;
  font-weight: 500;
}

.dp-selected-date {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-weight: 600;
  color: #58a6ff;
  letter-spacing: 0.5px;
}

.dp-badge-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  line-height: 1.3;
}

.dp-badge-tag.tag-today {
  background: rgba(46, 160, 67, 0.2);
  color: #3fb950;
  border: 1px solid rgba(46, 160, 67, 0.4);
}

.dp-badge-tag.tag-history {
  background: rgba(210, 153, 34, 0.2);
  color: #d29922;
  border: 1px solid rgba(210, 153, 34, 0.4);
}

.dp-caret {
  font-size: 10px;
  color: #8b949e;
  transition: transform 0.2s ease;
  margin-left: 2px;
}

.dp-caret.open {
  transform: rotate(180deg);
}

/* Popover Panel */
.dp-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 440px;
  max-width: 95vw;
  background: #141c2b;
  border: 1px solid #334460;
  border-radius: 10px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.08);
  padding: 14px 16px;
  z-index: 99999;
  display: none;
  flex-direction: column;
  gap: 12px;
  animation: dpFadeSlide 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.dp-popover.show {
  display: flex;
}

@keyframes dpFadeSlide {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dp-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #252f42;
  padding-bottom: 10px;
}

.dp-header-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #e6edf3;
}

.dp-header-icon {
  font-size: 15px;
}

.dp-today-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #1f6feb;
  border: 1px solid #388bfd;
  color: #ffffff;
  border-radius: 5px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.dp-today-btn:hover:not(.disabled) {
  background: #388bfd;
  box-shadow: 0 0 8px rgba(56, 139, 253, 0.4);
}

.dp-today-btn.disabled {
  opacity: 0.45;
  cursor: default;
  border-color: #252f42;
  color: #8b949e;
  background: #161d2b;
}

.dp-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dp-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dp-section-sub {
  font-size: 10px;
  color: #6e7681;
  font-weight: normal;
}

/* Year Tabs */
.dp-year-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.dp-year-tab {
  background: #1b2230;
  border: 1px solid #283347;
  color: #c9d1d9;
  border-radius: 5px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dp-year-tab:hover {
  background: #252f42;
  border-color: #388bfd;
  color: #fff;
}

.dp-year-tab.active {
  background: #1f6feb;
  border-color: #58a6ff;
  color: #fff;
}

/* Month Tabs */
.dp-month-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.dp-month-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: #1b2332;
  border: 1px solid #283347;
  border-radius: 6px;
  cursor: pointer;
  color: #c9d1d9;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s ease;
  font-family: inherit;
}

.dp-month-tab:hover {
  border-color: #388bfd;
  background: #222d40;
  color: #fff;
}

.dp-month-tab.active {
  background: #1f6feb;
  border-color: #58a6ff;
  color: #fff;
  box-shadow: 0 0 10px rgba(56, 139, 253, 0.35);
}

.dp-month-tab-num {
  font-weight: 700;
}

.dp-month-tab-count {
  font-size: 10px;
  opacity: 0.85;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.25);
}

/* Days Grid / Legend */
.dp-days-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  max-height: 190px;
  overflow-y: auto;
  padding-right: 2px;
}

.dp-days-grid::-webkit-scrollbar {
  width: 4px;
}

.dp-days-grid::-webkit-scrollbar-thumb {
  background: #283347;
  border-radius: 4px;
}

.dp-day-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  background: #1b2332;
  border: 1px solid #2c384e;
  border-radius: 6px;
  color: #e6edf3;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  position: relative;
  white-space: nowrap !important;
  overflow: hidden;
}

.dp-day-card:hover {
  background: #253147;
  border-color: #388bfd;
  transform: translateY(-1px);
}

.dp-day-card.active {
  background: rgba(56, 139, 253, 0.18);
  border-color: #58a6ff;
  box-shadow: 0 0 10px rgba(56, 139, 253, 0.35);
}

.dp-day-card.is-today {
  border-color: rgba(46, 160, 67, 0.6);
}

.dp-day-main {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap !important;
}

.dp-day-num {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 700;
  color: #e6edf3;
}

.dp-day-card.active .dp-day-num {
  color: #58a6ff;
}

.dp-day-week {
  font-size: 11px;
  color: #8b949e;
}

.dp-day-pill {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  line-height: 1.2;
  white-space: nowrap !important;
}

.dp-day-pill.today-pill {
  background: rgba(46, 160, 67, 0.25);
  color: #3fb950;
  border: 1px solid rgba(46, 160, 67, 0.5);
}

.dp-day-pill.current-pill {
  background: rgba(56, 139, 253, 0.25);
  color: #58a6ff;
  border: 1px solid rgba(56, 139, 253, 0.5);
}

.dp-no-data {
  grid-column: span 3;
  text-align: center;
  padding: 16px;
  font-size: 12px;
  color: #8b949e;
  background: #101520;
  border-radius: 6px;
}

/* Footer */
.dp-popover-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid #252f42;
  padding-top: 10px;
  font-size: 11px;
  color: #8b949e;
}

.dp-footer-info strong.text-today {
  color: #3fb950;
}

.dp-footer-info strong.text-history {
  color: #d29922;
}

.dp-footer-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
}

.dp-footer-tag.tag-today-tag {
  background: rgba(46, 160, 67, 0.2);
  border: 1px solid rgba(46, 160, 67, 0.4);
  color: #3fb950;
}

.dp-footer-tag.tag-hist-tag {
  background: rgba(210, 153, 34, 0.2);
  border: 1px solid rgba(210, 153, 34, 0.4);
  color: #d29922;
}

.dp-footer-tip {
  color: #6e7681;
  font-size: 10px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(56, 139, 253, 0.12);
  color: #58a6ff;
  border: 1px solid rgba(56, 139, 253, 0.25);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #0ecb81;
  box-shadow: 0 0 8px #0ecb81;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.clock-display {
  font-family: "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 14px;
  color: #8b949e;
}

.clock-display strong {
  color: #e6edf3;
  font-weight: 600;
}

/* Layout */
.main-container {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 370px;
  overflow: hidden;
}

/* Chart Area */
.chart-panel {
  display: flex;
  flex-direction: column;
  background-color: #0b0e14;
  border-right: 1px solid #1f2636;
  position: relative;
  overflow: hidden;
}

.chart-toolbar {
  height: 42px;
  background: #121721;
  border-bottom: 1px solid #1f2636;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 12px;
}

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

.btn-pill {
  background: #1a2230;
  border: 1px solid #293449;
  color: #c9d1d9;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-pill:hover {
  background: #253147;
  color: #ffffff;
  border-color: #388bfd;
}

.btn-pill.active {
  background: #1f6feb;
  color: #ffffff;
  border-color: #58a6ff;
  font-weight: 600;
}

.search-input {
  background: #1a2230;
  border: 1px solid #293449;
  color: #e6edf3;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  width: 140px;
  outline: none;
  transition: all 0.2s;
}

.search-input:focus {
  border-color: #388bfd;
  width: 180px;
}

#chart-container {
  flex: 1;
  width: 100%;
  height: 100%;
}

/* Right Ranking Panel */
.ranking-panel {
  display: flex;
  flex-direction: column;
  background: #121721;
  overflow: hidden;
}

.ranking-tabs {
  display: flex;
  border-bottom: 1px solid #1f2636;
  background: #0f141d;
}

.ranking-tab {
  flex: 1;
  text-align: center;
  padding: 11px 4px;
  font-size: 13px;
  font-weight: 600;
  color: #8b949e;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
}

.ranking-tab:hover {
  color: #c9d1d9;
}

.ranking-tab.active {
  color: #ffffff;
  border-bottom-color: #1f6feb;
  background: #161c28;
}

.ranking-stats-summary {
  display: flex;
  justify-content: space-around;
  padding: 10px 12px;
  background: #141a24;
  border-bottom: 1px solid #1f2636;
  font-size: 12px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat-label {
  color: #8b949e;
  font-size: 11px;
}

.stat-val {
  font-weight: 700;
  font-family: "SF Mono", Consolas, monospace;
}

.ranking-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Custom scrollbar */
.ranking-list::-webkit-scrollbar {
  width: 6px;
}
.ranking-list::-webkit-scrollbar-track {
  background: #0f141d;
}
.ranking-list::-webkit-scrollbar-thumb {
  background: #252e42;
  border-radius: 3px;
}
.ranking-list::-webkit-scrollbar-thumb:hover {
  background: #364461;
}

/* Sector Card */
.sector-card {
  background: #171e2b;
  border: 1px solid #222b3d;
  border-radius: 6px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.sector-card:hover {
  background: #1e2738;
  border-color: #388bfd;
  transform: translateX(-2px);
}

.sector-card.highlighted {
  border-color: #58a6ff;
  box-shadow: 0 0 10px rgba(56, 139, 253, 0.25);
  background: #222c3f;
}

.sector-card.dimmed {
  opacity: 0.35;
}

.card-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rank-badge {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  background: #232c3d;
  color: #8b949e;
  flex-shrink: 0;
}

.rank-top-1 { background: #d4380d; color: #fff; }
.rank-top-2 { background: #d46b08; color: #fff; }
.rank-top-3 { background: #d48806; color: #fff; }

.sector-meta {
  display: flex;
  flex-direction: column;
}

.sector-name {
  font-size: 13px;
  font-weight: 600;
  color: #f0f6fc;
}

.sector-code {
  font-size: 11px;
  color: #7d8590;
  font-family: monospace;
}

.card-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.main-flow {
  font-size: 13px;
  font-weight: 700;
  font-family: "SF Mono", Consolas, monospace;
}

.sub-meta {
  font-size: 11px;
  display: flex;
  gap: 8px;
  font-family: "SF Mono", Consolas, monospace;
}

/* Red / Green Theme for A-Shares */
.up-color {
  color: #f6465d !important;
}

.down-color {
  color: #0ecb81 !important;
}

.flat-color {
  color: #8b949e !important;
}

/* Loading overlay */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(11, 14, 20, 0.7);
  backdrop-filter: blur(2px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 50;
  transition: opacity 0.3s;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(56, 139, 253, 0.2);
  border-top-color: #388bfd;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 13px;
  color: #8b949e;
}

/* Playback and Video Export Control Bar */
.playback-bar {
  height: 46px;
  background: #121722;
  border-top: 1px solid #1f2636;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  z-index: 10;
}

.playback-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  max-width: 650px;
}

.btn-playback {
  background: #1f6feb;
  border: 1px solid #388bfd;
  color: #ffffff;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-playback:hover {
  background: #388bfd;
}

.btn-playback.playing {
  background: #d46b08;
  border-color: #fa8c16;
}

.playback-time-tag {
  font-family: "SF Mono", Consolas, monospace;
  font-size: 13px;
  font-weight: 700;
  color: #58a6ff;
  min-width: 68px;
  flex-shrink: 0;
}

.playback-slider {
  flex: 1;
  height: 4px;
  background: #252f42;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  accent-color: #388bfd;
}

.playback-speed-group {
  display: flex;
  gap: 2px;
  background: #171d28;
  border-radius: 4px;
  padding: 2px;
  border: 1px solid #283347;
  flex-shrink: 0;
}

.btn-speed {
  background: transparent;
  border: none;
  color: #8b949e;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 11px;
  cursor: pointer;
  font-weight: 600;
}

.btn-speed.active {
  background: #233045;
  color: #ffffff;
}

.btn-export-video {
  background: linear-gradient(135deg, #1f6feb, #238636);
  border: 1px solid rgba(56, 139, 253, 0.4);
  color: #ffffff;
  padding: 5px 14px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.btn-export-video:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

.btn-export-video.recording {
  background: #cf1322;
  border-color: #f5222d;
  animation: pulse 1s infinite;
}

