/* ---------- scraping automation ---------- */
.auto-badge {
  position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px;
  padding: 0 4px; border-radius: 8px; background: var(--coral); color: var(--ink);
  font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}
.btn-icon { position: relative; }
.modal-auto { max-width: 680px; }
.modal-auto .modal-body { max-height: 74vh; overflow-y: auto; }
.auto-status { font-size: 13px; color: var(--text); margin-bottom: 10px; min-height: 18px; }
.auto-section { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.auto-section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.seed-wrap { display: flex; gap: 6px; }
.auto-add-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.auto-add-row input[type=text] { flex: 1; min-width: 160px; }
.src-label-in { flex: 0 1 140px !important; }
.src-interval { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.src-interval input { width: 52px; }

/* X account URL builder (fills the source URL field) */
.x-builder { display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin: 10px 0 2px; padding: 8px 10px; background: var(--surface-2);
  border: 1px dashed var(--border); border-radius: var(--radius); }
.x-builder-label { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.x-builder input[type=text] { flex: 1; min-width: 120px; }
.x-handle-in { flex: 0 1 150px !important; }
.x-terms-in { flex: 1 1 160px !important; }
.x-builder .sort-select { flex: 0 0 auto; }
.x-rt-toggle { display: flex; align-items: center; gap: 4px; font-size: 12px;
  color: var(--muted); white-space: nowrap; flex: 0 0 auto; }
.x-rt-toggle input[type=checkbox] { margin: 0; }

.sources-list, .runs-list { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
/* cap the runs list so the modal can't grow unbounded as runs accumulate; it
   scrolls within this height. Display is also capped in JS (10 groups, 10 runs
   each) -- the full log stays in the DB. */
.runs-list { max-height: 46vh; overflow-y: auto; padding-right: 4px; }
.run-more-note { color: var(--muted); font-style: italic; }
.runs-show-more { align-self: flex-start; margin-top: 2px; }
.source-row, .run-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px;
}
/* A source row now carries up to 4 action buttons; in a single flex row those
   squeezed the label/url/meta to nothing. Stack instead: info on its own full-
   width line, actions wrapping on the line below. (Run rows keep the side-by-side
   layout -- they only have one review control.) */
.source-row { flex-direction: column; align-items: stretch; }
.source-row.disabled { opacity: 0.55; }
.src-main, .run-main { min-width: 0; flex: 1; }
.src-label, .run-label { font-weight: 600; font-size: 13px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.src-url { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.src-meta, .run-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.src-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.src-status, .run-phase { padding: 1px 7px; border-radius: 8px; font-size: 10.5px; font-weight: 600;
  background: var(--bg); color: var(--muted); }
.src-status.ok, .run-phase.ok { color: #6fe0a0; }
.src-status.err, .run-phase.err { color: #ff7a90; }
.run-phase.run { color: var(--butter); }
.src-err { color: #ffb020; cursor: help; }
.src-nolimit { color: #ffb020; cursor: help; }
.src-next { color: var(--muted); cursor: help; }
.src-next.due { color: #6fe0a0; }   /* due now / imminent -> green */
.btn-del:hover { color: #ff7a90; }

.review-head-actions { display: flex; gap: 8px; align-items: center; }
.review-head-actions .btn-danger { margin-top: 0; }
.review-pager { display: flex; gap: 12px; align-items: center; justify-content: center;
  margin: 8px 0 4px; }
.pager-label { font-size: 12px; color: var(--muted); }

/* ---------- review: match-card badge, selected-actions, re-check ---------- */
.type-badge { background: rgba(0,0,0,0.72); color: #ffd23f; }

/* ---------- tag-pending menu ---------- */
/* tag-wrap lives inside the admin menu (which has overflow:hidden), so the
   sub-panel expands INLINE below the button rather than as an absolute flyout
   -- a flyout would be clipped by the parent's overflow. */
.tag-wrap { display: block; }
.tag-wrap > #tagBtn { width: 100%; }
.tag-menu {
  margin: 4px 2px 2px; padding: 10px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; gap: 8px;
}
.tag-menu-count { font-size: 13px; font-weight: 600; color: var(--text); }
.tag-menu-label { font-size: 12px; color: var(--muted); }
.tag-menu-row { display: flex; gap: 6px; }
.tag-menu-row input { flex: 1; }

/* ---------- global review-queue row ---------- */
.review-all-row { display: flex; align-items: center; gap: 12px; }
.pending-total { font-size: 13px; font-weight: 600; color: var(--text); }
.retag-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.retag-resume-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.retag-resume-row .field-note { margin: 0; }

/* one-off backfill URL box: was inheriting cramped browser defaults */
#backfillUrls { display: block; width: 100%; box-sizing: border-box; min-height: 84px;
  resize: vertical; padding: 10px 14px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-family: inherit; font-size: 14px; line-height: 1.5; outline: none;
  margin-bottom: 10px; }
#backfillUrls:focus { border-color: var(--coral); }
#backfillUrls::placeholder { color: var(--muted); }

/* top-of-modal quick jump to the review queue */
.review-all-top { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px; padding: 10px 14px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--coral) 10%, transparent); border: 1px solid color-mix(in srgb, var(--coral) 35%, transparent); }
.review-all-top-count { font-size: 13px; font-weight: 600; color: var(--text); }
.review-all-top .btn-sm { flex-shrink: 0; }

/* ---------- runs grouped by source + review dropdown ---------- */
.source-group {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 4px 4px 6px; margin-bottom: 8px;
}
.source-group .source-head {
  background: transparent; border: none; border-radius: 0;
  border-bottom: 1px solid var(--border); margin-bottom: 4px;
}
.run-subline {
  font-size: 11.5px; color: var(--muted); padding: 3px 12px; line-height: 1.5;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
}
.run-subline:hover { color: var(--text); }

/* ---------- collapsible section headers (sources / recent runs) ---------- */
.collapse-head {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  background: none; border: none; padding: 0; margin: 0;
  font: inherit; color: inherit; text-transform: uppercase;
  letter-spacing: 0.8px; font-size: 12px; font-weight: 600;
}
.collapse-head .chev { width: 0.9em; height: 0.9em; opacity: 0.7; }
.collapse-head:hover .chev { opacity: 1; }
.collapse-head[aria-expanded="false"] .chev-down { transform: rotate(0deg); }  /* point right when collapsed */
.collapse-count { text-transform: none; letter-spacing: 0; font-weight: 500;
  font-size: 11px; color: var(--muted); }
.collapse-body.collapsed { display: none; }
.review-dd-wrap { position: relative; flex-shrink: 0; }
.review-dd-menu {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: 70;
  min-width: 180px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 4px; box-shadow: 0 10px 28px rgba(0,0,0,0.35);
  display: flex; flex-direction: column; gap: 2px;
}
.review-dd-item {
  text-align: left; background: transparent; border: none; color: var(--text);
  font-size: 12px; padding: 7px 10px; border-radius: 8px; cursor: pointer;
}
.review-dd-item:hover { background: var(--surface-2); }

/* ---------- activity log ---------- */
.modal-head-tools { display: flex; align-items: center; gap: 12px; }
.log-link {
  background: none; border: none; color: var(--muted); font-size: 12px;
  cursor: pointer; padding: 2px 4px; text-decoration: underline;
}
