:root {
  --bg: #0d1117;
  --panel: #161b22;
  --border: #2d333b;
  --fg: #e6edf3;
  --dim: #8b949e;
  --up: #f85149;
  --down: #3fb950;
  --accent: #4493f8;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 13px;
  overflow: hidden;
}

button, select, input {
  background: #1f2730;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  outline: none;
}

button { cursor: pointer; }
button:hover { background: #2a3441; }

#topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 96px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  z-index: 40;
}

#brand { flex: none; }

#title { font-size: 16px; font-weight: 700; }

#subdate { font-size: 11px; color: var(--dim); margin-top: 2px; }

#tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
}

.tabBtn { padding: 7px 13px; background: #1f2730; }

.tabBtn.on { color: var(--accent); border-color: #2b5cad; background: #16202e; }

#controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: none;
}

#btnLoad { color: var(--accent); border-color: #2b5cad; padding: 7px 16px; }

#search { width: 200px; }

#datePick { width: 130px; color-scheme: dark; }

#grid {
  position: absolute;
  top: 96px; left: 0; right: 0; bottom: 26px;
}

#ladderBox {
  position: absolute;
  top: 96px; left: 0; right: 0; bottom: 26px;
  overflow: auto;
  padding: 12px;
}

#ladderBox.hidden, #statsBox.hidden { display: none; }

.ladRow {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}

.ladDate { width: 84px; flex: none; color: var(--dim); font-size: 12px; }

.ladCell { flex: 1; display: flex; flex-wrap: wrap; gap: 4px; min-height: 20px; }

.ladChip {
  display: inline-block;
  background: #1f2730;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 11px;
  white-space: nowrap;
}

.ladChip b { color: var(--up); font-weight: 600; margin-left: 4px; }

.ladChip.sealOff { opacity: 0.55; }

.ladHead { color: var(--dim); font-size: 12px; border-bottom: 1px solid var(--border); }

#statsBox {
  position: absolute;
  top: 96px; left: 0; right: 0; bottom: 26px;
  overflow: auto;
  padding: 18px;
}

.statCards { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }

.statCard {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 20px;
  min-width: 150px;
}

.statCard .infoLbl { margin-bottom: 6px; }

.statCard .big { font-size: 22px; font-weight: 700; }

.statTable { border-collapse: collapse; margin-bottom: 18px; }

.statTable th, .statTable td {
  border: 1px solid var(--border);
  padding: 6px 14px;
  font-size: 12px;
  text-align: center;
}

.statTable th { background: #1f2730; color: var(--dim); font-weight: 600; }

#statusbar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 26px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  font-size: 11px;
  color: var(--dim);
  z-index: 40;
}

#loading {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
}

#loading.hidden { display: none; }

#loadingCard {
  width: 460px;
  max-width: 92vw;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px 28px;
  text-align: center;
}

#loadingTitle { font-size: 15px; font-weight: 600; margin-bottom: 8px; }

#loadingMsg { font-size: 12px; color: var(--dim); margin-bottom: 12px; min-height: 16px; }

#loadingBarWrap {
  height: 6px;
  background: #1f2730;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 12px;
}

#loadingBar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.25s;
}

#loadingHint { font-size: 11px; color: var(--dim); line-height: 1.6; }

#errbox {
  display: none;
  position: fixed;
  left: 50%;
  bottom: 44px;
  transform: translateX(-50%);
  background: #2a1b1e;
  color: #f85149;
  border: 1px solid #6e2a2e;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 12px;
  z-index: 50;
  max-width: 80vw;
}

#infoModal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 46;
}

#infoModal.hidden { display: none; }

#infoCard {
  width: 560px;
  max-width: 92vw;
  max-height: 80vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
}

#infoTitle {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

#infoSym { color: var(--accent); }

#infoName { flex: 1; }

#btnInfoClose {
  width: 26px;
  height: 26px;
  flex: none;
  font-size: 12px;
}

#infoGrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px 18px;
  font-size: 13px;
}

.infoItem { display: flex; flex-direction: column; gap: 2px; }

.infoLbl { font-size: 11px; color: var(--dim); }

#infoTags { margin-top: 8px; line-height: 1.9; }

.infoTag {
  display: inline-block;
  background: #1f2730;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 9px;
  margin: 0 6px 6px 0;
  font-size: 12px;
}

.infoTag.tIndustry { border-color: #2b5cad; color: var(--accent); }
.infoTag.tRegion { border-color: #2ea04326; color: #7ee787; }
.infoTag.tTszs { border-color: #bb8009; color: #e3b341; }

.infoEmpty { color: var(--dim); font-size: 12px; }

.cell-up { color: var(--up) !important; }
.cell-down { color: var(--down) !important; }

#grid .ag-theme-quartz { --ag-background-color: var(--bg); }
