:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #667085;
  --line: #d9e0ea;
  --blue: #2563eb;
  --blue-strong: #1d4ed8;
  --green: #15803d;
  --amber: #a16207;
  --red: #b91c1c;
  --slate: #475569;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-size: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 700;
}

h2 {
  font-size: 16px;
  font-weight: 700;
}

.muted {
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px;
}

.panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel-wide {
  grid-column: 1 / -1;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.form-grid,
.webhook-form,
.session-form,
.login-form {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.webhook-form {
  grid-template-columns: minmax(0, 1.4fr) minmax(160px, 0.4fr) minmax(160px, 0.5fr) auto;
}

.session-form {
  grid-template-columns: minmax(170px, 0.7fr) minmax(110px, 0.35fr) minmax(180px, 0.8fr) minmax(180px, 0.7fr);
}

.login-form {
  grid-template-columns: minmax(160px, 0.6fr) minmax(140px, 0.4fr) minmax(180px, 0.6fr) auto;
}

.field-wide,
.events {
  grid-column: 1 / -1;
}

.checkline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
}

.checkline input {
  width: auto;
  min-height: 0;
}

.stack {
  display: grid;
  gap: 12px;
}

.split {
  display: grid;
  grid-template-columns: minmax(120px, 0.45fr) minmax(0, 1fr);
  gap: 12px;
}

label,
fieldset {
  display: grid;
  gap: 6px;
  color: var(--slate);
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid #c7d0dd;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

textarea {
  resize: vertical;
}

button {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--blue);
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--blue-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.secondary {
  border-color: #c7d0dd;
  background: #fff;
  color: var(--text);
}

button.secondary:hover {
  background: #f2f5f9;
}

button.danger {
  border-color: var(--red);
  background: #fff;
  color: var(--red);
}

.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.align-end {
  align-self: end;
}

.status-pill,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--slate);
  font-weight: 700;
}

.badge.connected,
.status-pill.ok {
  background: #dcfce7;
  color: var(--green);
}

.badge.starting,
.badge.auth_required,
.status-pill.warn {
  background: #fef3c7;
  color: var(--amber);
}

.badge.error,
.status-pill.error {
  background: #fee2e2;
  color: var(--red);
}

.session-list,
.webhook-list {
  display: grid;
  gap: 10px;
}

.empty {
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
}

.row-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.row-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.row-title {
  font-weight: 800;
  overflow-wrap: anywhere;
}

.meta {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

.events {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.events label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.events input {
  width: auto;
  min-height: 0;
}

.spacer-top {
  margin-top: 14px;
}

.result {
  min-height: 90px;
  max-height: 260px;
  overflow: auto;
  margin: 14px 0 0;
  padding: 12px;
  border-radius: 6px;
  background: #101828;
  color: #d1e7ff;
  font-size: 12px;
  line-height: 1.5;
}

.compact-result {
  min-height: 60px;
  max-height: 180px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 28px rgb(15 23 42 / 16%);
  color: var(--text);
  font-weight: 700;
}

@media (max-width: 820px) {
  .topbar,
  .layout {
    padding-left: 14px;
    padding-right: 14px;
  }

  .layout,
  .form-grid,
  .webhook-form,
  .session-form,
  .login-form,
  .split {
    grid-template-columns: 1fr;
  }

  .topbar,
  .panel-head,
  .row-card-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
