/* Agency Google tab (Actions table, toolbar, inspector). Loaded after style.css. */
/* #camp-panel / #google-tools-backdrop are Google-only ids that JS reparents to <body>. */

#google-actions {
  --g-ctl-h: var(--ctl-h-sm);
  --g-row-h: var(--table-row-h);
  --g-head-h: var(--table-head-h);
  --g-radius: 10px;
  --g-line: var(--border-subtle);
  --g-hover: color-mix(in srgb, var(--surface-2) 70%, transparent);
}

#google-actions #actions-error:empty {
  display: none;
}

/* ── Toolbar ─────────────────────────────────────────────────────────────── */

#google-actions #google-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: 0 0 12px;
  padding: 0;
  background: var(--bg);
  border: none;
  border-radius: 0;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  z-index: 20;
}

#google-actions #g-nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--g-ctl-h);
  height: var(--g-ctl-h);
  min-height: 0;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  transition: color 0.12s ease, background-color 0.12s ease, border-color 0.12s ease;
}
#google-actions #g-nav-toggle:hover {
  color: var(--text);
  background: var(--surface-2);
}
#google-actions #g-nav-toggle[aria-expanded="true"] {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}
#google-actions #g-nav-toggle:focus-visible,
#google-actions .google-level-tabs .level-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Level tabs as a segmented control */
#google-actions .google-level-tabs {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 2px;
  height: var(--g-ctl-h);
  box-sizing: border-box;
  margin: 0;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  overflow: visible;
}
#google-actions .google-level-tabs .level-tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  height: 26px;
  min-height: 0;
  margin: 0;
  padding: 0 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  transition: color 0.12s ease, background-color 0.12s ease;
}
#google-actions .google-level-tabs .level-tab:hover {
  color: var(--text);
  background: var(--g-hover);
}
#google-actions .google-level-tabs .level-tab.active {
  color: var(--text);
  background: var(--surface-2);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.35),
    inset 0 0 0 1px color-mix(in srgb, var(--border) 85%, transparent);
}

/* Breadcrumb (Ad groups / Keywords / Ads levels) */
#google-actions #google-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 0.8125rem;
}
#google-actions #google-breadcrumb:empty {
  display: none;
}
#google-actions #google-breadcrumb .crumb {
  max-width: 18rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}
#google-actions #google-breadcrumb .crumb.current {
  color: var(--text);
  font-weight: 500;
}
#google-actions #google-breadcrumb .sep {
  color: color-mix(in srgb, var(--muted) 60%, transparent);
}

/* Right group: count, search, filters */
#google-actions #google-toolbar .ads-mgr-toolbar-right {
  gap: 8px;
  margin-left: auto;
}
#google-actions #camp-count {
  margin-right: 4px;
  color: var(--muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
#google-actions #google-filter-q,
#google-actions #google-filter-channel,
#google-actions #google-filter-status {
  height: var(--g-ctl-h);
  box-sizing: border-box;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: var(--surface);
  color: var(--text);
  font-size: 0.8125rem;
  line-height: 1;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
#google-actions #google-filter-q {
  flex: 0 1 13.5rem;
  width: 13.5rem;
  min-width: 9rem;
  max-width: none;
  padding: 0 10px 0 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 16 16' fill='none' stroke='%238b93a7' stroke-width='1.6' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='4.75'/%3E%3Cpath d='M10.5 10.5 14 14'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
}
#google-actions #google-filter-q::placeholder {
  color: var(--muted);
}
#google-actions #google-filter-channel,
#google-actions #google-filter-status {
  width: auto;
  padding: 0 28px 0 10px;
  -webkit-appearance: 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 10 10' fill='none' stroke='%238b93a7' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 3.75 5 6.75 8 3.75'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
#google-actions #google-filter-q:hover,
#google-actions #google-filter-channel:hover,
#google-actions #google-filter-status:hover {
  border-color: color-mix(in srgb, var(--muted) 45%, var(--border));
}
#google-actions #google-filter-q:focus,
#google-actions #google-filter-channel:focus,
#google-actions #google-filter-status:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

/* Quiet context lines between toolbar and table */
#google-actions #g-structure-status,
#google-actions #g-structure-meta {
  margin: -4px 0 10px;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
#google-actions #g-structure-status:empty,
#google-actions #g-structure-meta[hidden],
#google-actions[data-g-level="campaigns"] #g-structure-status {
  display: none;
}

/* ── Table ───────────────────────────────────────────────────────────────── */

#google-actions .google-mgr-main {
  gap: 12px;
}
#google-actions .google-mgr-layout .ads-mgr-table-wrap {
  padding: 0;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--g-radius);
  background: var(--surface);
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
#google-actions .mgr-table.am-table {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8125rem;
}

/* Default widths for the server-rendered header (JS sets the same values inline). */
#google-actions #google-main-head th[data-col-key="status"] { width: 104px; }
#google-actions #google-main-head th[data-col-key="budget"] { width: 112px; }
#google-actions #google-main-head th[data-col-key="spend"] { width: 100px; }
#google-actions #google-main-head th[data-col-key="clicks"] { width: 76px; }
#google-actions #google-main-head th[data-col-key="impressions"] { width: 84px; }
#google-actions #google-main-head th[data-col-key="ctr"] { width: 76px; }
#google-actions #google-main-head th[data-col-key="avg_cpc"] { width: 96px; }
#google-actions #google-main-head th[data-col-key="conversions"] { width: 76px; }
#google-actions #google-main-head th[data-col-key="max_cpc"] { width: 100px; }
#google-actions #google-main-head th[data-col-key="match"] { width: 120px; }
#google-actions #google-main-head th[data-col-key="campaign"] { width: 260px; }
#google-actions #google-main-head th[data-col-key="adgroup"] { width: 240px; }
#google-actions #google-main-head th[data-col-key="final_url"] { width: 300px; }

#google-actions .mgr-table.am-table thead th {
  height: var(--g-head-h);
  box-sizing: border-box;
  padding: 0 12px;
  vertical-align: middle;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}
#google-actions .mgr-table.am-table thead th:first-child {
  border-top-left-radius: calc(var(--g-radius) - 1px);
}
#google-actions .mgr-table.am-table thead th:last-child {
  border-top-right-radius: calc(var(--g-radius) - 1px);
}
#google-actions .mgr-table.am-table thead th .am-col-label {
  padding-right: 4px;
}
#google-actions .mgr-table.am-table thead th.am-col-metric .am-col-label {
  padding-right: 0;
}

#google-actions .mgr-table.am-table tbody td {
  height: var(--g-row-h);
  box-sizing: border-box;
  padding: 0 12px;
  vertical-align: middle;
  border-bottom: 1px solid var(--g-line);
  color: var(--text);
  font-size: 0.8125rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#google-actions .mgr-table.am-table tbody tr:last-child td {
  border-bottom: none;
}
#google-actions .mgr-table.am-table tbody td.muted {
  color: var(--muted);
}
#google-actions .mgr-table.am-table th.am-col-metric,
#google-actions .mgr-table.am-table td.am-col-metric {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Name column: flexible, one line, never forced to a max */
#google-actions .mgr-table.am-table td.am-cell-name,
#google-actions .mgr-table.am-table td.camp-name {
  min-width: 0;
  max-width: none;
  font-weight: 500;
}
#google-actions .mgr-table.am-table tbody tr.row-active td.am-cell-name,
#google-actions .mgr-table.am-table tbody tr.row-active td.camp-name,
#google-actions .mgr-table.am-table tbody tr.row-active td:first-child {
  font-weight: 500;
}
#google-actions .camp-name-cell {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
  min-width: 0;
}
#google-actions .camp-name-cell .camp-name-text {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#google-actions td.g-cell-url {
  font-variant-numeric: normal;
}

/* Channel badge: quiet outline tag */
#google-actions .google-channel-badge {
  flex: 0 0 auto;
  margin: 0;
}

/* Status pill: fixed height, dot + label */
#google-actions .mgr-table.am-table .am-status {
  gap: 6px;
  height: 22px;
  padding: 0 9px 0 8px;
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1;
}
#google-actions .mgr-table.am-table .am-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* Row states */
#google-actions .mgr-table.am-table tbody tr.am-row:hover td,
#google-actions .mgr-table.am-table tbody tr.camp-row:hover td,
#google-actions .mgr-table.am-table tbody tr.adset-row:hover td {
  background: var(--row-hover);
}
#google-actions .mgr-table.am-table tbody tr.am-row-selected,
#google-actions .mgr-table.am-table tbody tr.camp-row.is-selected,
#google-actions .mgr-table.am-table tbody tr.adset-row.is-selected {
  box-shadow: none;
}
#google-actions .mgr-table.am-table tbody tr.am-row-selected td,
#google-actions .mgr-table.am-table tbody tr.is-selected td {
  background: var(--row-selected);
}
#google-actions .mgr-table.am-table tbody tr.am-row-selected td:first-child,
#google-actions .mgr-table.am-table tbody tr.is-selected td:first-child {
  box-shadow: inset 2px 0 0 var(--accent);
}
#google-actions .mgr-table.am-table tbody tr.am-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
#google-actions .mgr-table.am-table th.am-col-pin-edge,
#google-actions .mgr-table.am-table td.am-col-pin-edge {
  box-shadow: none;
}

/* Resize grip: only visible while hovering the header */
#google-actions .mgr-table.am-table thead th .am-col-resize,
#google-actions .mgr-table.am-table thead th .am-col-resize:hover {
  background: transparent;
}
#google-actions .mgr-table.am-table thead th .am-col-resize::after {
  width: 2px;
  margin-left: -1px;
  background: transparent;
  box-shadow: none;
}
#google-actions .mgr-table.am-table thead th:hover .am-col-resize::after {
  width: 2px;
  margin-left: -1px;
  background: color-mix(in srgb, var(--text) 22%, transparent);
  box-shadow: none;
}
#google-actions .mgr-table.am-table thead th .am-col-resize:hover::after,
body.am-col-resizing #google-actions .mgr-table.am-table thead th .am-col-resize::after {
  background: var(--accent);
}

/* Messages and empty states spanning the whole row */
#google-actions .mgr-table.am-table tbody td[colspan] {
  height: auto;
  padding: 16px;
  white-space: normal;
  color: var(--muted);
}
#google-actions .google-empty-filter {
  padding: 4px 0;
}

/* Failed load: plain message + Retry, distinct from an empty result (also used on the Meta table) */
.google-load-error {
  padding: 4px 0;
  white-space: normal;
}
.google-load-error p {
  margin: 0 0 0.5rem;
  color: var(--text);
}
.google-load-error .muted {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.85em;
}
.hub-error-details {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.hub-error-details summary {
  cursor: pointer;
  display: inline;
}
.hub-error-details pre {
  max-height: 12rem;
  overflow: auto;
  margin: 0.35rem 0 0;
  padding: 0.5rem;
  border-radius: 6px;
  background: var(--surface-2);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Skeleton rows match real row height so nothing jumps when data lands */
#google-actions .mgr-table.am-table tbody tr.skel-row td {
  height: var(--g-row-h);
  padding: 0 12px;
  border-bottom: 1px solid var(--g-line);
}
#google-actions .mgr-table.am-table tbody tr.skel-row:last-child td {
  border-bottom: none;
}
#google-actions .mgr-table.am-table tbody tr.skel-row .skel-bar {
  height: 10px;
  width: 62%;
  border-radius: 5px;
}
#google-actions .mgr-table.am-table tbody tr.skel-row:nth-child(2) .skel-bar { width: 48%; }
#google-actions .mgr-table.am-table tbody tr.skel-row:nth-child(3) .skel-bar { width: 55%; }

/* Search preview (Ads level) */
#google-actions .google-ad-preview-panel {
  max-width: 40rem;
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--g-radius);
  background: var(--surface);
}
#google-actions .google-ad-preview-panel .panel-title {
  margin: 0 0 4px;
  font-size: 0.875rem;
  font-weight: 600;
}
#google-actions .google-ad-preview-panel #google-ad-preview-hint {
  margin: 0 0 10px;
}
/* Preview renders on a light results page so Google's own colours read correctly */
#google-actions #google-rsa-preview.search-preview-card {
  padding: 14px 16px;
  border: 1px solid #dadce0;
  border-radius: 8px;
  background: #fff;
  color: #202124;
}
#google-actions #google-rsa-preview .search-preview-title {
  color: #1a0dab;
  font-size: 1.125rem;
  line-height: 1.3;
}
#google-actions #google-rsa-preview .search-preview-url {
  color: #202124;
}
#google-actions #google-rsa-preview .search-preview-desc {
  color: #4d5156;
  font-size: 0.84rem;
  line-height: 1.45;
}
#google-actions #google-rsa-preview > p.muted {
  margin: 0;
  color: #5f6368;
}

/* ── Change history (collapsible section) ───────────────────────────────── */

#google-actions #google-activity {
  margin: 12px 0 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--g-radius);
  background: var(--surface);
}
#google-actions #google-activity > summary {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 10px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: calc(var(--g-radius) - 1px);
  font-size: 0.8125rem;
  font-weight: 400;
  letter-spacing: 0;
  cursor: pointer;
  transition: background-color 0.12s ease;
}
#google-actions #google-activity > summary:hover {
  background: var(--g-hover);
}
#google-actions #google-activity > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
#google-actions #google-activity[open] > summary {
  border-bottom: 1px solid var(--g-line);
  border-radius: calc(var(--g-radius) - 1px) calc(var(--g-radius) - 1px) 0 0;
}
#google-actions #google-activity .g-activity-chevron {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  margin: 0 2px 0 1px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}
#google-actions #google-activity[open] .g-activity-chevron {
  transform: translateY(-2px) rotate(45deg);
}
#google-actions #google-activity .platform-activity-title {
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  opacity: 1;
}
#google-actions #google-activity .platform-activity-range {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.8rem;
}
#google-actions #google-activity .g-activity-toggle-hint {
  margin-left: auto;
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.78rem;
}
#google-actions #google-activity .g-activity-toggle-hint::after {
  content: "Show";
}
#google-actions #google-activity[open] .g-activity-toggle-hint::after {
  content: "Hide";
}
#google-actions #google-activity .platform-activity-status {
  margin: 0;
  padding: 10px 14px 0;
  font-size: 0.8rem;
}
#google-actions #google-activity .platform-activity-status:empty {
  display: none;
}
#google-actions #google-activity .platform-activity-list {
  max-height: 16rem;
  margin: 0;
  padding: 4px 14px 10px;
}

/* ── Inspector drawer (reparented to <body> when open) ───────────────────── */

#camp-panel .g-inline-notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 12px 16px 4px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  color: color-mix(in srgb, var(--text) 82%, var(--muted));
  font-size: 0.8rem;
  line-height: 1.45;
}
#camp-panel .g-inline-notice::before {
  content: "i";
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, var(--accent) 70%, transparent);
  color: var(--accent);
  font-size: 0.65rem;
  font-weight: 700;
  font-style: normal;
  line-height: 1;
}
#camp-panel .g-inline-notice[hidden] {
  display: none;
}
#camp-panel .panel-section .g-inline-notice {
  margin: 10px 0 0;
}
#camp-panel .g-inline-notice--danger {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
  background: color-mix(in srgb, var(--danger) 9%, var(--surface));
  color: var(--text);
}
#camp-panel .g-inline-notice--danger::before {
  content: "!";
  border-color: var(--danger);
  color: var(--danger);
}
#panel-budget-error {
  margin: 6px 0 0;
}

/* Push confirm: changes grouped by campaign; campaigns turning on come first in red. */
.hub-confirm-list {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 45vh;
  overflow: auto;
  font-size: 0.88rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.hub-confirm-line {
  padding: 2px 0 2px 0.9rem;
  color: var(--muted);
}
.hub-confirm-line--heading {
  margin-top: 0.55rem;
  padding-left: 0;
  color: var(--text);
  font-weight: 600;
}
.hub-confirm-line--danger {
  margin-bottom: 0.35rem;
  padding: 8px 10px;
  border: 1px solid color-mix(in srgb, var(--danger) 50%, var(--border));
  border-radius: 8px;
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
  color: var(--danger);
  font-weight: 600;
}
#camp-panel .panel-section h3 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}
#camp-panel details.panel-section > summary {
  cursor: pointer;
  padding: 2px 0;
}
#camp-panel .g-panel-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 14px;
  margin: 0;
  padding: 14px 16px 16px;
  border-bottom: 1px solid var(--border);
}
#camp-panel .g-panel-kpis[hidden] {
  display: none;
}
#camp-panel .g-panel-kpi {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
#camp-panel .g-panel-kpi-label {
  font-size: 0.72rem;
  color: var(--muted);
}
#camp-panel .g-panel-kpi-value {
  font-size: 0.98rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
#camp-panel .g-panel-kpi-value .am-status {
  font-size: 0.78rem;
}
#camp-panel .panel-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
#camp-panel .panel-section[hidden] {
  display: none;
}
#camp-panel .panel-section .toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
}
#camp-panel .panel-section .btn {
  margin: 0;
}
#camp-panel .panel-section select,
#camp-panel .panel-section input[type="number"],
#camp-panel .panel-section input.budget-input {
  height: var(--ctl-h);
  min-height: var(--ctl-h);
  margin: 0;
  border-radius: 8px;
  font-size: 0.85rem;
}
#camp-panel .panel-section label.muted {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
}
#camp-panel #st-status,
#camp-panel #neg-status {
  margin: 8px 0 0;
  font-size: 0.8rem;
}
#camp-panel #st-status:empty,
#camp-panel #neg-status:empty {
  display: none;
}
#camp-panel #st-table,
#camp-panel #actions-negatives table {
  width: 100%;
  margin-top: 10px;
  font-size: 0.82rem;
  border-collapse: collapse;
}
#camp-panel #st-table th,
#camp-panel #actions-negatives th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  padding: 6px 6px;
  border-bottom: 1px solid var(--border);
}
#camp-panel #st-table td,
#camp-panel #actions-negatives td {
  padding: 8px 6px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}

/* ── Narrow viewports ────────────────────────────────────────────────────── */

@media (width <= 900px) {
  #google-actions {
    --g-ctl-h: 40px;
    --g-row-h: 48px;
  }
  #google-actions #google-toolbar {
    position: sticky;
    top: 0;
    flex-direction: row;
    align-items: center;
    padding: 8px 0;
  }
  #google-actions .google-level-tabs {
    flex: 1 1 auto;
    width: auto;
    border-bottom: 1px solid var(--border);
    padding: 2px;
  }
  #google-actions .google-level-tabs .level-tab {
    flex: 1 1 auto;
    justify-content: center;
    height: calc(var(--g-ctl-h) - 6px);
    padding: 0 8px;
  }
  #google-actions #google-breadcrumb {
    order: 2;
    width: 100%;
  }
  #google-actions #google-toolbar .ads-mgr-toolbar-right {
    order: 3;
    width: 100%;
    margin-left: 0;
  }
  #google-actions #google-filter-q {
    width: 100%;
    flex: 1 1 auto;
    min-width: 0;
  }
  #google-actions .mgr-table.am-table thead th,
  #google-actions .mgr-table.am-table tbody td {
    padding: 0 10px;
    font-size: 0.8125rem;
  }
}

@media (width <= 640px) {
  #google-actions {
    --g-ctl-h: var(--ctl-h-touch);
  }
  #google-actions .google-level-tabs .level-tab {
    height: auto;
    min-height: 44px;
  }
  /* 16px stops iOS Safari zooming the page when a filter is focused. */
  #google-actions #google-filter-q,
  #google-actions #google-filter-channel,
  #google-actions #google-filter-status {
    font-size: 16px;
  }
}

/* ---------- Google → Searches & blocked words ---------- */
.g-subnav {
  display: flex;
  gap: 0.25rem;
  margin: 0 0 0.75rem;
  border-bottom: 1px solid var(--border);
}
.g-subnav-link {
  padding: 0.55rem 0.9rem;
  color: var(--muted);
  text-decoration: none;
  font-size: var(--fs-base);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.g-subnav-link:hover { color: var(--text); }
.g-subnav-link.active {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--google-blue);
}
.gs { padding-bottom: 5rem; }
.gs-head { display: flex; flex-direction: column; gap: 0.5rem; padding: 0.85rem 1rem; }
.gs-head-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem; }
.gs-field { display: flex; flex-direction: column; gap: 0.2rem; font-size: var(--fs-xs); color: var(--muted); }
.gs-field select { min-width: 14rem; max-width: 100%; }
.gs-ask-ai { margin-left: auto; }
.gs-views { margin: 0; }
.gs-count { color: var(--muted); font-weight: 400; margin-left: 0.15rem; }
.gs-status { margin: 0.6rem 0.1rem; }
.gs-toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; justify-content: space-between; margin-bottom: 0.4rem; }
.gs-toolbar input[type="search"] { max-width: 16rem; }
.gs-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.gs-chip {
  font: inherit;
  font-size: var(--fs-sm);
  padding: 0.3rem 0.7rem;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  min-height: var(--ctl-h-sm);
}
.gs-chip:hover { color: var(--text); }
.gs-chip.active { color: var(--text); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.gs-chip-n { opacity: 0.7; margin-left: 0.2rem; }
.gs-legend { margin: 0 0 0.5rem; }
.gs-help { margin: 0 0 0.6rem; font-size: 0.85rem; }
.gs-help summary { cursor: pointer; font-weight: 600; color: var(--accent, #2563eb); width: fit-content; }
.gs-help ul { margin: 0.4rem 0 0; padding-left: 1.1rem; display: grid; gap: 0.3rem; }
.gs-help .gs-pill { font-size: 0.72rem; }
.gs-pick { display: grid; gap: 0.15rem; max-height: 55vh; overflow: auto; margin: 0.5rem 0 1rem; }
.gs-dialog .gs-pick-row { display: flex; flex-direction: row; justify-content: flex-start; text-align: left; gap: 0.6rem; align-items: center; padding: 0.4rem 0.35rem; margin: 0; border-radius: 6px; cursor: pointer; font-size: 0.9rem; }
.gs-dialog .gs-pick-row input { width: auto; flex: none; margin: 0; }
.gs-pick-row:hover { background: rgba(127, 127, 127, 0.1); }
.gs-pick-head { margin-top: 0.5rem; text-transform: uppercase; letter-spacing: 0.04em; }
.gs-en { font-size: 0.78rem; color: var(--muted, #6b7280); font-style: italic; margin-top: 0.1rem; }
.gs-table-wrap { overflow-x: auto; }
.gs-table td, .gs-table th { vertical-align: middle; }
.gs-col-check { width: 2.25rem; text-align: center; }
.gs-col-check input { width: 18px; height: 18px; margin: 0; cursor: pointer; }
.gs-term { font-weight: 500; overflow-wrap: anywhere; min-width: 12rem; }
.gs-label { min-width: 16rem; }
.gs-reason { color: var(--muted); font-size: var(--fs-sm); }
.gs-one-campaign .gs-col-campaign { display: none; }
.gs-row.is-selected td { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.gs-row--blocked td { opacity: 0.6; }
.gs-empty { text-align: center; padding: 1.5rem; }
.gs-toolbar-right { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.gs-seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--r-pill); padding: 2px; background: var(--surface); }
.gs-seg-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: var(--fs-sm);
  padding: 0.3rem 0.8rem;
  border-radius: var(--r-pill);
  cursor: pointer;
}
.gs-seg-btn.active { background: color-mix(in srgb, var(--accent) 22%, var(--surface)); color: var(--text); font-weight: 600; }
.gs-group td {
  background: var(--surface-2, color-mix(in srgb, var(--text) 4%, var(--surface)));
  border-top: 1px solid var(--border);
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
}
.gs-group .am-col-metric { font-weight: 600; }
.gs-kw--strong { font-weight: 700; font-size: var(--fs-md); }
.gs-match {
  display: inline-block;
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 0.05rem 0.45rem;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  color: var(--muted);
  vertical-align: middle;
}
.gs-match--exact { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.gs-match--phrase { color: var(--text); }
.gs-row--child td.gs-term { padding-left: 1.6rem; position: relative; }
.gs-row--child td.gs-term::before { content: "↳"; position: absolute; left: 0.55rem; color: var(--muted); }
.gs-also { margin-top: 0.15rem; font-weight: 400; }
.gs-col-kw { min-width: 13rem; }
.gs-pill {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.gs-pill--waste { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.gs-pill--check { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.gs-pill--good { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.gs-pill--blocked { color: var(--muted); background: var(--surface-2, var(--surface)); border-color: var(--border); }
.gs-bar {
  position: fixed;
  left: 50%;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: var(--z-dock);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem 0.6rem 1rem;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--r-lg);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  max-width: calc(100vw - 2rem);
}
.gs-bar #gs-bar-text { font-weight: 600; white-space: nowrap; }
.gs-dialog { max-width: min(640px, calc(100vw - 1.5rem)); }
.gs-dialog-card { max-height: calc(100vh - 2rem); overflow: auto; }
.gs-dialog .hub-confirm-body { max-height: none; overflow: visible; flex: none; }
.gs-items { display: flex; flex-direction: column; gap: 0.6rem; }
.gs-item { padding: 0.6rem; border: 1px solid var(--border); border-radius: var(--r-md); }
.gs-item-row { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.gs-item-text { flex: 1 1 14rem; margin: 0; min-height: var(--ctl-h); font-size: var(--fs-input); }
.gs-item-match { flex: 0 1 12rem; }
.gs-item p { margin: 0.35rem 0 0; }
.gs-warn { font-size: var(--fs-sm); }
.gs-warn--danger { color: var(--danger); }
.gs-warn--info { color: var(--muted); }
.gs-where { border: 1px solid var(--border); border-radius: var(--r-md); padding: 0.5rem 0.75rem 0.75rem; margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.gs-where legend { padding: 0 0.3rem; font-size: var(--fs-sm); color: var(--muted); }
.gs-where-opt { display: flex; gap: 0.6rem; align-items: flex-start; cursor: pointer; font-size: var(--fs-sm); }
.gs-where-opt input { margin-top: 0.2rem; width: 18px; height: 18px; flex: none; }
.gs-where-fixed { margin: 0; font-weight: 600; }
.gs-where-ag { display: flex; flex-direction: column; gap: 0.2rem; font-size: var(--fs-xs); color: var(--muted); }
.gs-ack { display: flex; gap: 0.5rem; align-items: flex-start; color: var(--danger); font-size: var(--fs-sm); }
.gs-ack input { width: 18px; height: 18px; margin: 0.1rem 0 0; flex: none; }
.gs-sec { padding: 0.85rem 1rem; margin-bottom: 0.75rem; }
.gs-sec-head { display: flex; justify-content: space-between; gap: 0.75rem; align-items: flex-start; flex-wrap: wrap; margin-bottom: 0.5rem; }
.gs-sec-head h3 { margin: 0; font-size: var(--fs-md); }
.gs-sec-head p { margin: 0.15rem 0 0; }
.gs-negs { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.gs-neg {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.3rem 0.25rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface);
  font-size: var(--fs-sm);
}
.gs-neg--warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.gs-neg-text { font-weight: 500; }
.gs-neg-del {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
}
.gs-neg-del:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }
.gs-history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.gs-hist { display: flex; justify-content: space-between; gap: 0.75rem; align-items: center; padding: 0.7rem 1rem; }
.gs-hist.is-undone { opacity: 0.6; }

@media (width <= 640px) {
  .gs-ask-ai { margin-left: 0; }
  .gs-field, .gs-field select { width: 100%; min-width: 0; }
  .gs-toolbar input[type="search"] { max-width: none; width: 100%; font-size: 16px; }
  .gs-table thead { display: none; }
  .gs-table, .gs-table tbody, .gs-table tr { display: block; width: 100%; }
  .gs-table tr { display: grid; grid-template-columns: 2.25rem 1fr auto; gap: 0.15rem 0.5rem; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--border); }
  .gs-table td { display: block; border: 0; padding: 0; min-width: 0; }
  .gs-table td.gs-col-check { grid-row: span 3; }
  .gs-table td.gs-term, .gs-table td.gs-group-name { grid-column: 2; }
  .gs-table td.gs-col-kw, .gs-table td.gs-label { grid-column: 2 / 4; }
  .gs-table td.am-col-metric { grid-column: 3; grid-row: 1; text-align: right; }
  .gs-table td.am-col-metric ~ td.am-col-metric { display: none; }
  .gs-table td.gs-col-campaign { grid-column: 2 / 4; }
  .gs-table tr.gs-group td { background: transparent; border: 0; padding: 0; }
  .gs-table tr.gs-group { background: var(--surface-2, color-mix(in srgb, var(--text) 4%, var(--surface))); }
  .gs-table tr.gs-row--child { padding-left: 1rem; }
  .gs-toolbar-right { width: 100%; }
  .gs-toolbar-right input[type="search"] { flex: 1 1 10rem; }
  .gs-item-text { flex: 1 1 100%; }
  .gs-item-match { flex: 1 1 0; min-width: 0; }
  .gs-bar {
    left: 0.75rem;
    right: 0.75rem;
    bottom: calc(5rem + env(safe-area-inset-bottom));
    transform: none;
    justify-content: space-between;
  }
}
