/* gpuq dashboard — task-centric: cards with embedded charts + logs, dark theme */
:root {
  --bg: #0e1116;
  --bg2: #161b22;
  --bg3: #1c232d;
  --border: #2a3340;
  --text: #d6dee8;
  --muted: #7d8794;
  --accent: #4da3ff;
  --green: #3fb950;
  --yellow: #d29922;
  --red: #f85149;
  --purple: #bc8cff;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, "Courier New", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, "Segoe UI", "Microsoft YaHei", Roboto, sans-serif;
}
.muted { color: var(--muted); }
.hidden { display: none !important; }
code { font-family: var(--mono); background: var(--bg3); padding: 1px 5px; border-radius: 4px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 20px; background: var(--bg2); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-size: 18px; font-weight: 700; }
.tag { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 8px; }
.topbar-right { display: flex; align-items: center; gap: 12px; font-size: 12px; }
.badge {
  background: var(--bg3); border: 1px solid var(--border); padding: 2px 8px;
  border-radius: 10px; font-family: var(--mono); font-size: 12px;
}
.badge-muted { color: var(--muted); }

/* ---------- banners ---------- */
.banner {
  display: flex; align-items: center; gap: 12px; padding: 10px 20px; font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.banner-error { background: rgba(248,81,73,.12); color: #ffb4ae; }
.banner-warn { background: rgba(210,153,34,.12); color: #e3b341; }

/* ---------- layout ---------- */
main { padding: 20px; max-width: 1600px; margin: 0 auto; display: grid; gap: 18px; }

.panel {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 18px;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.panel-head h2 { margin: 0; font-size: 15px; }
.head-actions { display: flex; gap: 6px; }

/* ---------- buttons ---------- */
.btn {
  background: var(--bg3); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 12px; font-size: 13px; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn-sm { padding: 3px 9px; font-size: 12px; }
.btn-primary { background: var(--accent); color: #0b1220; border-color: var(--accent); font-weight: 600; }
.btn-danger { background: rgba(248,81,73,.15); color: var(--red); border-color: rgba(248,81,73,.4); }
.btn.active { border-color: var(--accent); color: var(--accent); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab {
  background: transparent; border: 1px solid transparent; color: var(--muted);
  border-radius: 6px; padding: 4px 12px; cursor: pointer; font-size: 13px;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--bg3); color: var(--text); border-color: var(--border); }

/* ============================================================
   task board: card grid -> split (rail + detail) on selection
   ============================================================ */
.board {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
}
.board.split {
  grid-template-columns: 340px minmax(0, 1fr);
}

/* ---------- card grid ---------- */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 1250px) { .cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 760px) { .cards { grid-template-columns: 1fr; } }

.task-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; cursor: pointer;
  transition: border-color .15s, transform .15s, box-shadow .15s;
  display: flex; flex-direction: column; gap: 8px;
}
.task-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.task-card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.card-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.status-ico { font-size: 17px; flex: 0 0 auto; }
.card-title {
  font-family: var(--mono); font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.card-id { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }

.status-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 9px; font-size: 11px; font-weight: 600;
  flex: 0 0 auto;
}
.status-queued { background: rgba(77,163,255,.15); color: #7cc4ff; }
.status-running { background: rgba(63,185,80,.15); color: var(--green); }
.status-succeeded { background: rgba(63,185,80,.12); color: var(--green); }
.status-failed { background: rgba(248,81,73,.15); color: var(--red); }
.status-cancelled { background: rgba(125,135,148,.15); color: var(--muted); }

.card-meta { font-size: 11.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 3px 12px; }
.card-meta b { color: var(--text); font-weight: 600; font-family: var(--mono); font-size: 11.5px; }
.card-runtime { font-family: var(--mono); font-size: 12px; color: var(--text); }
.card-runtime .est { color: var(--muted); }

/* ---------- embedded sparklines ---------- */
.spark-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.spark { background: var(--bg3); border-radius: 8px; padding: 5px 8px; }
.spark label { font-size: 10.5px; color: var(--muted); display: flex; justify-content: space-between; }
.spark label span:last-child { font-family: var(--mono); color: var(--text); }
.spark canvas { display: block; width: 100%; height: 40px; margin-top: 2px; }
.spark-empty { font-size: 11px; color: var(--muted); padding: 8px; }

.card-log-preview {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  background: #0a0d12; border: 1px solid var(--border); border-radius: 6px;
  padding: 5px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- split: left rail (selected card) ---------- */
.rail { position: sticky; top: 78px; }
.rail .task-card { cursor: default; }
.rail .task-card:hover { transform: none; }

/* ---------- split: right detail slide-over ---------- */
.detail {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 18px;
  transform: translateX(24px); opacity: 0; pointer-events: none;
  transition: transform .18s ease, opacity .18s ease;
  max-height: calc(100vh - 110px); overflow-y: auto;
}
.board.split .detail { transform: none; opacity: 1; pointer-events: auto; }
.detail-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.detail-head h3 { margin: 0; font-size: 15px; }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px,1fr)); gap: 8px; margin-bottom: 14px; }
.detail-cell { background: var(--bg3); border-radius: 8px; padding: 8px 10px; }
.detail-cell .k { font-size: 11px; color: var(--muted); }
.detail-cell .v { font-family: var(--mono); font-size: 13px; margin-top: 2px; word-break: break-all; }
.detail-cmd { margin-bottom: 14px; }
.detail-cmd .v { font-family: var(--mono); font-size: 12px; background: #0a0d12; border: 1px solid var(--border); border-radius: 6px; padding: 8px; word-break: break-all; }

/* ---------- detail chart ---------- */
.chart-box { margin-bottom: 14px; position: relative; }
.chart-box h4 { margin: 0 0 6px; font-size: 13px; color: var(--muted); }
.chart-box canvas { background: var(--bg3); border-radius: 8px; padding: 6px; }
#vline-tip {
  position: absolute; top: 6px; transform: translateX(-50%);
  background: #0b1220; border: 1px solid var(--red); color: var(--text);
  font-family: var(--mono); font-size: 11px; padding: 4px 8px; border-radius: 6px;
  pointer-events: none; z-index: 5; white-space: nowrap;
}

/* ---------- log viewer (timeline rows) ---------- */
.log-tools { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
.log-tools input { width: 240px; margin: 0; }
.log-viewer {
  background: #0a0d12; border: 1px solid var(--border); border-radius: 8px;
  max-height: 320px; overflow-y: auto; font-family: var(--mono); font-size: 12px;
  line-height: 1.5;
}
.log-row { display: flex; gap: 10px; padding: 1px 8px; cursor: default; transition: background .08s; }
.log-row:hover { background: rgba(77,163,255,.08); }
.log-row.pinned { background: rgba(248,81,73,.10); outline: 1px solid rgba(248,81,73,.5); outline-offset: -1px; }
.log-ts {
  flex: 0 0 auto; color: var(--muted); user-select: none;
  font-size: 11px; padding-top: 1px;
}
.log-line { white-space: pre-wrap; word-break: break-all; }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  width: 560px; max-width: 100%; max-height: 92vh; overflow-y: auto; padding: 18px;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h3 { margin: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.span2 { grid-column: span 2; }
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
input, textarea, select {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 7px 9px; font-size: 13px; font-family: var(--mono); margin-top: 3px;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; }

/* ---------- GitHub Pages live-demo banner (docs only) ---------- */
.demo-banner {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 8px 20px; font-size: 13px; color: #0b1220;
  background: linear-gradient(90deg, #4da3ff, #bc8cff);
}
.demo-banner a { color: #0b1220; font-weight: 600; text-decoration: none; }
.demo-banner a:hover { text-decoration: underline; }
