/* Server tracking and attribution: the Attribution tab, Integrations tab,
   the Meta delivery log and the tracking mode card on site settings.
   Tokens come from site.css; nothing here sets a color of its own. */

.tr-page {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

/* ---------- attribution report ---------- */

.tr-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
}

.tr-goals {
  margin: 0;
}

.tr-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.tr-kpi {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 14px 16px;
  border-right: 1px solid var(--line);
}

.tr-kpi:last-child {
  border-right: none;
}

.tr-kpi-label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.tr-kpi-value {
  overflow: hidden;
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The model name is a word, not a number: a size that fits beside the numbers. */
.tr-kpi-word {
  font-family: inherit;
  font-size: 20px;
  line-height: 1.5;
}

.tr-kpi-sub {
  font-size: 12px;
  color: var(--text-dim);
}

.tr-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.tr-panel {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 16px;
}

.tr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  table-layout: fixed;
}

.tr-table th {
  padding: 0 8px 6px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
  color: var(--text-faint);
}

.tr-table th:first-child {
  width: 52%;
}

.tr-table td {
  padding: 6px 8px;
  font-variant-numeric: tabular-nums;
  border-top: 1px solid var(--line);
}

.tr-table .num {
  text-align: right;
}

/* The share of conversions, as a soft bar behind the name. */
.tr-name {
  background: linear-gradient(90deg, var(--accent-soft) var(--w), transparent var(--w)) no-repeat;
  background-clip: padding-box;
  border-radius: 6px 0 0 6px;
}

.tr-name span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tr-empty {
  margin: 0;
  padding: 8px 0;
  font-size: 14px;
}

/* ---------- integrations ---------- */

.tr-newkey .code {
  background: var(--bg-raised);
}

.tr-keys td {
  white-space: nowrap;
}

.tr-sub {
  margin-top: 2px;
  font-size: 12px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.tr-actions {
  display: inline-flex;
  gap: 6px;
}

.tr-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.tr-inline .field {
  flex: 1 1 220px;
}

.tr-details {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.tr-details summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  font-weight: 600;
  cursor: pointer;
}

.tr-details[open] summary {
  margin-bottom: 8px;
}

/* display: flex drops the native marker; draw one that turns when open. */
.tr-details summary {
  justify-content: space-between;
  list-style: none;
}

.tr-details summary::-webkit-details-marker {
  display: none;
}

.tr-details summary::after {
  content: '+';
  font-family: var(--mono);
  font-size: 18px;
  color: var(--text-faint);
  transition: transform 0.15s ease;
}

.tr-details[open] summary::after {
  transform: rotate(45deg);
}

.tr-h3 {
  margin: 8px 0 0;
  font-size: 15px;
}

.tr-goal-list {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.tr-goal {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
}

.tr-goal:first-child {
  border-top: none;
}

.tr-goal code {
  overflow-wrap: anywhere;
}

.tr-goal-event {
  display: flex;
  gap: 8px;
}

.tr-select {
  width: auto;
  min-width: 190px;
}

.tr-custom {
  width: 150px;
}

/* Only while "Custom" is picked. */
.tr-goal-event:not(:has(option[value='_custom']:checked)) .tr-custom {
  display: none;
}

.goal-kind-option.is-locked {
  opacity: 0.75;
  cursor: default;
}

/* ---------- delivery log ---------- */

.tr-log-head {
  align-items: flex-end;
}

.tr-log-head .app-section-title {
  margin: 2px 0 0;
}

.tr-log td {
  vertical-align: top;
}

.tr-when {
  white-space: nowrap;
}

.tr-answer {
  max-width: 360px;
  font-size: 13px;
}

.tr-answer code {
  overflow-wrap: anywhere;
  white-space: normal;
}

@media (max-width: 720px) {
  .tr-kpis {
    grid-template-columns: minmax(0, 1fr);
  }
  .tr-kpi {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .tr-kpi:last-child {
    border-bottom: none;
  }
  .tr-kpi-value {
    font-size: 22px;
  }
  .tr-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .tr-controls .segmented {
    width: 100%;
  }
  .tr-goal {
    grid-template-columns: minmax(0, 1fr);
  }
  .tr-goal-event {
    flex-wrap: wrap;
  }
  .tr-select,
  .tr-custom {
    flex: 1 1 140px;
    min-width: 0;
  }
  .tr-inline .btn {
    width: 100%;
  }
}

/* Keeps visually hidden header text inside the scrolling table, not the page. */
.tr-integrations .table-wrap,
.tr-page .table-wrap {
  position: relative;
}

/* ---------------- connectors (Stripe, Shopify) ---------------- */

/* One row per tool: name and status on the left, one or two actions on the right. */
.cn-list {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.cn-row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}

.cn-row:first-child {
  border-top: none;
}

.cn-main {
  min-width: 0;
}

.cn-name {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.cn-line {
  margin: 2px 0 0;
  color: var(--text-dim);
  font-size: 14px;
  overflow-wrap: anywhere;
}

/* The error words in the error ink, which keeps 4.5:1 or more on panels in both themes. */
.cn-line-error {
  color: var(--error-text);
}

.cn-actions {
  display: flex;
  flex: none;
  gap: 8px;
  align-items: center;
}

.cn-actions form {
  margin: 0;
}

.cn-steps {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 22px;
}

.cn-steps li {
  padding-left: 4px;
  overflow-wrap: anywhere;
}

.cn-sub {
  margin: -6px 0 0;
  font-size: 13px;
}

.cn-detail {
  overflow-wrap: anywhere;
}

.cn-page .form-actions form {
  margin: 0;
}

@media (max-width: 720px) {
  .cn-row {
    flex-direction: column;
    align-items: stretch;
  }
  .cn-actions .btn {
    flex: 1 1 auto;
    min-height: 44px;
  }
  .cn-actions form {
    display: flex;
    flex: 1 1 auto;
  }
}

/* The fix card holds only a collapsed section: no rule above it. */
.cn-fix .tr-details {
  border-top: 0;
  padding-top: 0;
}

.cn-back {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.tr-details .cn-steps + form,
.tr-details .cn-steps + .code-block {
  margin-top: 16px;
}
