:root {
  --bg-deep: #10141b;
  --bg-panel: #171c25;
  --bg-panel-raised: #1d2330;
  --border: #262c38;
  --border-soft: #1e2430;
  --text-hi: #e9ecf1;
  --text-mid: #9aa3b2;
  --text-dim: #5c6577;
  --signal-active: #e8a33d;
  --signal-idle: #45c4b0;
  --signal-fail: #d9614f;
  --signal-queued: #8b90c7;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: -apple-system, "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg-deep);
  color: var(--text-hi);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  padding: 24px;
}

.wrap { max-width: 980px; margin: 0 auto; }

/* ---- header ---- */
header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
header h1 { font-size: 17px; font-weight: 600; margin: 0; letter-spacing: 0.01em; }
header .sub { color: var(--text-dim); font-size: 12px; margin-top: 3px; font-family: var(--mono); }
.header-right { display: flex; align-items: center; gap: 14px; }
.header-right form { margin: 0; }
.header-right button {
  font-family: var(--sans);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: var(--bg-panel-raised);
  color: var(--text-mid);
  cursor: pointer;
}
.header-right button:hover { border-color: var(--text-mid); color: var(--text-hi); }

.conn-badge {
  font-family: var(--mono);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-mid);
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-dim); flex-shrink: 0; }
.dot.connecting { background: var(--signal-queued); animation: pulse 1.2s infinite; }
.dot.connected { background: var(--signal-idle); }
.dot.error { background: var(--signal-fail); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---- stat row ---- */
.stat-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 1px;
}
.stat { background: var(--bg-panel); padding: 16px 18px; }
.stat .label { font-size: 11px; color: var(--text-dim); font-family: var(--mono); margin-bottom: 8px; }
.stat .value { font-size: 20px; font-weight: 600; font-family: var(--mono); }
.stat .value.active { color: var(--signal-active); }
.stat .value.queued { color: var(--signal-queued); }
.stat .detail { font-size: 12px; color: var(--text-mid); margin-top: 4px; }

/* Per-jobType tally under the workers stat (e.g. "8 import · 1 idle"),
   populated once WORKER_COUNTS/snapshot include a breakdown. Empty and
   invisible (no margin) until then. */
.stat .detail.worker-breakdown {
  font-family: var(--mono);
  color: var(--text-dim);
  margin-top: 2px;
}
.stat .detail.worker-breakdown:empty { margin-top: 0; }

/* ---- sections ---- */
.section {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 16px 18px;
  margin-top: 16px;
}
.section h2 {
  font-size: 12px;
  font-weight: 600;
  margin: 0 0 12px 0;
  color: var(--text-mid);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

/* Persistent trickle counter, next to the "Job progress" heading — kept
   separate from .job-row since trickle never completes and would
   otherwise sit there with a permanently-indeterminate bar. */
.trickle-stat {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  color: var(--text-dim);
}
.trickle-stat:empty { display: none; }

/* ---- job progress ---- */
.job-row { padding: 9px 0; border-top: 1px solid var(--border-soft); }
.job-row:first-child { border-top: none; padding-top: 0; }
.job-row .top { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 12.5px; margin-bottom: 6px; }
.job-row .jobtype { color: var(--text-hi); font-weight: 500; }
.job-row .kind-tag { color: var(--text-dim); }
.job-row .kind-tag.completed { color: var(--signal-idle); }
.job-row .kind-tag.failed { color: var(--signal-fail); }
.job-row .kind-tag.started, .job-row .kind-tag.progress { color: var(--signal-active); }
.bar-track { height: 5px; background: var(--bg-deep); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--signal-active); border-radius: 3px; transition: width 0.4s ease; }
.bar-fill.indeterminate { width: 30%; animation: slide 1.4s infinite ease-in-out; }
@keyframes slide { 0% { margin-left: 0%; } 50% { margin-left: 70%; } 100% { margin-left: 0%; } }
.empty-note { color: var(--text-dim); font-family: var(--mono); font-size: 12px; }

/* ---- throughput ---- */
.chart-wrap { display: flex; align-items: flex-end; gap: 3px; height: 60px; margin-top: 4px; }
.chart-bar { flex: 1; background: var(--signal-idle); border-radius: 1px 1px 0 0; min-height: 2px; opacity: 0.85; }
.chart-axis { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 10px; color: var(--text-dim); margin-top: 5px; }

/* ---- event log ---- */
.log-list { max-height: 320px; overflow-y: auto; }
.log-row {
  display: grid;
  grid-template-columns: 62px 12px 100px 1fr;
  gap: 10px;
  align-items: center;
  padding: 5px 0;
  font-family: var(--mono);
  font-size: 12px;
  border-top: 1px solid var(--border-soft);
}
.log-row:first-child { border-top: none; }
.log-row .time { color: var(--text-dim); }
.log-row .dot2 { width: 6px; height: 6px; border-radius: 50%; }
.log-row .job { color: var(--text-mid); }
.log-row .detail { color: var(--text-hi); }
.log-list::-webkit-scrollbar { width: 8px; }
.log-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ---- login page ---- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.login-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 28px 26px;
  width: 100%;
  max-width: 320px;
}
.login-card h1 { font-size: 16px; font-weight: 600; margin: 0 0 4px 0; }
.login-card .sub { font-size: 12px; color: var(--text-dim); margin: 0 0 20px 0; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 11px; color: var(--text-dim); font-family: var(--mono); }
.field input {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  color: var(--text-hi);
  font-family: var(--mono);
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 2px;
  width: 100%;
}
.field input:focus { outline: none; border-color: var(--signal-idle); }
button.primary {
  width: 100%;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 2px;
  border: 1px solid var(--signal-idle);
  background: var(--signal-idle);
  color: #08201c;
  cursor: pointer;
  margin-top: 4px;
}
button.primary:hover { filter: brightness(1.08); }
.form-msg { font-family: var(--mono); font-size: 12px; color: var(--signal-fail); margin: 4px 0 10px 0; }