:root {
  --bg: #0d1117;
  --panel: #161b22;
  --border: #232a33;
  --fg: #d5d9de;
  --dim: #8b949e;
  --up: #e5484d;
  --down: #2fb344;
}

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

#topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 58px;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

#brand { line-height: 1.2; }

#title {
  font-size: 15px;
  font-weight: 600;
}

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

#clock {
  font-size: 28px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
  min-width: 130px;
  text-align: center;
}

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

#controls button {
  width: 38px;
  height: 32px;
  background: #1f2730;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}

#controls button:hover { background: #2a3441; }

#speed {
  height: 32px;
  background: #1f2730;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 6px;
}

#slider {
  flex: 1;
  height: 4px;
  accent-color: #4493f8;
  cursor: pointer;
}

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

.ag-theme-quartz {
  --ag-background-color: var(--bg);
  --ag-foreground-color: var(--fg);
  --ag-header-background-color: var(--panel);
  --ag-odd-row-background-color: var(--bg);
  --ag-row-hover-color: #1b222c;
  --ag-border-color: var(--border);
  --ag-row-border-color: #1a2029;
  --ag-header-column-resize-handle-color: var(--border);
  --ag-font-size: 13px;
}

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

#search {
  width: 150px;
  height: 32px;
  background: #1f2730;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 10px;
  font-size: 13px;
  outline: none;
}

#search:focus { border-color: #4493f8; }

.ag-theme-quartz .ag-row.row-flash .ag-cell {
  background-color: rgba(68, 147, 248, 0.25) !important;
}

.ag-theme-quartz .ag-row.row-pinned .ag-cell {
  background-color: rgba(68, 147, 248, 0.10) !important;
}

.pin-wrap {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.pin-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: 1px solid var(--dim);
  border-radius: 3px;
  color: transparent;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  background: transparent;
  vertical-align: middle;
}

.pin-check:hover { border-color: #4493f8; }

.pin-check.on {
  background: #1f6feb;
  border-color: #1f6feb;
  color: #fff;
}

.pin-drag {
  cursor: grab;
  color: var(--dim);
  font-size: 13px;
  letter-spacing: -2px;
  user-select: none;
}

.pin-drag:hover { color: #4493f8; }

.ag-theme-quartz .ag-row.pin-drag-over .ag-cell {
  background-color: rgba(68, 147, 248, 0.30) !important;
}

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

#errbox {
  display: none;
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: #3b1d20;
  border: 1px solid var(--up);
  color: #ffb4b6;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 20;
  max-width: 70%;
}

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

#loading.hidden { display: none; }

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

#loadingTitle {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 14px;
}

#loadingMsg {
  font-size: 13px;
  color: var(--dim);
  margin-bottom: 16px;
  line-height: 1.7;
}

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

#loadingBar {
  height: 100%;
  width: 0%;
  background: #1f6feb;
  border-radius: 3px;
  transition: width 0.3s;
}

#datePick {
  height: 32px;
  background: #1f2730;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 8px;
  font-size: 13px;
  outline: none;
  color-scheme: dark;
  font-family: inherit;
}

#datePick:focus { border-color: #4493f8; }

#btnLoadDate {
  width: auto !important;
  padding: 0 14px;
  font-size: 13px;
  color: #4493f8 !important;
  border-color: #2b5cad !important;
}

#loadingHint {
  margin-top: 14px;
  font-size: 12px;
  color: var(--dim);
  opacity: 0.8;
}

#btnCancelLoad {
  margin-top: 16px;
  padding: 7px 22px;
  background: #2a1b1e;
  color: #f85149;
  border: 1px solid #6e2a2e;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

#btnCancelLoad:hover { background: #382225; }

#btnProxy { font-size: 15px; }

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

#proxyModal.hidden { display: none; }

#proxyCard {
  width: 460px;
  max-width: 92vw;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 26px;
}

#proxyTitle {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
}

.proxyRow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.proxyRow label {
  width: 56px;
  font-size: 13px;
  color: var(--dim);
  flex-shrink: 0;
}

.proxyRow select,
.proxyRow input {
  flex: 1;
  height: 32px;
  background: #1f2730;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 10px;
  font-size: 13px;
  outline: none;
}

.proxyRow select:focus,
.proxyRow input:focus { border-color: #4493f8; }

.proxyRow input:disabled { opacity: 0.45; }

#proxyHint {
  font-size: 12px;
  color: var(--dim);
  line-height: 1.6;
  margin: 4px 0 12px;
}

#proxyResult {
  min-height: 18px;
  font-size: 13px;
  margin-bottom: 12px;
}

#proxyResult.ok { color: #3fb950; }
#proxyResult.bad { color: #f85149; }

#proxyBtns {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

#proxyBtns button {
  padding: 7px 16px;
  background: #1f2730;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

#proxyBtns button:hover { background: #2a3441; }
#proxyBtns button:disabled { opacity: 0.5; cursor: default; }

#btnProxySave { color: #4493f8; border-color: #2b5cad; }

/* CF: 待机遮罩不挡顶栏，日期/加载随时可点 */
#topbar { position: relative; z-index: 40; }
#errbox { z-index: 50; }
