/* Modern processing overlay — clean light theme matching the app. */

.proc-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: linear-gradient(180deg, #f8fbff 0%, #eef4fc 100%);
  color: #0f172a;
  display: flex; align-items: stretch; justify-content: center;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  --primary: #2f7df0;
  --primary-hover: #1f63cc;
  --primary-soft: #e6f0ff;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --fg: #0f172a;
  --muted: #64748b;
  --surface: #ffffff;
  --shadow-sm: 0 1px 2px rgba(15, 39, 72, 0.04);
  --shadow-md: 0 1px 2px rgba(15, 39, 72, 0.04), 0 4px 14px rgba(15, 39, 72, 0.06);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  animation: overlay-in 0.25s ease;
}
.proc-overlay[hidden] { display: none !important; }
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }

/* Removed: animated grid background. */
.grid-bg { display: none; }

.proc-frame {
  position: relative; z-index: 1;
  width: 100%; max-width: 1480px; padding: 24px 28px 28px;
  display: flex; flex-direction: column; gap: 16px;
}

/* ---- Header ---- */

.proc-header {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 18px;
  box-shadow: var(--shadow-sm);
}
.proc-title { display: flex; align-items: center; gap: 12px; }
.proc-pulse {
  width: 10px; height: 10px; background: var(--primary); border-radius: 50%;
  position: relative; flex-shrink: 0;
}
.proc-pulse::after {
  content: ""; position: absolute; inset: -5px;
  border-radius: 50%; border: 2px solid var(--primary);
  animation: pulsering 1.6s ease-out infinite;
}
@keyframes pulsering {
  0%   { transform: scale(0.6); opacity: 0.7; }
  100% { transform: scale(1.7); opacity: 0; }
}
.proc-name {
  font-size: 14px; font-weight: 700; color: var(--fg);
}
.proc-phase {
  font-size: 12px; font-weight: 600; color: var(--primary);
  background: var(--primary-soft); padding: 4px 10px; border-radius: 999px;
}
.proc-meta {
  display: flex; align-items: center; gap: 16px;
}
.proc-counter {
  font-family: var(--mono); font-size: 13px; font-weight: 600;
  color: var(--fg);
}
.proc-elapsed {
  font-family: var(--mono); font-size: 12px; color: var(--muted);
}

.proc-stop {
  margin-left: 4px; background: #fff;
  color: #d83a3a; border: 1px solid #f3c3c3;
  border-radius: 8px; padding: 7px 14px;
  font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
}
.proc-stop:hover {
  background: #fde6e6; border-color: #d83a3a;
}
.proc-stop:disabled {
  color: var(--muted); border-color: var(--line); cursor: not-allowed;
  background: var(--surface);
}

.proc-min {
  background: #fff; color: var(--primary);
  border: 1px solid #c9dcfa;
  border-radius: 8px; padding: 7px 14px;
  font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
}
.proc-min:hover { background: var(--primary-soft); }

/* ---- Persistent topbar pill (shown when a job is running) ---- */
.proc-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px;
  background: #2f7df0;
  border: 1px solid #2f7df0;
  border-radius: 999px;
  color: #fff; cursor: pointer;
  font-family: inherit; font-size: 12px; font-weight: 600;
  transition: filter 0.15s, transform 80ms;
  box-shadow: 0 2px 6px rgba(47, 125, 240, 0.25);
}
.proc-pill:hover { filter: brightness(1.05); }
.proc-pill:active { transform: translateY(1px); }
.proc-pill[hidden] { display: none; }
.proc-pill .proc-pill-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #fff;
  position: relative;
  animation: pillpulse 1.6s ease-in-out infinite;
}
@keyframes pillpulse {
  0%, 100% { opacity: 0.55; transform: scale(0.85); }
  50%      { opacity: 1;    transform: scale(1.1); }
}
.proc-pill .proc-pill-counter {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px; opacity: 0.9;
  font-variant-numeric: tabular-nums;
}
.proc-pill.is-done {
  background: #10a37f; border-color: #10a37f;
  box-shadow: 0 2px 6px rgba(16, 163, 127, 0.3);
}
.proc-pill.is-done .proc-pill-dot { animation: none; opacity: 1; }
.proc-pill.is-error {
  background: #d83a3a; border-color: #d83a3a;
  box-shadow: 0 2px 6px rgba(216, 58, 58, 0.3);
}
.proc-pill.is-error .proc-pill-dot { animation: none; opacity: 1; }

/* ---- Progress ---- */

.proc-progress {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 18px;
  box-shadow: var(--shadow-sm);
}
.proc-progress-bar {
  height: 6px; background: #eff4fb;
  border-radius: 999px; overflow: hidden; position: relative;
}
.proc-progress-bar > div {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--primary), var(--primary-hover));
  border-radius: 999px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative; overflow: hidden;
}
.proc-progress-bar > div::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
  animation: shimmer 2s linear infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

.proc-message {
  margin-top: 10px; font-size: 13px; color: var(--muted);
}
/* Remove the old terminal '>_' prefix. */
.proc-message::before { content: none; }

/* Chunk badge in the header (e.g. "Chunk 3/45 · extract") */
.proc-chunk {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  background: #fff;
  color: var(--fg);
  border: 1px solid var(--line);
  padding: 3px 9px; border-radius: 999px;
}

/* Heartbeat indicator: how many seconds since the last activity-log event */
.proc-heartbeat {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  color: var(--muted);
  padding: 3px 8px; border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  min-width: 64px; text-align: center;
}
.proc-heartbeat.hb-warn {
  color: #c97a00; background: #fff3df; border-color: #f0c878;
}
.proc-heartbeat.hb-stuck {
  color: #fff; background: #d83a3a; border-color: #d83a3a;
  animation: hb-pulse 1.2s ease-in-out infinite;
}
@keyframes hb-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .6; }
}

/* Chunks strip: a row of small dots, each = one chunk in the run.
   Lit-up = done, ring = current, hollow = pending. */
.proc-chunks-strip {
  margin-top: 8px;
  display: flex; flex-wrap: wrap; gap: 3px;
  align-items: center;
}
.proc-chunks-strip .cd {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  background: var(--line);
  border: 1px solid var(--line-strong);
  flex-shrink: 0;
}
.proc-chunks-strip .cd.done    { background: var(--primary); border-color: var(--primary); }
.proc-chunks-strip .cd.pending { background: transparent; }
.proc-chunks-strip .cd.active {
  background: #fff; border: 2px solid var(--primary);
  width: 12px; height: 12px;
  box-shadow: 0 0 0 2px rgba(47, 125, 240, 0.18);
  animation: hb-pulse 1.4s ease-in-out infinite;
}
.proc-chunks-strip .cd.active.importing  { border-color: #2f7df0; }
.proc-chunks-strip .cd.active.pairing    { border-color: #c97a00; }
.proc-chunks-strip .cd.active.extracting { border-color: #10a37f; }

/* ---- Stage ---- */

.proc-stage {
  display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px;
  flex: 1; min-height: 0;
}

.proc-current {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.proc-image-wrap {
  position: relative; flex: 1; min-height: 0;
  background: #0f172a;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.proc-image-wrap img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  animation: img-in 0.4s ease;
}
@keyframes img-in {
  from { opacity: 0; transform: scale(1.01); }
  to   { opacity: 1; transform: scale(1); }
}

.proc-empty {
  position: absolute; font-size: 12px;
  color: rgba(255, 255, 255, 0.55); letter-spacing: 0.04em;
}
.proc-image-wrap.has-img .proc-empty { display: none; }
.proc-image-wrap:not(.has-img) img { display: none; }

/* Removed: cyan corner brackets and scan line. */
.corner, .scanline { display: none; }

.proc-current-info {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px; border-top: 1px solid var(--line);
  background: var(--surface);
}
.proc-label {
  font-size: 11px; font-weight: 700; color: var(--muted);
  letter-spacing: 0.08em; text-transform: uppercase;
}
.proc-filename {
  font-family: var(--mono); font-size: 12px; color: var(--fg);
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.proc-status-text {
  font-size: 12px; color: var(--muted);
}

/* ---- Activity log (live event tail) ---- */

.proc-activity-wrap {
  border-top: 1px solid var(--line);
  background: var(--surface);
  display: flex; flex-direction: column; min-height: 0;
  flex-shrink: 0;
  height: 220px;
}
.proc-activity-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 16px; border-bottom: 1px solid var(--line);
  background: #fafbfd;
}
.proc-activity-autoscroll {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--muted); cursor: pointer;
  user-select: none;
}
.proc-activity-autoscroll input { margin: 0; cursor: pointer; }

.proc-activity {
  list-style: none; margin: 0; padding: 6px 0;
  flex: 1; overflow-y: auto;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.55;
}
.proc-activity::-webkit-scrollbar { width: 8px; }
.proc-activity::-webkit-scrollbar-thumb {
  background: var(--line-strong); border-radius: 4px;
}
.proc-activity li {
  display: grid; grid-template-columns: 52px 14px 1fr;
  gap: 8px; align-items: baseline;
  padding: 2px 16px;
}
.proc-activity li:hover { background: #f5f8fc; }
.proc-activity li.is-new { animation: actfade 0.4s ease; }
@keyframes actfade {
  from { background: var(--primary-soft); }
  to   { background: transparent; }
}
.proc-activity .t {
  color: var(--muted); font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.proc-activity .glyph {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; margin-top: 5px;
  background: var(--line-strong);
}
.proc-activity .lvl-info  .glyph { background: var(--line-strong); }
.proc-activity .lvl-step  .glyph { background: var(--primary); }
.proc-activity .lvl-ok    .glyph { background: #10a37f; }
.proc-activity .lvl-warn  .glyph { background: #c97a00; }
.proc-activity .lvl-error .glyph { background: #d83a3a; }
.proc-activity .lvl-cache .glyph {
  background: var(--surface); border: 1.5px solid var(--primary);
  width: 7px; height: 7px;
}
.proc-activity .text { color: var(--fg); word-break: break-word; }
.proc-activity .lvl-info .text { color: var(--muted); }
.proc-activity .lvl-error .text { color: #d83a3a; font-weight: 500; }

/* ---- Recent panel ---- */

.proc-recent {
  display: flex; flex-direction: column; gap: 10px; min-height: 0;
  border: 0; padding: 0; overflow-y: auto;
}
.proc-recent::-webkit-scrollbar { width: 8px; }
.proc-recent::-webkit-scrollbar-thumb {
  background: var(--line-strong); border-radius: 4px;
}
.proc-recent .proc-label { padding: 0; flex-shrink: 0; }

/* Latest extraction card. */
.proc-detail {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 16px; flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  animation: detail-in 0.4s ease;
}
@keyframes detail-in {
  0%   { opacity: 0; transform: translateY(-6px); border-color: var(--primary); }
  100% { opacity: 1; transform: translateY(0); border-color: var(--line); }
}
.proc-detail-empty {
  font-size: 13px; color: var(--muted);
  letter-spacing: 0; text-transform: none; padding: 24px;
  text-align: center; animation: none;
}
.proc-detail-head {
  display: grid; grid-template-columns: 84px 1fr auto;
  gap: 14px; align-items: start; padding-bottom: 12px;
  border-bottom: 1px solid var(--line); margin-bottom: 12px;
}
.proc-detail-head img {
  width: 84px; height: 52px; object-fit: cover; border-radius: 6px;
  border: 1px solid var(--line); background: #0f172a;
}
.proc-detail-head .country {
  color: var(--fg); font-weight: 700; font-size: 14px;
  display: flex; align-items: center; gap: 8px; font-family: inherit;
}
.proc-detail-head .country::before {
  content: ""; display: inline-block; width: 6px; height: 6px;
  background: var(--primary); border-radius: 50%;
  box-shadow: none;
}
.proc-detail-head .denom {
  color: var(--muted); font-weight: 500; font-size: 13px; margin-top: 3px;
  font-family: inherit;
}
.proc-detail .conf {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  color: var(--primary); align-self: flex-start;
  padding: 3px 8px; border-radius: 6px;
  background: var(--primary-soft); border: 0;
}
.proc-detail .conf.low {
  color: #c97a00; background: #fff3df; border: 0;
}

.proc-detail-fields {
  display: flex; flex-direction: column; gap: 4px;
  font-family: inherit; font-size: 12px;
}
.proc-detail-fields .row {
  display: grid; grid-template-columns: 130px 1fr; gap: 12px;
  padding: 3px 0;
}
.proc-detail-fields .row .k {
  color: var(--muted); letter-spacing: 0.02em; text-transform: none;
  font-size: 11px; font-weight: 600;
}
.proc-detail-fields .row .v {
  color: var(--fg); word-break: break-word; line-height: 1.5;
}
.proc-detail-fields .row .v.empty { color: #cbd5e1; }
.proc-detail-fields .block {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--line);
}
.proc-detail-fields .block .k {
  color: var(--muted); letter-spacing: 0.02em; text-transform: none;
  font-size: 11px; font-weight: 600; margin-bottom: 4px;
}
.proc-detail-fields .block .v {
  color: var(--fg); line-height: 1.6; font-size: 12.5px;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical;
  overflow: hidden;
}

#proc-recent-list {
  display: flex; flex-direction: column; gap: 8px; min-height: 0;
}

.proc-empty-recent {
  font-size: 12px; color: var(--muted);
  letter-spacing: 0; text-transform: none; padding: 12px 0;
  text-align: center;
}
.proc-recent.has-items .proc-empty-recent { display: none; }

.proc-card {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 12px;
  align-items: center;
  padding: 10px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px;
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  animation: cardin 0.4s ease;
}
.proc-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  text-decoration: none;
}
@keyframes cardin {
  0%   { opacity: 0; transform: translateY(6px); border-color: var(--primary); }
  100% { opacity: 1; transform: translateY(0); border-color: var(--line); }
}
.proc-card img {
  width: 64px; height: 40px; object-fit: cover; border-radius: 4px;
  border: 1px solid var(--line); background: #0f172a;
}
.proc-card .info {
  font-family: inherit; font-size: 12px; color: var(--fg);
  line-height: 1.5; min-width: 0; overflow: hidden;
}
.proc-card .info .country {
  color: var(--fg); font-weight: 600; font-size: 12.5px;
  display: flex; align-items: center; gap: 6px;
}
.proc-card .info .country::before {
  content: ""; display: inline-block; width: 5px; height: 5px;
  background: var(--primary); border-radius: 50%;
  box-shadow: none;
}
.proc-card .info .denom { color: var(--muted); font-weight: 500; font-size: 11.5px; }
.proc-card .info .serial {
  color: var(--muted); font-family: var(--mono);
  word-break: break-all; font-size: 10.5px; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical;
  overflow: hidden;
}
.proc-card .conf {
  font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  color: var(--primary); align-self: center;
  padding: 2px 7px; border-radius: 5px;
  background: var(--primary-soft); border: 0;
}
.proc-card .conf.low {
  color: #c97a00; background: #fff3df; border: 0;
}
