/* Buyer Admin — list + tabbed editor
 * Loaded from admin/index.html. Mirrors admin/css/funnel-creator.css style.
 * All rules scoped under #buyer-admin-root or .buyer-* classes to avoid
 * bleeding into single-page / funnel creator surfaces.
 */

#buyer-admin-root { display: none; }
body.mode-buyers #buyer-admin-root { display: block; }
body.mode-buyers form#config-form { display: none; }
body.mode-buyers #funnel-tab { display: none !important; }
body.mode-buyers .tab-bar { display: none; }
/* Admin <main> constrains its children with a narrow max-width for the
 * single-page form. Buyer admin wants the full viewport. */
body.mode-buyers .admin-main {
  max-width: none !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* Toolbar */
.buyer-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 96px;
  z-index: 40;
}
.buyer-toolbar-left { flex: 1; display: flex; align-items: center; gap: 12px; }
.buyer-toolbar-right { display: flex; align-items: center; gap: 8px; }
.buyer-toolbar h2 { margin: 0; font-size: 18px; font-weight: 600; color: #111827; }
.buyer-dirty { color: #f59e0b; font-size: 12px; font-weight: 500; }

/* Banner */
.buyer-banner {
  margin: 12px 24px 0;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
}
.buyer-banner.ok { background: #d1fae5; color: #065f46; border: 1px solid #10b981; }
.buyer-banner.err { background: #fee2e2; color: #991b1b; border: 1px solid #ef4444; }

/* Two-column layout */
.buyer-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  padding: 16px 24px 32px;
  min-height: calc(100vh - 220px);
}

/* Left list */
.buyer-list-panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
}
.buyer-list-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}
.buyer-list-header h3 { margin: 0; font-size: 14px; font-weight: 600; color: #374151; }
.buyer-list-header .buyer-search-row {
  flex: 1 1 100%;
  display: flex;
  gap: 6px;
  align-items: center;
}
.buyer-list-header .buyer-sort {
  flex: 0 0 auto;
  padding: 6px 8px;
  font-size: 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: #374151;
  cursor: pointer;
}
.buyer-list-header .buyer-search {
  flex: 1 1 auto;
  width: auto;
  padding: 6px 10px;
  font-size: 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: #111827;
}
.buyer-list-header .buyer-search::placeholder { color: #9ca3af; }
.buyer-list-header .buyer-search:focus {
  outline: none;
  border-color: #1f2937;
  box-shadow: 0 0 0 2px rgba(31, 41, 55, 0.12);
}
.buyer-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.buyer-row {
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 4px;
  transition: background 100ms, border-color 100ms;
}
.buyer-row:hover { background: #f9fafb; }
.buyer-row.active { background: #eff6ff; border-color: #3b82f6; }
.buyer-row-main { font-size: 13px; color: #111827; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.buyer-row-meta { font-size: 11px; color: #6b7280; margin-top: 3px; }
.buyer-empty { padding: 16px; font-size: 12px; color: #9ca3af; text-align: center; }
.buyer-status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.buyer-status-pill.active { background: #d1fae5; color: #065f46; }
.buyer-status-pill.paused { background: #fef3c7; color: #92400e; }
.buyer-status-pill.deleted { background: #e5e7eb; color: #6b7280; }

/* Company DD enrichment indicator */
.dd-indicator { color: #10b981; font-size: 9px; cursor: help; flex-shrink: 0; }

/* Editor panel */
.buyer-editor-panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 20px 24px;
  min-height: 600px;
}
.buyer-editor-empty {
  padding: 80px 20px;
  text-align: center;
  color: #9ca3af;
  font-size: 14px;
}
.buyer-editor-header { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid #e5e7eb; }
.buyer-editor-title-row {
  display: flex;
  align-items: center;
  gap: 16px;
}
.buyer-name-input {
  flex: 1;
  font-size: 20px;
  font-weight: 600;
  padding: 8px 0;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: #111827;
}
.buyer-name-input:focus {
  outline: none;
  border-bottom-color: #3b82f6;
}
.buyer-status-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
}
.buyer-editor-meta { font-size: 11px; color: #9ca3af; margin-top: 4px; }

/* Tabs */
.buyer-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #e5e7eb;
  margin-bottom: 20px;
  overflow-x: auto;
}
.buyer-tab {
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #6b7280;
  white-space: nowrap;
}
.buyer-tab:hover { color: #111827; }
.buyer-tab.active {
  color: #1d4ed8;
  border-bottom-color: #1d4ed8;
}

/* Tab body */
.buyer-tab-body { min-height: 300px; }
.buyer-help {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 16px;
  padding: 10px 12px;
  background: #f9fafb;
  border-left: 3px solid #3b82f6;
  border-radius: 4px;
}
.buyer-help-secondary {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 16px;
  padding: 8px 12px;
  background: #f9fafb;
  border-radius: 4px;
}

.buyer-field { margin-bottom: 14px; }
.buyer-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 4px;
}
.buyer-field input[type="text"],
.buyer-field input[type="email"],
.buyer-field input[type="tel"],
.buyer-field input[type="url"],
.buyer-field input[type="number"],
.buyer-field textarea,
.buyer-field select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  color: #111827;
  background: #fff;
  box-sizing: border-box;
  font-family: inherit;
}
.buyer-field input:focus,
.buyer-field textarea:focus,
.buyer-field select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.buyer-field textarea { resize: vertical; min-height: 80px; }
.buyer-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.buyer-field-note { font-size: 11px; color: #6b7280; margin-top: 4px; }

/* Vertical checkbox grid */
.buyer-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}
.buyer-checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
  font-weight: normal;
}
.buyer-checkbox-grid label:hover { background: #f3f4f6; }

/* State grid */
.buyer-state-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 4px;
  margin-bottom: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding: 8px;
  background: #f9fafb;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}
.buyer-state-chk {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  background: #fff;
  border-radius: 4px;
  border: 1px solid #e5e7eb;
  cursor: pointer;
}
.buyer-state-chk:hover { background: #eff6ff; }
.buyer-state-bulk button {
  background: transparent;
  border: 1px solid #d1d5db;
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 4px;
  cursor: pointer;
  margin-right: 6px;
}

/* Assignments */
.buyer-site-group {
  margin-bottom: 16px;
  padding: 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}
.buyer-site-name {
  font-size: 13px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 8px;
}
.buyer-path-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  font-size: 13px;
}
.buyer-path-row label {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: normal;
}
.buyer-priority {
  width: 80px !important;
  padding: 4px 8px !important;
  font-size: 12px !important;
}

/* Delivery field mapping */
.buyer-map-row {
  display: grid;
  grid-template-columns: 1fr 20px 1fr 32px;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}
.buyer-map-row span { text-align: center; color: #9ca3af; font-size: 14px; }
.buyer-map-del {
  background: transparent;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  cursor: pointer;
  color: #ef4444;
  font-size: 16px;
  width: 28px;
  height: 28px;
  padding: 0;
}
.buyer-map-del:hover { background: #fee2e2; }
.buyer-map-row input {
  padding: 6px 10px !important;
  font-size: 12px !important;
}
.buyer-test-result {
  margin-top: 10px;
  padding: 12px;
  background: #111827;
  color: #d1fae5;
  border-radius: 6px;
  font-family: ui-monospace, 'SF Mono', Monaco, monospace;
  font-size: 11px;
  white-space: pre-wrap;
  max-height: 300px;
  overflow-y: auto;
}

/* Editor footer */
.buyer-editor-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 8px;
}
.btn-danger {
  background: #fff;
  border: 1px solid #ef4444;
  color: #ef4444;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.btn-danger:hover { background: #fee2e2; }

/* migrate-068: Everflow source panel on the Buyer card. Surfaces AM
   contact, account_status, offer counts, EF metadata last-saved, and
   Everflow internal_notes — fields that were previously empty because
   flattenAdvertiser read the wrong JSON paths. */
.buyer-everflow-panel {
  margin: 0 0 16px;
  padding: 10px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
  color: #1f2937;
}
.buyer-everflow-panel .row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 8px;
  padding: 4px 0;
  align-items: baseline;
  line-height: 1.45;
}
.buyer-everflow-panel .row + .row { border-top: 1px solid #f1f5f9; }
.buyer-everflow-panel .k {
  color: #64748b;
  font-weight: 500;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.04em;
}
.buyer-everflow-panel .v { color: #111827; }
.buyer-everflow-panel .v a { color: #1d4ed8; text-decoration: none; }
.buyer-everflow-panel .v a:hover { text-decoration: underline; }
.buyer-everflow-panel .muted { color: #94a3b8; }
.buyer-everflow-panel .badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  margin-left: 6px;
}
.buyer-everflow-panel .badge-status-active   { background: #d1fae5; color: #065f46; }
.buyer-everflow-panel .badge-status-inactive { background: #fee2e2; color: #991b1b; }
.buyer-everflow-panel .badge-status-pending  { background: #fef3c7; color: #92400e; }

/* Phase 4 — cleanup pills inside the buyer Everflow panel. Buyer-side
   buckets (unowned, stale-metadata, no-recent-offer) use the same
   amber/red palette as offers for cross-surface consistency. */
.buyer-everflow-panel .cleanup-pill {
  display: inline-block;
  padding: 2px 10px;
  margin-right: 6px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
}
.buyer-everflow-panel .cleanup-pill.cleanup-unowned         { background: #fee2e2; color: #991b1b; }
.buyer-everflow-panel .cleanup-pill.cleanup-stale-metadata  { background: #fef3c7; color: #92400e; }
.buyer-everflow-panel .cleanup-pill.cleanup-no-recent-offer { background: #f1f5f9; color: #475569; }

/* Responsive */
@media (max-width: 900px) {
  .buyer-grid { grid-template-columns: 1fr; }
  .buyer-field-row { grid-template-columns: 1fr; }
  .buyer-everflow-panel .row { grid-template-columns: 100px 1fr; }
}
@media (max-width: 600px) {
  .buyer-grid { padding: 12px; gap: 12px; }
  .buyer-state-grid { grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); max-height: 200px; }
  .buyer-map-row { grid-template-columns: 1fr; gap: 4px; }
  .buyer-map-row span { display: none; }
  .buyer-list-panel { max-height: 40vh; }
}

/* ============================================================
   Field Readiness sub-tab (Phase 029 M2.8)
   ============================================================ */
.buyer-subtabs {
  display: inline-flex;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  overflow: hidden;
  background: #f9fafb;
}
.buyer-subtab {
  background: transparent;
  border: 0;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: #4b5563;
  cursor: pointer;
}
.buyer-subtab + .buyer-subtab { border-left: 1px solid #d1d5db; }
.buyer-subtab.active { background: #1a2744; color: #fff; }

#buyer-readiness-tab { padding: 16px 24px 40px; }
.readiness-intro p { margin: 0 0 14px; color: #374151; font-size: 13.5px; line-height: 1.5; max-width: 760px; }
.readiness-picker-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.readiness-picker-row label { font-size: 13px; font-weight: 600; color: #111827; }
.readiness-picker-row select { padding: 7px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; min-width: 280px; }
.readiness-topology-badge { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.readiness-topology-badge.lp { background: #eef2ff; color: #3730a3; border: 1px solid #c7d2fe; }
.readiness-topology-badge.direct { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }

.readiness-banner { margin: 0 0 16px; padding: 10px 14px; border-radius: 8px; font-size: 13px; }
.readiness-banner.ok { background: #d1fae5; color: #065f46; border: 1px solid #10b981; }
.readiness-banner.open { background: #fef3c7; color: #92400e; border: 1px solid #f59e0b; }

.readiness-empty { padding: 28px; text-align: center; color: #6b7280; font-size: 13.5px; background: #f9fafb; border: 1px dashed #d1d5db; border-radius: 10px; }
.readiness-empty-guided { text-align: left; max-width: 640px; }
.readiness-empty-guided p { margin: 0 0 8px; line-height: 1.55; }
.readiness-empty-guided code { background: #eef0f3; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.readiness-error { color: #991b1b; background: #fee2e2; border-color: #ef4444; }

/* Per-spec card */
.rd-spec { border: 1px solid #e5e7eb; border-radius: 10px; margin-bottom: 12px; background: #fff; overflow: hidden; }
.rd-spec-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; cursor: pointer; list-style: none; }
.rd-spec-summary::-webkit-details-marker { display: none; }
.rd-spec-name { font-weight: 600; font-size: 14px; color: #111827; }
.rd-spec-counts { display: flex; gap: 6px; flex-wrap: wrap; }
.rd-pill { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.rd-pill.good { background: #d1fae5; color: #065f46; }
.rd-pill.soft { background: #f3f4f6; color: #4b5563; }
.rd-pill.warn { background: #fef3c7; color: #92400e; }
.rd-pill.open { background: #fee2e2; color: #991b1b; }
/* hand-off: a build-owner gap, not the operator's failure — calm slate, not alarm red. */
.rd-pill.handoff { background: #e0e7ff; color: #3730a3; }

.rd-fields { list-style: none; margin: 0; padding: 0; border-top: 1px solid #f0f1f3; }
.rd-row { display: flex; align-items: center; gap: 10px; padding: 9px 16px; border-bottom: 1px solid #f3f4f6; font-size: 13px; }
.rd-row:last-child { border-bottom: 0; }
.rd-row.actionable { cursor: pointer; }
.rd-row.actionable:hover { background: #f9fafb; }
.rd-row.actionable:focus-visible { outline: 2px solid #6366f1; outline-offset: -2px; }
.rd-glyph { width: 18px; text-align: center; font-size: 13px; }
.rd-field { flex: 1; color: #111827; }
.rd-req { font-size: 10.5px; font-weight: 600; color: #92400e; background: #fef3c7; padding: 1px 6px; border-radius: 999px; }
.rd-state { font-size: 12px; color: #6b7280; }
.rd-row.tone-good .rd-glyph { color: #059669; }
.rd-row.tone-soft .rd-glyph { color: #9ca3af; }
.rd-row.tone-warn .rd-glyph { color: #d97706; }
.rd-row.tone-open .rd-glyph { color: #dc2626; }
.rd-row.tone-open .rd-state { color: #dc2626; font-weight: 600; }
/* hand-off rows: calm indigo glyph + a "Tell build owner" copy verb (never a dead end). */
.rd-row.tone-handoff .rd-glyph { color: #6366f1; }
.rd-row.tone-handoff .rd-state { color: #4f46e5; }
.rd-handoff-btn {
  font-size: 11.5px; font-weight: 600; color: #4338ca; background: #eef2ff;
  border: 1px solid #c7d2fe; border-radius: 6px; padding: 3px 9px; cursor: pointer; white-space: nowrap;
}
.rd-handoff-btn:hover { background: #e0e7ff; }
.rd-handoff-btn:focus-visible { outline: 2px solid #6366f1; outline-offset: 1px; }
.rd-handoff-btn.copied { color: #065f46; background: #d1fae5; border-color: #6ee7b7; }
.rd-handoff-btn.err { color: #991b1b; background: #fee2e2; border-color: #fca5a5; }

/* Resolution drawer */
.readiness-drawer-scrim { position: fixed; inset: 0; background: rgba(17,24,39,0.35); z-index: 90; }
.readiness-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 440px; max-width: 92vw;
  background: #fff; box-shadow: -6px 0 24px rgba(0,0,0,0.18); z-index: 91;
  padding: 20px; overflow-y: auto;
}
.rd-drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.rd-drawer-head h3 { margin: 0; font-size: 16px; color: #111827; }
.rd-drawer-close { background: transparent; border: 0; font-size: 22px; line-height: 1; color: #6b7280; cursor: pointer; }
.rd-drawer-req { font-size: 12.5px; color: #92400e; background: #fef3c7; padding: 8px 10px; border-radius: 6px; margin: 4px 0 14px; }
.rd-drawer-req.soft { color: #4b5563; background: #f3f4f6; }
.rd-choices { display: flex; flex-direction: column; gap: 6px; }
.rd-choice { display: flex; gap: 9px; align-items: flex-start; padding: 9px 11px; border: 1px solid #e5e7eb; border-radius: 8px; cursor: pointer; }
.rd-choice:hover { background: #f9fafb; }
.rd-choice input { margin-top: 3px; }
.rd-choice-body { display: flex; flex-direction: column; gap: 2px; }
.rd-choice-title { font-size: 13.5px; font-weight: 600; color: #111827; }
.rd-choice-hint { font-size: 12px; color: #6b7280; line-height: 1.4; }
.rd-detail { margin-top: 14px; }
.rd-detail:empty { margin-top: 0; }
.rd-lbl { display: block; font-size: 12.5px; font-weight: 600; color: #111827; margin-bottom: 5px; }
.rd-detail input[type=text], .rd-detail select { width: 100%; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; box-sizing: border-box; }
.rd-map-row { display: flex; gap: 8px; }
.rd-map-row select { flex: 1; }
.rd-suggest-msg, .rd-default-explain { font-size: 12px; color: #6b7280; line-height: 1.45; margin: 8px 0 0; }
.rd-default-explain { background: #eef2ff; color: #3730a3; padding: 8px 10px; border-radius: 6px; margin: 0 0 12px; }
.rd-radio { display: flex; gap: 7px; align-items: flex-start; font-size: 13px; color: #374151; margin: 5px 0; cursor: pointer; }
.rd-lgf-stamp { margin-top: 10px; }
.rd-drawer-foot { display: flex; align-items: center; gap: 8px; margin-top: 22px; padding-top: 14px; border-top: 1px solid #f0f1f3; }
.rd-save-msg { flex: 1; font-size: 12px; color: #6b7280; }
.rd-save-msg.err { color: #991b1b; }
