/* SendGrid central tool */
.sg-tool { margin-top: 0.5rem; width: 100%; max-width: 100%; }
.sg-tool-title { margin: 0 0 0.25rem; font-size: 1.35rem; }
.sg-search-form {
  padding: 1rem 1.25rem;
  margin: 1rem 0 1.25rem;
  width: 100%;
  box-sizing: border-box;
}
.sg-search-stack {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  width: 100%;
}
.sg-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  width: 100%;
  min-width: 0;
}
.sg-field > span {
  font-weight: 500;
}
.sg-field input,
.sg-field select {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  font: inherit;
  color: var(--text);
  background: var(--surface, var(--bg));
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.55rem 0.75rem;
}
.sg-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  width: 100%;
}
@media (max-width: 640px) {
  .sg-field-row { grid-template-columns: 1fr; }
}
.sg-field-actions {
  margin-top: 0.25rem;
}
.sg-field-actions .btn {
  width: 100%;
  max-width: 16rem;
}
.sg-search-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}
.sg-search-actions .btn {
  width: auto;
  max-width: none;
}
.sg-find-account-section .btn {
  margin-top: 0.35rem;
}
.sg-results-wrap { margin-top: 0.5rem; }

.sg-scan-ticker {
  margin: 0.5rem 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface, var(--bg));
  overflow: hidden;
}
.sg-scan-ticker-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 1rem;
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.sg-scan-ticker-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}
.sg-scan-ticker-list {
  list-style: none;
  margin: 0;
  padding: 0.35rem 0;
  max-height: 10.5rem;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  line-height: 1.35;
}
.sg-scan-ticker-item {
  display: grid;
  grid-template-columns: minmax(6rem, 1.4fr) 2.75rem minmax(0, 2fr);
  gap: 0.35rem 0.65rem;
  padding: 0.2rem 0.75rem;
  align-items: baseline;
}
.sg-scan-ticker-item + .sg-scan-ticker-item {
  border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.sg-scan-acct { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-scan-code { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.sg-scan-detail { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-scan-ok .sg-scan-code { color: var(--ok, #1a7f37); }
.sg-scan-err .sg-scan-code { color: var(--danger, #cf222e); }
.sg-scan-retry .sg-scan-code { color: var(--warn, #9a6700); }
.sg-scan-ok .sg-scan-detail { color: var(--text-muted); }
.sg-scan-err .sg-scan-detail,
.sg-scan-retry .sg-scan-detail { color: var(--text); }
.sg-row { cursor: pointer; }
.sg-row:hover { background: var(--hover-bg, rgba(127,127,127,0.08)); }
.sg-row:focus-visible {
  outline: 2px solid var(--accent, #3b82f6);
  outline-offset: -2px;
}
.sg-msgid code {
  font-size: 0.72rem;
  word-break: break-all;
}
.sg-detail-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}
.sg-detail-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}
.sg-detail-section h3 {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
}
.sg-detail-kv {
  display: grid;
  grid-template-columns: minmax(7rem, 28%) 1fr;
  gap: 0.35rem 0.75rem;
  font-size: 0.875rem;
}
.sg-detail-kv dt {
  color: var(--text-muted);
  margin: 0;
}
.sg-detail-kv dd {
  margin: 0;
  word-break: break-word;
}
.sg-event-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 2px solid var(--border);
}
.sg-event-item {
  position: relative;
  padding: 0.65rem 0 0.65rem 1.1rem;
}
.sg-event-item::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 1rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent, #3b82f6);
}
.sg-event-name {
  font-weight: 600;
  text-transform: capitalize;
}
.sg-event-time { font-size: 0.85rem; color: var(--text-muted); }
.sg-event-meta { margin-top: 0.2rem; font-size: 0.8rem; }
.sg-event-json {
  margin-top: 0.4rem;
  font-size: 0.72rem;
  overflow: auto;
  max-height: 10rem;
  background: var(--surface, transparent);
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.sg-raw {
  font-size: 0.75rem;
  overflow: auto;
  max-height: 280px;
  background: var(--surface, transparent);
  padding: 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  white-space: pre-wrap;
  word-break: break-word;
}
.text-warn { color: var(--warn, #ca8a04); }

/* Delivery debug panel */
.sg-debug-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  background: var(--surface, transparent);
}
.sg-debug-outcome {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 0.65rem;
}
.sg-debug-summary {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
}
.sg-debug-meta { margin-bottom: 0.75rem; }
.sg-debug-hypotheses {
  margin: 0 0 0.85rem;
  font-size: 0.875rem;
}
.sg-debug-hypotheses ul {
  margin: 0.35rem 0 0;
  padding-left: 1.2rem;
}
.sg-debug-findings {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.sg-debug-finding {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.sg-debug-finding-title {
  font-weight: 600;
  font-size: 0.875rem;
}
.sg-debug-finding-body { min-width: 0; flex: 1; }
.sg-debug-remediation {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  line-height: 1.4;
}
.sg-debug-example {
  margin-top: 0.5rem;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  border: 1px dashed var(--border);
  background: var(--bg, transparent);
}
.sg-debug-example-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.sg-debug-example-pre {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
}
.sg-sev-badge {
  display: inline-block;
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg, transparent);
}
.sg-sev-ok .sg-sev-badge,
.sg-debug-outcome.sg-sev-ok .sg-sev-badge {
  color: #166534;
  border-color: #86efac;
  background: #f0fdf4;
}
.sg-sev-warn .sg-sev-badge,
.sg-debug-outcome.sg-sev-warn .sg-sev-badge {
  color: #854d0e;
  border-color: #fde047;
  background: #fefce8;
}
.sg-sev-fail .sg-sev-badge,
.sg-debug-outcome.sg-sev-fail .sg-sev-badge {
  color: #991b1b;
  border-color: #fca5a5;
  background: #fef2f2;
}
.sg-sev-info .sg-sev-badge {
  color: var(--text-muted);
}
