body.agency-webhook-open {
  overflow: hidden;
}

.agency-webhook-overlay {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  justify-content: flex-end;
  background: rgba(15, 23, 42, .48);
  backdrop-filter: blur(3px);
}

.agency-webhook-overlay.is-hidden,
.agency-webhook-secret.is-hidden,
.agency-webhook-health.is-hidden,
.agency-webhook-editor .is-hidden {
  display: none !important;
}

.agency-webhook-drawer {
  display: flex;
  flex-direction: column;
  width: min(96vw, 1080px);
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  box-shadow: -18px 0 50px rgba(15, 23, 42, .2);
}

.agency-webhook-head {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 26px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.agency-webhook-head h2 {
  margin: 3px 0 4px;
  color: var(--text);
  font-size: 23px;
}

.agency-webhook-head p {
  max-width: 700px;
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.55;
}

.agency-webhook-eyebrow {
  color: var(--blue);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.agency-webhook-close {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 29px;
  line-height: 1;
}

.agency-webhook-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 22px 26px 30px;
}

.agency-webhook-error {
  display: none;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #fecaca;
  border-radius: 10px;
  background: #fef2f2;
  color: #dc2626;
  font-size: 12px;
}

.agency-webhook-error.show {
  display: block;
}

.agency-webhook-secret {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid #fbbf24;
  border-radius: 12px;
  background: #fffbeb;
  color: #78350f;
}

.agency-webhook-secret strong {
  display: block;
  margin-bottom: 3px;
}

.agency-webhook-secret p {
  margin: 0 0 12px;
  font-size: 12px;
  line-height: 1.5;
}

.agency-webhook-secret code {
  display: block;
  overflow-wrap: anywhere;
  padding: 11px;
  border: 1px solid #fde68a;
  border-radius: 8px;
  background: rgba(255, 255, 255, .8);
  font-size: 12px;
}

.agency-webhook-secret-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.agency-webhook-secret-actions button {
  padding: 9px 12px;
  border: 1px solid #d97706;
  border-radius: 8px;
  background: transparent;
  color: #92400e;
  cursor: pointer;
  font-weight: 700;
}

.agency-webhook-layout {
  display: grid;
  grid-template-columns: minmax(230px, 300px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.agency-webhook-list-panel,
.agency-webhook-editor {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.agency-webhook-list-panel {
  position: sticky;
  top: 0;
  overflow: hidden;
}

.agency-webhook-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
}

.agency-webhook-panel-head strong,
.agency-webhook-panel-head span {
  display: block;
}

.agency-webhook-panel-head strong {
  color: var(--text);
}

.agency-webhook-panel-head span {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 10px;
}

.agency-webhook-panel-head button {
  padding: 8px 10px;
  border: 1px solid var(--blue);
  border-radius: 8px;
  background: transparent;
  color: var(--blue);
  cursor: pointer;
  font-weight: 800;
}

.agency-webhook-list {
  max-height: 520px;
  overflow: auto;
  padding: 8px;
}

.agency-webhook-list-item {
  display: block;
  width: 100%;
  margin-bottom: 6px;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.agency-webhook-list-item:hover,
.agency-webhook-list-item.is-selected {
  border-color: var(--blue);
  background: var(--bg);
}

.agency-webhook-list-item strong,
.agency-webhook-list-item span,
.agency-webhook-list-item small {
  display: block;
}

.agency-webhook-list-item span {
  overflow: hidden;
  margin: 4px 0 8px;
  color: var(--text-muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agency-webhook-list-item small,
.agency-webhook-health-badge {
  width: fit-content;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 800;
}

.agency-webhook-list-item .is-active,
.agency-webhook-health-badge.is-active {
  background: #d1fae5;
  color: #047857;
}

.agency-webhook-list-item .is-paused,
.agency-webhook-health-badge.is-paused {
  background: #e5e7eb;
  color: #4b5563;
}

.agency-webhook-list-item .is-warning,
.agency-webhook-health-badge.is-warning {
  background: #fef3c7;
  color: #b45309;
}

.agency-webhook-health-badge.is-new {
  background: #dbeafe;
  color: #1d4ed8;
}

.agency-webhook-empty {
  padding: 24px 14px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

.agency-webhook-editor {
  display: grid;
  gap: 17px;
  padding: 20px;
}

.agency-webhook-editor-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.agency-webhook-editor-title h3 {
  margin: 0 0 3px;
  color: var(--text);
  font-size: 17px;
}

.agency-webhook-editor-title p {
  margin: 0;
  color: var(--text-muted);
  font-size: 11px;
}

.agency-webhook-editor label,
.agency-webhook-editor legend {
  color: var(--text);
  font-size: 11px;
  font-weight: 750;
}

.agency-webhook-editor input[type="text"],
.agency-webhook-editor input[type="url"],
.agency-webhook-editor select {
  box-sizing: border-box;
  width: 100%;
  margin-top: 7px;
  padding: 12px 13px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 12px;
}

.agency-webhook-editor fieldset {
  margin: 0;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 11px;
}

.agency-webhook-editor fieldset > p {
  margin: 4px 0 13px;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.45;
}

.agency-webhook-events {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.agency-webhook-event {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
}

.agency-webhook-event input {
  margin: 0;
}

.agency-webhook-event span {
  color: var(--text);
  font-size: 10px;
  font-weight: 650;
}

.agency-webhook-health {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.agency-webhook-health > div {
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
}

.agency-webhook-health span,
.agency-webhook-health strong {
  display: block;
}

.agency-webhook-health span {
  margin-bottom: 5px;
  color: var(--text-muted);
  font-size: 9px;
}

.agency-webhook-health strong {
  color: var(--text);
  font-size: 10px;
}

.agency-webhook-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding-top: 3px;
}

.agency-webhook-actions button {
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
}

.agency-webhook-actions button.is-primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.agency-webhook-actions button.is-danger {
  border-color: #fecaca;
  color: #dc2626;
}

.agency-webhook-actions button:disabled,
.agency-webhook-panel-head button:disabled,
.agency-webhook-secret-actions button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

html[data-theme="dark"] .agency-webhook-error {
  border-color: #7f1d1d;
  background: rgba(127, 29, 29, .22);
  color: #fca5a5;
}

html[data-theme="dark"] .agency-webhook-secret {
  border-color: #92400e;
  background: rgba(120, 53, 15, .24);
  color: #fde68a;
}

html[data-theme="dark"] .agency-webhook-secret code {
  border-color: #92400e;
  background: rgba(15, 23, 42, .45);
}

@media (max-width: 760px) {
  .agency-webhook-head,
  .agency-webhook-body {
    padding-left: 16px;
    padding-right: 16px;
  }

  .agency-webhook-layout {
    grid-template-columns: 1fr;
  }

  .agency-webhook-list-panel {
    position: static;
  }

  .agency-webhook-list {
    max-height: 220px;
  }

  .agency-webhook-events,
  .agency-webhook-health {
    grid-template-columns: 1fr;
  }
}
/* Webhook drawer layout polish v2 */

.agency-webhook-drawer {
  box-sizing: border-box;
  width: min(100vw, 1080px);
  max-width: 1080px;
  margin: 0;
}

.agency-webhook-head {
  position: relative !important;
  inset: auto !important;
  z-index: 2 !important;
  box-sizing: border-box;
  width: auto !important;
  height: auto !important;
  min-height: 0 !important;
  flex: 0 0 auto !important;
}

.agency-webhook-body {
  position: relative !important;
  inset: auto !important;
  box-sizing: border-box;
  width: auto !important;
  height: auto !important;
  min-height: 0 !important;
}

.agency-webhook-close {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 9px;
}

.agency-webhook-close:hover {
  background: var(--bg);
  color: var(--text);
}

.agency-webhook-events {
  grid-template-columns:
    repeat(3, minmax(0, 1fr));
}

.agency-webhook-event {
  min-height: 40px;
  box-sizing: border-box;
}

.agency-webhook-event:has(input:checked) {
  border-color: var(--blue);
  background: color-mix(
    in srgb,
    var(--blue) 7%,
    var(--bg)
  );
}

.agency-webhook-event input {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}

@media (max-width: 900px) {
  .agency-webhook-events {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .agency-webhook-overlay {
    align-items: stretch;
  }

  .agency-webhook-drawer {
    width: 100vw;
    max-width: none;
    border-radius: 0;
  }

  .agency-webhook-head {
    align-items: flex-start;
    gap: 12px;
    padding: 16px !important;
  }

  .agency-webhook-head h2 {
    margin-top: 2px;
    font-size: 21px;
    line-height: 1.15;
  }

  .agency-webhook-head p {
    padding-right: 2px;
    font-size: 12px;
    line-height: 1.45;
  }

  .agency-webhook-body {
    padding: 14px 12px 24px !important;
  }

  .agency-webhook-layout {
    gap: 12px;
  }

  .agency-webhook-list-panel {
    position: static;
    top: auto;
  }

  .agency-webhook-panel-head {
    padding: 11px 12px;
  }

  .agency-webhook-list {
    max-height: 190px;
    padding: 6px;
  }

  .agency-webhook-empty {
    padding: 16px 10px;
  }

  .agency-webhook-editor {
    gap: 14px;
    padding: 15px;
  }

  .agency-webhook-editor-title {
    align-items: center;
  }

  .agency-webhook-editor-title h3 {
    font-size: 16px;
  }

  .agency-webhook-editor input[type="text"],
  .agency-webhook-editor input[type="url"],
  .agency-webhook-editor select {
    padding: 11px 12px;
  }

  .agency-webhook-editor fieldset {
    padding: 12px;
  }

  .agency-webhook-events {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .agency-webhook-event {
    min-height: 38px;
    padding: 8px 10px;
  }

  .agency-webhook-health {
    grid-template-columns: 1fr;
  }

  .agency-webhook-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .agency-webhook-actions button {
    width: 100%;
  }

  .agency-webhook-secret-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .agency-webhook-secret-actions button {
    width: 100%;
  }
}

@media (max-width: 380px) {
  .agency-webhook-eyebrow {
    font-size: 9px;
  }

  .agency-webhook-head h2 {
    font-size: 19px;
  }

  .agency-webhook-close {
    width: 34px;
    height: 34px;
  }

  .agency-webhook-editor {
    padding: 13px;
  }
}
/* Webhook operations UI v1 */

.agency-webhook-operations {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.agency-webhook-operations-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.agency-webhook-operations-head h3 {
  margin: 0 0 4px;
  color: var(--text);
  font-size: 17px;
}

.agency-webhook-operations-head p {
  margin: 0;
  color: var(--text-muted);
  font-size: 11px;
}

.agency-webhook-operations-head button,
.agency-webhook-delivery-actions button {
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
}

.agency-webhook-filters {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 220px));
  gap: 10px;
  margin-bottom: 14px;
}

.agency-webhook-filters label {
  color: var(--text);
  font-size: 10px;
  font-weight: 750;
}

.agency-webhook-filters select {
  box-sizing: border-box;
  width: 100%;
  margin-top: 6px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

.agency-webhook-deliveries {
  display: grid;
  gap: 9px;
}

.agency-webhook-delivery {
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.agency-webhook-delivery-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.agency-webhook-delivery-head strong,
.agency-webhook-delivery-head span {
  display: block;
}

.agency-webhook-delivery-head strong {
  color: var(--text);
  font-size: 12px;
}

.agency-webhook-delivery-head div > span {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 9px;
  overflow-wrap: anywhere;
}

.agency-webhook-delivery-status {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 850;
}

.agency-webhook-delivery-status.is-pending,
.agency-webhook-delivery-status.is-processing {
  background: #dbeafe;
  color: #1d4ed8;
}

.agency-webhook-delivery-status.is-retrying {
  background: #fef3c7;
  color: #b45309;
}

.agency-webhook-delivery-status.is-succeeded {
  background: #d1fae5;
  color: #047857;
}

.agency-webhook-delivery-status.is-failed,
.agency-webhook-delivery-status.is-abandoned {
  background: #fee2e2;
  color: #b91c1c;
}

.agency-webhook-delivery-meta {
  display: grid;
  grid-template-columns:
    repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin-top: 11px;
}

.agency-webhook-delivery-meta > span,
.agency-webhook-attempt-meta > span {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
}

.agency-webhook-delivery-meta small,
.agency-webhook-delivery-meta strong,
.agency-webhook-attempt-meta small,
.agency-webhook-attempt-meta strong {
  display: block;
}

.agency-webhook-delivery-meta small,
.agency-webhook-attempt-meta small {
  margin-bottom: 3px;
  color: var(--text-muted);
  font-size: 8px;
}

.agency-webhook-delivery-meta strong,
.agency-webhook-attempt-meta strong {
  color: var(--text);
  font-size: 9px;
  overflow-wrap: anywhere;
}

.agency-webhook-delivery-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.agency-webhook-delivery-actions button.is-retry {
  border-color: #f59e0b;
  color: #b45309;
}

.agency-webhook-attempts {
  display: grid;
  gap: 7px;
  margin-top: 11px;
  padding-top: 11px;
  border-top: 1px solid var(--border);
}

.agency-webhook-attempts.is-hidden {
  display: none;
}

.agency-webhook-attempt {
  padding: 10px;
  border-radius: 8px;
  background: var(--surface);
}

.agency-webhook-attempt > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.agency-webhook-attempt > div:first-child strong {
  color: var(--text);
  font-size: 10px;
}

.agency-webhook-attempt > div:first-child span {
  color: var(--text-muted);
  font-size: 9px;
}

.agency-webhook-attempt-meta {
  display: grid;
  grid-template-columns:
    repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.agency-webhook-delivery-empty,
.agency-webhook-attempt-empty {
  margin: 0;
  padding: 22px 12px;
  border: 1px dashed var(--border);
  border-radius: 9px;
  color: var(--text-muted);
  font-size: 10px;
  text-align: center;
}

.agency-webhook-delivery-empty.is-error {
  border-color: #fecaca;
  color: #dc2626;
}

@media (max-width: 760px) {
  .agency-webhook-operations {
    margin-top: 12px;
    padding: 14px;
  }

  .agency-webhook-operations-head {
    align-items: center;
  }

  .agency-webhook-filters {
    grid-template-columns: 1fr;
  }

  .agency-webhook-delivery-meta,
  .agency-webhook-attempt-meta {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 380px) {
  .agency-webhook-delivery-meta,
  .agency-webhook-attempt-meta {
    grid-template-columns: 1fr;
  }

  .agency-webhook-operations-head {
    align-items: stretch;
    flex-direction: column;
  }

  .agency-webhook-operations-head button {
    width: 100%;
  }
}
