* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: #0f1218; color: #e4e7ec; font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
.hidden { display: none !important; }
.loading { color: #8b95a4; text-align: center; padding: 40px; grid-column: 1/-1; }

/* ---------- top bar with tabs ---------- */
.bar { position: sticky; top: 0; z-index: 10; background: #161b22; padding: 10px 20px; border-bottom: 1px solid #2a313c; display: flex; align-items: center; gap: 16px; }
.tabs { display: flex; gap: 4px; }
.tab { background: transparent; color: #8b95a4; border: 1px solid transparent; padding: 8px 18px; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 500; }
.tab:hover { color: #e4e7ec; background: #1f2530; }
.tab.active { background: #2a313c; color: #e4e7ec; border-color: #3a424f; }
.stats { color: #8b95a4; font-size: 12px; margin-left: auto; }

/* ---------- controls (players tab) ---------- */
.controls-bar { display: flex; gap: 8px; padding: 12px 20px; border-bottom: 1px solid #2a313c; background: #131820; flex-wrap: wrap; }
.controls-bar input, .controls-bar select { background: #0f1218; color: #e4e7ec; border: 1px solid #2a313c; padding: 6px 10px; border-radius: 4px; font-size: 13px; }
.controls-bar input[type=search] { width: 280px; }

/* ---------- dashboard ---------- */
.dashboard { padding: 20px; max-width: 1400px; margin: 0 auto; }
.d-section { margin-bottom: 28px; }
.d-section h2 { margin: 0 0 12px; font-size: 16px; font-weight: 600; border-left: 3px solid #f4d35e; padding-left: 10px; }
.d-section h2 small { color: #8b95a4; font-size: 12px; font-weight: 400; margin-left: 8px; }
.d-section h3 { margin: 0 0 10px; font-size: 14px; font-weight: 600; color: #b8c0cc; }
.d-section h3 small { color: #8b95a4; font-weight: 400; font-size: 12px; margin-left: 6px; }

.big-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.big-stat { background: #161b22; border: 1px solid #2a313c; border-radius: 8px; padding: 14px 16px; }
.big-stat-num { font-size: 24px; font-weight: 700; color: #f4d35e; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.big-stat-label { font-size: 13px; color: #e4e7ec; margin-top: 4px; }
.big-stat-hint { font-size: 11px; color: #8b95a4; margin-top: 2px; }

.dual { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .dual { grid-template-columns: 1fr; } }
.block { background: #161b22; border: 1px solid #2a313c; border-radius: 8px; padding: 14px 16px; }

table.bars { width: 100%; border-collapse: collapse; }
table.bars th { text-align: left; color: #b8c0cc; font-weight: 400; padding: 4px 10px 4px 0; white-space: nowrap; font-size: 12px; width: 80px; }
table.bars td { padding: 4px 0; font-size: 12px; }
table.bars td.bar-cell { width: 100%; padding-right: 10px; }
table.bars td.bar-num { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: #e4e7ec; text-align: right; min-width: 60px; }
table.bars td.bar-pct { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: #8b95a4; text-align: right; min-width: 50px; padding-left: 8px; }
table.bars .bar { height: 16px; border-radius: 3px; min-width: 2px; }

.quantile-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.qbox { background: #0f1218; border: 1px solid #2a313c; border-radius: 6px; padding: 8px 10px; text-align: center; }
.qlabel { display: block; font-size: 11px; color: #8b95a4; }
.qval { display: block; font-size: 18px; font-weight: 700; color: #f4d35e; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; margin-top: 2px; }
.qbar-track { position: relative; height: 18px; background: #0f1218; border: 1px solid #2a313c; border-radius: 3px; }
.qbar-fill { position: absolute; top: 0; bottom: 0; background: rgba(244, 211, 94, 0.25); border-left: 2px solid #f4d35e; border-right: 2px solid #f4d35e; }
.qbar-tick { position: absolute; top: -2px; bottom: -2px; width: 2px; background: #f4d35e; }
.qbar-axis { display: flex; justify-content: space-between; font-size: 10px; color: #8b95a4; margin-top: 4px; font-family: ui-monospace, monospace; }

/* ---------- player grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; padding: 20px; }
.card { background: #161b22; border: 1px solid #2a313c; border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; }
.card-img { background: #0f1218; display: flex; align-items: center; justify-content: center; padding: 12px; min-height: 240px; }
.card-img img { max-width: 100%; max-height: 220px; object-fit: contain; }
.card-body { padding: 12px 14px; }
.name { margin: 0 0 8px; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { display: flex; gap: 10px; font-size: 12px; color: #b8c0cc; margin-bottom: 10px; flex-wrap: wrap; }
.meta .ovr { color: #f4d35e; font-weight: 600; }
.meta .pos { color: #8ecae6; }

table.kv { width: 100%; border-collapse: collapse; font-size: 12px; }
table.kv th { text-align: left; color: #8b95a4; font-weight: 400; padding: 3px 6px 3px 0; width: 45%; vertical-align: middle; }
table.kv td { color: #e4e7ec; padding: 3px 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; vertical-align: middle; }
table.kv td.price { color: #f4d35e; font-weight: 600; }
table.kv td.profit.pos { color: #10b981; font-weight: 600; }
table.kv td.profit.neg { color: #ef4444; font-weight: 600; }

.pos-bar { position: relative; background: #0f1218; border: 1px solid #2a313c; border-radius: 3px; height: 14px; overflow: hidden; }
.pos-bar-fill { position: absolute; top: 0; left: 0; bottom: 0; background: linear-gradient(to right, #10b981, #f4d35e, #ef4444); }
.pos-bar-num { position: absolute; top: 0; left: 50%; transform: translateX(-50%); font-size: 10px; line-height: 14px; color: #fff; text-shadow: 0 0 2px rgba(0,0,0,0.8); font-family: ui-monospace, monospace; }

/* ---------- updater ---------- */
.updater-layout { display: grid; grid-template-columns: 400px 1fr; gap: 20px; padding: 20px; max-width: 1500px; margin: 0 auto; height: calc(100vh - 60px); }
@media (max-width: 900px) { .updater-layout { grid-template-columns: 1fr; height: auto; } }
.updater-left { display: flex; flex-direction: column; gap: 16px; overflow-y: auto; padding-right: 4px; }
.updater-right { overflow-y: auto; }

.updater-block { background: #161b22; border: 1px solid #2a313c; border-radius: 8px; padding: 16px; }
.updater-block h3 { margin: 0 0 12px; font-size: 14px; font-weight: 600; color: #b8c0cc; border-left: 3px solid #f4d35e; padding-left: 8px; }

.cfg-form { display: flex; flex-direction: column; gap: 12px; }
.cfg-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #b8c0cc; }
.cfg-form input { background: #0f1218; color: #e4e7ec; border: 1px solid #2a313c; padding: 6px 10px; border-radius: 4px; font-size: 13px; font-family: ui-monospace, monospace; }
.cfg-form small { color: #6b7280; font-size: 11px; }
.range-row { display: flex; align-items: center; gap: 8px; }
.range-row input { flex: 1; min-width: 0; }
.range-row span { color: #8b95a4; font-size: 12px; }
.btn { background: #0f1218; color: #e4e7ec; border: 1px solid #2a313c; padding: 8px 14px; border-radius: 4px; cursor: pointer; font-size: 13px; }
.btn:hover { background: #1f2530; }
.btn:disabled { color: #4a525f; cursor: not-allowed; background: #0f1218; }
.btn-primary { background: #f4d35e; color: #161b22; border-color: #f4d35e; font-weight: 600; }
.btn-primary:hover { background: #e0bf46; }
.btn-warn { background: #f59e0b; color: #161b22; border-color: #f59e0b; font-weight: 600; }
.btn-warn:hover { background: #d98906; }
.btn-danger { background: #ef4444; color: #fff; border-color: #ef4444; font-weight: 600; }
.btn-danger:hover { background: #dc2626; }
.btn-danger:disabled { background: #1f2530; color: #4a525f; border-color: #2a313c; }
.btn-stack { display: flex; flex-direction: column; gap: 8px; }
.hint { font-size: 11px; color: #8b95a4; margin-left: 6px; }
.toggle-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }

.switch { position: relative; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #2a313c; border-radius: 22px; cursor: pointer; transition: 0.2s; }
.slider:before { content: ""; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.2s; }
.switch input:checked + .slider { background: #10b981; }
.switch input:checked + .slider:before { transform: translateX(18px); }

.updater-status { display: flex; flex-direction: column; gap: 12px; }
.us-mode { font-size: 13px; color: #b8c0cc; padding-left: 4px; }
.us-mode strong { color: #f4d35e; }
.us-card { background: #161b22; border: 1px solid #2a313c; border-radius: 8px; padding: 14px 16px; }
.us-card.us-running { border-color: #10b981; }
.us-card.us-idle { border-color: #4a525f; }
.us-card.us-faint { opacity: 0.7; }
.us-card h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: #b8c0cc; }
.us-card h3 small { color: #6b7280; font-weight: 400; font-size: 11px; margin-left: 6px; }

.kv2 { display: flex; gap: 12px; font-size: 12px; margin: 4px 0; }
.kv2 > span:first-child { color: #8b95a4; min-width: 90px; }
.kv2 > span:last-child { color: #e4e7ec; font-family: ui-monospace, monospace; }

.progress { background: #0f1218; border: 1px solid #2a313c; border-radius: 4px; height: 12px; margin: 8px 0; overflow: hidden; }
.progress-fill { background: linear-gradient(to right, #10b981, #f4d35e); height: 100%; transition: width 0.3s; }

.px-tag { display: inline-block; background: #0f1218; border: 1px solid #2a313c; padding: 2px 8px; border-radius: 3px; font-size: 11px; color: #b8c0cc; font-family: ui-monospace, monospace; margin: 2px; }
.api-tag { display: inline-block; background: rgba(244,211,94,0.15); color: #f4d35e; border: 1px solid rgba(244,211,94,0.4); padding: 1px 6px; border-radius: 3px; font-size: 10px; font-family: ui-monospace, monospace; font-weight: 400; margin-left: 4px; vertical-align: middle; }
.hour-tag { color: #10b981; font-weight: 600; }
.pending-row { font-size: 12px; color: #f59e0b; padding: 2px 0; font-family: ui-monospace, monospace; }

/* ---------- pager ---------- */
.pager { position: sticky; bottom: 0; background: #161b22; border-top: 1px solid #2a313c; padding: 10px 20px; display: flex; align-items: center; justify-content: center; gap: 12px; }
.pager button { background: #0f1218; color: #e4e7ec; border: 1px solid #2a313c; padding: 6px 14px; border-radius: 4px; cursor: pointer; font-size: 13px; }
.pager button:disabled { color: #4a525f; cursor: not-allowed; }
.pager input { width: 70px; background: #0f1218; color: #e4e7ec; border: 1px solid #2a313c; padding: 5px 8px; border-radius: 4px; }
#pageInfo { color: #8b95a4; min-width: 200px; text-align: center; }
#jumpWrap { display: flex; gap: 6px; align-items: center; margin-left: 12px; }

/* bucket editor for API1 discover */
.bucket-editor { display: flex; flex-direction: column; gap: 4px; margin: 4px 0; }
.bucket-row { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.bucket-row .bucket-idx { color: #6b7280; min-width: 26px; font-family: ui-monospace, monospace; }
.bucket-row input { width: 60px !important; text-align: center; }
.bucket-row span { color: #6b7280; }
.btn-small { background: #1a1f29; color: #b8c0cc; border: 1px solid #2a313c; padding: 3px 8px; border-radius: 3px; cursor: pointer; font-size: 11px; }
.btn-small:hover { background: #232936; }
.bucket-del { color: #ef4444 !important; padding: 2px 6px !important; }

/* ============================================================
 * Updater V2 (2026-06 refactor)
 * ============================================================ */
.uv2-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
  padding: 12px 20px;
  /* 关键:防止子元素硬撑出视口 */
  max-width: 100%;
  overflow-x: hidden;
}
.uv2-left { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.uv2-right { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.uv2-block, .uv2-card { background: #161b22; border: 1px solid #2a313c; border-radius: 6px; padding: 12px; min-width: 0; overflow: hidden; }
.uv2-block h3, .uv2-card h3 { margin: 0 0 8px 0; font-size: 14px; color: #e4e7ec; display: flex; justify-content: space-between; align-items: center; }
.uv2-status { font-size: 12px; font-weight: 400; }
.uv2-form fieldset { border: 1px solid #2a313c; border-radius: 4px; padding: 8px 10px; margin: 0 0 8px 0; }
.uv2-form legend { color: #8b95a4; font-size: 11px; padding: 0 4px; }
.uv2-form label { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; color: #b8c0cc; padding: 3px 0; }
.uv2-form input { width: 100px; background: #0f1218; color: #e4e7ec; border: 1px solid #2a313c; padding: 3px 6px; border-radius: 3px; font-size: 12px; text-align: right; }
.uv2-form button { background: #2563eb; color: #fff; border: 0; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-size: 13px; width: 100%; margin-top: 4px; }
.uv2-btn { background: #1a1f29; color: #b8c0cc; border: 1px solid #2a313c; padding: 8px 14px; border-radius: 4px; cursor: pointer; font-size: 12px; width: 100%; margin: 4px 0; }
.uv2-btn:hover { background: #232936; }
.uv2-btn-warn { color: #ef4444; border-color: rgba(239,68,68,0.4); }
.uv2-summary { font-size: 12px; color: #b8c0cc; font-family: ui-monospace, monospace; min-width: 0; }
/* 不再均分两端,标签 + 冒号紧跟内容 */
.uv2-row { padding: 3px 0; line-height: 1.5; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uv2-row span { color: #8b95a4; }
.uv2-row span::after { content: "："; }
.uv2-row b { color: #e4e7ec; font-weight: 500; }
.uv2-row.uv2-muted { color: #6b7280; font-size: 11px; }
.uv2-row.uv2-muted span::after { content: ""; }
.uv2-error { color: #ef4444; }
.uv2-progress { background: #0f1218; height: 6px; border-radius: 3px; overflow: hidden; margin: 4px 0; padding: 0; }
.uv2-progress div { background: #10b981; height: 100%; transition: width 0.3s; }
.uv2-channels { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.uv2-chan { font-size: 10px; background: #0f1218; padding: 2px 6px; border-radius: 3px; color: #8b95a4; }
.uv2-disc-recent { max-height: 76px; overflow-y: auto; font-family: ui-monospace, monospace; font-size: 11px; margin-top: 4px; }
.uv2-disc-row { padding: 2px 0; color: #8b95a4; border-bottom: 1px solid #1a1f29; }
.uv2-disc-row.fail { opacity: 0.5; }
.uv2-events { max-height: 480px; overflow-y: auto; font-family: ui-monospace, monospace; font-size: 11px; }
.uv2-event { display: flex; gap: 8px; padding: 2px 4px; border-bottom: 1px solid #1a1f29; }
.uv2-event.ev-fail { color: #ef4444; }
.ev-ts { color: #6b7280; min-width: 70px; }
.ev-src { color: #2563eb; min-width: 80px; }
.ev-kind { min-width: 100px; }
.ev-ea { color: #f4d35e; min-width: 70px; }
.ev-payload { color: #8b95a4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; min-width: 0; }
.uv2-scatter-legend { font-size: 11px; color: #8b95a4; padding: 4px 0; }
#uv2-scatter { background: #0e1116; border-radius: 4px; width: 100%; max-width: 100%; height: 160px; display: block; }

.uv2-desc { color: #8b95a4; font-size: 12px; line-height: 1.55; margin: 0 0 10px 0; padding: 8px 10px; background: #0f1218; border-left: 3px solid #2563eb; border-radius: 0 4px 4px 0; }

/* 卡片内左右分:左边状态/右边历史记录 */
.uv2-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 16px;
  min-width: 0;
}
.uv2-split-left { min-width: 0; }
.uv2-split-right { min-width: 0; padding-left: 12px; border-left: 1px solid #2a313c; }
.uv2-hist-title { font-size: 11px; color: #8b95a4; padding: 0 0 6px 0; border-bottom: 1px solid #1a1f29; margin-bottom: 4px; }
.uv2-history { max-height: 180px; overflow-y: auto; font-family: ui-monospace, monospace; font-size: 11px; min-width: 0; }
.uv2-hist-row {
  padding: 4px 0;
  border-bottom: 1px solid #1a1f29;
  color: #b8c0cc;
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
}
.uv2-hist-ts { color: #6b7280; }
.uv2-hist-body { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.uv2-hist-body b { color: #e4e7ec; font-weight: 500; }
.uv2-hist-body .hist-aux { color: #8b95a4; margin-left: 4px; }
.uv2-hist-row.fail .uv2-hist-body { color: #ef4444; opacity: 0.85; }
.uv2-history-empty { color: #6b7280; padding: 8px 0; font-size: 11px; }

/* 事件流双列 */
.uv2-events-2col {
  column-count: 2;
  column-gap: 16px;
  column-rule: 1px solid #1a1f29;
}
.uv2-events-2col .uv2-event {
  break-inside: avoid;        /* 不要把一条 event 拆到两列 */
  border-bottom: 1px solid #1a1f29;
  padding: 3px 4px;
}
.uv2-events-2col .uv2-event { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: 11px; line-height: 1.4; }
.uv2-events-2col .ev-ts { min-width: 60px; flex: 0 0 auto; }
.uv2-events-2col .ev-src { min-width: 60px; flex: 0 0 auto; }
.uv2-events-2col .ev-kind { min-width: 80px; flex: 0 0 auto; }
.uv2-events-2col .ev-ea { min-width: auto; flex: 0 0 auto; }
.uv2-events-2col .ev-payload { flex: 1 1 100%; max-width: 100%; font-size: 10.5px; color: #6b7280; padding-left: 60px; }
