:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --border: #e3e6ef;
  --text: #1a1f2e;
  --muted: #6b7488;
  --accent: #4353ff;
  --accent-soft: #eef0ff;
  --success: #1f9d55;
  --warn: #d97706;
  --code-bg: #0f172a;
  --code-text: #e2e8f0;
  --code-comment: #64748b;
  --code-keyword: #93c5fd;
  --code-string: #86efac;
  --code-number: #fca5a5;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}
header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
header h1 { font-size: 16px; font-weight: 600; margin: 0; }
header .badge {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  margin-left: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
header .user { font-size: 13px; color: var(--muted); }
main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  padding: 20px 28px;
  max-width: 1400px;
  margin: 0 auto;
}
@media (max-width: 900px) { main { grid-template-columns: 1fr; } }
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 22px 24px;
}
.panel h2 { margin: 0 0 4px 0; font-size: 15px; font-weight: 600; }
.panel .subtitle { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.field { margin-bottom: 18px; }
.field label {
  display: block; font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--muted); margin-bottom: 6px;
}
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
select, input[type="text"], input[type="number"], textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; font-family: inherit;
  background: white; color: var(--text);
}
select:focus, input:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea {
  resize: vertical; min-height: 70px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
}
.chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 6px; border: 1px solid var(--border);
  border-radius: 6px; background: white; min-height: 42px;
}
.chip {
  display: inline-flex; align-items: center;
  padding: 4px 8px 4px 10px;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 4px; font-size: 13px; font-weight: 500; gap: 6px;
}
.chip button {
  background: none; border: none; color: var(--accent);
  font-size: 14px; cursor: pointer; padding: 0; line-height: 1;
}
.chip-picker {
  flex: 1; min-width: 120px; border: none;
  padding: 4px 6px; font-size: 13px; background: transparent;
}
.radio-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.radio-card {
  border: 1px solid var(--border); padding: 10px 12px;
  border-radius: 6px; cursor: pointer;
  display: flex; gap: 10px; align-items: flex-start;
  transition: border-color 0.15s, background 0.15s;
}
.radio-card:hover { border-color: #b8bfd4; }
.radio-card.selected {
  border-color: var(--accent); background: var(--accent-soft);
}
.radio-card input { margin-top: 3px; }
.radio-card .rc-title { font-weight: 600; font-size: 13px; }
.radio-card .rc-desc { color: var(--muted); font-size: 12px; }
.params-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.actions {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 8px; padding-top: 20px;
  border-top: 1px solid var(--border);
}
button.primary {
  background: var(--accent); color: white; border: none;
  padding: 10px 18px; border-radius: 6px;
  font-size: 14px; font-weight: 600; cursor: pointer;
}
button.primary:hover { background: #3644d6; }
button.primary:disabled { background: #a0a7c4; cursor: not-allowed; }
button.secondary {
  background: white; color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 18px; border-radius: 6px;
  font-size: 14px; font-weight: 500; cursor: pointer;
}
.code-panel { display: flex; flex-direction: column; }
.code-header {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 12px;
}
.code-file {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px; color: var(--muted);
  background: #f0f2f8; padding: 3px 8px; border-radius: 4px;
}
pre.code {
  background: var(--code-bg); color: var(--code-text);
  padding: 16px 18px; border-radius: 6px;
  overflow-x: auto;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12.5px; line-height: 1.55;
  margin: 0; flex: 1; min-height: 400px;
}
.code-kw { color: var(--code-keyword); }
.code-str { color: var(--code-string); }
.code-num { color: var(--code-number); }
.code-com { color: var(--code-comment); font-style: italic; }
.flash { background: var(--code-bg); animation: flash 1.2s ease-out; }
@keyframes flash {
  0% { box-shadow: 0 0 0 0 rgba(67, 83, 255, 0); }
  30% { box-shadow: 0 0 0 6px rgba(67, 83, 255, 0.35); }
  100% { box-shadow: 0 0 0 0 rgba(67, 83, 255, 0); }
}
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--success); color: white;
  padding: 12px 18px; border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
  font-weight: 500; display: none; z-index: 100;
}
.toast.show { display: block; animation: toastin 0.3s ease-out; }
.toast.error { background: #dc2626; }
@keyframes toastin {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
details.slack-picker { position: relative; }
details.slack-picker summary {
  list-style: none;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 6px; background: white; cursor: pointer;
  font-size: 14px;
  display: flex; justify-content: space-between; align-items: center;
}
details.slack-picker summary::-webkit-details-marker { display: none; }
details.slack-picker summary::after { content: "▾"; color: var(--muted); }
details.slack-picker .dropdown {
  position: absolute; top: calc(100% + 4px);
  left: 0; right: 0; background: white;
  border: 1px solid var(--border); border-radius: 6px;
  max-height: 220px; overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08); z-index: 10;
}
details.slack-picker .dropdown input {
  border: none; border-bottom: 1px solid var(--border);
  border-radius: 0; padding: 10px 12px;
}
details.slack-picker .dropdown input:focus { box-shadow: none; }
details.slack-picker .dropdown .opt {
  padding: 8px 12px; cursor: pointer; font-size: 13px;
}
details.slack-picker .dropdown .opt:hover { background: var(--accent-soft); }
.placeholder { color: var(--muted); }
.loading { color: var(--muted); font-style: italic; }

.alert-row {
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 8px;
  background: white;
  overflow: hidden;
}
.alert-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  gap: 12px;
  cursor: pointer;
}
.alert-header:hover { background: #fafbff; }
.alert-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.alert-expand {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.alert-expand:hover { background: var(--border); }
.alert-details {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: #fafbff;
  font-size: 13px;
}
.alert-detail-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  padding: 5px 0;
  align-items: start;
}
.alert-detail-key {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding-top: 4px;
}
.alert-detail-val {
  color: var(--text);
  word-break: break-word;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12.5px;
  padding-top: 4px;
}
.alert-detail-code {
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  margin: 2px 0;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  line-height: 1.4;
  overflow-x: auto;
  white-space: pre;
}
.alert-row:last-child { margin-bottom: 0; }
.alert-info { flex: 1; min-width: 0; }
.alert-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 3px;
  word-break: break-word;
}
.alert-meta {
  font-size: 12px;
  color: var(--muted);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.alert-rule-pill {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-right: 6px;
}
.alert-delete {
  background: white;
  color: #b91c1c;
  border: 1px solid #fecaca;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
  flex-shrink: 0;
}
.alert-delete:hover { background: #fef2f2; border-color: #fca5a5; }
.alert-delete:disabled { opacity: 0.5; cursor: not-allowed; }
.alerts-empty {
  color: var(--muted);
  font-style: italic;
  padding: 6px 0;
}
