/* Resilia Dashboard UI Kit styles */
@import url('../../colors_and_type.css');

html, body, #root { height: 100%; }
body { background: var(--bg-app); color: var(--fg-1); font-size: 14px; overflow: hidden; }

[data-accent="amber"] { --primary-50:#fef6e7;--primary-100:#fde6b8;--primary-300:#f5c05a;--primary-500:#e69a0c;--primary-600:#c07d00;--primary-700:#a56c00; }
[data-accent="indigo"] { --primary-50:#eef0ff;--primary-100:#dde1fc;--primary-300:#a5adf5;--primary-500:#4f46e5;--primary-600:#3f38c4;--primary-700:#312aa0; }

/* ===================== APP SHELL ===================== */
.app { display: flex; flex-direction: column; height: 100vh; }
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-app);
  padding: 24px;
}
.auth-panel {
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 28px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
}
.auth-mark { width: 34px; height: 34px; }
.auth-brand { font-weight: 700; font-size: 18px; }
.auth-button { width: 100%; justify-content: center; }

/* ===================== TOPBAR ===================== */
.topbar {
  display: flex; align-items: center; gap: 16px;
  height: 56px; padding: 0 24px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-mark { height: 24px; width: 24px; }
.topbar-brand { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.topbar-divider { width: 1px; height: 18px; background: var(--border-default); margin: 0 4px; }
.topbar-workspace {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 0; padding: 4px 10px;
  border-radius: 6px; font: inherit; color: var(--fg-1); cursor: pointer;
  font-weight: 500;
}
.topbar-workspace:hover { background: var(--bg-hover); }
.topbar-center { flex: 1; display: flex; justify-content: center; }
.topbar-search {
  display: flex; align-items: center; gap: 8px;
  width: min(520px, 60%);
  height: 34px; padding: 0 12px;
  background: var(--bg-sunken); border: 1px solid var(--border-default);
  border-radius: 8px; color: var(--fg-3);
}
.topbar-search input { flex: 1; border: 0; background: transparent; font: inherit; color: var(--fg-1); outline: none; font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.admin-pending-badge {
  display: inline-flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 10px;
  border: 1px solid #fecaca; border-radius: 999px;
  background: #fff1f2; color: #b42318;
  font: inherit; font-size: 12px; font-weight: 700;
  cursor: pointer; white-space: nowrap;
}
.admin-pending-badge:hover { background: #ffe4e6; }
.admin-pending-dot { width: 7px; height: 7px; border-radius: 999px; background: #d92d20; }
.topbar-credits { display: inline-flex; gap: 6px; align-items: center; }
.credit-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; border: 1px solid transparent;
  font-size: 12px; font-weight: 600; line-height: 1; white-space: nowrap;
}
.credit-chip-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.credit-chip-value { font-variant-numeric: tabular-nums; opacity: 0.9; }
.icon-btn {
  width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; border-radius: 8px; color: var(--fg-2); cursor: pointer;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--fg-1); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.topbar-user { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.topbar-user-label { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg-2); font-size: 12px; }
.avatar {
  width: 32px; height: 32px; border-radius: 999px;
  background: var(--primary-500); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
}

/* ===================== TABBAR ===================== */
.tabbar {
  display: flex; gap: 2px;
  padding: 0 24px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  flex-shrink: 0;
  /* Tabs are flex-shrink:0, so when they exceed the width they'd overflow and
     get clipped (the last tab — Upload Leg — was unreachable). Scroll instead. */
  overflow-x: auto;
  scrollbar-width: thin;            /* Firefox: slim, unobtrusive scrollbar */
  overscroll-behavior-x: contain;   /* horizontal swipe doesn't bounce the page */
}
/* WebKit (Chrome/Safari): a slim, low-profile horizontal scrollbar for the bar. */
.tabbar::-webkit-scrollbar { height: 6px; }
.tabbar::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 999px; }
.tabbar::-webkit-scrollbar-track { background: transparent; }
.tab {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 14px;
  white-space: nowrap;
  flex-shrink: 0;
  background: transparent; border: 0; border-bottom: 2px solid transparent;
  font: inherit; font-size: 13px; font-weight: 500; color: var(--fg-2);
  cursor: pointer; position: relative; top: 1px;
  transition: color 120ms var(--ease-standard);
}
.tab:hover:not(.active) { color: var(--fg-1); }
.tab.active { color: var(--fg-brand); border-bottom-color: var(--primary-500); font-weight: 600; }
.tab.locked {
  color: var(--fg-4);
  cursor: not-allowed;
  height: auto;
  min-height: 44px;
  padding-top: 4px;
  padding-bottom: 4px;
  align-items: center;
}
.tab.locked:hover {
  color: var(--fg-3);
}
.tab-label-stack {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0;
}
.tab-label-stack.with-lock {
  flex-direction: column;
  align-items: center;
  line-height: 1.05;
}
.tab-label-line { white-space: nowrap; }
.tab-lock-text {
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: var(--bg-sunken);
  color: var(--fg-3);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  padding: 1px 5px;
  margin-top: 1px;
  white-space: nowrap;
}
.tab-count {
  font-family: var(--font-mono); font-size: 11px;
  background: var(--bg-sunken); padding: 1px 7px; border-radius: 999px; color: var(--fg-3);
}
.tab.active .tab-count { background: var(--primary-50); color: var(--primary-700); }

/* ===================== CONTENT SHELL ===================== */
.workspace-shell {
  flex: 1;
  min-height: 0;
  display: flex;
  background: var(--bg-app);
}
.management-sidebar {
  flex: 0 0 236px;
  width: 236px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-default);
  overflow: hidden;
  transition: flex-basis 160ms var(--ease-standard), width 160ms var(--ease-standard), padding 160ms var(--ease-standard);
}
.management-sidebar.collapsed {
  flex-basis: 56px;
  width: 56px;
  padding: 10px 8px;
}
.management-sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 34px; }
.management-sidebar.collapsed .management-sidebar-head { justify-content: center; }
.management-title { font-size: 12px; font-weight: 800; color: var(--fg-1); text-transform: uppercase; letter-spacing: 0.04em; }
.management-subtitle { margin-top: 1px; color: var(--fg-3); font-size: 11px; }
.management-toggle {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--border-default); border-radius: 8px;
  background: var(--bg-surface); color: var(--fg-2);
  cursor: pointer;
}
.management-toggle:hover { background: var(--bg-hover); color: var(--fg-1); }
.management-sidebar:not(.collapsed) .management-toggle svg { transform: rotate(90deg); }
.management-nav { display: flex; flex-direction: column; gap: 6px; }
.management-nav-item {
  position: relative;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--fg-2);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.management-nav-item:hover { background: var(--bg-hover); color: var(--fg-1); }
.management-nav-item.active { background: var(--primary-50); border-color: var(--primary-300); color: var(--fg-brand); }
.management-nav-copy { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.management-nav-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 700; }
.management-nav-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg-3); font-size: 11px; }
.management-count {
  min-width: 19px;
  height: 19px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border-radius: 999px;
  background: #fff1f2;
  color: #b42318;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 800;
}
.management-sidebar.collapsed .management-nav { align-items: center; }
.management-sidebar.collapsed .management-nav-item {
  width: 38px;
  height: 38px;
  min-height: 38px;
  display: inline-flex;
  justify-content: center;
  padding: 0;
}
.management-sidebar.collapsed .management-count {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 9px;
}
.content {
  flex: 1; overflow-y: auto;
  min-width: 0;
  padding: 24px 32px 120px;
  background: var(--bg-app);
}
.content-hdr { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.content-title { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.content-sub { font-size: 12px; color: var(--fg-3); }
.content-hdr .spacer { flex: 1; }

/* ===================== SEARCH ROW ===================== */
.search-rows { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px; align-items: center;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 10px; padding: 10px 12px;
}
.sr-main-controls,
.sr-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  min-width: 0;
}
.sr-main-controls { flex-wrap: wrap; }
.sr-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}
.sr-filter-section {
  display: grid;
  grid-column: 1 / -1;
  gap: 8px;
  max-width: 100%;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--bg-app);
}
.sr-filter-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--fg-3);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.sr-filter-section-head span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.sr-filter-section-head i {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--primary-500);
}
.sr-filter-section-foreplay .sr-filter-section-head i { background: #8b5cf6; }
.sr-filter-section-adspy .sr-filter-section-head i { background: #f97316; }
.sr-filter-section-brandsearch .sr-filter-section-head i { background: #0ea5e9; }
.sr-main-controls > .sr-select { flex: 0 1 190px; }
.sr-main-controls > .sr-input:not(.sr-select):not(.sr-num) {
  flex: 1 1 220px;
  min-width: 180px;
}
.sr-main-controls > .sr-num { flex: 0 0 80px; }
.sr-select {
  height: 32px; padding: 0 28px 0 10px;
  font: inherit; font-size: 13px; color: var(--fg-1);
  background: var(--bg-sunken); border: 1px solid var(--border-default);
  border-radius: 6px; outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.sr-select:focus { border-color: var(--primary-500); box-shadow: var(--shadow-focus); background-color: var(--bg-surface); }
.sr-input {
  height: 32px; padding: 0 10px;
  font: inherit; font-size: 13px; color: var(--fg-1);
  background: var(--bg-sunken); border: 1px solid var(--border-default);
  border-radius: 6px; outline: none;
}
.sr-input:focus { border-color: var(--primary-500); box-shadow: var(--shadow-focus); background: var(--bg-surface); }
.sr-num { text-align: center; font-family: var(--font-mono); }
.sr-num::-webkit-inner-spin-button, .sr-num::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.sr-toggles { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.sr-row-search {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border-default);
  border-radius: 7px;
  background: var(--bg-sunken);
  color: var(--fg-1);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.sr-row-search:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--border-strong); }
.sr-row-search:disabled { opacity: 0.65; cursor: default; }
.sr-foreplay-filters,
.sr-adspy-filters,
.sr-brandsearch-filters {
  grid-column: 1 / -1;
  max-width: 100%;
  min-width: 0;
  gap: 6px;
}
.sr-mini {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 7px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  background: var(--bg-sunken);
  color: var(--fg-3);
  font-size: 11px;
}
.sr-mini input {
  width: 56px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--fg-1);
  font: inherit;
  font-family: var(--font-mono);
}
.sr-mini.wide input { width: 92px; }
.sr-mini.date input { width: 96px; }
.sr-slider {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  min-width: 0;
  padding: 0 8px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  background: var(--bg-sunken);
  color: var(--fg-3);
  font-size: 11px;
}
.sr-main-controls > .sr-slider { flex: 0 1 170px; }
.sr-main-controls > .sr-slider-wide { flex-basis: 220px; }
.sr-slider input[type="range"] {
  width: 90px;
  min-width: 0;
  accent-color: var(--primary-500);
}
.sr-slider-wide input[type="range"] { width: 130px; }
.sr-slider strong {
  min-width: 34px;
  color: var(--fg-1);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-align: right;
}
.sr-slider-wide strong { min-width: 46px; }
.sr-mini-select { width: 86px; }
.sr-mini-select.wide { width: 116px; }
.sr-bs-platform { width: 92px; }
.sr-foreplay-filters,
.sr-brandsearch-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}
.sr-adspy-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  align-items: start;
  gap: 14px 24px;
  padding: 12px 0 4px;
}
.sr-brandsearch-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  align-items: start;
  gap: 10px 14px;
}
.adspy-dd { position: relative; min-width: 0; }
.adspy-dd-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0 7px;
  border: 0;
  border-bottom: 1px solid var(--border-strong);
  background: transparent;
  color: var(--fg-2);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.adspy-dd-trigger-text {
  display: grid;
  min-width: 0;
  text-align: left;
}
.adspy-dd-label,
.adspy-dd-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.adspy-dd-preview {
  margin-top: 2px;
  color: var(--fg-brand);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.1;
}
.adspy-dd.open .adspy-dd-trigger,
.adspy-dd.active .adspy-dd-trigger {
  color: var(--fg-1);
  border-bottom-color: var(--primary-500);
}
.adspy-dd.open .adspy-dd-trigger svg { transform: rotate(180deg); }
.adspy-dd-menu {
  position: absolute;
  z-index: 40;
  top: calc(100% + 8px);
  left: 0;
  min-width: 230px;
  max-width: min(300px, calc(100vw - 48px));
  padding: 16px;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  background: var(--bg-surface);
  color: var(--fg-1);
  box-shadow: var(--shadow-lg);
}
.adspy-dd-body { display: grid; gap: 12px; }
.adspy-dd-options { display: grid; gap: 12px; }
.adspy-dd-scroll {
  max-height: 220px;
  overflow: auto;
  padding-right: 4px;
}
.adspy-dd-option {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--fg-2);
  font-size: 13px;
}
.adspy-dd-option input { width: 16px; height: 16px; accent-color: var(--primary-500); }
.adspy-dd-help { color: var(--fg-3); font-size: 12px; }
.adspy-dd-range,
.adspy-dd-field {
  display: grid;
  gap: 8px;
  color: var(--fg-2);
  font-size: 12px;
}
.adspy-dd-range input[type="range"] {
  width: 100%;
  accent-color: var(--primary-500);
}
.adspy-dd-field input {
  width: 100%;
  height: 32px;
  border: 0;
  border-bottom: 1px solid var(--border-default);
  outline: 0;
  background: transparent;
  color: var(--fg-1);
  font: inherit;
}
.adspy-dd-field input:focus { border-bottom-color: var(--primary-500); }
.adspy-dd-reset {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding: 8px 12px;
  border: 0;
  border-radius: 4px;
  background: var(--fg-2);
  color: var(--bg-surface);
  font: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
@media (max-width: 760px) {
  .sr-main-controls > .sr-select,
  .sr-main-controls > .sr-input:not(.sr-select):not(.sr-num),
  .sr-main-controls > .sr-slider,
  .sr-main-controls > .sr-slider-wide {
    flex-basis: 100%;
  }
  .sr-main-controls > .sr-num { flex: 1 1 80px; }
  .sr-actions { justify-content: flex-start; }
  .sr-adspy-filters,
  .sr-brandsearch-filters { grid-template-columns: 1fr 1fr; }
}
.sr-url-fields {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px;
}
.sr-url-input { width: 100%; }
.plat-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px 5px 8px;
  background: var(--bg-sunken); color: var(--fg-3);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  font: inherit; font-size: 11px; font-weight: 500;
  cursor: pointer;
  transition: all 120ms var(--ease-standard);
}
.plat-toggle:hover { color: var(--fg-1); }
.plat-dot { width: 6px; height: 6px; border-radius: 999px; }

.sr-add {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 1px dashed var(--border-strong);
  border-radius: 8px; padding: 8px 12px;
  color: var(--fg-2); font: inherit; font-size: 13px;
  cursor: pointer; align-self: flex-start;
}
.sr-add:hover { background: var(--bg-hover); color: var(--fg-1); border-style: solid; border-color: var(--border-default); }

/* ===================== PRIMARY BUTTONS ===================== */
.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 16px;
  background: var(--primary-500); color: #fff;
  border: 0; border-radius: 8px;
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background 120ms var(--ease-standard);
}
.btn-primary:hover { background: var(--primary-600); }
.btn-primary:active { background: var(--primary-700); }
.btn-primary:disabled { background: var(--neutral-200); color: var(--fg-4); cursor: not-allowed; }

.btn-secondary {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 14px;
  background: var(--bg-surface); color: var(--fg-1);
  border: 1px solid var(--border-default);
  border-radius: 8px; font: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer;
}
.btn-secondary:hover { background: var(--bg-hover); }
.btn-secondary.compact { height: 28px; padding: 0 9px; font-size: 12px; }
.btn-secondary.danger { color: #b42318; border-color: #fecaca; }
.btn-secondary.danger:hover { background: #fff1f2; }
.ghost-btn {
  background: transparent; border: 0; padding: 4px 8px;
  color: var(--fg-3); font: inherit; font-size: 12px; cursor: pointer;
  border-radius: 6px;
}
.ghost-btn:hover { background: var(--bg-hover); color: var(--fg-1); }

/* ===================== PLATFORM PANEL ===================== */
.platform-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
}
.pp-hdr {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  position: sticky; top: 0; z-index: 2;
}
.pp-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.pp-dot { width: 6px; height: 6px; border-radius: 999px; }
.pp-count { font-size: 12px; color: var(--fg-2); font-weight: 500; }
.pp-dedupe { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--fg-3); font-family: var(--font-mono); }
.pp-spacer { flex: 1; }
.pp-selected { font-size: 12px; color: var(--primary-600); font-family: var(--font-mono); font-weight: 600; }

.pp-grid {
  display: grid;
  gap: 12px;
  padding: 14px;
}
.pp-grid.density-comfortable { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; padding: 18px; }
.pp-grid.density-compact { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 12px; }

/* ===================== AD CARD ===================== */
.creative {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: all 120ms var(--ease-standard);
  display: flex; flex-direction: column;
}
.creative:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.creative.sel { border-color: var(--primary-500); box-shadow: var(--shadow-focus); }
.creative.current-run {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 1px rgba(15, 181, 168, 0.24), var(--shadow-xs);
}
.creative.truncation-warning {
  background: #fefce8;
  border-color: #facc15;
}
.creative.truncation-warning:hover {
  border-color: #eab308;
  box-shadow: 0 0 0 1px rgba(234, 179, 8, 0.18), var(--shadow-md);
}
.creative.truncation-warning.sel {
  border-color: var(--primary-500);
  box-shadow: var(--shadow-focus);
}
[data-theme="dark"] .creative.truncation-warning {
  background: rgba(234, 179, 8, 0.12);
  border-color: rgba(250, 204, 21, 0.45);
}
.creative-thumb {
  aspect-ratio: 4/5; position: relative;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.creative-thumb-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  z-index: 1;
}
.creative-thumb-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  background: #111827;
  z-index: 0;
}
.creative-cbx {
  position: absolute; top: 8px; left: 8px;
  width: 20px; height: 20px;
  background: rgba(255,255,255,0.92); border: 1px solid rgba(0,0,0,0.08);
  border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  color: transparent;
  box-shadow: var(--shadow-xs);
  transition: all 120ms var(--ease-standard);
  z-index: 2;
}
.creative-cbx.on { background: var(--primary-500); border-color: var(--primary-500); color: #fff; }
.creative-plat {
  position: absolute; top: 8px; right: 8px;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 10px; font-weight: 600;
  z-index: 2;
}
.creative-plat-dot { width: 5px; height: 5px; border-radius: 999px; }
.creative-current-run {
  position: absolute;
  top: 34px;
  right: 8px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--primary-500);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  box-shadow: var(--shadow-xs);
}
.creative-dislike {
  position: absolute; top: 34px; left: 8px;
  z-index: 2;
  width: 26px; height: 26px;
  border: 0; border-radius: 6px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.55); color: #fff;
  opacity: 0;
  transition: opacity 120ms var(--ease-standard), background 120ms var(--ease-standard);
}
.creative:hover .creative-dislike { opacity: 1; }
.creative-dislike:hover { background: rgba(185,28,28,0.9); }
.creative-play {
  position: relative;
  z-index: 2;
  width: 40px; height: 40px; border-radius: 999px;
  background: rgba(0,0,0,0.55); color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: all 150ms var(--ease-standard);
}
.creative:hover .creative-play { background: rgba(0,0,0,0.75); transform: scale(1.05); }
.creative-duration {
  position: absolute; bottom: 8px; right: 8px;
  background: rgba(0,0,0,0.7); color: #fff;
  padding: 1px 6px; border-radius: 4px;
  font-family: var(--font-mono); font-size: 10px; font-weight: 500;
  z-index: 2;
}
.creative-truncation-badge {
  position: absolute;
  left: 42px;
  bottom: 8px;
  max-width: calc(100% - 96px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: #facc15;
  color: #713f12;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  z-index: 2;
  box-shadow: var(--shadow-xs);
}
.creative-expand {
  position: absolute; bottom: 8px; left: 8px;
  width: 26px; height: 26px;
  background: rgba(0,0,0,0.55); color: #fff;
  border: 0; border-radius: 6px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 120ms var(--ease-standard), background 120ms var(--ease-standard);
  z-index: 2;
}
.creative:hover .creative-expand { opacity: 1; }
.creative-expand:hover { background: rgba(0,0,0,0.8); }
.creative-brand-row { display: flex; align-items: center; gap: 6px; }
.creative-has-transcript {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 4px;
  background: var(--primary-50); color: var(--primary-600);
}
[data-theme="dark"] .creative-has-transcript { background: rgba(47,179,156,0.15); color: var(--primary-300); }

/* ===================== DRAWER ===================== */
.drawer-scrim {
  position: fixed; inset: 0; background: var(--bg-overlay);
  z-index: 300;
  animation: scrim-in 180ms var(--ease-standard);
}
@keyframes scrim-in { from { opacity: 0; } to { opacity: 1; } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(520px, 92vw);
  background: var(--bg-surface);
  border-left: 1px solid var(--border-default);
  box-shadow: var(--shadow-xl);
  z-index: 301;
  display: flex; flex-direction: column;
  animation: drawer-in 220ms var(--ease-standard);
}
@keyframes drawer-in { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.drawer-hdr {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.drawer-id { font-family: var(--font-mono); font-size: 11px; color: var(--fg-3); }
.drawer-body {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column;
}
.drawer-media {
  aspect-ratio: 4/5;
  max-height: 400px;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.drawer-section {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex; flex-direction: column; gap: 10px;
}
.drawer-section:last-child { border-bottom: 0; }
.drawer-brand { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.drawer-copy { font-size: 14px; color: var(--fg-2); line-height: 1.55; margin: 0; }
.drawer-stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px; margin-top: 4px;
}
.stat {
  background: var(--bg-sunken);
  border: 1px solid var(--border-subtle);
  border-radius: 8px; padding: 8px 10px;
  display: flex; flex-direction: column; gap: 2px;
}
.stat-label {
  font-size: 10px; color: var(--fg-3);
  letter-spacing: 0.04em; text-transform: uppercase; font-weight: 500;
}
.stat-value { font-size: 13px; font-weight: 600; color: var(--fg-1); }
.stat-score {
  display: inline-flex; align-items: center; gap: 4px;
  color: #a56c00; font-family: var(--font-mono);
}
[data-theme="dark"] .stat-score { color: #f5c05a; }
.drawer-section-hdr {
  display: flex; align-items: center; gap: 8px;
}
.drawer-section-title {
  font-size: 12px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--fg-2);
}
.drawer-section-meta { font-size: 11px; color: var(--fg-3); font-family: var(--font-mono); }
.transcript-body {
  background: var(--bg-sunken);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px;
  max-height: 360px; overflow-y: auto;
}
.transcript-line {
  display: grid; grid-template-columns: 52px 1fr;
  gap: 12px; align-items: baseline;
  font-size: 13px; line-height: 1.5;
}
.transcript-t {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--primary-600); font-weight: 600;
}
[data-theme="dark"] .transcript-t { color: var(--primary-300); }
.transcript-body-text { color: var(--fg-1); }
.creative-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.creative-body-min { flex-direction: row; align-items: center; justify-content: space-between; padding: 8px 10px; }
.creative-brand { font-size: 13px; font-weight: 600; letter-spacing: -0.01em; }
.creative-copy { font-size: 12px; color: var(--fg-2); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.creative-direction {
  display: inline-flex; align-items: center; gap: 5px;
  max-width: 100%;
  padding: 2px 7px; border-radius: 999px;
  background: var(--primary-50, #e7f5f3); color: var(--primary-500, #0fb5a8);
  border: 1px solid var(--primary-500, #0fb5a8);
  font-size: 11px; font-weight: 500;
  margin-top: 2px;
}
.creative-arrived-at {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 999px;
  background: var(--bg-sunken); color: var(--fg-3);
  border: 1px solid var(--border-subtle);
  font-size: 11px; font-weight: 500; white-space: nowrap;
}
.creative-arrived-at svg { opacity: 0.75; }
[data-theme="dark"] .creative-arrived-at { background: rgba(255, 255, 255, 0.04); }
.creative-direction span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 220px;
}
.creative-search-return {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg-sunken);
  color: var(--fg-2);
  border: 1px solid var(--border-subtle);
  font-size: 11px;
  font-weight: 500;
}
.creative-search-return span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}
/* Static-ads platform pill (filled): which platform the ad runs on (Facebook / Instagram),
   derived from the post URL. Shown under the brand chip on static-ads image cards only. */
.creative-publisher {
  display: inline-flex; align-items: center; gap: 4px;
  width: fit-content; max-width: 100%;
  padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; color: #fff;
  margin-top: 2px;
}
.creative-publisher-facebook { background: #1877f2; }
.creative-publisher-instagram {
  background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
}
.search-run-summary {
  margin: 14px 14px 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-default);
  border-radius: 8px;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  flex-wrap: wrap;
}
.search-run-summary.current {
  border-color: var(--primary-500);
  background: var(--primary-50, #e7f5f3);
}
.search-run-summary.previous {
  background: var(--bg-sunken);
}
.search-run-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.search-run-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--fg-1);
  font-size: 12px;
  font-weight: 700;
}
.search-run-count {
  color: var(--fg-2);
  font-size: 12px;
  font-family: var(--font-mono);
}
.search-run-muted,
.search-run-labels {
  color: var(--fg-3);
  font-size: 11px;
}
.search-run-labels {
  max-width: min(520px, 100%);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-run-progress {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.search-run-progress-bar {
  flex-basis: 100%;
}
.search-run-shared-pool {
  flex-basis: 100%;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--primary-50, #eef4ff);
  color: var(--primary-700, #1d4ed8);
  font-size: 12px;
  font-weight: 600;
}
.search-run-progress-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.search-run-progress-status {
  color: var(--fg-1);
  font-size: 12px;
  font-weight: 600;
}
.search-run-progress-bar .ar-progress-bar {
  margin-top: 0;
}
.search-run-empty {
  margin: 0 14px 16px;
  padding: 12px 14px;
  border: 1px dashed var(--border-default);
  border-radius: 8px;
  color: var(--fg-3);
  background: var(--bg-surface);
  font-size: 13px;
}
.creative-meta {
  display: flex; gap: 8px 10px; align-items: center; flex-wrap: wrap;
  font-size: 11px; color: var(--fg-3); font-family: var(--font-mono);
  margin-top: 2px; padding-top: 8px; border-top: 1px solid var(--border-subtle);
}
.creative-score {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 6px; border-radius: 4px;
  background: #fef6e7; color: #a56c00;
  font-weight: 600; font-family: var(--font-mono);
}
[data-theme="dark"] .creative-score { background: #3a2a0a; color: #f5c05a; }
.creative-metric-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border-radius: 4px;
  background: #ffede2;
  color: #9a3412;
  font-weight: 600;
  font-family: var(--font-mono);
}
.creative-metric-label {
  font-family: inherit;
  font-size: 9px;
  text-transform: uppercase;
  opacity: 0.72;
}
[data-theme="dark"] .creative-metric-chip { background: rgba(234,88,12,0.18); color: #fdba74; }
.creative-metric-chip.bs { background: #e0f2fe; color: #0369a1; }
[data-theme="dark"] .creative-metric-chip.bs { background: rgba(2,132,199,0.2); color: #7dd3fc; }

/* ===================== SELECTION BAR ===================== */
.selbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 24px;
  display: flex; align-items: center; gap: 12px;
  background: var(--neutral-900); color: #fff;
  border-radius: 12px;
  padding: 10px 12px 10px 18px;
  box-shadow: var(--shadow-xl);
  z-index: 100;
  min-width: 520px;
  animation: selbar-in 180ms var(--ease-standard);
}
@keyframes selbar-in { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
.selbar-count { font-size: 13px; font-weight: 500; }
.selbar-n { font-family: var(--font-mono); color: var(--primary-300); font-weight: 700; font-size: 14px; }
.selbar-ghost {
  background: transparent; border: 1px solid rgba(255,255,255,0.12);
  color: #eef0f3; padding: 5px 10px; border-radius: 6px;
  font: inherit; font-size: 12px; cursor: pointer;
}
.selbar-ghost:hover { background: rgba(255,255,255,0.08); }
.selbar-spacer { flex: 1; }
.selbar-primary {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 14px;
  background: var(--primary-500); color: #fff;
  border: 0; border-radius: 8px;
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
}
.selbar-primary:hover { background: var(--primary-400); }
.selbar-kbd {
  font-family: var(--font-mono); font-size: 10px;
  padding: 1px 6px; background: rgba(0,0,0,0.25); border-radius: 3px;
  color: rgba(255,255,255,0.8); margin-left: 2px;
}

/* ===================== TRANSCRIPT ===================== */
.transcript {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 120ms var(--ease-standard);
}
.transcript:hover { border-color: var(--border-strong); }
.transcript.sel { border-color: var(--primary-500); box-shadow: var(--shadow-focus); }
.transcript.current-run {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 1px rgba(15, 181, 168, 0.24), var(--shadow-xs);
}
.t-hdr { display: flex; align-items: center; gap: 10px; }
.t-cbx {
  width: 16px; height: 16px;
  border: 1.5px solid var(--border-strong); border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  color: transparent;
  transition: all 120ms var(--ease-standard);
}
.t-cbx.on { background: var(--primary-500); border-color: var(--primary-500); color: #fff; }
.t-brand { font-size: 13px; font-weight: 600; }
.t-meta { font-size: 11px; color: var(--fg-3); font-family: var(--font-mono); margin-left: auto; }
.t-script {
  font-family: var(--font-mono); font-size: 12px; line-height: 1.6;
  color: var(--fg-2);
  background: var(--bg-sunken);
  border: 1px solid var(--border-subtle);
  border-radius: 8px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 4px;
  max-height: 460px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.t-line { display: flex; gap: 8px; align-items: baseline; }
.t-line span:last-child { min-width: 0; overflow-wrap: anywhere; }
.t-tag { color: var(--primary-600); font-weight: 700; font-size: 10px; letter-spacing: 0.04em; min-width: 70px; }
.t-hdr-spacer { flex: 1; }
.t-edit-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 6px;
  border: 1px solid var(--border-default); background: transparent;
  color: var(--fg-2); font: inherit; font-size: 12px; cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.t-edit-btn:hover:not(:disabled) { color: var(--fg-1); border-color: var(--primary-500); }
.t-edit-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.t-edit-btn.primary {
  background: var(--primary-500); color: #fff; border-color: var(--primary-500);
}
.t-edit-btn.primary:hover:not(:disabled) { background: var(--primary-600); border-color: var(--primary-600); color: #fff; }
.t-edit-btn.ghost { color: var(--fg-3); }
.t-edit-area {
  width: 100%; min-height: 220px; resize: vertical;
  padding: 12px; margin-top: 4px;
  font-family: inherit; font-size: 13px; line-height: 1.5;
  color: var(--fg-1); background: var(--bg-sunken);
  border: 1px solid var(--border-default); border-radius: 8px; outline: none;
}
.t-edit-area:focus { border-color: var(--primary-500); box-shadow: var(--shadow-focus); }
.manual-entry-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: var(--bg-surface);
}
.manual-entry-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.manual-entry-head div { display: grid; gap: 3px; }
.manual-entry-head strong { color: var(--fg-1); font-size: 13px; }
.manual-entry-head span { color: var(--fg-3); font-size: 12px; line-height: 1.4; }
.manual-entry-badge {
  flex: 0 0 auto;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--bg-sunken);
  color: var(--fg-2);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.manual-entry-grid {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}
.manual-entry-label {
  display: grid;
  gap: 5px;
  color: var(--fg-3);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.manual-entry-label input {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border-default);
  border-radius: 8px;
  background: var(--bg-sunken);
  color: var(--fg-1);
  font: inherit;
  font-size: 13px;
  outline: none;
  text-transform: none;
}
.manual-entry-label input:focus { border-color: var(--primary-500); box-shadow: var(--shadow-focus); }
.manual-entry-text { text-transform: none; }
.manual-entry-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--fg-3);
  font-size: 12px;
}
.ar-script-readonly {
  margin: 0;
  min-height: 180px;
  padding: 12px;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  color: var(--fg-1);
  background: var(--bg-sunken);
  border: 0;
  border-radius: 0;
  overflow: auto;
}

.ar-result-hdr {
  min-height: 30px;
}
.ar-result-card.current-run {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 1px rgba(15, 181, 168, 0.24), var(--shadow-xs);
}
.ar-script-toggle {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  background: var(--bg-sunken);
  color: var(--fg-2);
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.12s, color 0.12s;
  flex-shrink: 0;
}
.ar-script-toggle:hover {
  color: var(--fg-1);
  border-color: var(--primary-500);
}
.ar-script-toggle svg { transition: transform 0.14s ease; }
.ar-script-toggle.open svg { transform: rotate(180deg); }
.ar-result-status {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  background: var(--bg-sunken);
  color: var(--fg-3);
  border: 1px solid var(--border-subtle);
}
.ar-result-status.ready {
  background: var(--primary-50);
  color: var(--primary-700);
  border-color: var(--primary-500);
}
.ar-result-status.error {
  background: #fff1f1;
  color: #b42318;
  border-color: #f3b3ad;
}
[data-theme="dark"] .ar-result-status.error {
  background: rgba(180,35,24,0.16);
  color: #ffb4aa;
  border-color: rgba(255,180,170,0.28);
}
.ar-result-meta {
  padding: 8px 14px 0;
  color: var(--fg-3);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.ar-result-meta .creative-direction {
  margin-top: 0;
}

.compliance-select-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--fg-3);
}
.compliance-select {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border-default);
  border-radius: 8px;
  background: var(--bg-surface);
  color: var(--fg-1);
  font: inherit;
  font-size: 12px;
}
.compliance-running-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.compliance-card {
  cursor: default;
}
.compliance-card .t-meta {
  margin-left: 0;
}
.compliance-variant-select-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 240px;
  max-width: 420px;
  color: var(--fg-3);
  font-size: 12px;
}
.compliance-variant-select-wrap .compliance-select {
  min-width: 180px;
  max-width: 300px;
}
.compliance-score-badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: #e6f6ec;
  color: #137333;
  font-size: 11px;
  font-weight: 700;
}
.compliance-score-badge.bad {
  background: #fde8e8;
  color: #b3261e;
}
.compliance-verdict-badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.compliance-verdict-badge.pass {
  background: #e6f6ec;
  color: #137333;
}
.compliance-verdict-badge.fail,
.compliance-verdict-badge.error {
  background: #fde8e8;
  color: #b3261e;
}
.compliance-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.1fr);
  gap: 12px;
  align-items: start;
}
.compliance-script-stack {
  display: grid;
  gap: 10px;
}
.compliance-left-stack {
  display: grid;
  gap: 10px;
}
.compliance-left-stack .ar-source-preview {
  margin: 0;
  padding: 0;
}
.compliance-full-output {
  display: grid;
  gap: 8px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: var(--bg-sunken);
  padding: 10px 12px;
}
.compliance-full-output-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  cursor: pointer;
}
.compliance-full-output-head span {
  color: var(--fg-3);
  font-size: 12px;
}
.compliance-full-output pre {
  margin: 0;
  max-height: 720px;
  overflow: auto;
  white-space: pre-wrap;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  color: var(--fg-2);
}
.compliance-details {
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--bg-sunken);
  padding: 8px 10px;
}
.compliance-details summary {
  cursor: pointer;
  color: var(--fg-2);
  font-size: 12px;
  font-weight: 600;
}
.compliance-details pre {
  margin: 8px 0 0;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  font-size: 12px;
  line-height: 1.45;
  color: var(--fg-2);
}
.compliance-decision {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--bg-sunken);
}
.compliance-decision ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
}
.compliance-decision li {
  color: var(--fg-2);
  font-size: 12px;
  line-height: 1.45;
}
.compliance-chat {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: var(--bg-sunken);
}
.compliance-chat-head,
.compliance-chat-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.compliance-chat-head {
  font-size: 13px;
}
.compliance-chat-input {
  min-height: 76px;
  resize: vertical;
  border: 1px solid var(--border-default);
  border-radius: 8px;
  background: var(--bg-surface);
  color: var(--fg-1);
  font: inherit;
  font-size: 12px;
  line-height: 1.45;
  padding: 8px 10px;
}
.compliance-chat-input:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}
.compliance-chat-actions span {
  color: var(--fg-3);
  font-size: 11px;
}
.compliance-chat-thread {
  display: grid;
  gap: 7px;
  max-height: 180px;
  overflow: auto;
}
.compliance-chat-turn {
  display: grid;
  gap: 4px;
  padding-top: 7px;
  border-top: 1px solid var(--border-subtle);
}
.compliance-chat-user,
.compliance-chat-assistant {
  font-size: 11px;
  line-height: 1.4;
}
.compliance-chat-user {
  color: var(--fg-1);
  font-weight: 600;
}
.compliance-chat-assistant {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--fg-3);
}
.compliance-chat-assistant span {
  color: var(--primary-700);
  font-weight: 700;
}
.compliance-final {
  display: grid;
  gap: 8px;
}
.compliance-final-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ar-source-preview {
  display: grid;
  grid-template-columns: minmax(132px, 180px) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
  margin: 10px 0 2px;
  padding: 0 14px;
}
.ar-source-media {
  aspect-ratio: 4/5;
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  background-size: cover !important;
  background-position: center !important;
}
.ar-source-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}
.ar-source-thumb-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  z-index: 0;
}
.ar-source-video-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  background: #111827;
  z-index: 1;
}
.ar-source-manual-label {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 18px;
  text-align: center;
  color: #fff;
  background: linear-gradient(180deg, rgba(17,24,39,0.1), rgba(17,24,39,0.45));
  text-shadow: 0 1px 2px rgba(0,0,0,0.28);
}
.ar-source-manual-label strong {
  font-size: 14px;
  line-height: 1.2;
}
.ar-source-manual-label span {
  font-size: 11px;
  opacity: 0.85;
}
.ar-source-media > .creative-plat,
.ar-source-media > .creative-play,
.ar-source-media > .creative-duration,
.ar-source-media > .ar-source-score {
  z-index: 2;
}
.ar-source-play { border: 0; cursor: pointer; }
.ar-source-play:disabled { opacity: 0.65; cursor: default; }
.ar-source-score {
  position: absolute;
  left: 8px;
  bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(0,0,0,0.68);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}
.ar-source-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
  padding: 4px 0;
}
.ar-source-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.ar-source-title { font-size: 12px; font-weight: 700; color: var(--fg-1); }
.ar-source-pill {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--primary-50);
  color: var(--primary-700);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}
[data-theme="dark"] .ar-source-pill { background: rgba(47,179,156,0.16); color: var(--primary-300); }
.ar-source-pill.muted { background: var(--bg-sunken); color: var(--fg-3); }
.ar-source-copy {
  margin: 0;
  color: var(--fg-2);
  font-size: 13px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ar-source-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--fg-3);
  font-size: 11px;
}
.ar-source-meta span { display: inline-flex; align-items: center; gap: 3px; }

@media (max-width: 760px) {
  .management-sidebar {
    flex-basis: 56px;
    width: 56px;
    padding: 10px 8px;
  }
  .management-sidebar-head { justify-content: center; }
  .management-title,
  .management-subtitle,
  .management-nav-copy { display: none; }
  .management-nav { align-items: center; }
  .management-nav-item {
    width: 38px;
    height: 38px;
    min-height: 38px;
    display: inline-flex;
    justify-content: center;
    padding: 0;
  }
  .management-count {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 9px;
  }
  .content { padding: 16px 14px 100px; }
  .manual-entry-grid { grid-template-columns: 1fr; }
  .manual-entry-actions { align-items: flex-start; flex-direction: column; }
  .ar-source-preview { grid-template-columns: 1fr; }
  .compliance-grid { grid-template-columns: 1fr; }
  .ar-source-media { max-width: 220px; }
}

/* ===================== EMPTY ===================== */
.empty {
  border: 1px dashed var(--border-default);
  border-radius: 14px; padding: 56px 24px;
  text-align: center;
  background: var(--bg-surface);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  max-width: 560px; margin: 0 auto;
}
.empty-display {
  font-family: var(--font-display); font-size: 28px; font-style: italic;
  color: var(--fg-1); letter-spacing: -0.01em;
  white-space: nowrap;
  margin-bottom: 2px;
}
.empty-body { font-size: 13px; color: var(--fg-3); max-width: 420px; margin: 0; line-height: 1.5; }
.section-loading {
  margin: 14px auto;
  max-width: 640px;
  min-height: 210px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 28px 30px;
  border: 1px dashed var(--border-default);
  border-radius: 18px;
  background:
    radial-gradient(circle at 20% 25%, color-mix(in srgb, var(--primary-500) 10%, transparent), transparent 34%),
    var(--bg-surface);
  text-align: left;
}
.section-loading-spinner {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  border-radius: 999px;
  border: 7px solid color-mix(in srgb, var(--primary-500) 18%, transparent);
  border-top-color: var(--primary-500);
  border-right-color: var(--primary-300);
  animation: ar-spin 0.9s linear infinite;
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--primary-500) 6%, transparent);
}
.section-loading-copy {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.section-loading-title {
  color: var(--fg-1);
  font-family: var(--font-display);
  font-size: 26px;
  font-style: italic;
  letter-spacing: -0.02em;
}
.section-loading-body {
  color: var(--fg-3);
  font-size: 13px;
  line-height: 1.5;
  max-width: 420px;
}

/* ===================== TOAST ===================== */
.toast {
  position: fixed; top: 72px; right: 24px; z-index: 2000;
  background: var(--neutral-900); color: #fff;
  border-radius: 10px; padding: 10px 14px;
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; box-shadow: var(--shadow-lg);
  animation: toast-in 180ms var(--ease-standard);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.toast-badge {
  font-family: var(--font-mono); font-size: 11px;
  background: var(--primary-500); color: #fff;
  padding: 2px 8px; border-radius: 4px; font-weight: 600;
}

/* ===================== TWEAKS PANEL ===================== */
.tweaks {
  position: fixed; right: 20px; bottom: 20px;
  width: 260px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  box-shadow: var(--shadow-xl);
  z-index: 200;
  overflow: hidden;
}
.tweaks-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--fg-2);
}
.tweaks-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; }
.tweak-row { display: flex; flex-direction: column; gap: 6px; }
.tweak-label { font-size: 11px; color: var(--fg-3); font-weight: 500; }
.seg {
  display: flex; background: var(--bg-sunken);
  border: 1px solid var(--border-subtle); border-radius: 8px;
  padding: 3px; gap: 2px;
}
.seg button {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  background: transparent; border: 0;
  padding: 5px 8px;
  font: inherit; font-size: 11px; color: var(--fg-2);
  border-radius: 6px; cursor: pointer; text-transform: capitalize;
}
.seg button:hover { color: var(--fg-1); }
.seg button.on {
  background: var(--bg-surface); color: var(--fg-1);
  box-shadow: var(--shadow-xs);
  font-weight: 500;
}
.seg .swatch { width: 10px; height: 10px; border-radius: 999px; }

.tweaks-fab {
  position: fixed; right: 20px; bottom: 20px;
  width: 44px; height: 44px; border-radius: 999px;
  background: var(--neutral-900); color: #fff;
  border: 0; cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}

/* ===================== KBD ===================== */
kbd {
  font-family: var(--font-mono); font-size: 10px;
  padding: 1px 6px; background: var(--bg-surface); border: 1px solid var(--border-default);
  border-radius: 4px; color: var(--fg-3);
}

/* ===================== RESEARCH HEADER / SEARCH CARD ===================== */
.search-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-xs);
}
.sc-hdr {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
}
.sc-title { font-size: 14px; font-weight: 600; }
.sc-sub { font-size: 12px; color: var(--fg-3); }
.sc-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.sc-pass-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--fg-2);
  user-select: none; cursor: pointer;
  padding: 4px 10px; border: 1px solid var(--border-default);
  border-radius: 999px; background: var(--bg-1);
}
.sc-pass-toggle input { margin: 0; cursor: pointer; }
.sc-pass-toggle:hover { background: var(--bg-hover); color: var(--fg-1); }
.sc-filter-banner {
  display: flex; align-items: center; gap: 10px;
  margin: 0 14px 10px; padding: 8px 12px;
  background: var(--bg-hover);
  border: 1px solid var(--border-default);
  border-radius: 8px; font-size: 12px; color: var(--fg-2);
}
.link-btn {
  background: none; border: 0; padding: 0;
  color: var(--accent, #129683); cursor: pointer;
  font-size: 12px; text-decoration: underline;
}
.link-btn:hover { color: var(--accent-strong, #0f7a6a); }

/* ===================== ADMIN CATALOG ===================== */
.admin-grid-view { display: flex; flex-direction: column; gap: 14px; }
.admin-crawler-live.ar-progress {
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}
.admin-pool-type-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.admin-pool-type-tab {
  border: 1px solid var(--border, #e5e7eb);
  background: var(--bg-surface, #fff);
  color: var(--text-muted, #6b7280);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.admin-pool-type-tab.active {
  color: var(--text, #111827);
  border-color: var(--accent, #2563eb);
  background: color-mix(in srgb, var(--accent, #2563eb) 10%, white);
}
.admin-crawler-settings {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
  padding: 0 4px;
}
.admin-crawler-platforms {
  flex: 1 1 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.admin-crawler-platforms-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted, #6b7280);
}
.admin-crawler-settings-note {
  flex: 1 1 100%;
  font-size: 12px;
  color: var(--text-muted, #6b7280);
}
.admin-crawler-state-note {
  flex: 1 1 100%;
  font-size: 12px;
  color: var(--text-muted, #6b7280);
  border: 1px solid var(--border-default, #e5e7eb);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--bg-surface, #fff);
}
.admin-crawler-state-note.paused {
  color: #92400e;
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.12);
}
.admin-crawler-scheduler {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
  padding-top: 8px;
  border-top: 1px solid var(--border-default, #e5e7eb);
}
.pool-direction-below-floor td:first-child {
  background: rgba(245, 158, 11, 0.08);
}
.pool-floor-badge {
  display: inline-block;
  margin-left: 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #b45309;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 999px;
  padding: 1px 7px;
  vertical-align: middle;
}
.admin-pool-version-create {
  align-items: end;
  display: grid;
  gap: 10px 12px;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto;
  margin-bottom: 12px;
}
.admin-pool-version-create label {
  display: grid;
  gap: 4px;
}
.admin-pool-version-create label span {
  color: var(--text-muted, #6b7280);
  font-size: 12px;
}
.admin-pool-ads-filter {
  align-items: center;
  display: inline-flex;
  gap: 6px;
  font-size: 13px;
}
.admin-pool-ads-filter select {
  min-width: 140px;
}
.pool-version-active td {
  background: color-mix(in srgb, var(--accent, #2563eb) 8%, transparent);
}
.linkish.admin-inline-action {
  margin-left: 8px;
  font-size: 12px;
}
.inline-edit-row {
  align-items: center;
  display: inline-flex;
  gap: 6px;
}
.admin-import-input { display: none; }
.admin-import-status {
  padding: 9px 11px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  background: var(--bg-surface);
  color: var(--fg-2);
  font-size: 12px;
}
.admin-grid {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(420px, 1fr) minmax(220px, 280px);
  gap: 14px;
  align-items: start;
}
.admin-grid.directions { grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); }
.admin-grid.workspaces { grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); }
.admin-list,
.admin-editor,
.admin-pool-panel,
.admin-workspace-detail {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  box-shadow: var(--shadow-xs);
}
.admin-list { display: flex; flex-direction: column; gap: 4px; padding: 8px; max-height: calc(100vh - 190px); overflow-y: auto; }
.admin-list-row {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  width: 100%; padding: 9px 10px;
  border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: var(--fg-1);
  font: inherit; text-align: left; cursor: pointer;
}
.admin-list-row:hover { background: var(--bg-hover); }
.admin-list-row.active { border-color: var(--primary-300); background: var(--primary-50); color: var(--fg-brand); }
.admin-list-row.muted { opacity: 0.58; }
.admin-list-row span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; }
.admin-list-row small { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg-3); font-size: 11px; }
.admin-editor { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.admin-form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.admin-form-grid.simple { grid-template-columns: minmax(0, 1fr) minmax(180px, 240px); }
.admin-form-grid label,
.admin-field-full,
.admin-platform-box { display: flex; flex-direction: column; gap: 5px; color: var(--fg-3); font-size: 11px; font-weight: 700; }
.admin-form-grid input,
.admin-form-grid select,
.admin-field-full textarea,
.admin-keyword-add input,
.admin-keyword-add select,
.admin-filter-field input,
.admin-filter-field select,
.admin-platform-box textarea,
.admin-pool-panel textarea {
  width: 100%; border: 1px solid var(--border-default); border-radius: 6px;
  background: var(--bg-sunken); color: var(--fg-1);
  font: inherit; font-size: 12px; outline: none;
}
.admin-form-grid input,
.admin-form-grid select,
.admin-keyword-add input,
.admin-keyword-add select,
.admin-filter-field input,
.admin-filter-field select { height: 32px; padding: 0 9px; }
.admin-field-full textarea { min-height: 72px; resize: vertical; padding: 9px; font-family: var(--font-mono); }
.admin-form-grid input:focus,
.admin-form-grid select:focus,
.admin-field-full textarea:focus,
.admin-keyword-add input:focus,
.admin-keyword-add select:focus,
.admin-filter-field input:focus,
.admin-filter-field select:focus,
.admin-platform-box textarea:focus,
.admin-pool-panel textarea:focus { border-color: var(--primary-500); box-shadow: var(--shadow-focus); background: var(--bg-surface); }
.admin-section-title { color: var(--fg-2); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.direction-keywords textarea { min-height: 150px; font-family: inherit; line-height: 1.45; }
.admin-platform-select-row { display: flex; flex-wrap: wrap; gap: 8px; }
.admin-platform-toggle {
  display: inline-flex; align-items: flex-start; gap: 7px;
  min-height: 32px; padding: 8px 10px;
  border: 1px solid var(--border-default); border-radius: 8px;
  background: var(--bg-surface); color: var(--fg-2);
  font-size: 12px; font-weight: 700; cursor: pointer;
}
.admin-platform-toggle.active { border-color: var(--primary-300); background: var(--primary-50); color: var(--fg-brand); }
.admin-platform-toggle input { width: 14px; height: 14px; margin-top: 2px; accent-color: var(--primary-500); flex-shrink: 0; }
.admin-platform-toggle-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.admin-platform-toggle-stats {
  font-size: 10px;
  font-weight: 600;
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}
.admin-platform-toggle.active .admin-platform-toggle-stats { color: var(--fg-2); }
.admin-platform-pool-summary {
  flex: 1 1 100%;
  font-size: 12px;
  color: var(--fg-2);
  font-weight: 600;
}
.pool-direction-totals-row td {
  border-top: 2px solid var(--border-default);
  background: var(--bg-sunken);
}
.pool-platform-subtotal {
  margin-top: 2px;
  font-size: 10px;
  font-weight: 600;
  color: var(--fg-3);
}
.admin-pool-ads-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}
.admin-pool-ads-page-label {
  font-size: 12px;
  color: var(--fg-2);
  font-variant-numeric: tabular-nums;
}
.admin-pool-ad-link { margin-left: 0; white-space: nowrap; }
.admin-pool-ad-links { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.admin-pool-ad-reason {
  max-width: 280px;
  font-size: 12px;
  color: var(--fg-2);
  line-height: 1.35;
  white-space: normal;
}

/* Pool ads browser — card grid (reuses AdCard + AdDrawer like Static Ads) */
.admin-pool-ads-grid-scroll { min-width: 0; }
.admin-pool-ads-grid-scroll .pp-grid { padding: 4px 0; }
.admin-pool-ads-empty { padding: 24px 8px; color: var(--fg-3); font-size: 13px; }
.admin-keyword-add { display: grid; grid-template-columns: 128px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.admin-chip-row { display: flex; flex-wrap: wrap; gap: 6px; min-height: 24px; }
.admin-chip {
  display: inline-flex; align-items: center; gap: 6px;
  max-width: 100%; padding: 4px 7px;
  border: 1px solid var(--border-subtle); border-radius: 999px;
  background: var(--bg-sunken); color: var(--fg-2);
  font-size: 11px; overflow-wrap: anywhere;
}
.admin-chip button { display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--fg-3); cursor: pointer; padding: 0; }
.admin-platform-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.admin-platform-box { padding: 10px; border: 1px solid var(--border-subtle); border-radius: 8px; background: var(--bg-app); }
.admin-platform-box.disabled { opacity: 0.58; }
.admin-platform-box span { color: var(--fg-2); }
.admin-platform-box textarea { min-height: 130px; resize: vertical; padding: 8px; font-family: var(--font-mono); line-height: 1.35; }
.admin-platform-box-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.admin-platform-box-head small { color: var(--fg-3); font: 600 10px/1 var(--font-mono); }
.admin-filter-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.admin-filter-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.admin-filter-field.wide,
.admin-filter-field.range { grid-column: span 2; }
.admin-filter-field > span { color: var(--fg-3); font-size: 10px; }
.admin-filter-field input:disabled,
.admin-filter-field select:disabled { cursor: not-allowed; opacity: 0.7; }
.admin-filter-range { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; }
.admin-danger-row { display: flex; justify-content: flex-end; }
.admin-grid.criteria { grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); }
.criteria-platform-name { display: inline-flex; align-items: center; gap: 7px; }
.criteria-platform-name i { width: 7px; height: 7px; border-radius: 999px; flex-shrink: 0; }
.criteria-editor textarea,
.criteria-threshold input {
  width: 100%;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  background: var(--bg-sunken);
  color: var(--fg-1);
  font: inherit;
  font-size: 12px;
  outline: none;
}
.criteria-editor textarea:focus,
.criteria-threshold input:focus { border-color: var(--primary-500); box-shadow: var(--shadow-focus); background: var(--bg-surface); }
.criteria-top-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.criteria-version-select { min-width: 190px; display: flex; flex-direction: column; gap: 5px; color: var(--fg-3); font-size: 11px; font-weight: 700; }
.criteria-version-select select {
  height: 32px;
  border: 1px solid var(--border-default);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--fg-1);
  padding: 0 9px;
  outline: none;
}
.criteria-version-select select:focus { border-color: var(--primary-500); box-shadow: var(--shadow-focus); background: var(--bg-surface); }
.criteria-threshold { width: 150px; display: flex; flex-direction: column; gap: 5px; color: var(--fg-3); font-size: 11px; font-weight: 700; }
.criteria-threshold input { height: 32px; padding: 0 9px; font-family: var(--font-mono); }
.criteria-score textarea { min-height: 210px; resize: vertical; padding: 9px; line-height: 1.5; }
.criteria-rubric textarea { min-height: 150px; resize: vertical; padding: 9px; line-height: 1.5; }
.criteria-signals textarea { min-height: 130px; resize: vertical; padding: 9px; line-height: 1.45; }
.criteria-meta-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.criteria-meta-grid div { border: 1px solid var(--border-subtle); border-radius: 8px; background: var(--bg-sunken); padding: 10px; min-width: 0; }
.criteria-meta-grid span { display: block; color: var(--fg-3); font-size: 11px; margin-bottom: 4px; }
.criteria-meta-grid strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-size: 12px; color: var(--fg-1); }
.cost-dashboard { gap: 16px; }
.cost-kpi-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.cost-kpi, .cost-panel, .cost-platform-card { border: 1px solid var(--border-subtle); border-radius: 8px; background: var(--bg-surface); box-shadow: var(--shadow-sm); }
.cost-kpi { display: grid; gap: 6px; padding: 14px; min-width: 0; }
.cost-kpi span, .cost-kpi small, .cost-panel-head span, .cost-user-id span, .cost-user-total span, .cost-platform-metrics span, .cost-flow-cell span { color: var(--fg-3); font-size: 12px; }
.cost-kpi strong { color: var(--fg-1); font-size: 26px; letter-spacing: 0; overflow-wrap: anywhere; }
.cost-kpi.primary strong { color: var(--primary-700); }
.cost-main-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr); gap: 14px; }
.cost-panel { min-width: 0; padding: 14px; }
.cost-panel-head { align-items: center; display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.cost-panel-head > div:first-child { display: grid; gap: 3px; }
.cost-panel-head strong, .cost-user-id strong, .cost-user-total strong, .cost-platform-title strong, .cost-platform-title span { color: var(--fg-1); font-size: 14px; }
.cost-legend { align-items: center; display: flex; flex-wrap: wrap; gap: 10px; }
.cost-legend span { align-items: center; display: inline-flex; gap: 5px; }
.cost-legend i, .cost-stack-segment { display: block; }
.cost-legend i { border-radius: 99px; height: 8px; width: 8px; }
.cost-legend i.search, .cost-stack-segment.search { background: #2563eb; }
.cost-legend i.autoresearch, .cost-stack-segment.autoresearch { background: #14b8a6; }
.cost-legend i.auto_remodel, .cost-stack-segment.auto_remodel { background: #f97316; }
.cost-legend i.visual_breakdown, .cost-stack-segment.visual_breakdown { background: #db2777; }
.cost-user-list, .cost-daily-bars { display: grid; gap: 10px; }
.cost-user-filter-control { align-items: center; display: flex; gap: 8px; max-width: 760px; }
.cost-user-filter-select { background: var(--bg-sunken); border: 1px solid var(--border-subtle); border-radius: 8px; color: var(--fg-1); flex: 1; font: inherit; height: 38px; min-width: 260px; padding: 0 10px; }
.cost-user-filter-select:focus { border-color: var(--primary-400); box-shadow: 0 0 0 3px var(--primary-100); outline: none; }
.cost-user-row { align-items: center; display: grid; grid-template-columns: minmax(180px, 0.9fr) minmax(180px, 1.3fr) minmax(110px, auto); gap: 12px; padding: 9px 0; }
.cost-user-row + .cost-user-row, .cost-daily-row + .cost-daily-row { border-top: 1px solid var(--border-subtle); }
.cost-user-id, .cost-user-total { display: grid; gap: 3px; min-width: 0; }
.cost-user-id strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cost-user-total { justify-items: end; text-align: right; }
.cost-user-bar-wrap, .cost-daily-track { min-width: 0; }
.cost-stacked-bar { align-items: stretch; background: var(--bg-sunken); border-radius: 999px; display: flex; height: 12px; overflow: hidden; width: 100%; }
.cost-stack-segment:first-child { border-bottom-left-radius: 999px; border-top-left-radius: 999px; }
.cost-stack-segment:last-child { border-bottom-right-radius: 999px; border-top-right-radius: 999px; }
.cost-daily-row { align-items: center; display: grid; grid-template-columns: 92px minmax(120px, 1fr) 86px; gap: 10px; padding: 9px 0; }
.cost-daily-row > span { color: var(--fg-3); font-size: 12px; }
.cost-daily-row strong { color: var(--fg-1); font-size: 12px; text-align: right; }
.cost-platform-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.cost-platform-card { display: grid; gap: 10px; padding: 13px; }
.cost-platform-title { align-items: center; display: flex; justify-content: space-between; gap: 10px; }
.cost-platform-title span, .cost-platform-title strong { overflow-wrap: anywhere; }
.cost-platform-metrics { display: grid; gap: 5px; }
.cost-kpi.savings { border-color: #bbf7d0; background: linear-gradient(180deg, #f0fdf4 0%, var(--bg-surface) 100%); }
.cost-stage-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); gap: 14px; }
.cost-stage-rows { display: grid; gap: 8px; margin-top: 12px; }
.cost-stage-row { align-items: center; display: grid; grid-template-columns: minmax(120px, 1fr) 52px 92px; gap: 10px; }
.cost-stage-label { align-items: center; color: var(--fg-2); display: inline-flex; font-size: 12px; gap: 8px; }
.cost-stage-label i { border-radius: 999px; display: inline-block; flex: 0 0 auto; height: 10px; width: 10px; }
.cost-stage-pct { color: var(--fg-3); font-size: 12px; text-align: right; }
.cost-stage-row strong { color: var(--fg-1); font-size: 12px; text-align: right; }
.cost-sprint-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.cost-sprint-metric { background: var(--bg-sunken); border: 1px solid var(--border-subtle); border-radius: 8px; display: grid; gap: 4px; padding: 10px; }
.cost-sprint-metric span { color: var(--fg-3); font-size: 11px; }
.cost-sprint-metric strong { color: var(--fg-1); font-family: var(--font-mono); font-size: 18px; }
.cost-sprint-metric small { color: var(--fg-3); font-size: 11px; }
.cost-sprint-metric.savings { border-color: #bbf7d0; background: #f0fdf4; }
.cost-pool-dedup-banner { align-items: center; background: var(--bg-sunken); border: 1px solid var(--border-subtle); border-radius: 8px; display: flex; gap: 12px; justify-content: space-between; margin-top: 12px; padding: 12px; }
.cost-pool-dedup-banner strong { display: block; font-size: 13px; }
.cost-pool-dedup-banner span { color: var(--fg-3); display: block; font-size: 11px; margin-top: 2px; }
.cost-pool-dedup-value { color: #166534; font-family: var(--font-mono); font-size: 16px; white-space: nowrap; }
.cost-sprint-table { min-width: 980px; }
.cost-config-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; overflow-x: auto; }
.cost-table-scroll { overflow-x: auto; }
/* Tall scrolling tables (per-ad / per-user cost tables cap their height):
   keep the header row pinned while the body scrolls. No-op for tables
   that never scroll vertically. */
.cost-table-scroll table thead th { position: sticky; top: 0; background: var(--bg-surface); z-index: 1; }
.cost-config-table, .cost-platform-flow-table { border-collapse: collapse; min-width: 460px; width: 100%; }
.cost-config-table th, .cost-config-table td, .cost-platform-flow-table th, .cost-platform-flow-table td { border-bottom: 1px solid var(--border-subtle); color: var(--fg-2); font-size: 12px; padding: 9px 8px; text-align: left; vertical-align: top; }
.cost-config-table th, .cost-platform-flow-table th { color: var(--fg-3); font-weight: 700; }
.cost-platform-flow-table td strong { color: var(--fg-1); }
.cost-flow-cell { display: grid; gap: 3px; min-width: 92px; }
.cost-top-ad { align-items: center; display: flex; gap: 10px; }
.cost-top-ad-thumb { background: var(--bg-sunken); border: 1px solid var(--border-subtle); border-radius: 6px; flex: 0 0 auto; height: 40px; object-fit: cover; width: 40px; }
.cost-top-ad a { color: var(--accent, #2563eb); text-decoration: none; }
.cost-top-ad a:hover { text-decoration: underline; }
/* Cost-panel semantic variant hooks (shared by the video + Image cost dashboards).
   Pre-existing class names that had no explicit rule. Defined here as grid/flex card
   children with min-width:0 so their inner cost-table-scroll tables scroll instead of
   forcing horizontal overflow — non-visual when content already fits. */
.cost-user-filter-panel,
.cost-stage-panel,
.cost-sprint-panel,
.cost-sprint-history-panel,
.cost-user-panel,
.cost-daily-panel,
.cost-platform-flow-panel,
.cost-config-panel { min-width: 0; }
.cost-config-table code { background: var(--bg-sunken); border: 1px solid var(--border-subtle); border-radius: 6px; color: var(--fg-1); display: inline-block; font-size: 11px; padding: 2px 5px; }
.cost-key-state { border-radius: 999px; display: inline-block; font-size: 11px; font-weight: 700; margin-left: 6px; padding: 2px 7px; }
.cost-key-state.ok { background: #dcfce7; color: #166534; }
.cost-key-state.missing { background: #fee2e2; color: #991b1b; }
.admin-pool-panel { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.admin-pool-active { font-size: 13px; color: var(--fg-2); }
.admin-pool-panel textarea { min-height: 84px; resize: vertical; padding: 9px; }
.admin-version-list { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.admin-version { display: flex; justify-content: space-between; gap: 8px; padding: 8px; border: 1px solid var(--border-subtle); border-radius: 6px; background: var(--bg-sunken); font-size: 12px; }
.admin-version.active { border-color: var(--primary-300); background: var(--primary-50); }
.admin-version small { color: var(--fg-3); font-family: var(--font-mono); }
.admin-workspace-detail { min-height: 420px; padding: 14px; }
.admin-work-summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.admin-work-summary div { border: 1px solid var(--border-subtle); border-radius: 8px; background: var(--bg-sunken); padding: 10px; }
.admin-work-summary span { display: block; color: var(--fg-3); font-size: 11px; margin-bottom: 4px; }
.admin-work-summary strong { font-family: var(--font-mono); font-size: 18px; }
.admin-work-sections { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.admin-work-card { border: 1px solid var(--border-subtle); border-radius: 8px; overflow: hidden; background: var(--bg-surface); }
.admin-work-card header { display: flex; justify-content: space-between; padding: 10px; border-bottom: 1px solid var(--border-subtle); font-size: 13px; }
.admin-work-card header span { font-family: var(--font-mono); color: var(--fg-3); }
.admin-work-empty { padding: 14px; color: var(--fg-3); font-size: 12px; }
.admin-work-ads { display: flex; flex-direction: column; }
.admin-work-ad { display: flex; flex-direction: column; gap: 3px; padding: 8px 10px; border-bottom: 1px solid var(--border-subtle); }
.admin-work-ad:last-child { border-bottom: 0; }
.admin-work-ad span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 12px; }
.admin-work-ad small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg-3); font-size: 11px; }
@media (max-width: 1120px) {
  .admin-grid,
  .admin-grid.workspaces { grid-template-columns: 1fr; }
  .admin-list { max-height: none; }
  .admin-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cost-main-grid,
  .cost-config-grid,
  .cost-stage-grid { grid-template-columns: 1fr; }
  .cost-kpi-grid,
  .cost-platform-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-platform-grid,
  .admin-work-sections,
  .criteria-meta-grid { grid-template-columns: 1fr; }
  .criteria-top-row { flex-direction: column; }
  .criteria-threshold { width: 100%; }
  .admin-work-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .cost-kpi-grid,
  .cost-platform-grid { grid-template-columns: 1fr; }
  .cost-user-row { grid-template-columns: 1fr; }
  .cost-user-total { justify-items: start; text-align: left; }
  .cost-daily-row { grid-template-columns: 1fr; }
  .cost-daily-row strong { text-align: left; }
}

/* ===================== ACCESS REQUESTS ===================== */
.access-admin { display: flex; flex-direction: column; gap: 14px; }

.quota-guardrails-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.quota-guardrails-defaults,
.quota-guardrails-totals,
.quota-guardrails-reset {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--border-default);
  border-radius: 10px;
  background: var(--bg-surface);
  font-size: 13px;
  color: var(--fg-2);
}
.quota-guardrails-toolbar { display: flex; gap: 8px; }
.quota-guardrails-table-wrap {
  overflow: auto;
  border: 1px solid var(--border-default);
  border-radius: 10px;
  background: var(--bg-surface);
}
.quota-guardrails-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.quota-guardrails-table th,
.quota-guardrails-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-default);
  vertical-align: top;
  text-align: left;
}
.quota-guardrails-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-3);
}
.quota-user-cell { display: flex; flex-direction: column; gap: 2px; }
.quota-user-cell small { color: var(--fg-3); }
.quota-cap-inputs {
  display: grid;
  gap: 8px;
}
.quota-cap-inputs label {
  display: grid;
  gap: 4px;
  font-size: 11px;
  color: var(--fg-3);
}
.daily-quota-bar { display: grid; gap: 6px; min-width: 180px; }
.daily-quota-bar-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--fg-2);
}
.daily-quota-bar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-muted, #eef2f7);
  overflow: hidden;
}
.daily-quota-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--primary-500, #2563eb);
}
.daily-quota-bar.warn .daily-quota-bar-fill { background: #d97706; }
.daily-quota-bar.danger .daily-quota-bar-fill { background: #dc2626; }

.access-filters {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.access-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border-default);
  border-radius: 8px;
  background: var(--bg-surface);
  color: var(--fg-2);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
  cursor: pointer;
}
.access-filter.active { color: var(--fg-brand); border-color: var(--primary-300); background: var(--primary-50); }
.access-filter span { font-family: var(--font-mono); font-size: 11px; }
.access-error,
.access-loading,
.access-notice {
  border: 1px solid var(--border-default);
  border-radius: 8px;
  background: var(--bg-surface);
  padding: 12px 14px;
  color: var(--fg-2);
  font-size: 13px;
}
.access-error { color: #b42318; border-color: #fecaca; background: #fff1f2; }
.access-notice { color: #027a48; border-color: #abefc6; background: #ecfdf3; }
.access-table { display: flex; flex-direction: column; gap: 10px; }
.access-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--border-default);
  border-radius: 8px;
  background: var(--bg-surface);
}
.access-main { min-width: 0; }
.access-name-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.access-name-line strong { font-size: 14px; }
.access-role-badge { display: flex; justify-content: flex-end; margin-bottom: 6px; }
.access-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
  color: var(--fg-3);
  font-size: 12px;
}
.access-meta span { overflow-wrap: anywhere; }
.access-reason,
.access-notes {
  margin: 10px 0 0;
  line-height: 1.5;
  color: var(--fg-2);
  overflow-wrap: anywhere;
}
.access-notes { font-size: 12px; color: var(--fg-3); }
.access-actions { display: flex; flex-direction: column; gap: 10px; }
.access-actions textarea {
  width: 100%;
  min-height: 86px;
  resize: vertical;
  border: 1px solid var(--border-default);
  border-radius: 8px;
  background: var(--bg-sunken);
  color: var(--fg-1);
  padding: 9px 10px;
  font: inherit;
  font-size: 13px;
  outline: none;
}
.access-actions textarea:focus { border-color: var(--primary-500); box-shadow: var(--shadow-focus); background: var(--bg-surface); }
.access-action-buttons { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.feature-access-controls {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.feature-access-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--border-default);
  border-radius: 999px;
  background: var(--bg-surface);
  color: var(--fg-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.feature-access-toggle input { margin: 0; }
.feature-access-toggle.disabled {
  color: var(--fg-4);
  cursor: not-allowed;
  opacity: 0.72;
}
.feature-access-applied {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #ecfdf3;
  color: #067647;
  font-size: 12px;
  font-weight: 700;
}
.feature-access-note {
  color: var(--fg-3);
  font-size: 12px;
  text-align: right;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: capitalize;
}
.status-pill.pending { background: #fff1f2; color: #b42318; }
.status-pill.approved { background: #ecfdf3; color: #067647; }
.status-pill.rejected { background: #f2f4f7; color: #475467; }
@media (max-width: 860px) {
  .access-row { grid-template-columns: 1fr; }
  .access-action-buttons { justify-content: flex-start; }
  .feature-access-controls { justify-content: flex-start; }
  .feature-access-note { text-align: left; }
}

/* badges for the 'Filter' / 'Remodel' pipeline icons within the tab */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 500;
  background: var(--bg-sunken); color: var(--fg-2);
}

/* ===================== SELECTION BAR — SECONDARY CTA ===================== */
.selbar-secondary {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px;
  background: transparent; color: #eef0f3;
  border: 1px solid rgba(255,255,255,0.18); border-radius: 8px;
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
  margin-right: 8px;
}
.selbar-secondary:hover { background: rgba(255,255,255,0.06); }

/* ===================== AUTORESEARCH PANEL ===================== */
.ar-card { margin-top: 16px; }
.ar-sources {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 10px;
}
.ar-sources-spacer { flex: 1; }
.ar-progress {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--bg-sunken);
  border: 1px solid var(--border-default);
  border-radius: 8px;
}
.ar-progress-head {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
}
.ar-running-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid rgba(15, 181, 168, 0.35);
  background: rgba(15, 181, 168, 0.12);
  color: var(--primary-700, #0a7c72);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}
.ar-running-chip .ar-spinner {
  width: 10px;
  height: 10px;
  border-width: 2px;
}
.ar-scheduler-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--primary-700, #0a7c72);
  background: rgba(15, 181, 168, 0.12);
  border: 1px solid rgba(15, 181, 168, 0.35);
  border-radius: 999px;
  padding: 2px 8px;
}
.ar-progress-status {
  font-size: 13px; font-weight: 600; color: var(--fg-1);
}
.ar-progress-meta {
  margin-left: auto;
  font-size: 12px; color: var(--fg-2);
  font-family: var(--font-mono, inherit);
}
.ar-progress-bar {
  margin-top: 8px;
  height: 8px; border-radius: 999px;
  background: rgba(0,0,0,0.08);
  overflow: hidden;
}
.ar-progress-fill {
  height: 100%;
  background: var(--primary-500, #0fb5a8);
  transition: width 0.4s ease;
}
.ar-platform-progress {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ar-platform-progress-row {
  color: var(--fg-2);
  font-size: 11px;
  font-family: var(--font-mono, inherit);
}
.ar-card .ar-platform-progress {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.ar-card .ar-platform-progress-row {
  display: block;
}
.ar-direction-details {
  margin-top: 8px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 8px;
}
.ar-direction-details summary {
  cursor: pointer;
  color: var(--fg-2);
  font-size: 11px;
  font-weight: 600;
}
.ar-direction-detail-list {
  margin-top: 8px;
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
}
.ar-direction-detail-group {
  display: grid;
  gap: 4px;
}
.ar-direction-detail-name {
  color: var(--fg-1);
  font-size: 12px;
  font-weight: 600;
}
.ar-direction-detail-platforms {
  display: grid;
  gap: 3px;
}
.ar-direction-detail-row {
  color: var(--fg-2);
  font-size: 11px;
  font-family: var(--font-mono, inherit);
}
.ar-spinner {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.12);
  border-top-color: var(--primary-500, #0fb5a8);
}
.ar-spinner.spin { animation: ar-spin 0.9s linear infinite; }
.ar-complete-indicator {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--primary-500, #0fb5a8);
  flex: 0 0 auto;
}
@keyframes ar-spin { to { transform: rotate(360deg); } }
/* Loader icons animate only when callers opt in with icon-spin or .spin. */
.icon-spin { animation: ar-spin 0.9s linear infinite; transform-origin: center; }
.ar-filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin-top: 12px;
  margin-bottom: 12px;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px;
  background: var(--bg-sunken); color: var(--fg-2);
  border: 1px solid var(--border-default);
  font: inherit; font-size: 12px; cursor: pointer;
}
.chip.on {
  background: var(--primary-50, #e7f5f3); color: var(--primary-500);
  border-color: var(--primary-500);
}
.chip-count {
  font-family: var(--font-mono); font-size: 10px;
  background: rgba(0,0,0,0.08); padding: 1px 6px; border-radius: 999px;
}
.ar-target {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--fg-3);
}
.ar-target input {
  width: 60px; height: 28px; padding: 0 8px;
  text-align: center; font-family: var(--font-mono);
  background: var(--bg-sunken); border: 1px solid var(--border-default);
  border-radius: 6px; font-size: 12px; color: var(--fg-1); outline: none;
}
.ar-target input:focus { border-color: var(--primary-500); box-shadow: var(--shadow-focus); }
.ar-target.ar-keyword {
  flex: 1 1 320px; max-width: 460px;
}
.ar-target.ar-keyword input {
  width: 100%; min-width: 280px; text-align: left; font-family: var(--font-sans);
}
.ar-target.ar-keyword span { white-space: nowrap; }

.ar-dirs { position: relative; border-top: 1px solid var(--border-subtle); padding-top: 12px; margin-top: 12px; }
.ar-dirs-inline {
  border-top: 0; padding-top: 0; margin-top: 0;
  flex: 1 0 100%; order: 10;
}
.ar-dirs-trigger {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 6px 12px; border-radius: 8px;
  border: 1px solid var(--border-default); background: var(--bg-sunken);
  color: var(--fg-2); font: inherit; font-size: 12px; cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.ar-dirs-trigger:hover { color: var(--fg-1); border-color: var(--primary-500); }
.ar-dirs-trigger.active {
  color: var(--primary-700, #4338ca);
  background: var(--primary-100, #eef2ff);
  border-color: var(--primary-500);
}
.ar-dirs-trigger-label { font-weight: 600; }
.ar-dirs-trigger-value { opacity: 0.85; font-variant-numeric: tabular-nums; }
.ar-dirs-chevron { display: inline-flex; transition: transform 0.15s ease; }
.ar-dirs-chevron.up { transform: rotate(180deg); }
.ar-dirs-popover {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  background: var(--bg-default, #fff);
  border: 1px solid var(--border-default);
  border-radius: 10px; padding: 12px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
  z-index: 20;
  max-height: 340px; overflow-y: auto;
}
.ar-dirs-inline .ar-dirs-popover {
  top: calc(100% + 4px); bottom: auto; right: auto;
  width: min(620px, 100%);
}
.ar-dirs-popover-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; gap: 12px; }
.ar-dirs-popover-hint { font-size: 11px; color: var(--fg-3); }
.ar-dirs-actions { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; }
.ar-dirs-clear {
  background: transparent; border: 0; color: var(--fg-3); cursor: pointer;
  font: inherit; font-size: 11px; padding: 2px 8px; border-radius: 6px; white-space: nowrap;
}
.ar-dirs-clear:hover { background: var(--bg-sunken); color: var(--fg-1); }
.ar-dirs-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.ar-dir-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border-default); background: var(--bg-sunken);
  color: var(--fg-2); font-size: 12px; cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.ar-dir-pill:hover { color: var(--fg-1); }
.ar-dir-pill input { margin: 0; accent-color: var(--primary-500); }
.ar-dir-pill.on {
  background: var(--primary-100, #eef2ff);
  color: var(--primary-700, #4338ca);
  border-color: var(--primary-500);
}
.ar-dir-label { white-space: nowrap; text-transform: lowercase; }
.ar-dirs-preview { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; max-width: 100%; }
.ar-dir-preview-pill,
.ar-dir-preview-more {
  display: inline-flex; align-items: center; min-width: 0; max-width: 160px;
  padding: 3px 7px; border-radius: 999px;
  background: var(--bg-sunken); border: 1px solid var(--border-subtle);
  color: var(--fg-2); font-size: 11px; line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ar-dir-preview-more { color: var(--fg-3); font-variant-numeric: tabular-nums; }

.ar-dims {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 10px;
}
.ar-dim {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px; border-radius: 10px; text-align: left;
  background: var(--bg-surface); border: 1px solid var(--border-default);
  font: inherit; cursor: pointer;
  transition: background 120ms var(--ease-standard), border-color 120ms var(--ease-standard);
}
.ar-dim:hover { background: var(--bg-hover); }
.ar-dim.on { border-color: var(--primary-500); background: var(--primary-50, #e7f5f3); }
.ar-dim-cbx {
  width: 16px; height: 16px; flex-shrink: 0;
  border: 1.5px solid var(--border-strong, #cbd2dc); border-radius: 4px;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.ar-dim-cbx.on { background: var(--primary-500); border-color: var(--primary-500); }
.ar-dim-body { flex: 1; min-width: 0; }
.ar-dim-name {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--fg-1);
  margin-bottom: 4px;
}
.ar-dim-type {
  font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 2px 6px; border-radius: 4px;
  background: var(--bg-sunken); color: var(--fg-3);
}
.ar-dim-desc {
  font-size: 12px; color: var(--fg-2); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 6px;
}
.ar-dim-meta {
  display: flex; gap: 6px; font-size: 11px; color: var(--fg-3);
  font-family: var(--font-mono);
}

/* count pill on the Run Autoresearch button */
.count-pill {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 6px;
  border-radius: 999px; background: rgba(255,255,255,0.2); color: #fff;
  font-size: 11px; font-family: var(--font-mono); margin-left: 4px;
}

/* disabled platform toggles (backend not wired) — muted */
.plat-toggle:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.plat-toggle.all {
  font-weight: 600;
  border-style: dashed;
}

/* ----------------------------------------------------------------------
   Static Ads — image-ad generation surface (first tab).
   Reuses .search-card / .ar-progress / .btn-* and adds .sa-* selectors.
   ---------------------------------------------------------------------- */
.static-ads-panel { display: flex; flex-direction: column; gap: 16px; }
.sa-card { margin-top: 0; }

.sa-form {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px;
  padding: 4px 0 2px;
}
.sa-field { display: grid; gap: 6px; font-size: 12px; color: var(--fg-2); min-width: 160px; }
.sa-field-grow { flex: 1 1 240px; }
.sa-field > span { font-weight: 600; }
.sa-field input[type="text"],
.sa-field select {
  height: 34px; padding: 0 10px;
  border: 1px solid var(--border-default); border-radius: 8px;
  background: var(--bg-surface); color: var(--fg-1);
  font: inherit; font-size: 13px; outline: none;
}
.sa-field input[type="text"]:focus,
.sa-field select:focus { border-color: var(--primary-500); box-shadow: var(--shadow-focus); }
.sa-field input[type="range"] { width: 100%; accent-color: var(--primary-500); }
.sa-field input:disabled, .sa-field select:disabled { opacity: 0.6; cursor: not-allowed; }

/* History (Previously Generated Ads) date filter — themed, pinned far-right of the bar. */
.sa-gallery-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--fg-3);
  font-size: 11px;
  margin-left: auto;
}
.sa-gallery-filter input[type="date"] {
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border-default);
  border-radius: 8px;
  background: var(--bg-surface);
  color: var(--fg-1);
  font: inherit;
  font-size: 12px;
  outline: none;
}
.sa-gallery-filter input[type="date"]:focus {
  border-color: var(--primary-500);
  box-shadow: var(--shadow-focus);
}
.sa-gallery-filter .btn-secondary { height: 30px; padding: 0 10px; }

/* History rows — each row reuses .sa-gallery (same 240px cards + horizontal scroll as
   the studio); stack them inside the vertical scroller with light separators. */
.sa-gallery-rows .sa-gallery { margin-top: 0; padding: 8px 0; border-bottom: 1px solid var(--border-subtle); }
.sa-gallery-rows .sa-gallery:last-child { border-bottom: none; }
.sa-history-pass { margin-left: 4px; }

.sa-field-disabled { opacity: 0.75; }
.sa-field-disabled em { font-style: normal; color: var(--fg-4); font-weight: 500; }
.sa-strictness { display: inline-flex; border: 1px solid var(--border-default); border-radius: 8px; overflow: hidden; }
.sa-strictness-opt {
  padding: 7px 12px; border: 0; background: var(--bg-sunken); color: var(--fg-3);
  font: inherit; font-size: 12px; text-transform: capitalize; cursor: pointer;
}
.sa-strictness-opt + .sa-strictness-opt { border-left: 1px solid var(--border-default); }
.sa-strictness-opt:hover:not(:disabled):not(.on) { background: var(--bg-hover); color: var(--fg-1); }
.sa-strictness-opt:disabled { cursor: not-allowed; opacity: 0.6; }
.sa-strictness-opt.on { background: var(--primary-50); color: var(--primary-700); }

.sa-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.sa-cancel-btn { margin-left: auto; flex-shrink: 0; }
.sa-error { margin-top: 8px; color: #e5484d; font-size: 12px; }

/* Per-step progress stepper (#221) */
.sa-stepper { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sa-step { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--fg-3); }
.sa-step-dot {
  width: 20px; height: 20px; flex-shrink: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--border-default); background: var(--bg-sunken);
  font-size: 11px; color: var(--fg-4);
}
.sa-step.done { color: var(--fg-2); }
.sa-step.done .sa-step-dot { background: var(--primary-600, #2563eb); border-color: var(--primary-600, #2563eb); color: #fff; }
.sa-step.active { color: var(--fg-1); font-weight: 600; }
.sa-step.active .sa-step-dot { border-color: var(--primary-500, #3b82f6); }
.sa-step.failed { color: #e5484d; font-weight: 600; }
.sa-step.failed .sa-step-dot { background: #e5484d; border-color: #e5484d; color: #fff; }
.sa-step-spin {
  width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid var(--primary-200, #bfdbfe); border-top-color: var(--primary-600, #2563eb);
  animation: ar-spin 0.8s linear infinite;
}
.sa-error-tech { margin-top: 6px; }
.sa-error-tech summary { cursor: pointer; color: var(--fg-4); font-size: 11px; }
.sa-error-tech p {
  margin: 4px 0 0; color: var(--fg-3); font-size: 11px; white-space: pre-wrap; word-break: break-word;
  font-family: var(--font-mono, monospace);
}

/* indeterminate bar while a run is "running" (backend holds progress at 0.05) */
.ar-progress-fill.sa-indeterminate {
  width: 35% !important;
  background: linear-gradient(90deg, transparent, var(--primary-500), transparent);
  animation: sa-slide 1.2s ease-in-out infinite;
}
@keyframes sa-slide {
  0% { margin-left: -35%; }
  100% { margin-left: 100%; }
}

/* variants gallery — responsive tiles */
/* Variants render as a single-row horizontal carousel — Original + Variant 1..N
   stay on one line and scroll sideways instead of wrapping to new rows. */
.sa-gallery {
  margin-top: 14px;
  display: flex; gap: 14px;
  overflow-x: auto; overflow-y: hidden;
  padding-bottom: 6px;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
}
.sa-variant-card {
  border: 1px solid var(--border-subtle); border-radius: 10px;
  background: var(--bg-surface); overflow: hidden;
  display: flex; flex-direction: column;
  flex: 0 0 240px; scroll-snap-align: start;
}
.sa-variant-img { aspect-ratio: 1 / 1; background: var(--bg-sunken); }
.sa-variant-img img { width: 100%; height: 100%; object-fit: contain; cursor: zoom-in; display: block; }
.sa-variant-missing {
  width: 100%; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px;
  color: var(--fg-4); font-size: 12px;
}
.sa-variant-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px; font-size: 12px; color: var(--fg-2);
}
.sa-variant-idx { font-weight: 600; color: var(--fg-1); }
.sa-variant-date { margin-left: auto; color: var(--fg-4); font-size: 11px; white-space: nowrap; }
.sa-variant-cost { font-family: var(--font-mono, inherit); }
.sa-variant-compliance { margin-left: auto; color: var(--fg-3); }
.sa-variant-prompt { padding: 0 10px 8px; font-size: 12px; }
.sa-variant-prompt summary { cursor: pointer; color: var(--fg-3); }
.sa-variant-prompt p { margin: 6px 0 0; color: var(--fg-2); white-space: pre-wrap; }
.sa-variant-actions { display: flex; gap: 6px; padding: 0 10px 10px; }
.sa-variant-actions .btn-secondary { height: 28px; padding: 0 10px; font-size: 12px; }
.sa-disabled { opacity: 0.5; cursor: not-allowed; }

/* Per-variant actions (#221) */
.sa-variant-img { position: relative; }
/* Per-image spinner shown over the exact variant(s) being regenerated. */
.sa-variant-regen {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: rgba(0, 0, 0, 0.5); color: #fff; font-size: 11px; font-weight: 600;
  backdrop-filter: blur(1px); -webkit-backdrop-filter: blur(1px);
  pointer-events: none;
}
.sa-variant-card.regenerating { border-color: var(--primary-400, var(--primary-700)); }

/* Facebook full-image fetch (Apify) + clean-original status on the Original card. */
/* In-progress: spinner overlay over the cropped image (same pattern as sa-variant-regen). */
.sa-fetch-overlay {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 8px; text-align: center;
  background: rgba(0, 0, 0, 0.5); color: #fff; font-size: 11px; font-weight: 600;
  backdrop-filter: blur(1.5px); -webkit-backdrop-filter: blur(1.5px);
  pointer-events: none;
}
.sa-variant-card.fetching { border-color: var(--primary-400, var(--primary-700)); }
/* Done: small green pill, top-left, over the (now full) image. */
.sa-variant-keeper {
  position: absolute; top: 6px; left: 6px; z-index: 2;
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.2px; line-height: 1.6;
  background: var(--success-bg, #e7f7ee); color: var(--success-fg, #157347);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}
/* Fallback: small amber chip in the meta row when the full image couldn't be fetched. */
.sa-variant-cropped {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 7px; border-radius: 999px; cursor: help;
  font-size: 10px; font-weight: 600;
  background: var(--warning-bg, #fff4e5); color: var(--warning-fg, #b45309);
}
.sa-variant-actions .btn-secondary.on { background: var(--primary-50); color: var(--primary-700); border-color: var(--primary-400, var(--primary-700)); }

/* ── D2 revert: 🕘 version-history button + popover + size-mismatch badge ─────── */
.sa-size-mismatch { cursor: help; }
.sa-variant-history-wrap { position: relative; display: inline-flex; }
.sa-variant-history {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 0 8px; font-variant-numeric: tabular-nums;
}
.sa-variant-history[disabled] { opacity: .6; cursor: default; }
.sa-hist-count { font-size: 11px; font-weight: 700; color: var(--fg-3); }
/* position:fixed (set inline from the button's rect) so the overflow:hidden card/gallery
   never clips it; these are the look, not the placement. */
.sa-versions-pop {
  z-index: var(--z-dropdown, 100);
  width: 246px; max-width: calc(100vw - 16px);
  background: var(--bg-surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg, 12px); box-shadow: var(--shadow-lg);
  padding: 8px;
}
.sa-versions-hd {
  margin: 2px 4px 8px; font-size: 11px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: var(--fg-3);
}
.sa-versions-empty { display: flex; align-items: center; gap: 6px; padding: 8px 4px; font-size: 12px; color: var(--fg-3); }
.sa-ver-row { display: flex; align-items: center; gap: 9px; padding: 6px; border-radius: 9px; }
.sa-ver-row + .sa-ver-row { margin-top: 2px; }
.sa-ver-row.cur { background: var(--bg-sunken); }
.sa-ver-thumb {
  width: 34px; height: 34px; border-radius: 6px; flex: none; object-fit: cover;
  border: 1px solid var(--border-default); background: var(--bg-sunken); display: block;
}
.sa-ver-meta { min-width: 0; flex: 1; }
.sa-ver-title { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--fg-1); }
.sa-ver-curtag {
  font-size: 9px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  color: var(--primary-700); background: var(--primary-50); border-radius: 999px; padding: 1px 7px;
}
.sa-ver-sub {
  font-size: 10.5px; color: var(--fg-3); font-family: var(--font-mono, monospace);
  margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sa-ver-revert {
  flex: none; height: 26px; padding: 0 10px; font: inherit; font-size: 11.5px; font-weight: 700;
  border: 1px solid var(--border-default); border-radius: 7px;
  background: var(--bg-surface); color: var(--fg-1); cursor: pointer;
}
.sa-ver-revert:hover { border-color: var(--primary-500); color: var(--primary-700); background: var(--primary-50); }
.sa-versions-foot { margin: 8px 4px 2px; font-size: 10.5px; color: var(--fg-4); }
.sa-variant-actions .btn-secondary.danger:hover:not(:disabled) { color: var(--danger-600, #dc2626); border-color: var(--danger-400, #dc2626); }
/* Per-variant Delete button: spinner overlay while the delete + refresh is in flight.
   The label stays in place (visibility:hidden) so the button keeps its size. */
.sa-variant-delete { position: relative; }
.sa-variant-delete.deleting { cursor: default; }
.sa-variant-delete.deleting .sa-variant-delete-label { visibility: hidden; }
.sa-variant-delete-spinner {
  position: absolute; inset: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.sa-regen-box { padding: 0 10px 8px; display: flex; flex-direction: column; gap: 6px; }
.sa-regen-prompt {
  width: 100%; resize: vertical; font: inherit; font-size: 12px; padding: 6px 8px;
  border: 1px solid var(--border-default); border-radius: 6px; background: var(--bg-surface); color: var(--fg-1);
}
.sa-regen-actions { display: flex; gap: 6px; }
.sa-regen-actions .btn-primary, .sa-regen-actions .btn-secondary { height: 28px; padding: 0 10px; font-size: 12px; }

/* Per-ad studio card (two-stage selection -> generate) */
.sa-studio-card {
  border: 1px solid var(--border-subtle); border-radius: 10px;
  background: var(--bg-surface); padding: 12px 14px; margin-bottom: 10px;
}
.sa-studio-head { display: flex; align-items: center; gap: 10px; }
.sa-studio-brand { font-weight: 600; font-size: 13px; color: var(--fg-1); }
.sa-studio-score { font-size: 11px; color: var(--fg-3); }
.sa-studio-status { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--fg-3); }
.sa-studio-status.failed { color: #e5484d; }
.sa-studio-spacer { flex: 1; }
.sa-studio-controls { display: flex; align-items: center; gap: 12px; margin: 10px 0 4px; flex-wrap: wrap; }
.sa-studio-variants { display: inline-flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 600; color: var(--fg-2); }
.sa-studio-variants input[type="range"] { width: 160px; accent-color: var(--primary-500); }
.sa-studio-variants-n { min-width: 20px; text-align: center; font-family: var(--font-mono, inherit); font-weight: 700; color: var(--fg-1); }
.sa-size-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.sa-size-seg { display: inline-flex; flex: none; border: 1px solid var(--border-default); border-radius: 8px; overflow: hidden; }
.sa-size-seg-btn { background: var(--bg-surface); border: none; border-right: 1px solid var(--border-subtle); padding: 6px 11px; font-size: 12px; font-weight: 600; color: var(--fg-2); cursor: pointer; font-variant-numeric: tabular-nums; }
.sa-size-seg-btn:last-child { border-right: none; }
.sa-size-seg-btn.active { background: var(--primary-500); color: #fff; }
.sa-size-seg-btn:disabled { opacity: .55; cursor: default; }
.sa-studio-error {
  margin: 8px 0; padding: 6px 8px; font-size: 12px;
  color: #b42318; background: #fef3f2; border: 1px solid #fecdca; border-radius: 6px;
}
/* ~2-line "chat" instructions box that sits next to the variants slider. */
.sa-studio-instr { flex: 1 1 240px; width: auto; resize: vertical; min-height: 40px; max-height: 96px; }
.sa-meta-upload { margin-left: auto; width: 26px; height: 26px; }
/* M-of-N variant pick tick (overlay, top-right so it clears the keeper badge). */
.sa-variant-pick {
  position: absolute; top: 8px; right: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.92); border-radius: 6px; padding: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18); cursor: pointer;
}
.sa-variant-pick input { margin: 0; cursor: pointer; width: 15px; height: 15px; }
/* History creative-select tick sits top-LEFT, matching the researched-ad checkbox (.creative-cbx). */
.sa-variant-pick.sa-pick-left { left: 8px; right: auto; }
.sa-variant-card.picked {
  border-color: var(--primary-500, #3b82f6);
  box-shadow: 0 0 0 2px var(--primary-500, #3b82f6) inset;
}

.sa-empty { padding: 18px 4px; color: var(--fg-3); font-size: 13px; }

/* run history */
.sa-history { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.sa-history-row { border: 1px solid var(--border-subtle); border-radius: 10px; overflow: hidden; }
.sa-history-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  cursor: pointer; font-size: 13px;
}
.sa-history-head:hover { background: var(--bg-hover); }
.sa-history-keyword { font-weight: 600; color: var(--fg-1); }
.sa-history-brand { color: var(--primary-700); font-size: 12px; }
.sa-history-dim { color: var(--fg-3); font-size: 12px; font-family: var(--font-mono, inherit); }
.sa-history-spacer { flex: 1; }
.sa-history-chevron { display: inline-flex; color: var(--fg-3); transition: transform 0.2s ease; }
.sa-history-chevron.up { transform: rotate(180deg); }
/* Collapsible section headers (Selected for Remodelling + History).
   Two toggle affordances share one handler: a leading disclosure caret on the
   title, and a right-aligned "Show N / Hide" pill that names the hidden count. */
.sa-sec-toggle {
  cursor: pointer; user-select: none;
  display: inline-flex; align-items: center; gap: 6px;
}
.sa-sec-toggle:hover .sa-sec-caret { color: var(--primary-600); }
.sa-sec-toggle:focus-visible,
.sa-sec-pill:focus-visible { outline: 2px solid var(--primary-500); outline-offset: 2px; border-radius: 6px; }
.sa-sec-caret {
  display: inline-flex; color: var(--primary-600);
  transition: transform 0.2s ease; flex-shrink: 0;
}
.sa-sec-caret.open { transform: rotate(180deg); }
.sa-sec-pill {
  display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0;
  background: var(--bg-surface); color: var(--primary-700);
  border: 1px solid var(--primary-500); border-radius: 999px;
  padding: 3px 11px; font-family: var(--font-sans); font-size: 11px; font-weight: 600;
  line-height: 1.5; cursor: pointer; transition: background 0.15s ease;
}
.sa-sec-pill:hover { background: var(--primary-50); }
.sa-sec-pill-caret { display: inline-flex; transition: transform 0.2s ease; }
.sa-sec-pill-caret.open { transform: rotate(180deg); }
/* History date filter, relocated from the header into the expanded body. */
.sa-gallery-filter-body { margin: 2px 14px 12px; }
.sa-history-body { padding: 0 12px 12px; }
.icon-btn.danger:hover { color: #e5484d; }

.sa-badge {
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--bg-sunken); color: var(--fg-3); text-transform: capitalize;
}
.sa-badge.ok { background: #e6f6ec; color: #137333; }
.sa-badge.err { background: #fde8e8; color: #b3261e; }
.sa-badge.warn { background: #fff4e5; color: #9a6700; }
.sa-badge.run { background: var(--primary-50); color: var(--primary-700); }

/* full-size lightbox */
.sa-lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.82);
  display: flex; align-items: center; justify-content: center; padding: 32px;
}
.sa-lightbox img { max-width: 92vw; max-height: 88vh; object-fit: contain; border-radius: 8px; cursor: default; }
.sa-lightbox-error {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  color: #fff; font-size: 14px; padding: 40px; text-align: center;
}
.sa-lightbox-close {
  position: absolute; top: 18px; right: 18px;
  background: rgba(255,255,255,0.12); color: #fff; border: 0; border-radius: 8px;
  width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.sa-lightbox-close:hover { background: rgba(255,255,255,0.24); }

.sa-candidates { margin-top: 14px; }
.sa-candidates-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.sa-candidates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  max-height: 320px;
  overflow: auto;
}
.sa-candidate-card {
  border: 1px solid var(--border-default);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-1, #fff);
}
.sa-candidate-thumb { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--bg-2); }
.sa-candidate-thumb-empty {
  width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--fg-4); background: var(--bg-2);
}
.sa-candidate-meta { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 8px 0; font-size: 10px; }
.sa-candidate-platform { text-transform: uppercase; font-weight: 600; color: var(--fg-3); }
.sa-candidate-source.pool { color: var(--primary-600, #2563eb); }
.sa-candidate-source.live { color: var(--fg-4); }
.sa-candidate-score { margin-left: auto; font-weight: 600; }
.sa-candidate-pass { color: #16a34a; font-weight: 600; }
.sa-candidate-copy { padding: 4px 8px 8px; font-size: 11px; color: var(--fg-2); line-height: 1.3; }

@media (max-width: 768px) {
  .sa-gallery { grid-template-columns: 1fr; }
  .sa-form { flex-direction: column; align-items: stretch; }
  .sa-actions { margin-left: 0; }
}

/* ============================== Video Leg ==============================
   Read-only Leg 4 gallery (Phase A). Mirrors the .sa-* conventions:
   panel cards reuse .search-card, badges echo .sa-badge colors. */
.video-leg-panel { display: flex; flex-direction: column; gap: 14px; }
.vl-card { margin-top: 0; }
.vl-totals { font-size: 12px; color: var(--fg-3); margin-right: 8px; white-space: nowrap; }
.vl-error {
  margin-top: 10px; padding: 10px 12px; border-radius: 8px; font-size: 13px;
  background: #fde8e8; color: #b3261e;
}
.vl-empty { padding: 18px 4px; text-align: center; }

/* two-column layout: transcript list | detail */
.vl-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 14px; align-items: start; }
.vl-detail { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.vl-list-rows { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.vl-list-row {
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
  padding: 9px 11px; border: 1px solid var(--border-subtle); border-radius: 10px;
  background: transparent; cursor: pointer; text-align: left; width: 100%;
}
.vl-list-row:hover { background: var(--bg-hover); }
.vl-list-row.active { border-color: var(--primary-400, var(--primary-700)); box-shadow: 0 0 0 1px var(--primary-400, var(--primary-700)) inset; }
.vl-list-id {
  font-family: var(--font-mono, monospace); font-size: 12px; font-weight: 600; color: var(--fg-1);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.vl-list-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 11px; }
.vl-dim { color: var(--fg-3); font-size: 12px; }
.vl-mono { font-family: var(--font-mono, monospace); font-size: 12px; }

.vl-badge {
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--bg-sunken); color: var(--fg-3); text-transform: none;
}
.vl-badge.ok { background: #e6f6ec; color: #137333; }
.vl-badge.err { background: #fde8e8; color: #b3261e; }
.vl-badge.warn { background: #fff4e5; color: #9a6700; }
.vl-badge.run { background: var(--primary-50); color: var(--primary-700); }

/* asset sub-tabs */
.vl-subtabs { display: flex; gap: 6px; margin: 10px 0 12px; flex-wrap: wrap; }
.vl-subtab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border-subtle);
  background: transparent; color: var(--fg-2); font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.vl-subtab:hover { background: var(--bg-hover); }
.vl-subtab.on { background: var(--primary-50); border-color: var(--primary-400, var(--primary-700)); color: var(--primary-700); }
.vl-subtab-count { font-size: 11px; font-weight: 600; color: var(--fg-3); }
.vl-subtab.on .vl-subtab-count { color: var(--primary-700); }

/* asset + output grids */
.vl-asset-grid, .vl-output-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px;
}
.vl-output-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.vl-asset-card, .vl-output-card {
  display: flex; flex-direction: column; gap: 8px;
  border: 1px solid var(--border-subtle); border-radius: 10px; padding: 10px;
  background: var(--bg-raised, transparent); min-width: 0;
}
.vl-preview {
  position: relative; width: 100%; aspect-ratio: 9 / 16; border-radius: 8px; overflow: hidden;
  background: var(--bg-sunken); cursor: pointer;
}
.vl-preview img, .vl-preview video { width: 100%; height: 100%; object-fit: cover; display: block; }
.vl-preview-video { cursor: default; }
.vl-preview-missing {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  color: var(--fg-3); font-size: 11.5px; text-align: center; padding: 8px; cursor: default;
}
.vl-expand {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  width: 26px; height: 26px; border: 0; border-radius: 6px; cursor: pointer;
  background: rgba(0,0,0,0.55); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.vl-expand:hover { background: rgba(0,0,0,0.75); }
.vl-asset-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.vl-chip {
  font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 6px;
  background: var(--bg-sunken); color: var(--fg-2); font-family: var(--font-mono, monospace);
}
.vl-chip.on { background: var(--primary-50); color: var(--primary-700); font-family: inherit; font-size: 11px; }
.vl-asset-desc summary { font-size: 11.5px; color: var(--fg-3); cursor: pointer; }
.vl-asset-desc p { font-size: 12px; color: var(--fg-2); margin: 6px 0 0; white-space: pre-wrap; }
.vl-asset-actions { display: flex; align-items: center; gap: 8px; margin-top: auto; }
.vl-filename {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--font-mono, monospace); font-size: 10.5px; color: var(--fg-3);
}
a.vl-download { text-decoration: none; font-size: 11.5px; padding: 4px 10px; flex-shrink: 0; }
.vl-show-all { margin-top: 12px; }

/* collapsible sections (step history, costs) */
.vl-section summary { cursor: pointer; }
.vl-section summary .vl-dim { font-weight: 400; }
.vl-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 12.5px; }
.vl-table th {
  text-align: left; padding: 6px 8px; color: var(--fg-3); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--border-subtle);
}
.vl-table td { padding: 6px 8px; border-bottom: 1px solid var(--border-subtle); color: var(--fg-2); }
.vl-table tr:last-child td { border-bottom: 0; }

.vl-lightbox-video { max-width: 92vw; max-height: 88vh; border-radius: 8px; }

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

/* ========================= Asset Generation (Phase C) =========================
   Builds on the .vl-* primitives; .ag-* covers the selection model + beat
   sections + job strip. */
.ag-preview-text {
  display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-size: 11.5px;
}
.ag-manual-open { display: flex; gap: 8px; margin-top: 14px; }
.ag-manual-open input {
  flex: 1; padding: 8px 11px; border: 1px solid var(--border-subtle); border-radius: 8px;
  font-family: var(--font-mono, monospace); font-size: 12px;
  background: transparent; color: var(--fg-1);
}

.ag-dryrun {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--fg-3); margin-right: 8px; cursor: pointer; white-space: nowrap;
}

.ag-jobstrip {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 10px; padding: 9px 12px;
  background: var(--bg-sunken); border-radius: 8px; font-size: 12.5px;
}
.ag-job-error { color: #b3261e; font-size: 12px; }

/* selection model */
.ag-selectable { position: relative; }
.ag-select-toggle {
  position: absolute; top: 16px; left: 16px; z-index: 3;
  width: 24px; height: 24px; border-radius: 7px; cursor: pointer;
  border: 2px solid rgba(255,255,255,0.85);
  background: rgba(0,0,0,0.35); color: transparent;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.ag-select-toggle.on { background: var(--primary-700); color: #fff; }
.ag-select-toggle:disabled { opacity: 0.45; cursor: not-allowed; }
.ag-deselected .vl-preview { opacity: 0.38; filter: grayscale(0.7); }
.ag-deselected .vl-asset-meta, .ag-deselected .vl-asset-desc { opacity: 0.55; }

.vl-subtab-spacer { flex: 1; }
.ag-subtab-off { text-decoration: line-through; opacity: 0.6; }
.ag-group-toggle.off { color: #9a6700; border-color: #f2c76a; }
.ag-group-off-note {
  margin: 0 0 12px; padding: 9px 12px; border-radius: 8px; font-size: 12.5px;
  background: #fff4e5; color: #9a6700;
}

/* beat sections */
.ag-beat { margin-bottom: 22px; }
.ag-beat-header {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 10px 12px; margin-bottom: 10px;
  background: var(--bg-sunken); border-radius: 10px;
}
.ag-beat-thumb {
  width: 54px; aspect-ratio: 9 / 16; border-radius: 7px; overflow: hidden;
  flex-shrink: 0; cursor: pointer; background: var(--bg-raised, #000);
}
.ag-beat-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ag-beat-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ag-beat-title { font-size: 13px; font-weight: 700; color: var(--fg-1); }
.ag-beat-line { font-size: 12px; color: var(--fg-2); }
.ag-beat-hint { font-size: 11px; }

.ag-chunk { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ag-chunk-text {
  margin: 0; font-size: 11.5px; color: var(--fg-3); line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.ag-chunk-pending .vl-preview { aspect-ratio: 9 / 16; }

/* ================== Asset Generation — design handoff (.agx-*) ==================
   Tokens from docs/design_handoff_video_leg/README.md §7, scoped to the screen
   so the rest of the dashboard is untouched. Fonts map to the app's stacks. */
.agx-screen {
  --agx-brand: #10947F; --agx-brand-hover: #0C7E6C; --agx-brand-soft: #E7F4F1;
  --agx-teal: #10947F; --agx-teal-soft: #E7F4F1;
  --agx-blue: #0060D0; --agx-blue-soft: #E7F0FC;
  --agx-gold: #E69B0D; --agx-gold-soft: #FDF5E4; --agx-gold-deep: #C7820A;
  --agx-ink: #121418; --agx-ink-2: #6D737E; --agx-ink-3: #9AA0AB;
  --agx-border: #E4E6EC; --agx-hover: #EFF0F4; --agx-subtle: #F6F7F9; --agx-card: #FFFFFF;
  --agx-success-fg: #0C7E6C; --agx-success-bg: #E7F4F1;
  --agx-warn-fg: #B3760A; --agx-warn-bg: #FDF5E4;
  --agx-danger-fg: #C0392F; --agx-danger-bg: #FBEAE8;
  --agx-info-fg: #0051B0; --agx-info-bg: #E7F0FC;
  color: var(--agx-ink);
}
.agx-pagehead { margin-bottom: 18px; }
.agx-pagehead h2 { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.agx-pagehead p { font-size: 13px; color: var(--agx-ink-2); margin: 0; max-width: 640px; }
.agx-row { display: flex; align-items: center; }
.agx-col { display: flex; flex-direction: column; }
.agx-sub { font-size: 12px; color: var(--agx-ink-2); }
.agx-mono { font-family: var(--font-mono, monospace); font-size: 12px; font-weight: 600; }
.agx-mono-sub { font-family: var(--font-mono, monospace); font-size: 11px; color: var(--agx-ink-3); }
.agx-money { font-family: var(--font-mono, monospace); font-size: 12px; font-weight: 700; color: var(--agx-gold-deep); }

.agx-btn {
  display: inline-flex; align-items: center; gap: 7px; border: 1px solid transparent;
  border-radius: 10px; font-weight: 600; cursor: pointer; transition: all 150ms ease;
  text-decoration: none; font-size: 13px; height: 36px; padding: 0 14px; background: transparent;
}
.agx-btn.sm { height: 30px; padding: 0 11px; font-size: 12.5px; }
.agx-btn.primary { background: var(--agx-brand); color: #fff; }
.agx-btn.primary:hover:not(:disabled) { background: var(--agx-brand-hover); }
.agx-btn.secondary { background: var(--agx-card); color: var(--agx-ink); border-color: var(--agx-border); }
.agx-btn.secondary:hover:not(:disabled) { background: var(--agx-hover); }
.agx-btn.ghost { color: var(--agx-ink-2); }
.agx-btn.ghost:hover:not(:disabled) { background: var(--agx-hover); }
.agx-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.agx-badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600;
  padding: 2px 9px; border-radius: 999px; white-space: nowrap;
}
.agx-badge .agx-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.agx-badge.neutral { background: var(--agx-subtle); color: var(--agx-ink-2); }
.agx-badge.brand { background: var(--agx-brand-soft); color: var(--agx-brand); }
.agx-badge.brand.solid { background: var(--agx-brand); color: #fff; }
.agx-badge.success { background: var(--agx-success-bg); color: var(--agx-success-fg); }
.agx-badge.warning { background: var(--agx-warn-bg); color: var(--agx-warn-fg); }
.agx-badge.danger { background: var(--agx-danger-bg); color: var(--agx-danger-fg); }
.agx-badge.info { background: var(--agx-info-bg); color: var(--agx-info-fg); }

.agx-tag {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  padding: 5px 11px; border-radius: 999px; cursor: pointer; transition: all 150ms ease;
  border: 1px solid var(--agx-border); background: var(--agx-card); color: var(--agx-ink-2);
}
.agx-tag:hover { background: var(--agx-hover); }
.agx-tag.on { background: var(--agx-brand-soft); border-color: var(--agx-brand); color: var(--agx-brand); }

.agx-card { background: var(--agx-card); border: 1px solid var(--agx-border); border-radius: 12px; }
.agx-card-sel { border-color: color-mix(in srgb, var(--agx-brand) 38%, var(--agx-border)); }

.agx-check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; font-weight: 600; }
.agx-check input { accent-color: var(--agx-brand); width: 15px; height: 15px; cursor: pointer; }
.agx-check.disabled { opacity: 0.5; cursor: not-allowed; }
.agx-check.disabled input { cursor: not-allowed; }

.agx-seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--agx-subtle); border: 1px solid var(--agx-border); border-radius: 10px; }
.agx-seg-opt {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 13px; border: 0;
  cursor: pointer; border-radius: 7px; font-size: 12.5px; font-weight: 600;
  background: transparent; color: var(--agx-ink-2); transition: all 150ms ease;
}
.agx-seg-opt.on { background: var(--agx-card); color: var(--agx-ink); box-shadow: 0 1px 2px rgba(0,0,0,0.06); }
.agx-seg-lock { color: var(--agx-brand); }

.agx-thumb {
  position: relative; width: 100%; border-radius: 12px; overflow: hidden; flex: none;
  background: linear-gradient(160deg, #2A2E37, #14161B); border: 1px solid var(--agx-border);
  display: flex; align-items: center; justify-content: center;
}
.agx-thumb img, .agx-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; cursor: pointer; }
.agx-thumb-glyph { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; }
.agx-thumb-label { position: absolute; left: 10px; bottom: 10px; display: inline-flex; align-items: center; gap: 5px; color: rgba(255,255,255,.9); font-size: 11px; font-weight: 600; cursor: pointer; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.agx-thumb-dur { position: absolute; right: 10px; bottom: 10px; font-family: var(--font-mono, monospace); font-size: 10px; color: #fff; background: rgba(0,0,0,.45); padding: 2px 6px; border-radius: 999px; }
.agx-thumb-badge { position: absolute; right: 10px; top: 10px; }

.agx-lockicon { width: 40px; height: 40px; flex: none; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: var(--agx-success-bg); color: var(--agx-success-fg); }
.agx-script-text { font-size: 14px; font-weight: 500; margin: 0; }
.agx-pick { text-align: left; cursor: pointer; padding: 14px; border-radius: 12px; background: var(--agx-card); border: 1.5px solid var(--agx-border); transition: all 150ms ease; width: 100%; }
.agx-pick:hover { background: var(--agx-hover); }
.agx-pick.on { background: var(--agx-brand-soft); border-color: var(--agx-brand); }
.agx-pick-text { font-size: 13px; color: var(--agx-ink-2); margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agx-manual { display: flex; gap: 8px; margin-top: 4px; }
.agx-manual input { flex: 1; padding: 9px 12px; border: 1px solid var(--agx-border); border-radius: 10px; font-family: var(--font-mono, monospace); font-size: 12px; background: var(--agx-subtle); }
.agx-paste { width: 100%; padding: 10px 12px; border: 1px solid var(--agx-border); border-radius: 10px; font-size: 13px; background: var(--agx-card); resize: vertical; box-sizing: border-box; }
.agx-dropzone-wrap { display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.agx-dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 34px 24px;
  border: 1.5px dashed var(--agx-ink-3); border-radius: 16px; background: var(--agx-subtle);
}
.agx-drop-icon { width: 48px; height: 48px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; background: var(--agx-card); border: 1px solid var(--agx-border); color: var(--agx-ink-2); }

.agx-avatar-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.agx-avatar-pick { display: flex; flex-direction: column; align-items: center; gap: 9px; padding: 18px 10px; }
.agx-avatar-img { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; }
.agx-avatar-img.lg { width: 64px; height: 64px; }
.agx-avatar-fallback { width: 56px; height: 56px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--agx-brand-soft); color: var(--agx-brand); font-weight: 700; text-transform: uppercase; }
.agx-avatar-fallback.lg { width: 64px; height: 64px; }

.agx-subtabs { display: flex; gap: 8px; margin-bottom: 16px; border-bottom: 1px solid var(--agx-border); }
.agx-subtab {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 6px; margin-bottom: -1px; border: 0;
  background: transparent; cursor: pointer; border-bottom: 2px solid transparent;
  color: var(--agx-ink-2); font-weight: 600; font-size: 14px; transition: color 150ms ease;
}
.agx-subtab.on { border-bottom-color: var(--agx-brand); color: var(--agx-brand); }

.agx-asset-grid { display: grid; grid-template-columns: 320px 1fr; }
.agx-asset-left { padding: 16px; border-right: 1px solid var(--agx-hover); }
.agx-asset-right { padding: 16px; display: flex; flex-direction: column; background: var(--agx-subtle); border-radius: 0 12px 12px 0; }
.agx-kind-ic { width: 26px; height: 26px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; }

.agx-jobstrip { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; padding: 9px 12px; background: var(--agx-subtle); border: 1px solid var(--agx-border); border-radius: 10px; font-size: 12.5px; }
.agx-note { padding: 10px 12px; border-radius: 10px; font-size: 12.5px; background: var(--agx-subtle); color: var(--agx-ink-2); border: 1px solid var(--agx-border); }
.agx-note.warn { background: var(--agx-warn-bg); color: var(--agx-warn-fg); border-color: transparent; }
.agx-note.danger { background: var(--agx-danger-bg); color: var(--agx-danger-fg); border-color: transparent; }
.agx-note-inline { color: var(--agx-danger-fg); font-size: 12px; }

@media (max-width: 980px) {
  .agx-asset-grid { grid-template-columns: 1fr; }
  .agx-asset-left { border-right: 0; border-bottom: 1px solid var(--agx-hover); }
  .agx-avatar-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Swipe File (user-facing) — per-acquisition-platform list of saved ads. */
.swipe-file-panel { display: flex; flex-direction: column; gap: 4px; }
.swipe-file-platform-group { margin-top: 8px; }
.swipe-file-view-more .btn-secondary {
  font-size: 12px; padding: 6px 16px; border-radius: 999px;
}
/* Legacy date-group rules retained for backward compatibility. */
.swipe-file-day-group { margin-top: 8px; }
.swipe-file-day-hdr {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px 6px;
  position: sticky; top: 0; z-index: 2;
  background: var(--bg, #fff);
  border-bottom: 1px solid var(--border, rgba(0,0,0,0.08));
}
.swipe-file-day-label {
  font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--fg-2, #555);
}
.swipe-file-day-count {
  font-size: 11px; font-weight: 600; color: var(--fg-3, #888);
  background: rgba(0,0,0,0.05); padding: 1px 8px; border-radius: 999px;
}

/* ── Multi-product selector — standalone top-of-page card ────────────────── */
.sa-product-card {
  display: flex; align-items: center; flex-wrap: wrap; gap: 14px 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-xs);
}
/* ── BYO Ad: upload a competitor ad the crawl never found ──────────────────────
   Trails the product/size controls in the global bar (it is run-scoped like they are)
   and pushes right, so it reads as an action rather than another setting. */
.sa-byo-btn {
  margin-left: auto; flex: none;
  display: inline-flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 15px;
  background: var(--bg-surface); color: var(--primary-700);
  border: 1.5px solid var(--primary-500); border-radius: 8px;
  font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background 120ms var(--ease-standard);
}
.sa-byo-btn:hover { background: var(--primary-50); }
.sa-byo-btn input[type="file"] { display: none; }
/* Disabled while a crawl is live: candidates are rebuilt wholesale during research, so an
   upload made now would be dropped within seconds. The server returns 409 on the same rule. */
.sa-byo-btn.disabled {
  opacity: .45; cursor: not-allowed;
  border-color: var(--border-strong); color: var(--fg-3);
}
.sa-byo-btn.disabled:hover { background: var(--bg-surface); }

/* Origin tag for an uploaded ad — centred on and straddling the studio card's top edge so
   it labels the whole card rather than the Original tile alone. The card itself carries the
   same amber so the whole rectangle reads as "not from the pool" at a glance, not just the
   pill. box-shadow rather than a thicker border, so it gains weight without a 1px reflow. */
.sa-studio-card.byo {
  position: relative;
  margin-top: 26px;
  border-color: var(--accent-500, #e69a0c);
  box-shadow: 0 0 0 1px var(--accent-500, #e69a0c);
  background: color-mix(in srgb, var(--accent-500, #e69a0c) 4%, var(--bg-surface));
}
.sa-byo-tag {
  position: absolute; top: 0; left: 50%; transform: translate(-50%, -50%); z-index: 3;
  display: inline-flex; align-items: center;
  padding: 7px 20px; border-radius: 999px;
  font-size: 13px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  white-space: nowrap;
  background: var(--accent-500, #e69a0c); color: #1f1503;
  border: 2px solid var(--bg-surface);
  box-shadow: 0 3px 12px rgba(10, 14, 20, .28);
}

.sa-product-card-info { min-width: 150px; }
.sa-product-card-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 13.5px; font-weight: 700; letter-spacing: -.01em;
}
.sa-product-dot { width: 8px; height: 8px; border-radius: 999px; background: #7A3FB0; flex: none; }
.sa-product-card-sub { font-size: 11.5px; color: var(--fg-3, #98A1AD); margin-top: 2px; }
.sa-product-tiles { display: flex; flex-wrap: wrap; gap: 10px; }
.sa-product-tile {
  position: relative;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 8px 14px 8px 8px;
  border-radius: 11px;
  border: 1.5px solid var(--border-default);
  background: transparent;
  color: var(--fg-2, inherit);
  font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: border-color .12s, background .12s, box-shadow .12s;
}
.sa-product-tile:hover { border-color: var(--border-strong, var(--border-default)); color: var(--fg, inherit); }
.sa-product-tile.active {
  border-color: var(--accent, #0FB5A8);
  background: color-mix(in srgb, var(--accent, #0FB5A8) 8%, transparent);
  color: var(--fg, inherit);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #0FB5A8) 18%, transparent);
}
.sa-product-tile:disabled { opacity: .45; cursor: not-allowed; }
.sa-product-tile-frame {
  width: 34px; height: 42px; border-radius: 7px; overflow: hidden; flex: none;
  border: 1px solid rgba(0,0,0,.15);
  display: inline-flex; align-items: center; justify-content: center;
}
.sa-product-thumb { width: 100%; height: 100%; object-fit: cover; display: block; background: #fff; }
.sa-product-tile-name { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; }
.sa-product-tile-default {
  font-size: 9.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--fg-3, #98A1AD);
}
.sa-product-tile-check {
  position: absolute; top: -7px; right: -7px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent, #0FB5A8); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.sa-studio-product { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.sa-studio-product > span:first-child { font-size: 10.5px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; opacity: .7; }
.sa-studio-product select { font: inherit; font-size: 12.5px; padding: 4px 6px; border-radius: 7px; border: 1px solid var(--border-default, rgba(127,127,127,.3)); background: transparent; color: inherit; }
.sa-studio-product-thumb {
  width: 20px; height: 24px; object-fit: contain; border-radius: 3px; flex: none;
  background: #fff; border: 1px solid var(--border-default, rgba(127,127,127,.25));
}
.sa-product-batch { font-size: 10.5px; opacity: .65; white-space: nowrap; }

/* ── "Product and their gifts" — per-ad references tray (option D) ───────── */
.sa-refs-handle {
  display: flex; align-items: center; gap: 8px; width: 100%; margin-top: 10px;
  border: 1px solid var(--border-default, rgba(127,127,127,.25));
  background: var(--bg-inset, rgba(127,127,127,.06));
  border-radius: 9px; padding: 8px 12px;
  font: inherit; font-size: 12px; font-weight: 650; color: var(--fg-2, inherit);
  cursor: pointer;
}
.sa-refs-handle:hover { color: var(--fg, inherit); border-color: var(--border-strong, rgba(127,127,127,.4)); }
.sa-refs-car { display: inline-flex; transition: transform .18s; }
.sa-refs-car.open { transform: rotate(180deg); }
.sa-refs-hint { margin-left: auto; font-weight: 400; color: var(--fg-3, #98A1AD); font-size: 11.5px; }
.sa-refs-tray {
  margin-top: 10px; border: 1.5px dashed var(--accent, #0FB5A8); border-radius: 12px;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--accent, #0FB5A8) 4%, transparent);
}
.sa-refs-hd { display: flex; align-items: baseline; gap: 9px; font-size: 12.5px; font-weight: 700; color: var(--accent, #0FB5A8); }
.sa-refs-cap { margin-left: auto; font-size: 11px; font-weight: 400; color: var(--fg-3, #98A1AD); }
.sa-refs-sub { font-size: 12px; color: var(--fg-2, inherit); margin: 4px 0 11px; max-width: 560px; }
.sa-refs-row { display: flex; flex-wrap: wrap; gap: 9px; align-items: stretch; }
.sa-ref-chip {
  display: inline-flex; align-items: center; gap: 9px;
  background: var(--bg-surface, transparent); border: 1px solid var(--border-default, rgba(127,127,127,.25));
  border-radius: 10px; padding: 7px 9px;
}
.sa-ref-thumb { width: 34px; height: 40px; object-fit: cover; border-radius: 6px; background: #fff; flex: none; }
.sa-ref-meta { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.sa-ref-name { font-size: 11.5px; font-weight: 600; font-family: var(--font-mono, ui-monospace, monospace); max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sa-ref-meta select { font: inherit; font-size: 10.5px; color: var(--fg-2, inherit); background: transparent; border: 1px solid var(--border-default, rgba(127,127,127,.3)); border-radius: 5px; padding: 1px 4px; }
.sa-ref-x { border: 0; background: transparent; color: var(--fg-3, #98A1AD); font-size: 15px; cursor: pointer; padding: 2px 4px; }
.sa-ref-x:hover { color: #C24A16; }
.sa-ref-add {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-width: 120px; border: 1.5px dashed var(--border-strong, rgba(127,127,127,.4));
  border-radius: 10px; padding: 10px 12px;
  font-size: 11.5px; font-weight: 600; color: var(--fg-3, #98A1AD); cursor: pointer;
}
.sa-ref-add:hover { color: var(--accent, #0FB5A8); border-color: var(--accent, #0FB5A8); }
.sa-ref-add.busy { opacity: .6; cursor: progress; }
.sa-ref-add-plus { font-size: 17px; line-height: 1; }
.sa-refs-capmsg { align-self: center; font-size: 11px; color: #C24A16; }

/* ── tray v2: Products / Their gifts sections ────────────────────────────── */
.sa-refs-sec-hd {
  font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--fg-2, inherit); margin: 12px 0 7px;
}
.sa-refs-sec-hd.gifts { color: var(--fg-3, #98A1AD); }
.sa-refs-cat-tile {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 6px; border-radius: 10px;
  border: 1.5px solid var(--border-default, rgba(127,127,127,.25));
  background: var(--bg-surface, transparent); color: var(--fg-2, inherit);
  font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
}
.sa-refs-cat-tile:hover { border-color: var(--border-strong, rgba(127,127,127,.4)); color: var(--fg, inherit); }
.sa-refs-cat-tile.active {
  border-color: var(--accent, #0FB5A8);
  background: color-mix(in srgb, var(--accent, #0FB5A8) 8%, transparent);
  color: var(--fg, inherit);
}
.sa-refs-cat-tile:disabled { opacity: .45; cursor: not-allowed; }
.sa-refs-cat-thumb { width: 26px; height: 32px; object-fit: cover; border-radius: 5px; background: #fff; border: 1px solid rgba(0,0,0,.12); }
.sa-refs-cat-check {
  position: absolute; top: -6px; right: -6px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent, #0FB5A8); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.sa-ref-chip.hero { border-color: var(--accent, #0FB5A8); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent, #0FB5A8) 18%, transparent); }
.sa-ref-hero-toggle {
  border: 0; background: transparent; padding: 0; text-align: left; cursor: pointer;
  font: inherit; font-size: 10.5px; font-weight: 650; color: var(--fg-3, #98A1AD);
}
.sa-ref-hero-toggle:hover { color: var(--accent, #0FB5A8); }
.sa-ref-hero-toggle.on { color: var(--accent, #0FB5A8); }
.sa-ref-hero-toggle:disabled { cursor: not-allowed; opacity: .6; }
.sa-ref-gift-tag { font-size: 10.5px; color: var(--fg-3, #98A1AD); }
.sa-ref-add.disabled { opacity: .5; cursor: not-allowed; }
.sa-ref-add.disabled:hover { color: var(--fg-3, #98A1AD); border-color: var(--border-strong, rgba(127,127,127,.4)); }
.sa-ref-add-soon { font-size: 9.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-3, #98A1AD); }

.sa-ref-dormant { font-size: 9.5px; color: var(--fg-3, #98A1AD); font-style: italic; }

.sa-refs-status {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: 10px; padding: 2px 9px 2px 3px;
  border: 1px solid var(--border-default, rgba(127,127,127,.25));
  border-radius: 999px;
  font-size: 11.5px; font-weight: 600; color: var(--fg, inherit);
  background: var(--bg-surface, transparent);
}
.sa-refs-status-thumb { width: 16px; height: 20px; object-fit: cover; border-radius: 3px; background: #fff; }
.sa-refs-status.gifts { padding: 2px 9px; color: var(--fg-2, inherit); }
.sa-refs-status.gifts.none { color: var(--fg-3, #98A1AD); font-weight: 500; border-style: dashed; }
