/* Webhooks — design tokens + components. Bordered-card rail, both themes. */

:root {
  color-scheme: light dark;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #d7dbe1;
  --border-strong: #b9c0c9;
  --text: #1c2129;
  --text-2: #5b6572;
  --accent: #3b6ef6;
  --accent-text: #ffffff;
  --accent-soft: #e7edff;
  --accent-contr: #e7edff;
  --danger: #d53a3a;
  --danger-bg: #fdecec;
  --ok: #1a9e4b;
  --ok-bg: #e7f6ec;
  --warn: #b8860b;
  --warn-bg: #fbf3dd;
  --shadow: 0 1px 2px rgba(20, 24, 31, 0.06);
  --radius: 8px;
  --radius-sm: 6px;
  --spacer: 20px;
  --header-h: 56px;
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121418;
  --surface: #1b1f26;
  --surface-2: #22272f;
  --border: #2c323b;
  --border-strong: #3c434e;
  --text: #e6e9ee;
  --text-2: #9aa3b0;
  --accent: #5a8bff;
  --accent-text: #0d1219;
  --accent-contr: #232c42;
  --accent-soft: #1e2640;
  --danger: #f26363;
  --danger-bg: #3a2222;
  --ok: #3ecf7a;
  --ok-bg: #1e3327;
  --warn: #e0b13e;
  --warn-bg: #37301b;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--header-h) + 12px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--mono); }
code { font-size: 0.9em; }

/* Skip link */
.skip-link {
  position: absolute; left: -999px; top: 8px; z-index: 1000;
  background: var(--accent); color: var(--accent-text);
  padding: 8px 14px; border-radius: var(--radius-sm);
}
.skip-link:focus { left: 8px; }

/* App shell */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  margin: 0 auto; padding: 0 24px;
  height: 100%; display: flex; align-items: center; gap: 24px;
}
.brand { font-weight: 700; font-size: 17px; color: var(--text); letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
nav { display: flex; gap: 6px; }
nav a {
  color: var(--text-2); padding: 6px 10px; border-radius: var(--radius-sm);
  font-weight: 500;
}
nav a:hover { color: var(--text); text-decoration: none; background: var(--surface-2); }
nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.account { color: var(--text-2); font-size: 13px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-ghost { color: var(--text-2); font-size: 13px; }
.link-ghost:hover { color: var(--text); }

/* Theme toggle */
.theme-toggle { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.theme-btn {
  background: transparent; border: 0; padding: 5px 12px; font-size: 13px;
  color: var(--text-2); cursor: pointer;
}
.theme-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }

.page-wrap { margin: 0 auto; padding: 28px 24px 80px; }

/* Cards — single bordered rail */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--spacer);
  box-shadow: var(--shadow);
}
@media (forced-colors: active) {
  .card, .site-header, .dialog-card, .toast { border: 1px solid CanvasText; }
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 16px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px;
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
}
a.btn { text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-ghost { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-icon { background: transparent; border: 0; cursor: pointer; color: var(--text-2); font-size: 16px; padding: 2px 6px; border-radius: 4px; }
.btn-icon:hover { color: var(--text); background: var(--surface-2); }

/* Forms */
.field { margin-bottom: 14px; }
label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
input[type="text"], input[type="email"], input[type="password"], .url-cell {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent); border: 1px solid transparent;
  white-space: nowrap;
}
.badge-filled { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.badge-ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge-pending { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge-disabled { background: transparent; color: var(--text-2); border-color: var(--border-strong); }
.badge-method.get { background: var(--ok-bg); color: var(--ok); }
.badge-method.post { background: var(--accent-contr); color: var(--accent); }
.badge-method.put, .badge-method.patch { background: var(--warn-bg); color: var(--warn); }
.badge-method.delete { background: var(--danger-bg); color: var(--danger); }

/* Page head */
.page-head { margin-bottom: 20px; }
.page-head h1 { margin: 0 0 4px; font-size: 24px; }
.muted { color: var(--text-2); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Dashboard create card */
.create-row { display: flex; gap: 12px; align-items: flex-end; }
.create-row > div { flex: 1; }
.create-card { margin-bottom: 24px; }

/* Data table */
.table-card { padding: 0; overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.data-table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-2); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--surface-2); }
.url-cell { font-size: 13px; background: var(--surface-2); width: auto; }
.row-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.inline-form { display: inline; }

/* Empty state */
.empty-state { text-align: center; padding: 40px 20px; }
.empty-icon { font-size: 32px; }
.empty-state h2 { margin: 12px 0 6px; font-size: 18px; }
.empty-state p { color: var(--text-2); margin: 0 auto 16px; max-width: 420px; }

/* Code block */
.code-block {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px; overflow: auto; font-size: 13px; line-height: 1.5; margin: 8px 0 12px;
  max-height: 480px; white-space: pre-wrap; word-break: break-word;
}

/* Master-detail */
.viewer-head { margin-bottom: 20px; }
.master-detail { display: grid; grid-template-columns: 340px 1fr; gap: 20px; align-items: start; }
.md-list { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.md-list-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.md-list-head h2 { font-size: 15px; margin: 0; }
.request-list { list-style: none; margin: 0; padding: 0; max-height: calc(100vh - 220px); overflow: auto; }
.request-item {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: center;
  width: 100%; text-align: left; padding: 10px 16px; background: transparent; border: 0;
  border-bottom: 1px solid var(--border); cursor: pointer; color: var(--text); font: inherit;
}
.request-item:hover { background: var(--surface-2); }
.request-item[aria-selected="true"] { background: var(--accent-contr); }
.ri-path { font-family: var(--mono); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ri-time, .ri-size { font-size: 12px; color: var(--text-2); }
.request-detail { max-height: calc(100vh - 220px); overflow: auto; }

.md-detail { min-width: 0; }
@media (max-width: 820px) {
  .master-detail { grid-template-columns: 1fr; }
}

/* Request detail */
.rd-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.rd-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.rd-title strong { font-family: var(--mono); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Definition lists (metadata grid) */
.dl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 0 0 16px; padding: 12px; background: var(--surface-2); border-radius: var(--radius-sm); }
.dl-pair dt { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-2); margin-bottom: 2px; }
.dl-pair dd { margin: 0; font-weight: 600; font-size: 13px; word-break: break-word; }

/* Key/value list (headers, query, form) */
.kv-list { margin: 0; }
.kv-row { display: grid; grid-template-columns: minmax(140px, 32%) 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.kv-row:last-child { border-bottom: 0; }
.kv-row dt { font-family: var(--mono); font-size: 13px; color: var(--text-2); word-break: break-word; }
.kv-row dd { margin: 0; font-family: var(--mono); font-size: 13px; word-break: break-word; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tabs button {
  background: transparent; border: 0; padding: 8px 14px; cursor: pointer;
  font-weight: 600; font-size: 14px; color: var(--text-2); border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tabs button:disabled { opacity: 0.4; cursor: not-allowed; }

/* Alert */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; border: 1px solid var(--border); }
.alert-success { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.alert-info { background: var(--accent-contr); color: var(--accent); border-color: transparent; }

/* Auth */
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 32px; }
.auth-tagline { color: var(--text-2); margin: 4px 0 24px; }
.auth-result { min-height: 20px; }
.auth-footer { text-align: center; color: var(--text-2); font-size: 14px; margin-top: 20px; }
.auth-error, .auth-pending, .auth-success { padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px; }
.auth-error { background: var(--danger-bg); color: var(--danger); }
.auth-success { background: var(--ok-bg); color: var(--ok); }
.auth-pending { background: var(--surface-2); color: var(--text-2); }

/* Dialog */
.dialog { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,0.45); display: grid; place-items: center; padding: 20px; }
.dialog[hidden] { display: none; }
.dialog-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; max-width: 420px; width: 100%; }
.dialog-card h2 { margin: 0 0 8px; font-size: 18px; }
.dialog-card p { margin: 0 0 20px; color: var(--text-2); }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* Toasts */
.toast-region { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 10px 14px; font-size: 14px; display: flex; gap: 10px; align-items: center; max-width: 320px; }
.toast-close { background: transparent; border: 0; cursor: pointer; color: var(--text-2); font-size: 16px; line-height: 1; }

/* Forced colors */
@media (forced-colors: active) {
  .badge, .theme-btn { border: 1px solid currentColor; }
}

/* Replay dialog */
.dialog-card-wide { max-width: 640px; }
textarea.code-input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-family: var(--mono); font-size: 13px; line-height: 1.5;
  resize: vertical;
}
select {
  padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit;
}
.replay-result { min-height: 20px; margin-bottom: 12px; }
.replay-response { max-height: 320px; }

/* Request detail actions (replay + export) */
.rd-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.export-split { display: inline-flex; gap: 4px; align-items: center; padding-left: 8px; border-left: 1px solid var(--border); }
.export-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-2); margin-right: 4px; }
.btn-sm { padding: 5px 10px; font-size: 13px; }

/* Viewer head buttons */
.viewer-copy { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Security page */
.security-add-card { margin-bottom: 20px; }
.security-add-row { display: flex; gap: 12px; align-items: flex-end; }
.security-add-row input { flex: 1; }