* { margin: 0; padding: 0; box-sizing: border-box; }
a, a:hover, a:visited { color: inherit; text-decoration: none; cursor: pointer; }

html, body {
  height: 100%;
  font-family: -apple-system, 'PingFang SC', 'Microsoft YaHei', 'SF Mono', monospace;
  background: #0a0e14;
  color: #c5cdd9;
  font-size: 14px;
  overflow: hidden;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: #0d1117;
  border-bottom: 1px solid #1a1f2e;
  flex-shrink: 0;
}
.logo { font-weight: 700; color: #f0f6fc; font-size: 14px; }
.trade-date { color: #8b949e; margin-left: 8px; }
.countdown { color: #8b949e; font-variant-numeric: tabular-nums; }

.market-status {
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 3px;
  margin-left: 8px;
  font-weight: 500;
}
.market-status.trading {
  color: #3fb950;
  background: #3fb95022;
}
.market-status.closed {
  color: #8b949e;
  background: #8b949e22;
}
.market-status.holiday {
  color: #f0883e;
  background: #f0883e22;
}
.version {
  font-size: 10px;
  color: #444;
  font-family: 'SF Mono', monospace;
  margin-right: 12px;
  letter-spacing: -0.5px;
}

/* Global Filter */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  background: #0d1117;
  border-bottom: 1px solid #1a1f2e;
  flex-shrink: 0;
}
.filter-label { font-size: 11px; color: #8b949e; margin-right: 4px; }
.filter-btn {
  padding: 2px 8px;
  border: 1px solid #1a1f2e;
  border-radius: 3px;
  background: transparent;
  color: #8b949e;
  font-size: 11px;
  cursor: pointer;
}
.filter-btn:hover { border-color: #58a6ff; color: #c5cdd9; }
.filter-btn.active { background: #1f6feb22; border-color: #1f6feb; color: #58a6ff; }
.filter-count { font-size: 11px; color: #f0883e; margin-left: auto; white-space: nowrap; }

/* Warning Bar */
.warning-bar {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  background: #f0883e15;
  border-bottom: 1px solid #f0883e44;
  flex-shrink: 0;
  min-height: 36px;
  overflow: hidden;
}
.warning-label {
  font-size: 18px;
  font-weight: 700;
  color: #f0883e;
  white-space: nowrap;
  flex-shrink: 0;
  margin-right: 8px;
}
.warning-track {
  display: flex;
  white-space: nowrap;
  gap: 0;
  flex: 1;
  overflow: hidden;
}
.warning-track.marquee {
  mask-image: linear-gradient(90deg, transparent 0, #000 3%, #000 97%, transparent 100%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 3%, #000 97%, transparent 100%);
}
.warning-track.marquee .warning-marquee-inner {
  display: inline-flex;
  animation: marquee 30s linear infinite;
}
.warning-track.marquee:hover .warning-marquee-inner {
  animation-play-state: paused;
}
@keyframes marquee {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}
.warning-stocks {
  font-size: 18px;
  color: #f0f6fc;
  display: inline-flex;
  gap: 4px;
}
.warning-item {
  display: inline;
  margin-right: 12px;
}
.warning-item .wname { color: #f0f6fc; font-weight: 500; }
.warning-item .wname-warn { color: #ff6b35; font-weight: 600; }
.inner-tr.bomb .sname { color: #c5cdd9; }
.inner-tr.bomb .sname.wname-warn { color: #ff6b35; font-weight: 600; }
.warning-item .wcp { color: #ff4444; font-weight: 700; }

/* Grid */
.grid {
  display: grid;
  grid-template-columns: 1.5fr 0.7fr 1fr 1fr 2fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Columns */
.col {
  display: flex;
  flex-direction: column;
  border-right: 1px solid #1a1f2e;
  min-width: 0;
  overflow: hidden;
}
.col:last-child { border-right: none; }

.col-header {
  padding: 5px 8px;
  font-size: 13px;
  font-weight: 600;
  color: #8b949e;
  background: #0d1117;
  border-bottom: 1px solid #1a1f2e;
  flex-shrink: 0;
  letter-spacing: 0.5px;
}

.col-body {
  flex: 1;
  overflow: auto;
  padding: 2px 0;
  min-height: 0;
}
.col-body::-webkit-scrollbar { width: 4px; height: 4px; }
.col-body::-webkit-scrollbar-thumb { background: #1a1f2e; border-radius: 2px; }
.col-body::-webkit-scrollbar-corner { background: transparent; }

/* Concept */
.concept-block { margin-bottom: 2px; }
.concept-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 8px;
  cursor: default;
}
.concept-header:hover { background: #0d1117; }
.concept-name { color: #ff7b72; font-weight: 600; font-size: 12px; }
.concept-count { color: #f0f6fc; font-weight: 600; }
.concept-reason { font-size: 10px; color: #8b949e; padding: 0 8px 3px; }

.concept-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.concept-tr:hover { background: #0d1117; }
.concept-tr td, .concept-tr th {
  padding: 1px 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.concept-tr-header th {
  color: #555;
  font-weight: 500;
  text-align: left;
  border-bottom: 1px solid #0d1117;
  padding: 1px 4px;
}
.concept-tr-header th:nth-child(n+3) { text-align: right; }
.concept-tr td:nth-child(n+3) { text-align: right; }
.code-inline { color: #58a6ff; font-family: 'SF Mono', monospace; font-size: 13px; margin-left: 2px; }
.concept-tr .sname { color: #c5cdd9; }
.concept-tr .scode { color: #58a6ff; font-family: 'SF Mono', monospace; font-size: 13px; }
.concept-tr .scp { color: #ff4444; }
.concept-tr .sdays { color: #f0883e; }
.concept-tr .sbreak { color: #ff7b72; }
.concept-tr .stime { color: #8b949e; font-size: 13px; }
.concept-tr .sfund { color: #f0f6fc; }
.concept-tr .samount { color: #f0f6fc; }
.concept-tr .smcap { color: #8b949e; }

.sort-btn {
  font-size: 10px;
  color: #8b949e;
  background: transparent;
  border: 1px solid #1a1f2e;
  border-radius: 2px;
  padding: 1px 5px;
  cursor: pointer;
  margin-left: auto;
}
.sort-btn:hover { border-color: #58a6ff; color: #c5cdd9; }
.sort-btn.active { color: #58a6ff; border-color: #1f6feb; }

/* Echelon Block */
.echelon-block { margin-bottom: 1px; }
.echelon-title {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  background: #0d1117;
  font-size: 13px;
  font-weight: 600;
  color: #f0f6fc;
}
.echelon-title .badge {
  display: inline-block;
  padding: 0 5px;
  border-radius: 2px;
  font-size: 10px;
  line-height: 16px;
}
.badge-5 { background: #ff4444; color: #fff; }
.badge-4 { background: #ff6622; color: #fff; }
.badge-3 { background: #ff8800; color: #fff; }
.badge-2 { background: #ffaa00; color: #000; }
.badge-1 { background: #333; color: #8b949e; }

.inner-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.inner-tr:hover { background: #0d1117; }
.inner-tr td, .inner-tr th {
  padding: 1px 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.inner-tr-header th {
  color: #555;
  font-weight: 500;
  text-align: left;
  border-bottom: 1px solid #0d1117;
  padding: 1px 4px;
}
.inner-tr-header th:nth-child(n+2) { text-align: right; }
.inner-tr td:nth-child(n+3) { text-align: right; }
.inner-tr td:first-child { text-align: left; }
.inner-tr .sname { color: #c5cdd9; }
.inner-tr .scode { color: #58a6ff; font-family: 'SF Mono', monospace; font-size: 13px; }
.inner-tr .scp { color: #ff4444; }
.tc-t0 { color: #e040fb !important; }
.tc-t1 { color: #ff4444 !important; }
.tc-t2 { color: #ffaa00 !important; }
.tc-t3 { color: #66bb6a !important; }
.tc-t4 { color: #78909c !important; }
.tc-gray { color: #c5cdd9 !important; }

.bomb-stat {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  padding: 4px 8px;
  background: #0d1117;
  margin-bottom: 2px;
}
.bomb-stat-item { text-align: center; }
.bomb-stat-label { font-size: 10px; color: #8b949e; }
.bomb-stat-value { font-size: 14px; font-weight: 700; color: #ff7b72; }


/* Pool Table */
.pool-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.pool-table td, .pool-table th {
  padding: 1px 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pool-table th:nth-child(3),
.pool-table td:nth-child(3),
.pool-table th:nth-child(5),
.pool-table td:nth-child(5) { text-align: right; }
.pool-table th:nth-child(4),
.pool-table td:nth-child(4) { text-align: left; }
.pool-table th:nth-child(2),
.pool-table td:nth-child(2) { text-align: left; }
.pool-tag {
  display: inline-block;
  background: #1f6feb22;
  color: #58a6ff;
  font-size: 13px;
  padding: 0 4px;
  border-radius: 2px;
  margin-right: 2px;
}
.pool-tag-count {
  color: #3a7bbf;
  font-size: 11px;
  margin-left: 1px;
}

/* Legend */
.legend {
  padding: 4px 12px;
  background: #0d1117;
  border-top: 1px solid #1a1f2e;
  font-size: 10px;
  color: #8b949e;
  flex-shrink: 0;
  display: flex;
  gap: 12px;
  align-items: center;
}
.legend-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 2px;
  margin-right: 3px;
}
.legend-dot.red { background: #ff4444; }
.legend-dot.green { background: #3fb950; }
.legend-dot.yellow { background: #f0883e; }
.legend-dot.orange { background: #ff7b72; }
.legend-dot.gray { background: #8b949e; }

/* Mobile Tab Bar */
.mobile-tab-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #0d1117;
  border-top: 1px solid #1a1f2e;
  z-index: 100;
  padding: 4px 0;
  padding-bottom: max(4px, env(safe-area-inset-bottom));
}
.m-tab {
  flex: 1;
  border: none;
  background: transparent;
  color: #8b949e;
  font-size: 11px;
  padding: 6px 2px;
  cursor: pointer;
  transition: color 0.2s;
  white-space: nowrap;
}
.m-tab.active {
  color: #58a6ff;
  font-weight: 600;
}
.m-tab:hover { color: #c5cdd9; }

/* Responsive */
@media (max-width: 1200px) {
  .grid { grid-template-columns: 1fr 1fr 1fr; }
  .col:nth-child(4) { border-right: none; }
  .col:nth-child(5) { border-right: none; }
}
@media (max-width: 768px) {
  .grid { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
  .col { display: none; border-right: none; flex: 1; }
  .col.m-active { display: flex; }
  .col-body { max-height: none; }
  .app { padding-bottom: 52px; }
  .mobile-tab-bar { display: flex; }
  .legend { display: none; }
  .col .col-header { padding: 6px 8px; font-size: 13px; }
}
