/* Webhook setup and receipts share the console's paper, type and focus tokens.
 * Dialogs use the shared .modal shell (app.css); only their contents are
 * styled here, under .wh-modal. Agent Studio's section reuses the workspace
 * cards and switch (agent-workspace.css), under .wh-agent. */
.wh { min-width: 0; max-width: 1120px; margin: 0 auto; color: var(--c-ink); font-size: 12.5px; }
.wh [hidden], .wh-modal [hidden] { display: none !important; }
.wh h2 { font-size: 16px; font-weight: 600; letter-spacing: -0.018em; margin: 0; }
.wh h3, .wh-modal h3, .wh-card h2 { font-size: 13px; margin: 0; font-weight: 600; letter-spacing: -0.01em; }
.wh p { line-height: 1.6; }
.wh-head, .wh-section-head, .wh-card-head, .wh-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wh-head { align-items: flex-start; }
.wh-eyebrow { display: block; font-size: 10px; letter-spacing: 0.1em; color: var(--c-ink-3); margin-bottom: 8px; }
.wh-help { color: var(--c-ink-3); font-size: 12px; line-height: 1.65; margin: 6px 0; }
.wh-code { font-family: var(--mono); font-size: 11px; overflow-wrap: anywhere; }
.wh button, .wh-modal .modal-body button { font-size: 12px; min-height: 30px; border-radius: var(--r-sm); padding: 8px 12px;
  transition: transform 140ms var(--ease-out), background-color 140ms ease; }
.wh button:active:not(:disabled), .wh-modal button:active:not(:disabled) { transform: scale(0.97); }
.wh button:focus-visible, .wh summary:focus-visible, .wh-modal summary:focus-visible { outline: 2px solid var(--c-ink); outline-offset: 3px; }
.wh button:disabled, .wh-modal button:disabled { cursor: not-allowed; opacity: 0.55; }
.wh-actions { justify-content: flex-start; flex-wrap: wrap; }
.wh-tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--c-line); margin-bottom: 18px; }
.wh-tabs button { background: transparent; border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--c-ink-3); padding: 9px 1px; }
.wh-tabs button[aria-selected="true"] { color: var(--c-ink); border-bottom-color: var(--c-ink); }
.wh-count { font-variant-numeric: tabular-nums; font-size: 10px; margin-left: 7px; padding: 2px 5px; background: var(--c-sunk); border-radius: 3px; }
.wh-section-head { margin-bottom: 12px; align-items: flex-start; }
.wh-list { display: grid; gap: 14px; }
.wh-card { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-md); overflow: hidden; }
.wh-card-head { align-items: flex-start; padding: 16px 18px; }
.wh-card-identity { min-width: 0; flex: 1; }
.wh-title-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 5px; }
.wh-url { color: var(--c-ink-3); margin: 0; overflow-wrap: anywhere; font-size: 12px; }
.wh-card-foot { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px;
  border-top: 1px solid var(--c-line); padding: 8px 18px; background: var(--c-paper); }
.wh-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; white-space: nowrap; border: 1px solid var(--c-line);
  padding: 3px 6px; border-radius: var(--r-sm); font-weight: 500; }
.wh-badge[data-tone="good"] { color: var(--accent); background: var(--accent-bg); border-color: var(--accent-line); }
.wh-badge[data-tone="bad"] { color: var(--c-alarm-ink); background: var(--c-alarm-bg); border-color: var(--c-alarm-line); }
.wh-badge[data-tone="wait"] { color: var(--c-open-ink); background: var(--c-open-bg); border-color: var(--c-open-line); }
.wh-empty { padding: 32px 18px; text-align: center; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-md); }
.wh-empty h2 { margin: 16px 0 9px; }
.wh-empty p { max-width: 410px; margin: 0 auto 22px; color: var(--c-ink-3); font-size: 12.5px; }
.wh-symbol { width: 36px; height: 36px; display: grid; place-items: center; flex: none; border: 1px solid var(--c-line);
  border-radius: var(--r-md); margin: 0 auto; background: var(--c-paper); color: var(--c-ink-2); }
.wh-symbol svg { width: 20px; height: 20px; }
.wh-status { font-size: 12px; color: var(--c-ink-3); margin: 12px 0; overflow-wrap: anywhere; }
.wh-status:empty { display: none; }
.wh-status[data-error="true"] { color: var(--c-alarm-ink); background: var(--c-alarm-bg); border: 1px solid var(--c-alarm-line);
  border-radius: var(--r-sm); padding: 12px; }
.wh-filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 14px; }
.wh-filters label { min-width: 120px; flex: 1; }
.wh-field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 14px; min-width: 0; font-size: 12px; font-weight: 500; }
.wh .wh-field input, .wh .wh-field select, .wh-modal .wh-header-row input { width: 100%; min-width: 0; box-sizing: border-box; padding: 7px 9px;
  font: inherit; font-size: 12.5px; font-weight: 400; line-height: 1.3; color: var(--c-ink); background: var(--c-surface);
  border: 1px solid var(--c-line-strong); border-radius: var(--r-sm); min-height: 32px; }
.wh-field small { color: var(--c-ink-3); font-size: 11px; font-weight: 400; line-height: 1.6; }
.wh-filters .wh-field { margin: 0; }
.wh-table-wrap { overflow-x: auto; border: 1px solid var(--c-line); border-radius: var(--r-md); background: var(--c-surface); }
.wh-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 12px; }
.wh-table th { background: var(--c-paper); font-size: 10px; font-weight: 500; color: var(--c-ink-3); white-space: nowrap; }
.wh-table th, .wh-table td { padding: 10px 12px; border-bottom: 1px solid var(--c-line); }
.wh-table tr:last-child td { border-bottom: 0; }
.wh-table td { vertical-align: top; }
.wh-table td .wh-help { margin: 3px 0 0; font-size: 10px; }
.wh-table time { white-space: nowrap; font-variant-numeric: tabular-nums; }
.wh-link { background: none; color: var(--c-ink); border: 0; text-align: left; text-decoration: underline; text-underline-offset: 3px; }
.wh .wh-link, .wh-modal .wh-link { padding: 0; min-height: 28px; }
.wh-pagination { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; }
.wh-guide { border-top: 1px solid var(--c-line); margin-top: 20px; padding-top: 14px; }
.wh-guide summary { font-size: 12px; cursor: pointer; }
.wh-guide-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; margin-top: 16px; }
.wh-guide-grid strong { font-size: 12px; font-weight: 550; }
.wh-skeleton { height: 104px; background: var(--c-sunk); border-radius: var(--r-md); margin: 14px 0; }
.wh label { text-transform: none; letter-spacing: normal; color: var(--c-ink-2); }

/* ── the event checklist: picked, never typed ── */
.wh-events { display: grid; gap: 14px; }
.wh-event-group { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.wh-event-group-title { grid-column: 1 / -1; margin: 0; font-size: 11.5px; font-weight: 600; color: var(--c-ink-3); }
.wh-event { display: flex; align-items: flex-start; gap: 9px; margin: 0; padding: 10px 11px; border: 1px solid var(--ui-edge);
  border-radius: var(--ui-r-control); background: var(--c-surface); cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease; }
.wh-event:has(input:checked) { border-color: var(--c-ink-3); background: var(--c-paper); }
.wh-event:has(input:focus-visible) { box-shadow: var(--ui-ring); }
.wh-event input { accent-color: var(--c-ink); width: 15px; height: 15px; flex-shrink: 0; margin: 2px 0 0; }
.wh-event strong { display: block; font-size: 12.5px; font-weight: 600; color: var(--c-ink); }
.wh-event small { display: block; font-size: 11.5px; font-weight: 400; line-height: 1.5; color: var(--c-ink-3); margin-top: 3px; }
/* The low-balance alert level, inside the Billing & wallet group. */
.wh-threshold { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 2px 0 0; padding: 10px 11px;
  border: 1px solid var(--ui-edge); border-radius: var(--ui-r-control); background: var(--c-surface); font-size: 12.5px; font-weight: 600; color: var(--c-ink); }
.wh-threshold-input { display: inline-flex; align-items: center; gap: 4px; font-weight: 500; color: var(--c-ink-3); }
.wh-threshold input { width: 120px; font: inherit; font-weight: 500; color: var(--c-ink); font-variant-numeric: tabular-nums; }
.wh-threshold small { flex-basis: 100%; font-size: 11.5px; font-weight: 400; line-height: 1.5; color: var(--c-ink-3); }
.wh-fieldset, .wh-setup-events { border: 0; margin: 0 0 12px; padding: 0; min-width: 0; }
.wh-fieldset > legend, .wh-setup-events > legend { padding: 0; margin-bottom: 8px; font: 600 13px/1.4 var(--sans); color: var(--c-ink); }

/* ── dialog contents (shell: .modal in app.css) ── */
.wh-modal .modal-body { font-size: 12.5px; }
.wh-modal .modal-sub { margin-top: 4px; }
.wh-modal .modal-note { display: block; margin: 0 0 16px; }
.wh-modal .modal-note p { margin: 0; }
.wh-modal .wh-help { margin: 6px 0 14px; }
.wh-modal .wh-field small { display: block; }
.wh-header-row { display: grid; grid-template-columns: 1fr 1.3fr 32px; align-items: center; gap: 8px; margin-bottom: 8px; }
.wh-header-row .wh-field { margin: 0; }
.wh-header-row button { padding: 5px; }
.wh-advanced { margin: 14px 0; border-top: 1px solid var(--ui-sep); padding-top: 12px; }
.wh-advanced summary { font-size: 12.5px; cursor: pointer; margin-bottom: 12px; color: var(--c-ink-2); }
.wh-secret { padding: 12px; border: 1px solid var(--c-line-strong); background: var(--c-paper); border-radius: var(--ui-r-control);
  display: flex; align-items: center; gap: 10px; }
.wh-secret code { flex: 1; overflow-wrap: anywhere; user-select: all; font-size: 12px; }
.wh-danger { color: var(--c-alarm-ink) !important; }
.wh-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 16px 0; }
.wh-facts dt { font-size: 11px; color: var(--c-ink-3); margin-bottom: 4px; }
.wh-facts dd { margin: 0; font-size: 12.5px; overflow-wrap: anywhere; }
.wh-payload { border: 1px solid var(--c-line); border-radius: var(--ui-r-control); background: var(--c-paper); padding: 12px; overflow: auto;
  max-height: 320px; font: 11px/1.7 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.wh-attempts { padding: 0; list-style: none; }
.wh-attempts li { display: grid; grid-template-columns: 24px 1fr auto; gap: 10px; padding: 10px 0; border-top: 1px solid var(--ui-sep); font-size: 12.5px; }
.wh-attempts .wh-badge { align-self: start; }
.wh-attempt-number { border: 1px solid var(--c-line); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; }

/* ── Agent Studio → Webhooks ── */
.wh.wh-agent { max-width: 980px; margin: 0; font-size: 13px; }
.wh-agent > .wh-status { margin: 0 0 14px; }
.wh-agent .wh-skeleton { height: 120px; margin: 0 0 18px; border-radius: var(--ui-r-card); }
.wh-agent button.ghost.small { min-height: 28px; padding: 5px 10px; }
.wh-quiet { display: flex; gap: 14px; align-items: flex-start; }
.wh-quiet .wh-symbol { margin: 0; }
.wh-quiet h3 { font-size: 14px; }
.wh-quiet p { margin: 4px 0 0; max-width: 58ch; }
.wh-quiet > button { margin-top: 10px; }
.wh-subs { display: grid; gap: 0; }
.wh-sub > header { align-items: flex-start; margin-bottom: 8px; }
.wh-sub-identity { min-width: 0; }
.wh-sub h3 { overflow-wrap: anywhere; }
.wh-sub .wh-url { font: 12px/1.5 var(--mono); }
.wh-sub .workspace-chips { margin: 4px 0 12px; }
.wh-sub[data-scope="workspace"] { background: var(--c-paper); box-shadow: none; border: 1px solid var(--ui-edge); }
.wh-inherited { color: var(--c-ink-2); background: var(--ui-fill-2); border-color: transparent; }
.wh-sub-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--ui-sep); }
.wh-sub-actions .wh-help { margin: 0 auto 0 0; }
.wh-sub-actions .wh-help:last-child { flex-basis: 100%; margin: 4px 0 0; }
.wh-add-row { margin: -4px 0 18px; }
/* The suggestion: a card that is a switch. Off, it is one line of promise;
 * on, the form opens beneath it. Nothing is created until Save. */
.wh-suggest { padding: 0; overflow: hidden; }
.wh-suggest .wh-suggest-switch { margin: 0; padding: 16px 18px; background: none; border-radius: 0; cursor: pointer; }
.wh-suggest .wh-suggest-switch strong { font-size: 14px; }
.wh-suggest .wh-suggest-switch small { max-width: 64ch; }
.wh-suggest[data-on="false"] .wh-suggest-switch:hover { background: var(--ui-fill-2); }
.wh-setup { padding: 4px 18px 18px 58px; border-top: 1px solid var(--ui-sep); padding-top: 16px; }
.wh-setup .workspace-field { max-width: 560px; }
.wh-setup .workspace-field small { color: var(--c-ink-3); font-size: 12px; font-weight: 400; line-height: 1.5; }
.wh-setup .wh-help { margin: 0 0 10px; }
.wh-setup-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.wh-setup-actions .wh-status { flex: 1 1 220px; margin: 0; }
.wh-setup-actions button { margin: 0; min-height: 34px; padding: 8px 15px; font-size: 13px; border-radius: var(--ui-r-control); }
.wh-recent > header { align-items: flex-start; }
.wh-recent .wh-status { margin: 0 0 10px; }
.wh-deliveries { margin: 0; padding: 0; list-style: none; }
.wh-deliveries li { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--ui-sep); }
.wh-deliveries li:first-child { border-top: 0; }
.wh.wh-agent .wh-delivery { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "event state" "meta state";
  gap: 2px 12px; align-items: center; margin: 0; padding: 10px 6px; border: 0; border-radius: var(--ui-r-control);
  background: none; color: var(--c-ink); text-align: left; font-size: 13px; }
.wh-delivery-event { grid-area: event; font-weight: 600; }
.wh-delivery-meta { grid-area: meta; font-size: 12px; color: var(--c-ink-3); overflow-wrap: anywhere; }
.wh-delivery .wh-badge { grid-area: state; }
.wh-agent .wh-pagination { margin-top: 8px; }
.wh-agent-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0; padding: 0 2px; }

@media (hover: hover) and (pointer: fine) {
  .wh-link:hover { color: var(--accent); }
  .wh-event:hover { border-color: var(--c-ink-4); }
  .wh-table tbody tr:hover { background: var(--c-paper); }
  .wh.wh-agent .wh-delivery:hover { background: var(--ui-fill-2); }
}
/* The setup form arrives under the switch that opened it: a short rise and
 * fade on the console's ease, no overshoot (nothing was thrown). */
@media (prefers-reduced-motion: no-preference) {
  .wh-suggest[data-on="true"] .wh-setup { animation: wh-reveal 220ms var(--ease-out); }
  @keyframes wh-reveal { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
}
@media (prefers-reduced-motion: reduce) {
  .wh button, .wh-modal button, .wh-event { transition: none; }
  .wh button:active, .wh-modal button:active { transform: none; }
}
@media (max-width: 700px) {
  .wh-head { flex-wrap: wrap; gap: 18px; }
  .wh-card-head { flex-wrap: wrap; padding: 16px; }
  .wh-card-head > .wh-actions { width: 100%; }
  .wh-card-foot { padding: 12px 16px; }
  .wh-guide-grid { grid-template-columns: 1fr; gap: 12px; }
  .wh-event-group { grid-template-columns: 1fr; }
  .wh .wh-field input, .wh .wh-field select, .wh-setup input, .wh-setup select { font-size: 16px; min-height: 40px; }
  .wh-facts { grid-template-columns: 1fr; }
  .wh-table th, .wh-table td { padding: 12px; }
  .wh button { min-height: 40px; }
  .wh-secret { align-items: flex-start; }
  .wh-setup { padding: 14px 14px 16px; }
  .wh-suggest .wh-suggest-switch { padding: 14px; }
  .wh-setup-actions button { flex: 1 1 auto; min-height: 42px; }
  .wh-setup-actions .wh-status { flex-basis: 100%; }
  .wh-quiet { flex-direction: column; }
}
/* Give workspace settings room. An active call keeps its existing controls. */
body:not(.calling) .app.webhooks-workspace { grid-template-columns: 216px minmax(0, 1fr); }
body:not(.calling) .webhooks-workspace > .rail, body:not(.calling) .webhooks-workspace > .dock,
body:not(.calling) .webhooks-workspace > .insp { display: none; }
