/*
 * Scrape Tracker Styles
 *
 * Feature-prefixed with `scrape-` following the project convention
 * (smtp-, wr-, sponsor-report-). Uses design tokens from design_tokens.css.
 */

/* ===== Layout ===== */

/* Page / header / split layout — mirrors the sponsor_email_formatter
   pattern (.sef-page / .sef-header / .sef-layout). Header is a full-width
   card above the 2fr+1fr grid, both centered at max-width 1100px. */

.scrape-page {
  /* Outer page padding lives at the app frame's .viewport > .shell rule
     (24px / --s-6). Do not re-set it here. */
  min-height: 100vh;
  background-color: var(--color-bg-secondary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--color-text-primary);
}

/* Header card: contains breadcrumb, title, badges, and action buttons */
/* Hero-card spacing stolen from audience-marketing .cpv1-hero —
   tighter padding, consistent gaps, 24px title font. */
.scrape-header {
  max-width: 1100px;
  margin: 0 auto 12px;
  background: var(--color-bg-primary);
  padding: 22px 22px 20px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.scrape-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.scrape-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.scrape-header-title {
  flex: 1;
  min-width: 0;
}

.scrape-header-kicker {
  font-family: Monaco, Menlo, Consolas, monospace;
  font-size: 11.5px;
  color: var(--color-text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.scrape-header-name {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.005em;
  color: var(--color-text-primary);
  margin: 0;
  overflow-wrap: break-word;
}

/* 2-column grid of label / value rows under the title — mirrors
   audience-marketing's cpv1-hero-fields. */
.scrape-header-fields {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 6px 16px;
  align-items: baseline;
}

.scrape-header-field-label {
  font-size: 12px;
  color: var(--color-text-secondary, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.scrape-header-field-value {
  font-size: 14px;
  color: var(--color-text-primary, #111827);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.scrape-header-field-value--muted {
  color: var(--color-text-muted, #9ca3af);
}

.scrape-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Page-level list view — still uses its own title row, unchanged from
   before for the scrapes index. Listing-only classes: */
.scrape-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 0;
}

.scrape-nav-group {
  display: flex;
  gap: 16px;
}

.scrape-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  text-decoration: none;
}

.scrape-nav-link:hover {
  color: var(--color-interactive-primary);
  text-decoration: underline;
}

.scrape-nav-icon {
  width: 14px;
  height: 14px;
}

/* ===== Buttons ===== */

.scrape-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s;
  line-height: 1.4;
}

.scrape-btn-primary {
  background: var(--color-interactive-primary);
  color: #fff;
  border-color: var(--color-interactive-primary);
}

.scrape-btn-primary:hover {
  background: var(--color-interactive-primary-hover);
  border-color: var(--color-interactive-primary-hover);
  color: #fff;
  text-decoration: none;
}

.scrape-btn-secondary {
  background: #fff;
  color: var(--color-text-primary);
  border-color: var(--color-border-default);
}

.scrape-btn-secondary:hover {
  background: var(--color-gray-50);
  border-color: var(--color-gray-400);
}

.scrape-btn-danger {
  background: #dc2626;
  color: #fff;
  border-color: #dc2626;
}

.scrape-btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
  color: #fff;
}

.scrape-btn-sm {
  padding: 4px 10px;
  font-size: 13px;
}

.scrape-btn-text {
  background: none;
  border: none;
  color: var(--color-interactive-primary);
  padding: 4px 8px;
  cursor: pointer;
}

.scrape-btn-text:hover {
  text-decoration: underline;
}

.scrape-btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== Flash Messages ===== */

.scrape-flash {
  max-width: 1100px;
  margin: 0 auto 0.75rem;
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 14px;
}

.scrape-flash-success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.scrape-flash-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* ===== Status Badges ===== */

.scrape-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}

/* State badge — top-right of the hero card. Primary state-change UI.
   Pattern adopted from audience-marketing cpv1-hero-state. Click to
   open a dropdown menu listing every state; pick one to set
   workflow_state directly (bypasses the model's transition guards). */
.scrape-header-state {
  position: relative;
  flex-shrink: 0;
}

.scrape-state-badge {
  display: inline-flex;
  align-items: center;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
}

.scrape-state-badge:hover {
  filter: brightness(0.96);
}

.scrape-state-badge:focus-visible {
  outline: 2px solid var(--color-interactive-focus, #3b82f6);
  outline-offset: 2px;
}

/* State-badge color variants — same palette as the small inline
   badges so it reads consistently. */
.scrape-state-badge--not_started { background: var(--color-blue-50, #eff6ff); color: var(--color-blue-800, #1e40af); border-color: var(--color-blue-200, #bfdbfe); }
.scrape-state-badge--in_progress { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.scrape-state-badge--in_review   { background: #faf5ff; color: #6b21a8; border-color: #e9d5ff; }
.scrape-state-badge--approved    { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.scrape-state-badge--uploaded    { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.scrape-state-badge--launched    { background: #dcfce7; color: #14532d; border-color: #86efac; }
.scrape-state-badge--cancelled   { background: var(--color-gray-50, #f9fafb); color: var(--color-gray-500, #6b7280); border-color: var(--color-gray-200, #e5e7eb); }
.scrape-state-badge--archived    { background: var(--color-gray-50, #f9fafb); color: var(--color-gray-500, #6b7280); border-color: var(--color-gray-200, #e5e7eb); }

/* Actions row sits below the title/state row, right-aligned. Only
   shows non-state buttons (downloads); state changes happen via the
   clickable state badge. */
.scrape-header-actions-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.scrape-header-actions-row:empty {
  display: none;
}

.scrape-state-menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 200px;
  background: #fff;
  border: 1px solid var(--color-border-default, #d1d5db);
  border-radius: 6px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
  z-index: 50;
  padding: 4px 0;
}

.scrape-state-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 14px;
  background: transparent;
  border: 0;
  text-align: left;
  font-size: 13px;
  color: var(--color-text-primary, #111827);
  cursor: pointer;
  font-family: inherit;
}

.scrape-state-menu-item:hover {
  background: var(--color-gray-50, #f9fafb);
}

/* button_to wraps every menu item in a <form>. Browsers' user-agent
   stylesheet sets form { margin-block-end: 1em } — that's what causes
   the huge inter-row gaps. Zero margin + padding matches the working
   wr-row-menu-panel pattern. */
.scrape-state-menu-dropdown form {
  margin: 0;
  padding: 0;
}

.scrape-state-menu-item--current {
  background: var(--color-gray-50, #f9fafb);
  color: var(--color-text-secondary, #6b7280);
  cursor: default;
}

.scrape-state-menu-tag {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted, #9ca3af);
}

.scrape-state-label {
  flex: 1;
}

.scrape-state-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.scrape-state-dot--not_started { background: #3b82f6; }
.scrape-state-dot--in_progress { background: #f59e0b; }
.scrape-state-dot--in_review   { background: #a855f7; }
.scrape-state-dot--approved    { background: #22c55e; }
.scrape-state-dot--uploaded    { background: #10b981; }
.scrape-state-dot--launched    { background: #14532d; }
.scrape-state-dot--cancelled   { background: #9ca3af; }
.scrape-state-dot--archived    { background: #6b7280; }

.scrape-badge--not_started {
  background: var(--color-blue-50);
  color: var(--color-blue-800);
  border: 1px solid var(--color-blue-200);
}

.scrape-badge--in_progress {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

.scrape-badge--in_review {
  background: #faf5ff;
  color: #6b21a8;
  border: 1px solid #e9d5ff;
}

.scrape-badge--approved {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.scrape-badge--uploaded {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.scrape-badge--launched {
  background: #dcfce7;
  color: #14532d;
  border: 1px solid #86efac;
}

.scrape-badge--archived {
  background: var(--color-gray-50);
  color: var(--color-gray-500);
  border: 1px solid var(--color-gray-200);
}

.scrape-badge--cancelled {
  background: var(--color-gray-50);
  color: var(--color-gray-400);
  border: 1px solid var(--color-gray-200);
}

/* Vertical badges */
.scrape-vertical-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.scrape-vertical-badge--hr {
  background: var(--event-type-live-bg);
  color: var(--event-type-live-text);
}

.scrape-vertical-badge--marketing {
  background: var(--event-type-virtual-bg);
  color: var(--event-type-virtual-text);
}

.scrape-vertical-badge--both {
  background: var(--event-type-webinar-bg);
  color: var(--event-type-webinar-text);
}

/* ===== Template + Due badges (header card) ===== */

.scrape-template-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: 1px solid transparent;
}

.scrape-template-badge--competitive_event {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

.scrape-template-badge--custom {
  background: #f3f4f6;
  color: #4b5563;
  border-color: #d1d5db;
}

.scrape-due-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

/* ===== Template reference panel (new scrape form + show page) ===== */

.scrape-template-reference {
  background: var(--color-gray-50, #f9fafb);
  border: 1px solid var(--color-border-light, #e5e7eb);
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.55;
}

.scrape-template-reference p {
  margin: 0;
}

.scrape-template-cols {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-size: 12px;
  color: var(--color-text-secondary, #6b7280);
  overflow-wrap: anywhere;
}

/* ===== Uncategorized people banner ===== */

.scrape-uncategorized-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #78350f;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 14px;
  font-size: 13px;
}

.scrape-uncategorized-banner > span {
  flex: 1;
  min-width: 240px;
}

/* ===== Tabs ===== */

.scrape-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-border-light);
  margin: 0 auto 20px;
  max-width: 1100px;
}

.scrape-tab {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

.scrape-tab:hover {
  color: var(--color-text-primary);
  text-decoration: none;
}

.scrape-tab--active {
  color: var(--color-interactive-primary);
  border-bottom-color: var(--color-interactive-primary);
}

.scrape-tab-count {
  display: inline-block;
  background: var(--color-gray-200);
  color: var(--color-text-secondary);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 9999px;
  margin-left: 6px;
}

.scrape-tab--active .scrape-tab-count {
  background: var(--color-blue-50);
  color: var(--color-interactive-primary);
}

/* ===== Filters ===== */

.scrape-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 auto 16px;
  max-width: 1100px;
  gap: 12px;
}

.scrape-filters {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.scrape-input {
  padding: 6px 12px;
  font-size: 14px;
  border: 1px solid var(--color-border-default);
  border-radius: 6px;
  background: #fff;
  color: var(--color-text-primary);
}

.scrape-input:focus {
  outline: none;
  border-color: var(--color-interactive-focus);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.scrape-filter-search {
  min-width: 200px;
}

/* ===== Table ===== */

.scrape-table-container {
  overflow-x: auto;
  max-width: 1100px;
  margin: 0 auto;
}

.scrape-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.scrape-table thead th {
  text-align: left;
  padding: 0.5rem;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-secondary);
  background: var(--color-gray-50);
  border-bottom: 1px solid var(--color-border-light);
  white-space: nowrap;
}

.scrape-table tbody td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--color-border-light);
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scrape-table-col-num {
  text-align: right;
  width: 72px;
}

.scrape-table tbody tr:hover {
  background: var(--color-gray-50);
}

.scrape-table-link {
  color: var(--color-interactive-primary);
  text-decoration: none;
  font-weight: 500;
}

.scrape-table-link:hover {
  text-decoration: underline;
}

.scrape-table-code {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", monospace;
  font-size: 12px;
  color: var(--color-text-muted);
}

.scrape-table-truncate {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scrape-table-meta {
  font-size: 13px;
  color: var(--color-text-secondary);
}

.scrape-table-source-cell {
  display: inline-flex;
  align-items: center;
  max-width: 200px;
}

.scrape-table-source-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scrape-table-source-link {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  color: var(--color-text-muted);
  vertical-align: middle;
  text-decoration: none;
}

.scrape-table-source-link:hover,
.scrape-table-source-link:focus-visible {
  color: var(--color-interactive-primary);
}

.scrape-table-source-link:focus-visible {
  outline: 2px solid var(--color-interactive-focus, #3b82f6);
  outline-offset: 2px;
  border-radius: 2px;
}

.scrape-table-source-icon {
  display: block;
}

.scrape-table-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-text-muted);
}

/* ===== Note Banner ===== */

.scrape-note-banner {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 20px;
}

.scrape-note-banner-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.scrape-note-banner-icon {
  width: 18px;
  height: 18px;
  color: #d97706;
  flex-shrink: 0;
}

.scrape-note-banner-header strong {
  font-size: 14px;
  color: #92400e;
}

.scrape-note-banner-by {
  font-size: 13px;
  color: #b45309;
  margin-left: auto;
}

.scrape-note-banner-text {
  font-size: 14px;
  color: #78350f;
  margin: 0;
  line-height: 1.5;
}

/* ===== Detail Page ===== */

/* .scrape-detail-* removed — the detail header was merged into the
   full-width .scrape-header card above the 2fr+1fr split. */

/* ===== Detail Sections ===== */

.scrape-section {
  background: #fff;
  border: 1px solid var(--color-border-light);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.scrape-section-title {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-secondary);
  margin: 0 0 14px 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border-light);
}

.scrape-field {
  margin-bottom: 14px;
}

.scrape-field:last-child {
  margin-bottom: 0;
}

.scrape-field-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.scrape-field-value {
  font-size: 14px;
  color: var(--color-text-primary);
  line-height: 1.5;
}

.scrape-field-value a {
  color: var(--color-interactive-primary);
  text-decoration: none;
}

.scrape-field-value a:hover {
  text-decoration: underline;
}

.scrape-field-empty {
  color: var(--color-text-muted);
  font-style: italic;
}

/* .scrape-attribution* removed — attribution lives in the activity log
   sidebar, one line per lifecycle event, with who/when/what baked in. */

/* ===== Data table pagination ===== */

.scrape-data-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.scrape-data-pagination-range {
  font-size: 13px;
  color: var(--color-text-secondary, #6b7280);
}

.scrape-data-pagination-nav {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.scrape-data-pagination-page {
  font-size: 13px;
  color: var(--color-text-secondary, #6b7280);
  padding: 0 4px;
}

.scrape-btn--disabled {
  opacity: 0.45;
  pointer-events: none;
  cursor: default;
}

/* ===== File / Data Table ===== */

/* Table scroll wrapper — mirrors smtp-recipients-table-scroll.
   overflow-x on the wrapper + no width constraint on the table means
   the table is as wide as its natural content and the wrapper
   horizontally scrolls when it exceeds the main column.
   Scrollbar is forced persistently-visible (not macOS's
   auto-hide-on-idle) so users can tell scrolling is available — with
   18+ columns this is the only cue there's more data to the right. */
.scrape-data-table-scroll {
  overflow-x: auto;
  max-width: 100%;
  border: 1px solid var(--color-border-light);
  border-radius: 6px;
  scrollbar-width: thin;
}

.scrape-data-table-scroll::-webkit-scrollbar {
  height: 10px;
}

.scrape-data-table-scroll::-webkit-scrollbar-track {
  background: var(--color-bg-secondary, #f3f4f6);
  border-radius: 0 0 6px 6px;
}

.scrape-data-table-scroll::-webkit-scrollbar-thumb {
  background: var(--color-border-default, #cbd5e1);
  border-radius: 5px;
}

.scrape-data-table-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-secondary, #9ca3af);
}

.scrape-data-table {
  border-collapse: collapse;
  font-size: 13px;
  min-width: 100%; /* fill the wrapper when narrow; grow beyond when wide */
}

.scrape-data-table thead th {
  text-align: left;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  background: var(--color-gray-50);
  border-bottom: 1px solid var(--color-border-light);
  white-space: nowrap;
}

.scrape-data-table tbody td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--color-border-light);
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scrape-data-table tbody tr:hover {
  background: var(--color-gray-50);
}

/* Toolbar above each data table — matches smtp-recipients-toolbar.
   Count / meta text on the left, action buttons on the right. */
.scrape-data-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.scrape-data-count {
  color: var(--color-text-secondary);
  font-size: 0.875rem;
}

.scrape-data-count strong {
  font-weight: 600;
  color: var(--color-text-primary);
}

.scrape-data-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ===== Revision Log ===== */

.scrape-revision-log {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", monospace;
  font-size: 13px;
  line-height: 1.8;
  color: var(--color-text-secondary);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ===== Form ===== */

.scrape-form {
  max-width: 700px;
  margin: 0 auto;
}

.scrape-form-group {
  margin-bottom: 20px;
}

.scrape-form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 6px;
}

.scrape-form-hint {
  display: block;
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

.scrape-form-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid var(--color-border-default);
  border-radius: 6px;
  background: #fff;
  color: var(--color-text-primary);
  box-sizing: border-box;
}

.scrape-form-input:focus {
  outline: none;
  border-color: var(--color-interactive-focus);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.scrape-form-textarea {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid var(--color-border-default);
  border-radius: 6px;
  background: #fff;
  color: var(--color-text-primary);
  min-height: 80px;
  resize: vertical;
  font-family: inherit;
  box-sizing: border-box;
}

.scrape-form-textarea:focus {
  outline: none;
  border-color: var(--color-interactive-focus);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.scrape-form-select {
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid var(--color-border-default);
  border-radius: 6px;
  background: #fff;
  color: var(--color-text-primary);
}

.scrape-form-select:focus {
  outline: none;
  border-color: var(--color-interactive-focus);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.scrape-form-error {
  color: #dc2626;
  font-size: 13px;
  margin-top: 4px;
}

.scrape-form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.scrape-form-required {
  color: #dc2626;
}

/* ===== Action Modals (inline) ===== */

.scrape-action-form {
  display: inline;
}

.scrape-action-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.scrape-action-input {
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid var(--color-border-default);
  border-radius: 6px;
  min-width: 250px;
}

.scrape-action-input:focus {
  outline: none;
  border-color: var(--color-interactive-focus);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

/* ===== Help Page ===== */

.scrape-help {
  max-width: 800px;
  margin: 0 auto;
  line-height: 1.7;
}

.scrape-help h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 32px 0 12px 0;
  color: var(--color-text-primary);
}

.scrape-help h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 24px 0 8px 0;
  color: var(--color-text-primary);
}

.scrape-help p {
  margin: 0 0 12px 0;
  color: var(--color-text-secondary);
}

.scrape-help ul {
  margin: 0 0 12px 0;
  padding-left: 24px;
  color: var(--color-text-secondary);
}

.scrape-help li {
  margin-bottom: 4px;
}

.scrape-help code {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", monospace;
  font-size: 13px;
  background: var(--color-gray-50);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--color-border-light);
}

.scrape-help ol {
  margin: 0 0 12px 0;
  padding-left: 24px;
  color: var(--color-text-secondary);
}

.scrape-help-dl {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 8px 24px;
  margin: 0 0 16px 0;
  color: var(--color-text-secondary);
}

.scrape-help-dl dt {
  font-weight: 600;
  color: var(--color-text-primary);
}

.scrape-help-dl dd {
  margin: 0;
}

/* ===== Action bar: forward button + overflow menu ===== */

.scrape-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.scrape-status-form {
  display: inline-block;
  margin: 0;
}

.scrape-btn-icon-only {
  padding: 4px 8px;
  min-width: auto;
  line-height: 1;
}

.scrape-overflow {
  display: inline-block;
  position: relative;
}

.scrape-overflow-menu {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 20;
  min-width: 220px;
  margin-top: 4px;
  padding: 4px;
  background: #fff;
  border: 1px solid var(--color-border-default);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.scrape-overflow-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: 4px;
  font: inherit;
  text-align: left;
  color: var(--color-text-primary, #111);
  cursor: pointer;
}

.scrape-overflow-item:hover {
  background: var(--color-bg-secondary, #f3f4f6);
}

/* Submit Files drawer (in_progress) */
.scrape-submit-drawer,
.scrape-note-drawer {
  display: inline-block;
  position: relative;
}

.scrape-submit-drawer > summary,
.scrape-note-drawer > summary {
  list-style: none;
  cursor: pointer;
}

.scrape-submit-drawer > summary::-webkit-details-marker,
.scrape-note-drawer > summary::-webkit-details-marker { display: none; }

.scrape-submit-drawer-panel,
.scrape-note-drawer-panel {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 20;
  min-width: 300px;
  margin-top: 4px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--color-border-default);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.scrape-submit-drawer-panel { min-width: 380px; padding: 16px; }

.scrape-submit-drawer-hint {
  margin: 0 0 10px 0;
  font-size: 13px;
  color: var(--color-text-secondary, #6b7280);
}

/* ===== 2fr + 1fr split: main content + activity log sidebar ===== */

.scrape-split {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
  max-width: 1100px;
  margin: 0 auto;
  align-items: start;
}

.scrape-main {
  min-width: 0; /* prevent overflow from wide data tables */
}

.scrape-log-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 24rem;
  background: #1a1a2e;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  font-family: Monaco, Menlo, Consolas, monospace;
  font-size: 0.75rem;
}

.scrape-log-stream {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  color: #c0c0c0;
  /* Constrain so overflow-y actually has something to clip — matches
     sponsor_email_formatter's scrollable chat log. */
  max-height: 70vh;
}

.scrape-log-empty {
  color: #4b5563;
  padding: 2rem 0.5rem;
  text-align: center;
}

/* Each entry is a two-line block: a bracketed [Month D · HH:MM] line
   above, then the actor + content on a second line. Color of the
   bracket is the sole cue for kind — gray for machine events, blue
   for user notes — mirroring sponsor_email_formatter's pattern. */
.scrape-log-entry {
  padding: 0.25rem 0 0.5rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.scrape-log-bracket {
  display: block;
  font-weight: 600;
  font-size: 0.6875rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.scrape-log-body {
  display: block;
  white-space: pre-wrap;
}

.scrape-log-entry--event .scrape-log-bracket { color: #6b7280; }
.scrape-log-entry--note  .scrape-log-bracket { color: #93c5fd; }

.scrape-log-entry--event .scrape-log-body { color: #c0c0c0; }
.scrape-log-entry--note  .scrape-log-body { color: #e5e7eb; }
.scrape-log-entry--raw   .scrape-log-body { color: #6b7280; }

.scrape-log-composer {
  padding: 0.5rem 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.scrape-log-composer-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.scrape-log-composer-textarea {
  display: block;
  width: 100%;
  padding: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 0.25rem;
  color: #e5e7eb;
  background: transparent;
  font-family: inherit;
  font-size: 0.75rem;
  line-height: 1.4;
  resize: vertical;
  min-height: 2.2em;
}

.scrape-log-composer-textarea::placeholder {
  color: #6b7280;
}

.scrape-log-composer-btn {
  align-self: flex-end;
  padding: 4px 10px;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  color: #e5e7eb;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 0.25rem;
  cursor: pointer;
}

.scrape-log-composer-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

@media (max-width: 900px) {
  .scrape-split { grid-template-columns: 1fr; }
}

/* ===== Upload / source picker (in_progress) ===== */

.scrape-source {
  max-width: 640px;
  margin: 0 auto;
}

/* State A: URL row on top */
.scrape-source-url-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.scrape-source-url-row input {
  flex: 1;
  min-width: 0;
}

.scrape-source-divider {
  position: relative;
  text-align: center;
  margin: 14px 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-secondary, #6b7280);
}

.scrape-source-divider::before,
.scrape-source-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: calc(50% - 24px);
  height: 1px;
  background: var(--color-border-default, #e5e7eb);
}

.scrape-source-divider::before { left: 0; }
.scrape-source-divider::after  { right: 0; }

.scrape-source-divider > span {
  background: #fff;
  padding: 0 8px;
  position: relative;
  z-index: 1;
}

.scrape-source-dropzone {
  border: 2px dashed var(--color-border-default, #d1d5db);
  border-radius: 8px;
  padding: 28px 20px;
  text-align: center;
  background: var(--color-bg-secondary, #f9fafb);
  cursor: pointer;
  transition: border-color 120ms, background 120ms, opacity 120ms;
}

.scrape-source-dropzone.is-dragover {
  border-color: #3b82f6;
  background: #eff6ff;
}

.scrape-source-dropzone.is-loading {
  opacity: 0.6;
  pointer-events: none;
}

.scrape-source-dropzone-main {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
}

.scrape-source-dropzone-hint {
  font-size: 12px;
  color: var(--color-text-secondary, #6b7280);
}

.scrape-source-error {
  margin-top: 12px;
  padding: 8px 10px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  color: #991b1b;
  font-size: 13px;
}

/* State B: source loaded, tab pickers visible */
.scrape-source-loaded-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 6px;
  font-size: 13px;
  color: #065f46;
  margin-bottom: 14px;
}

.scrape-source-kind {
  color: var(--color-text-secondary, #6b7280);
  font-weight: normal;
}

.scrape-source-change {
  background: transparent;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 13px;
  color: #047857;
  cursor: pointer;
  white-space: nowrap;
}

.scrape-source-change:hover {
  text-decoration: underline;
}

.scrape-source-row1-note {
  margin: 0 0 10px 0;
  font-size: 12px;
  color: var(--color-text-secondary, #6b7280);
  font-style: italic;
}

/* Append-mode banner that appears when the user clicked "Upload
   additional rows →" on a populated slot. */
.scrape-source-append-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  font-size: 13px;
  color: #1e40af;
  margin-bottom: 14px;
}

.scrape-source-append-cancel {
  color: #1e40af;
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
}

.scrape-source-append-cancel:hover { text-decoration: underline; }

.scrape-source-slot-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.scrape-source-slot-row .scrape-form-label {
  margin: 0;
}

.scrape-source-ingest-row {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.scrape-source-ingest-hint {
  font-size: 13px;
  color: var(--color-text-secondary, #6b7280);
}

@media (max-width: 640px) {
  .scrape-source-slot-row { grid-template-columns: 1fr; gap: 4px; }
  .scrape-source-url-row  { flex-direction: column; align-items: stretch; }
}

/* ===== Responsive ===== */

@media (max-width: 768px) {
  /* Outer page padding lives at the app frame's .viewport > .shell rule
     (24px / --s-6); intentionally NOT re-set here for mobile. */

  .scrape-header-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .scrape-header-actions {
    width: 100%;
  }
}
