:root {
  --wm-bg: #f3f6f5;
  --wm-panel: #ffffff;
  --wm-ink: #101828;
  --wm-muted: #667085;
  --wm-line: #e4e9e7;
  --wm-green: #148653;
  --wm-green-soft: #e9f8f0;
  --wm-red: #c4323f;
  --wm-red-soft: #fff0f1;
  --wm-amber: #a56008;
  --wm-amber-soft: #fff7e7;
  --wm-blue: #2363c4;
  --wm-blue-soft: #edf4ff;
}

#webhook-monitor-launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 1200;
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 190px;
  padding: 11px 15px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: #111827;
  color: #fff;
  text-align: left;
  box-shadow: 0 18px 48px rgba(16, 24, 40, 0.24);
  cursor: pointer;
  font-family: Outfit, Inter, Arial, sans-serif;
}

#webhook-monitor-launcher:hover {
  background: #172131;
  transform: translateY(-1px);
}

#webhook-monitor-launcher strong,
#webhook-monitor-launcher small {
  display: block;
}

#webhook-monitor-launcher strong {
  font-size: 14px;
  line-height: 1.2;
}

#webhook-monitor-launcher small {
  margin-top: 2px;
  color: #b9c2d0;
  font-size: 11px;
}

.webhook-monitor-launcher-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #40d88b;
  box-shadow: 0 0 0 5px rgba(64, 216, 139, 0.14);
}

body.webhook-monitor-open {
  overflow: hidden !important;
}

#webhook-monitor-app {
  position: fixed;
  inset: 0;
  z-index: 1150;
  overflow: auto;
  background: var(--wm-bg);
  color: var(--wm-ink);
  font-family: Outfit, Inter, Arial, sans-serif;
}

/* Integra el monitor en el <main> de MUI y conserva visible el menú Admin. */
main.webhook-monitor-host {
  position: relative !important;
  isolation: isolate;
}

main.webhook-monitor-host > :not(#webhook-monitor-app) {
  display: none !important;
}

main.webhook-monitor-host > #webhook-monitor-app.webhook-monitor-embedded {
  position: relative;
  inset: auto;
  z-index: 1;
  width: 100%;
  min-height: 100%;
  overflow: visible;
}

.wm-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 82px;
  padding: 14px clamp(20px, 4vw, 58px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(10, 18, 30, 0.97);
  color: #fff;
  backdrop-filter: blur(16px);
}

.wm-header-brand,
.wm-header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.wm-header h1,
.wm-modal-card h2 {
  margin: 1px 0 0;
  font-size: 23px;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.wm-eyebrow {
  display: block;
  color: #78e2aa;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.wm-back,
.wm-modal-close {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
}

.wm-live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #d8e1eb;
  font-size: 12px;
  font-weight: 600;
}

.wm-live i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3dd187;
  box-shadow: 0 0 0 4px rgba(61, 209, 135, 0.14);
}

.wm-main {
  width: min(1560px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.wm-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 13px;
  margin-bottom: 18px;
}

.wm-summary-card {
  position: relative;
  min-height: 112px;
  padding: 17px 18px;
  overflow: hidden;
  border: 1px solid var(--wm-line);
  border-radius: 12px;
  background: var(--wm-panel);
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.035);
}

.wm-summary-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: #98a2b3;
}

.wm-tone-online::before,
.wm-tone-success::before {
  background: var(--wm-green);
}

.wm-tone-warning::before {
  background: #e7a72d;
}

.wm-tone-error::before {
  background: var(--wm-red);
}

.wm-summary-label,
.wm-summary-detail {
  display: block;
  color: var(--wm-muted);
}

.wm-summary-label {
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.wm-summary-value {
  display: block;
  margin-bottom: 4px;
  font-size: 27px;
  line-height: 1;
}

.wm-summary-detail {
  font-size: 12px;
}

.wm-panel {
  overflow: hidden;
  border: 1px solid var(--wm-line);
  border-radius: 14px;
  background: var(--wm-panel);
  box-shadow: 0 14px 38px rgba(16, 24, 40, 0.05);
}

.wm-filters {
  display: grid;
  grid-template-columns: minmax(160px, 1.1fr) minmax(180px, 1.2fr) minmax(145px, 0.8fr) minmax(155px, 0.8fr) auto;
  gap: 12px;
  align-items: end;
  padding: 18px;
  border-bottom: 1px solid var(--wm-line);
  background: #fbfcfc;
}

.wm-filters label,
.wm-filters label span {
  display: block;
}

.wm-filters label span {
  margin: 0 0 6px 2px;
  color: #475467;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.wm-filters input,
.wm-filters select {
  box-sizing: border-box;
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid #d7ddda;
  border-radius: 9px;
  outline: none;
  background: #fff;
  color: var(--wm-ink);
  font: inherit;
  font-size: 13px;
}

.wm-filters input:focus,
.wm-filters select:focus {
  border-color: #35a86f;
  box-shadow: 0 0 0 3px rgba(20, 134, 83, 0.11);
}

.wm-button {
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 9px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.wm-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.wm-button-primary {
  background: #1b9a61;
  color: #fff;
}

.wm-button-filter {
  background: #111827;
  color: #fff;
}

.wm-table-wrap {
  min-height: 300px;
  overflow-x: auto;
  transition: opacity 150ms ease;
}

.wm-table-wrap.wm-is-loading {
  opacity: 0.62;
}

.wm-table {
  width: 100%;
  min-width: 1240px;
  border-collapse: collapse;
  table-layout: fixed;
}

.wm-table th {
  padding: 12px 14px;
  border-bottom: 1px solid var(--wm-line);
  background: #f7f9f8;
  color: #667085;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-align: left;
  text-transform: uppercase;
}

.wm-table td {
  padding: 14px;
  border-bottom: 1px solid #edf0ef;
  color: #344054;
  font-size: 12px;
  vertical-align: top;
}

.wm-table tbody tr:hover {
  background: #fbfdfc;
}

.wm-table th:nth-child(1) { width: 145px; }
.wm-table th:nth-child(2) { width: 170px; }
.wm-table th:nth-child(3) { width: 130px; }
.wm-table th:nth-child(4) { width: 260px; }
.wm-table th:nth-child(5) { width: 210px; }
.wm-table th:nth-child(6) { width: 85px; }
.wm-table th:nth-child(7) { width: 145px; }

.wm-table td strong,
.wm-table td small,
.wm-table td time {
  display: block;
}

.wm-table td strong {
  color: #1d2939;
  font-weight: 700;
}

.wm-table td small,
.wm-table td time {
  margin-top: 4px;
  color: var(--wm-muted);
  font-size: 11px;
  line-height: 1.35;
}

.wm-trace {
  font-family: Consolas, monospace;
}

.wm-message p,
.wm-result {
  display: -webkit-box !important;
  margin: 6px 0 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-height: 1.4;
}

.wm-type {
  display: inline-block;
  padding: 3px 6px;
  border-radius: 5px;
  background: #eef1f0;
  color: #475467;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.wm-status {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
}

.wm-status-success { background: var(--wm-green-soft); color: var(--wm-green); }
.wm-status-warning,
.wm-status-ignored { background: var(--wm-amber-soft); color: var(--wm-amber); }
.wm-status-error { background: var(--wm-red-soft); color: var(--wm-red); }
.wm-status-processing,
.wm-status-received { background: var(--wm-blue-soft); color: var(--wm-blue); }

.wm-detail-button {
  padding: 7px 9px;
  border: 1px solid #d8dfdc;
  border-radius: 7px;
  background: #fff;
  color: #1b6847;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.wm-detail-button:hover {
  border-color: #68bd91;
  background: #f1fbf6;
}

.wm-row-actions {
  display: grid;
  gap: 6px;
}

.wm-send-button {
  padding: 7px 9px;
  border: 1px solid #1b9a61;
  border-radius: 7px;
  background: #1b9a61;
  color: #fff;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.wm-send-button:hover {
  border-color: #137a4c;
  background: #137a4c;
}

.wm-send-button:disabled {
  border-color: #d8dfdc;
  background: #eef1f0;
  color: #98a2b3;
  cursor: not-allowed;
}

.wm-loading,
.wm-empty {
  display: flex;
  min-height: 300px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  color: var(--wm-muted);
  text-align: center;
}

.wm-empty strong {
  color: var(--wm-ink);
  font-size: 17px;
}

.wm-empty-error strong {
  color: var(--wm-red);
}

.wm-empty .wm-button {
  margin-top: 10px;
}

.wm-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 0 18px;
  border-top: 1px solid var(--wm-line);
  color: var(--wm-muted);
  font-size: 12px;
}

.wm-pagination div {
  display: flex;
  gap: 8px;
}

.wm-pagination button {
  padding: 7px 11px;
  border: 1px solid #d8dfdc;
  border-radius: 7px;
  background: #fff;
  color: #344054;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.wm-pagination button:disabled {
  cursor: default;
  opacity: 0.4;
}

.wm-modal[hidden] {
  display: none;
}

.wm-modal {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: grid;
  place-items: center;
  padding: 20px;
}

.wm-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 12, 20, 0.68);
  backdrop-filter: blur(4px);
}

.wm-modal-card {
  position: relative;
  width: min(900px, 100%);
  max-height: calc(100vh - 40px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 34px 100px rgba(0, 0, 0, 0.32);
}

.wm-modal-card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 75px;
  padding: 0 22px;
  background: #101824;
  color: #fff;
}

.wm-modal-close {
  width: 38px;
  height: 38px;
}

.wm-modal-body {
  max-height: calc(100vh - 115px);
  padding: 22px;
  overflow-y: auto;
}

.wm-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.wm-detail-grid > div {
  min-height: 70px;
  padding: 12px;
  border: 1px solid var(--wm-line);
  border-radius: 9px;
  background: #fafcfb;
}

.wm-detail-grid span,
.wm-detail-grid strong {
  display: block;
}

.wm-detail-grid span {
  margin-bottom: 7px;
  color: var(--wm-muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.wm-detail-grid strong {
  overflow-wrap: anywhere;
  color: #1d2939;
  font-size: 12px;
}

.wm-detail-section,
.wm-payload {
  margin-top: 18px;
}

.wm-detail-section h3 {
  margin: 0 0 8px;
  color: #344054;
  font-size: 13px;
}

.wm-message-full,
.wm-reason-full {
  padding: 13px 14px;
  border: 1px solid var(--wm-line);
  border-radius: 9px;
  background: #f8faf9;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.wm-reason-full strong {
  color: #1b6847;
  font-family: Consolas, monospace;
  font-size: 11px;
}

.wm-reason-full p {
  margin: 5px 0 0;
}

.wm-manual-send {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid #bfe8d1;
  border-radius: 11px;
  background: #f3fbf7;
}

.wm-manual-send-heading,
.wm-manual-send-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.wm-manual-send h3 {
  margin: 2px 0 0;
  color: #164e36;
  font-size: 15px;
}

.wm-manual-send > p {
  margin: 10px 0 14px;
  color: #475467;
  font-size: 12px;
  line-height: 1.55;
}

.wm-no-flow {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 999px;
  background: #dff5e8;
  color: #176b46;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.wm-manual-send form > label {
  display: block;
  margin-bottom: 6px;
  color: #344054;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.wm-manual-send textarea {
  box-sizing: border-box;
  width: 100%;
  min-height: 100px;
  padding: 11px 12px;
  resize: vertical;
  border: 1px solid #b9d8c7;
  border-radius: 9px;
  outline: none;
  background: #fff;
  color: #1d2939;
  font: 13px/1.5 Outfit, Inter, Arial, sans-serif;
}

.wm-manual-send textarea:focus {
  border-color: #35a86f;
  box-shadow: 0 0 0 3px rgba(20, 134, 83, 0.11);
}

.wm-manual-send-footer {
  margin-top: 9px;
}

.wm-manual-send-footer > span {
  color: #667085;
  font-size: 11px;
}

.wm-manual-result {
  margin-top: 11px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.45;
}

.wm-manual-result[hidden] {
  display: none;
}

.wm-manual-result strong,
.wm-manual-result span {
  display: block;
}

.wm-manual-result-success {
  background: #dff5e8;
  color: #176b46;
}

.wm-manual-result-error {
  background: #fdebec;
  color: #a2262f;
}

.wm-manual-result-loading {
  background: #edf4ff;
  color: #23558f;
}

.wm-manual-send-disabled {
  border-color: #e1e5e3;
  background: #f8faf9;
}

.wm-timeline {
  margin: 0;
  padding: 0;
  list-style: none;
}

.wm-timeline li {
  position: relative;
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  padding-bottom: 15px;
}

.wm-timeline li:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 12px;
  bottom: -1px;
  left: 5px;
  width: 1px;
  background: #dce2df;
}

.wm-timeline-dot {
  position: relative;
  z-index: 1;
  width: 11px;
  height: 11px;
  margin-top: 3px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #6882aa;
  box-shadow: 0 0 0 2px #cdd9eb;
}

.wm-timeline-success .wm-timeline-dot { background: var(--wm-green); box-shadow: 0 0 0 2px #bfe8d1; }
.wm-timeline-warning .wm-timeline-dot,
.wm-timeline-ignored .wm-timeline-dot { background: #d9911d; box-shadow: 0 0 0 2px #f5ddb2; }
.wm-timeline-error .wm-timeline-dot { background: var(--wm-red); box-shadow: 0 0 0 2px #f2c6ca; }

.wm-timeline time,
.wm-timeline strong,
.wm-timeline p {
  display: block;
}

.wm-timeline time {
  color: var(--wm-muted);
  font-size: 10px;
}

.wm-timeline strong {
  margin-top: 2px;
  color: #1d2939;
  font-size: 12px;
}

.wm-timeline p {
  margin: 2px 0 0;
  color: #667085;
  font-size: 12px;
}

.wm-payload {
  border: 1px solid var(--wm-line);
  border-radius: 9px;
  background: #f8faf9;
}

.wm-payload summary {
  padding: 12px 14px;
  color: #344054;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.wm-payload pre {
  max-height: 320px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  border-top: 1px solid var(--wm-line);
  background: #101824;
  color: #d8f6e5;
  font: 11px/1.5 Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 1050px) {
  .wm-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .wm-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .wm-button-filter {
    grid-column: span 2;
  }

  .wm-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  #webhook-monitor-launcher {
    right: 12px;
    bottom: 12px;
  }

  .wm-header {
    align-items: flex-start;
    padding: 13px 14px;
  }

  .wm-header h1 {
    font-size: 18px;
  }

  .wm-header-actions {
    gap: 6px;
  }

  .wm-live {
    display: none;
  }

  .wm-main {
    width: calc(100% - 20px);
    padding-top: 14px;
  }

  .wm-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .wm-summary-card {
    min-height: 92px;
    padding: 14px;
  }

  .wm-summary-value {
    font-size: 22px;
  }

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

  .wm-button-filter {
    grid-column: auto;
  }

  .wm-pagination {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
  }

  .wm-detail-grid {
    grid-template-columns: 1fr;
  }

  .wm-modal {
    padding: 0;
  }

  .wm-modal-card {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }

  .wm-modal-body {
    max-height: calc(100vh - 75px);
    padding: 14px;
  }
}
