/*
 * Apple hierarchy system
 *
 * A disclosure is a quiet spatial control, not a blue text badge. Hierarchy
 * is expressed with proximity, indentation and hairline connectors instead
 * of stacked blue-grey boxes.
 */

:root {
  --ah-ink: #1d1d1f;
  --ah-secondary: #6e6e73;
  --ah-line: rgba(60, 60, 67, .12);
  --ah-soft-line: rgba(60, 60, 67, .075);
  --ah-surface: rgba(255, 255, 255, .82);
  --ah-inset: rgba(246, 246, 248, .76);
  --ah-hover: rgba(118, 118, 128, .08);
  --ah-blue: #007aff;
  --ah-blue-soft: rgba(0, 122, 255, .10);
  --ah-ease: cubic-bezier(.23, 1, .32, 1);
}

/* Compact Apple disclosure control in the plan overview table. */
#app-shell #view .facebook-name-hierarchy-trigger {
  position: relative;
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  flex: 0 0 18px;
  display: inline-grid;
  place-items: center;
  margin: 0;
  padding: 0 !important;
  overflow: visible;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #515154;
  box-shadow: none;
  cursor: pointer;
  transition: color 140ms ease, background-color 140ms ease, transform 100ms var(--ah-ease), box-shadow 140ms ease;
}

#app-shell #view .facebook-name-hierarchy-trigger::after {
  position: absolute;
  inset: -3px;
  border-radius: 8px;
  content: "";
}

#app-shell #view .ad-data-latest-table td.ad-campaign-name-cell {
  vertical-align: middle !important;
}

#app-shell #view .ad-campaign-name-line {
  min-height: 24px;
  align-items: center !important;
  gap: 3px;
  line-height: 16px;
}

#app-shell #view .ad-campaign-name-line > span:first-child,
#app-shell #view .ad-campaign-name-line > .ad-campaign-owner-inline {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  line-height: 18px;
}

#app-shell #view .facebook-name-hierarchy-trigger > i,
#app-shell #view .facebook-adset-expand > i {
  position: relative;
  width: 16px !important;
  height: 16px !important;
  flex: 0 0 16px;
  display: block;
  overflow: hidden;
  border-radius: 999px;
  color: transparent !important;
  font-size: 0 !important;
  transition: color 140ms ease, background-color 140ms ease, transform 180ms var(--ah-ease);
}

#app-shell #view .facebook-name-hierarchy-trigger > i::before,
#app-shell #view .facebook-adset-expand > i::before {
  position: absolute;
  top: 5px;
  left: 4px;
  width: 5px;
  height: 5px;
  border: 0;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  border-radius: .7px;
  color: #515154;
  content: "";
  transform: rotate(-45deg);
  transform-origin: center;
  transition: transform 180ms var(--ah-ease), color 140ms ease;
}

#app-shell #view .facebook-name-hierarchy-trigger[aria-expanded="true"] {
  background: rgba(0, 122, 255, .08);
  color: var(--ah-blue);
}

#app-shell #view .facebook-name-hierarchy-trigger[aria-expanded="true"] > i::before,
#app-shell #view .facebook-adset-expand[aria-expanded="true"] > i::before {
  top: 4px;
  left: 5px;
  color: var(--ah-blue);
  transform: rotate(45deg);
}

#app-shell #view .facebook-name-hierarchy-trigger:focus-visible,
#app-shell #view .facebook-adset-expand:focus-visible {
  outline: 3px solid rgba(0, 122, 255, .22);
  outline-offset: 2px;
}

#app-shell #view .facebook-name-hierarchy-trigger:active {
  transform: scale(.92);
}

/* The expanded plan hierarchy is one inset outline, not nested heavy cards. */
#app-shell #view .facebook-hierarchy-detail-row > td {
  padding: 0 !important;
  border-top-color: rgba(60, 60, 67, .08) !important;
  background: var(--ah-inset) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .72), inset 0 -1px 0 rgba(60, 60, 67, .06);
}

#app-shell #view .facebook-hierarchy-panel {
  min-width: 950px;
  padding: 12px 18px 16px 54px;
  color: var(--ah-ink);
  font-family: "Microsoft YaHei", "微软雅黑", sans-serif;
  text-align: left;
}

#app-shell #view .facebook-hierarchy-note {
  min-height: 26px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 8px;
  color: var(--ah-secondary);
  font-size: 11px;
  line-height: 1.35;
}

#app-shell #view .facebook-hierarchy-note strong {
  flex: 0 0 auto;
  color: #3a3a3c;
  font-size: 12px;
  font-weight: 680;
  letter-spacing: .003em;
}

#app-shell #view :is(.facebook-hierarchy-campaign, .facebook-hierarchy-adset, .facebook-hierarchy-ad) {
  box-sizing: border-box;
  min-height: 48px;
  display: grid;
  grid-template-columns: minmax(280px, 1.4fr) minmax(190px, .8fr) minmax(150px, .62fr) 70px;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border: 1px solid var(--ah-line);
  border-radius: 12px;
  background: var(--ah-surface);
  box-shadow: 0 .5px 1.5px rgba(0, 0, 0, .035), inset 0 .5px 0 rgba(255, 255, 255, .82);
  -webkit-backdrop-filter: blur(16px) saturate(155%);
  backdrop-filter: blur(16px) saturate(155%);
}

#app-shell #view .facebook-hierarchy-campaign {
  border-color: rgba(0, 122, 255, .18);
  background: rgba(255, 255, 255, .88);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .045), inset 3px 0 0 rgba(0, 122, 255, .42), inset 0 .5px 0 rgba(255, 255, 255, .90);
}

#app-shell #view .facebook-hierarchy-list {
  position: relative;
  margin: 8px 0 0 24px;
  padding-left: 16px;
  border-left: 1px solid rgba(60, 60, 67, .15);
}

#app-shell #view .facebook-adset-block {
  position: relative;
  margin: 0 0 7px;
}

#app-shell #view .facebook-adset-block:last-child {
  margin-bottom: 0;
}

#app-shell #view .facebook-adset-block::before {
  position: absolute;
  top: 23px;
  left: -16px;
  width: 16px;
  height: 1px;
  background: rgba(60, 60, 67, .15);
  content: "";
}

#app-shell #view .facebook-hierarchy-adset {
  border-color: var(--ah-soft-line);
  background: rgba(255, 255, 255, .74);
}

#app-shell #view .facebook-adset-expand {
  min-width: 0;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

#app-shell #view .facebook-adset-expand > i {
  background: rgba(118, 118, 128, .075);
  box-shadow: inset 0 .5px 0 rgba(255, 255, 255, .85);
}

#app-shell #view .facebook-adset-expand[aria-expanded="true"] > i {
  background: var(--ah-blue-soft);
}

#app-shell #view .facebook-adset-block.is-expanded .facebook-adset-expand > i {
  transform: none;
}

#app-shell #view .facebook-adset-expand > span {
  min-width: 0;
  flex: 1 1 auto;
}

#app-shell #view :is(.facebook-hierarchy-campaign, .facebook-hierarchy-adset, .facebook-hierarchy-ad) strong,
#app-shell #view :is(.facebook-hierarchy-campaign, .facebook-hierarchy-adset, .facebook-hierarchy-ad) small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#app-shell #view .facebook-ad-list {
  position: relative;
  display: grid;
  gap: 6px;
  margin: 6px 0 0 27px;
  padding-left: 14px;
  border-left: 1px solid rgba(60, 60, 67, .12);
}

#app-shell #view .facebook-hierarchy-ad {
  margin: 0;
  border-color: rgba(60, 60, 67, .065);
  border-radius: 10px;
  background: rgba(255, 255, 255, .62);
  box-shadow: none;
}

#app-shell #view .facebook-level-tag {
  padding: 3px 7px;
  border: 1px solid rgba(60, 60, 67, .07);
  border-radius: 7px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .01em;
}

#app-shell #view .facebook-level-tag.campaign {
  border-color: rgba(0, 122, 255, .10);
  background: rgba(0, 122, 255, .09);
  color: #0068d9;
}

#app-shell #view .facebook-level-tag.adset {
  border-color: rgba(88, 86, 214, .10);
  background: rgba(88, 86, 214, .085);
  color: #4d4ab8;
}

#app-shell #view .facebook-level-tag.ad {
  border-color: rgba(52, 199, 89, .10);
  background: rgba(52, 199, 89, .085);
  color: #217a38;
}

#app-shell #view .facebook-hierarchy-loading,
#app-shell #view .facebook-hierarchy-error {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px 10px 54px;
  border-top: 1px solid var(--ah-soft-line);
  border-bottom: 1px solid var(--ah-soft-line);
  background: var(--ah-inset);
  color: var(--ah-secondary);
}

#app-shell #view .facebook-hierarchy-error {
  color: #b42318;
}

/*
 * Overview hierarchy uses real table rows. Because the child rows live in the
 * same tbody and colgroup as the campaign, every metric remains locked to the
 * global header even after users resize columns.
 */
#app-shell #view .facebook-hierarchy-entity-row > td {
  height: 46px;
  box-sizing: border-box;
  border-top-color: rgba(60, 60, 67, .08) !important;
  color: var(--ah-ink);
  vertical-align: middle;
}

#app-shell #view .facebook-hierarchy-adset-row > td {
  background: rgba(255, 255, 255, .96) !important;
}

#app-shell #view .facebook-hierarchy-ad-row > td {
  background: rgba(255, 255, 255, .96) !important;
}

#app-shell #view .facebook-hierarchy-entity-row:hover > td {
  background: rgba(246, 249, 253, .98) !important;
}

#app-shell #view .facebook-hierarchy-entity-row .ad-campaign-name-cell {
  position: relative;
  padding-block: 5px !important;
  overflow: hidden;
}

#app-shell #view .facebook-hierarchy-name {
  min-width: 0;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
}

#app-shell #view .facebook-adset-expand.facebook-hierarchy-name {
  padding-left: 20px;
  border-radius: 7px;
}

#app-shell #view .facebook-adset-expand.facebook-hierarchy-name > i {
  flex: 0 0 16px;
}

#app-shell #view .facebook-adset-expand.facebook-hierarchy-name > .facebook-level-tag,
#app-shell #view .facebook-hierarchy-name.is-ad > .facebook-level-tag {
  flex: 0 0 auto;
}

#app-shell #view .facebook-adset-expand.facebook-hierarchy-name > .facebook-hierarchy-name-copy,
#app-shell #view .facebook-hierarchy-name.is-ad > .facebook-hierarchy-name-copy {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}

#app-shell #view .facebook-hierarchy-name-copy strong,
#app-shell #view .facebook-hierarchy-name-copy small {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#app-shell #view .facebook-hierarchy-name-copy strong {
  font-size: 11px;
  font-weight: 680;
  line-height: 14px;
}

#app-shell #view .facebook-hierarchy-name-copy small {
  color: var(--ah-secondary);
  font-size: 9px;
  line-height: 12px;
}

#app-shell #view .facebook-hierarchy-ad-row .facebook-hierarchy-name {
  padding-left: 40px;
}

#app-shell #view .facebook-hierarchy-guide {
  position: absolute;
  top: -1px;
  bottom: -1px;
  left: 8px;
  width: 11px;
  pointer-events: none;
}

#app-shell #view .facebook-hierarchy-guide::before,
#app-shell #view .facebook-hierarchy-guide::after {
  position: absolute;
  content: "";
}

#app-shell #view .facebook-hierarchy-guide::before {
  top: 0;
  bottom: 0;
  left: 0;
  border-left: 1px solid rgba(60, 60, 67, .20);
}

#app-shell #view .facebook-hierarchy-guide::after {
  top: 50%;
  left: 0;
  width: 10px;
  border-top: 1px solid rgba(60, 60, 67, .20);
}

#app-shell #view .facebook-hierarchy-entity-row.is-last-sibling .facebook-hierarchy-guide::before {
  bottom: 50%;
}

#app-shell #view .facebook-hierarchy-ad-row .facebook-hierarchy-guide {
  left: 28px;
}

#app-shell #view .facebook-hierarchy-ad-row:not(.parent-is-last) .ad-campaign-name-cell::before {
  position: absolute;
  top: -1px;
  bottom: -1px;
  left: 8px;
  border-left: 1px solid rgba(60, 60, 67, .20);
  content: "";
  pointer-events: none;
}

#app-shell #view .facebook-hierarchy-budget-owner {
  color: var(--ah-secondary);
  font-size: 10px;
  white-space: nowrap;
}

#app-shell #view .facebook-hierarchy-feedback-row > td {
  padding: 0 !important;
  background: rgba(246, 246, 248, .88) !important;
}

#app-shell #view .facebook-hierarchy-feedback-row .facebook-hierarchy-loading,
#app-shell #view .facebook-hierarchy-feedback-row .facebook-hierarchy-error {
  min-height: 42px;
  padding: 8px 16px 8px 54px;
  border: 0;
  background: transparent;
}

#app-shell #view .facebook-hierarchy-feedback-row.is-child-empty .facebook-hierarchy-loading {
  padding-left: 82px;
}

#app-shell #view .facebook-hierarchy-entity-row .table-actions {
  flex-wrap: nowrap;
  justify-content: center;
}

/*
 * Record-table hierarchy toolbar: everything remains on one line. Repeated
 * visible labels are visually hidden, long names ellipsize, and selectors
 * have bounded widths so their menus cannot push the table out of alignment.
 */
#app-shell #view .ad-data-live-controls.is-utm {
  position: relative;
  z-index: 18;
  box-sizing: border-box;
  width: 100%;
  min-width: 980px;
  min-height: 40px;
  display: grid !important;
  grid-template-columns: minmax(150px, 1fr) auto max-content max-content;
  align-items: center;
  gap: 8px;
  padding: 3px 12px;
  overflow: visible;
  border-top: 0;
  border-bottom: 1px solid var(--ah-line);
  background: rgba(255, 255, 255, .86);
  box-shadow: inset 0 .5px 0 rgba(255, 255, 255, .92);
  -webkit-backdrop-filter: blur(18px) saturate(170%);
  backdrop-filter: blur(18px) saturate(170%);
}

#app-shell #view .ad-data-live-controls.is-utm .ad-data-live-control-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}

#app-shell #view .ad-data-live-controls.is-utm .ad-data-live-control-title strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ah-ink);
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#app-shell #view .facebook-report-level-controls {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: visible;
  white-space: nowrap;
}

#app-shell #view .facebook-report-level-tabs {
  width: auto !important;
  height: 32px !important;
  min-height: 32px !important;
  flex: 0 0 auto !important;
  padding: 2px !important;
  border-radius: 10px !important;
}

#app-shell #view .facebook-report-level-tabs button {
  min-width: 62px !important;
  height: 26px !important;
  min-height: 26px !important;
  padding: 0 10px !important;
  border-radius: 8px !important;
  font-size: 11px !important;
}

#app-shell #view .facebook-report-entity-selectors {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: visible;
}

#app-shell #view .facebook-report-entity-label,
#app-shell #view .facebook-report-toggle-control > span:first-child {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

#app-shell #view .facebook-report-entity-select {
  position: relative;
  min-width: 0;
  display: block;
  overflow: visible;
}

#app-shell #view .facebook-report-entity-select > .custom-select-wrap {
  width: 132px !important;
  min-width: 112px !important;
  max-width: 132px !important;
  flex: 0 1 132px !important;
}

#app-shell #view .facebook-report-entity-select.is-ad > .custom-select-wrap {
  width: 120px !important;
  min-width: 104px !important;
  max-width: 120px !important;
  flex-basis: 120px !important;
}

#app-shell #view .facebook-report-entity-select .custom-select-trigger {
  height: 27px !important;
  min-height: 27px !important;
  padding-inline: 8px 5px !important;
  border-radius: 8px !important;
}

#app-shell #view .facebook-report-entity-select .custom-select-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#app-shell #view .facebook-report-entity-select .custom-select-menu {
  z-index: 90;
  width: 100%;
  min-width: 100%;
  max-width: 100%;
  max-height: 190px;
  gap: 2px !important;
  padding: 3px !important;
  border-radius: 10px !important;
  overflow: auto;
}

#app-shell #view .facebook-report-entity-select .custom-select-option {
  min-height: 28px !important;
  padding: 5px 8px !important;
  border-radius: 7px !important;
  font-size: 11px !important;
}

#app-shell #view .facebook-report-entity-select.is-ad .custom-select-menu {
  right: 0;
  left: auto;
}

#app-shell #view .ad-data-live-controls.is-utm > :nth-child(3),
#app-shell #view .ad-data-live-controls.is-utm > :nth-child(4) {
  justify-self: end;
}

#app-shell #view .facebook-report-toggle-control {
  min-width: 54px;
  justify-content: flex-end;
}

@media (hover: hover) and (pointer: fine) {
  #app-shell #view .facebook-name-hierarchy-trigger:hover,
  #app-shell #view .facebook-adset-expand:hover > i {
    border-color: rgba(0, 122, 255, .12);
    background: rgba(0, 122, 255, .09);
  }

  #app-shell #view .facebook-hierarchy-adset:has(.facebook-adset-expand:hover) {
    background: rgba(255, 255, 255, .90);
  }
}

@media (max-width: 1180px) {
  #app-shell #view .ad-data-live-controls.is-utm {
    grid-template-columns: minmax(120px, 1fr) auto max-content max-content;
    gap: 6px;
    padding-inline: 9px;
  }

  #app-shell #view .facebook-report-level-tabs button {
    min-width: 54px !important;
    padding-inline: 8px !important;
  }

  #app-shell #view .facebook-report-entity-select > .custom-select-wrap {
    width: 120px !important;
    max-width: 120px !important;
  }

  #app-shell #view .facebook-report-entity-select.is-ad > .custom-select-wrap {
    width: 110px !important;
    max-width: 110px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  #app-shell #view .facebook-name-hierarchy-trigger,
  #app-shell #view .facebook-name-hierarchy-trigger > i::before,
  #app-shell #view .facebook-adset-expand > i,
  #app-shell #view .facebook-adset-expand > i::before {
    transition-duration: 0ms !important;
  }
}

@media (prefers-reduced-transparency: reduce) {
  #app-shell #view :is(.facebook-hierarchy-detail-row > td, .facebook-hierarchy-campaign, .facebook-hierarchy-adset, .facebook-hierarchy-ad, .ad-data-live-controls.is-utm) {
    background: #f8f8fa !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
}

@media (prefers-contrast: more) {
  #app-shell #view :is(.facebook-hierarchy-campaign, .facebook-hierarchy-adset, .facebook-hierarchy-ad) {
    border-color: rgba(29, 29, 31, .38);
  }

  #app-shell #view .facebook-name-hierarchy-trigger,
  #app-shell #view .facebook-adset-expand > i {
    border-color: rgba(29, 29, 31, .35);
  }
}
