:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #20242c;
  --muted: #667085;
  --line: #d9e0ea;
  --blue: #2563eb;
  --blue-soft: #eaf1ff;
  --green: #177a55;
  --red: #b42318;
  --amber: #a15c07;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 12px 30px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "SF Pro Text", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 38px;
  padding: 9px 12px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}

button:hover {
  border-color: #b6c0cf;
  background: #f9fbfd;
  box-shadow: var(--shadow-sm);
}

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

button:active:not(:disabled) {
  transform: translateY(1px);
}

button.primary {
  position: relative;
  overflow: hidden;
  background: var(--blue);
  border-color: var(--blue);
  color: #ffffff;
}

button.primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 0%, rgba(255, 255, 255, 0.28) 42%, transparent 64%);
  transform: translateX(-120%);
}

button.primary:hover::after {
  animation: statusSheen 1s ease;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #ffffff;
  min-height: 38px;
  padding: 9px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  letter-spacing: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: #ffffff;
  padding: 16px;
  display: grid;
  align-content: start;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 2px 8px;
}

.brand p,
.panel-head p,
.note {
  color: var(--muted);
  line-height: 1.55;
}

.mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #172033 0%, #253858 100%);
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(23, 32, 51, 0.16);
}

.mark svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

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

.side-card h2 {
  font-size: 13px;
  color: var(--muted);
}

.bot-manager {
  background: #fbfcff;
}

.mini-list {
  display: grid;
  gap: 8px;
  max-height: 180px;
  overflow: auto;
}

.mini-item {
  display: grid;
  gap: 3px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.mini-item strong {
  font-size: 13px;
}

.mini-item span,
.mini-empty {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.empty-state {
  display: grid;
  gap: 6px;
  align-content: center;
  min-height: 92px;
  padding: 16px;
  border: 1px dashed #cfd8e6;
  border-radius: 6px;
  background: #fbfcfe;
  color: var(--muted);
  text-align: left;
}

.empty-state strong {
  color: #344054;
  font-size: 14px;
}

.empty-state span,
.empty-state small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.empty-state small {
  color: #475467;
}

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

.webhook-list-panel {
  display: block;
}

.webhook-list-panel summary {
  display: grid;
  gap: 6px;
  cursor: pointer;
  list-style-position: inside;
}

.webhook-list-panel summary strong {
  font-size: 16px;
}

.webhook-list-panel summary span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.webhook-list-panel[open] summary {
  margin-bottom: 12px;
}

.webhook-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.webhook-item div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.webhook-item span {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 12px;
  font-style: normal;
  font-weight: 600;
  color: #2563eb;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
}

.status-badge.warn {
  color: #9a3412;
  background: #fff7ed;
  border-color: #fed7aa;
}

.webhook-send-box {
  display: grid;
  gap: 12px;
  padding-top: 8px;
}

.webhook-batch-section {
  background: #fbfcff;
}

.webhook-batch-section .field {
  margin-top: 12px;
}

.side-nav {
  display: grid;
  gap: 8px;
  padding-top: 4px;
}

.nav-button {
  position: relative;
  text-align: left;
  border-color: transparent;
  background: transparent;
  font-weight: 700;
  min-height: 40px;
  padding: 9px 11px;
}

.nav-button:hover,
.nav-button.is-active {
  border-color: rgba(37, 99, 235, 0.18);
  background: var(--blue-soft);
  color: var(--blue);
}

.nav-button.is-active::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 50%;
  width: 5px;
  height: 18px;
  border-radius: 999px;
  background: var(--blue);
  transform: translateY(-50%);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08);
}

.workspace {
  min-width: 0;
  padding: 18px;
  display: grid;
  gap: 14px;
  align-content: start;
}

.status-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
}

.status-band > div,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.status-band > div {
  position: relative;
  overflow: hidden;
  padding: 12px 14px;
  display: grid;
  gap: 5px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.status-band > div:hover {
  border-color: rgba(37, 99, 235, 0.22);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.status-band > div::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(100deg, transparent 0%, rgba(37, 99, 235, 0.08) 45%, transparent 70%);
  opacity: 0;
  transform: translateX(-100%);
}

.status-band > div:hover::after {
  animation: statusSheen 1.05s ease;
}

.status-band strong {
  overflow-wrap: anywhere;
}

.status-band #wsState {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  line-height: 1.4;
}

.usage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1.5fr)) repeat(4, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.usage-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 16px;
  display: grid;
  gap: 8px;
  align-content: start;
  min-height: 128px;
}

.usage-card > span,
.usage-card small,
.usage-card-head,
.usage-meta {
  color: var(--muted);
  font-size: 12px;
}

.usage-scope {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.usage-card strong {
  font-size: 28px;
  line-height: 1.1;
}

.usage-card-wide {
  background: #fbfcff;
}

.manual-quota-card {
  background: #fffdf8;
}

.manual-quota-form {
  display: grid;
  grid-template-columns: minmax(80px, 1fr) minmax(90px, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.manual-quota-form label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.manual-quota-form input {
  min-height: 34px;
  padding: 7px 9px;
}

.manual-quota-form button {
  min-height: 34px;
  padding: 7px 12px;
}

.usage-card-head,
.usage-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.usage-main {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.usage-main strong {
  font-size: 34px;
}

.usage-main span {
  color: var(--muted);
  font-weight: 700;
}

.usage-progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f7;
}

.usage-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 0.2s ease;
}

.usage-progress span.warn {
  background: var(--amber);
}

.usage-progress span.danger {
  background: var(--red);
}

.usage-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.usage-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 14px;
}

.usage-section h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.usage-list {
  display: grid;
  gap: 8px;
}

.usage-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.usage-line div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.usage-line strong,
.usage-line span {
  overflow-wrap: anywhere;
}

.usage-line span,
.usage-empty {
  color: var(--muted);
  font-size: 12px;
}

.usage-line b {
  font-size: 16px;
  white-space: nowrap;
}

.label,
.field span {
  color: var(--muted);
  font-size: 12px;
}

.field {
  display: grid;
  gap: 8px;
}

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

.field-tools {
  display: inline-flex;
  gap: 6px;
}

.field-tools button {
  padding: 5px 8px;
  font-size: 12px;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
  animation: panelIn 0.16s ease;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) minmax(500px, 0.82fr);
  gap: 16px;
  align-items: start;
}

.right-rail {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 12px;
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding-right: 2px;
}

.panel {
  padding: 16px;
}

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

.head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: end;
}

.composer,
.ai-tools {
  display: grid;
  gap: 12px;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

details.side-card summary {
  cursor: pointer;
  font-weight: 800;
}

details.side-card[open] summary {
  margin-bottom: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.template-tools {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(180px, 0.7fr) repeat(3, auto);
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.mention-tools {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) repeat(4, auto);
  gap: 10px;
  align-items: end;
}

.compact-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 10px 12px;
}

.compact-section summary {
  cursor: pointer;
  font-weight: 700;
  color: #344054;
}

.compact-section[open] summary {
  margin-bottom: 10px;
}

.module-builder {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  padding: 12px;
  display: grid;
  gap: 12px;
}

.module-builder[hidden] {
  display: none;
}

.module-builder-head,
.module-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.module-builder-head h3,
.module-builder-head p {
  margin: 0;
}

.module-builder-head p {
  color: var(--muted);
  font-size: 12px;
}

.module-actions,
.module-item-head {
  flex-wrap: wrap;
}

.module-list {
  display: grid;
  gap: 10px;
}

.module-item {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.module-item-head {
  display: grid;
  grid-template-columns: 130px minmax(180px, 1fr) repeat(3, auto);
}

.module-title-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.module-title-field button,
.module-field-tools button {
  min-height: 34px;
  padding: 7px 10px;
}

.module-field {
  display: grid;
  gap: 8px;
}

.module-field > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.module-field-tools {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.action-stack {
  display: grid;
  grid-template-columns: 1fr;
}

.action-panel {
  background: #fbfcff;
}

.preview-panel {
  overflow: visible;
}

.tab-panel[data-panel="webhooks"] .split-layout {
  grid-template-columns: minmax(520px, 1fr) minmax(560px, 0.9fr);
}

.tab-panel[data-panel="webhooks"] .preview-panel {
  max-height: none;
}

#webhookPreview {
  min-height: 520px;
}

.icon-button {
  width: auto;
  min-width: 72px;
}

.ai-tools {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel-soft);
}

.rule-tools {
  display: grid;
  gap: 14px;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel-soft);
}

.tab-panel[data-panel="ai"] > .panel {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(380px, 0.85fr);
  gap: 16px;
  align-items: start;
}

.tab-panel[data-panel="ai"] > .panel > .panel-head {
  grid-column: 1 / -1;
}

.tab-panel[data-panel="ai"] .rule-tools {
  margin-top: 0;
}

.panel-head.compact {
  margin-bottom: 0;
}

.ai-switches {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
}

.ai-switches label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.ai-switches input {
  width: auto;
}

.ai-switches strong {
  color: var(--muted);
  font-size: 12px;
}

.ai-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.1fr) minmax(180px, 0.9fr) minmax(220px, 1fr) 110px;
  gap: 10px;
}

.schedule-tools {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 160px repeat(3, auto);
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.schedule-list,
.message-list,
.log-list,
.rule-list {
  display: grid;
  gap: 10px;
}

.right-rail .schedule-list {
  max-height: calc(100vh - 220px);
  overflow: auto;
  padding-right: 4px;
}

.message-list,
.log-list {
  max-height: calc(100vh - 214px);
  overflow: auto;
  padding-right: 4px;
}

.message,
.log,
.schedule-item,
.rule-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
}

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

.message.is-system {
  background: #f7f8fb;
  color: var(--muted);
}

.message-meta,
.log-meta,
.preview-meta,
.schedule-meta {
  color: var(--muted);
  font-size: 12px;
}

.message-meta,
.log-meta {
  margin-bottom: 8px;
}

.message-content,
.log-content,
.preview-text,
.preview-markdown {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
}

.message-actions {
  display: flex;
  align-items: start;
}

.select-message {
  padding: 7px 10px;
}

.raw-json {
  margin-top: 10px;
}

.raw-json summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}

.raw-json pre {
  max-height: 240px;
  overflow: auto;
  margin: 8px 0 0;
  padding: 10px;
  border-radius: 8px;
  background: #f7f8fb;
  border: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.45;
}

.preview-box {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 14px;
  min-height: 260px;
  display: grid;
  gap: 12px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.preview-box.is-updated {
  animation: previewPulse 0.62s ease;
}

.preview-box.is-loading::after {
  content: "";
  position: absolute;
  top: 10px;
  right: 12px;
  width: 46px;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.1), rgba(37, 99, 235, 0.5), rgba(37, 99, 235, 0.1));
  background-size: 160% 100%;
  animation: loadingSlide 0.88s ease-in-out infinite;
}

.preview-empty,
.schedule-empty {
  color: var(--muted);
}

.preview-markdown {
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f7f8fb;
  font-family: inherit;
}

.preview-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.preview-table-tools {
  position: sticky;
  left: 0;
  z-index: 1;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.preview-table-tools button {
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}

.preview-table-tools button[data-preview-table-action^="delete"] {
  color: #b42318;
  border-color: #f4c7c3;
  background: #fffafa;
}

.preview-table-tools button[data-preview-table-action^="delete"]:hover {
  border-color: #e99d95;
  background: #fff1f0;
}

.preview-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
}

.preview-table th,
.preview-table td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 13px 15px;
  text-align: left;
  vertical-align: middle;
}

.preview-table th {
  font-weight: 800;
  background: #ffffff;
}

.schedule-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.schedule-title {
  font-weight: 800;
  margin-bottom: 6px;
}

.schedule-title span {
  margin-left: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.schedule-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: end;
}

.rule-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.rule-title {
  font-weight: 800;
  margin-bottom: 6px;
}

.rule-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.rule-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: end;
}

.ws-chip {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f7f8fb;
  color: var(--muted);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
  max-width: 100%;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.ws-chip::before {
  content: "";
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #98a2b3;
}

.ws-chip::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(100deg, transparent 0%, rgba(255, 255, 255, 0.65) 42%, transparent 70%);
  transform: translateX(-110%);
  opacity: 0;
}

.ws-chip:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.ws-chip.ok {
  border-color: rgba(23, 122, 85, 0.25);
  background: rgba(23, 122, 85, 0.08);
  color: var(--green);
}

.ws-chip.ok::before {
  background: var(--green);
  animation: capsulePulse 1.7s ease-in-out infinite;
}

.ws-chip.ok::after {
  animation: chipSheen 2.8s ease-in-out infinite;
}

.ws-chip.warn {
  border-color: rgba(161, 92, 7, 0.25);
  background: rgba(161, 92, 7, 0.08);
  color: var(--amber);
}

.ws-chip.warn::before {
  background: var(--amber);
  animation: capsulePulseAmber 1.25s ease-in-out infinite;
}

.ws-chip.idle::before {
  background: #98a2b3;
}

.log.ok {
  border-left: 4px solid var(--green);
}

.log.warn {
  border-left: 4px solid var(--amber);
}

.log.error {
  border-left: 4px solid var(--red);
}

@media (max-width: 1160px) {
  .split-layout {
    grid-template-columns: 1fr;
  }

  .tab-panel[data-panel="webhooks"] .split-layout,
  .tab-panel[data-panel="ai"] > .panel {
    grid-template-columns: 1fr;
  }

  .usage-grid,
  .usage-detail-grid {
    grid-template-columns: 1fr 1fr;
  }

  .right-rail {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .preview-panel {
    max-height: none;
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .side-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace {
    padding: 14px;
  }

  .status-band,
  .usage-grid,
  .usage-detail-grid,
  .form-grid,
  .ai-grid,
  .mention-tools,
  .template-tools,
  .schedule-tools,
  .schedule-item {
    grid-template-columns: 1fr;
  }

  .schedule-actions {
    justify-content: start;
  }
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes capsulePulse {
  0% {
    box-shadow: 0 0 0 0 rgba(23, 122, 85, 0.28);
  }
  70% {
    box-shadow: 0 0 0 7px rgba(23, 122, 85, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(23, 122, 85, 0);
  }
}

@keyframes capsulePulseAmber {
  0% {
    box-shadow: 0 0 0 0 rgba(161, 92, 7, 0.3);
  }
  70% {
    box-shadow: 0 0 0 7px rgba(161, 92, 7, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(161, 92, 7, 0);
  }
}

@keyframes chipSheen {
  0%,
  55% {
    opacity: 0;
    transform: translateX(-110%);
  }
  72% {
    opacity: 0.55;
  }
  100% {
    opacity: 0;
    transform: translateX(110%);
  }
}

@keyframes previewPulse {
  0% {
    border-color: var(--line);
    box-shadow: var(--shadow-sm);
    transform: translateY(0);
  }
  42% {
    border-color: rgba(37, 99, 235, 0.34);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08), var(--shadow-sm);
    transform: translateY(-1px);
  }
  100% {
    border-color: var(--line);
    box-shadow: none;
    transform: translateY(0);
  }
}

@keyframes loadingSlide {
  0% {
    background-position: 120% 0;
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
  100% {
    background-position: -60% 0;
    opacity: 0.55;
  }
}

@keyframes statusSheen {
  0% {
    opacity: 0;
    transform: translateX(-100%);
  }
  38% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateX(100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}

.demo-notice {
  position: sticky;
  z-index: 50;
  top: 10px;
  display: flex;
  width: fit-content;
  max-width: calc(100% - 28px);
  min-height: 34px;
  align-items: center;
  gap: 8px;
  margin: 10px auto -2px;
  padding: 7px 13px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: #53627e;
  box-shadow: 0 12px 30px rgba(48, 73, 123, 0.13);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  font-size: 12px;
}

.demo-notice strong {
  color: #2b57bd;
}

.demo-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #35b58a;
  box-shadow: 0 0 0 5px rgba(53, 181, 138, 0.13);
}

[data-demo-readonly="true"] button[data-demo-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.52;
  filter: saturate(0.65);
}

@media (max-width: 680px) {
  .demo-notice {
    position: relative;
    top: 0;
    align-items: flex-start;
    border-radius: 18px;
    line-height: 1.45;
  }

  .demo-notice span:last-child {
    flex: 1;
  }
}

/* Enterprise console polish: restrained, dense, operations-focused. */
:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #1f2937;
  --muted: #667085;
  --line: #d6dde8;
  --blue: #1d5fd1;
  --blue-soft: #eef4ff;
  --green: #087443;
  --red: #b42318;
  --amber: #a15c07;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 22px rgba(15, 23, 42, 0.07);
}

body {
  background:
    linear-gradient(180deg, #f8fafc 0, #f5f7fa 220px),
    var(--bg);
  color: var(--text);
}

button,
input,
textarea,
select,
.panel,
.side-card,
.mini-item,
.webhook-item,
.compact-section,
.module-builder,
.module-item,
.message,
.log,
.schedule-item,
.rule-item,
.preview-box,
.preview-table-wrap,
.usage-card,
.usage-section,
.usage-line {
  border-radius: 6px;
}

button {
  min-height: 36px;
  padding: 8px 12px;
  transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}

button:hover {
  border-color: #aeb9c9;
  background: #f8fafc;
  box-shadow: none;
}

button:active:not(:disabled) {
  transform: none;
}

button.primary {
  background: #1d5fd1;
  border-color: #1d5fd1;
  box-shadow: none;
}

button.primary::after,
.status-band > div::after,
.ws-chip::after {
  display: none;
}

button.primary:hover {
  background: #174ea8;
  border-color: #174ea8;
}

.app-shell {
  grid-template-columns: 268px minmax(0, 1fr);
}

.sidebar {
  background: #ffffff;
  padding: 14px;
  gap: 12px;
}

.brand {
  border-bottom: 1px solid var(--line);
  padding: 4px 2px 14px;
}

.mark {
  width: 36px;
  height: 36px;
  border-radius: 6px;
}

.mark svg {
  width: 22px;
  height: 22px;
}

h1 {
  font-size: 17px;
}

h2 {
  font-size: 15px;
}

.side-card {
  background: #fbfcfe;
  padding: 12px;
}

.side-card h2 {
  color: #344054;
  font-size: 12px;
  letter-spacing: 0.04em;
}

.side-nav {
  gap: 4px;
}

.nav-button {
  min-height: 38px;
  padding: 8px 12px 8px 16px;
  border-radius: 6px;
  color: #344054;
  font-weight: 700;
}

.nav-button:hover {
  border-color: transparent;
  background: #f3f6fa;
  color: #1d5fd1;
}

.nav-button.is-active {
  border-color: #cddcf8;
  background: #eef4ff;
  color: #174ea8;
}

.nav-button.is-active::before {
  left: 6px;
  width: 3px;
  height: 18px;
  background: #1d5fd1;
  box-shadow: none;
}

.workspace {
  padding: 16px;
  gap: 12px;
}

.status-band {
  gap: 10px;
}

.status-band > div {
  padding: 11px 13px;
  gap: 4px;
  box-shadow: none;
  border-color: #dbe2ec;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.status-band > div:hover {
  border-color: #b9c7dc;
  box-shadow: none;
  transform: none;
}

.status-band .label,
.field span {
  color: #667085;
}

.status-band strong {
  color: #1f2937;
  font-size: 13px;
}

.panel {
  padding: 15px;
  box-shadow: none;
  border-color: #dbe2ec;
}

.panel-head {
  padding-bottom: 12px;
  border-bottom: 1px solid #edf1f6;
}

.panel-head p {
  color: #667085;
  font-size: 13px;
}

.split-layout {
  gap: 14px;
}

.right-rail {
  gap: 10px;
}

.preview-box {
  min-height: 260px;
  border-color: #dbe2ec;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.preview-box.is-updated {
  animation: enterprisePreviewRefresh 0.44s ease;
}

.preview-box.is-loading::after {
  top: 0;
  left: 0;
  right: auto;
  width: 100%;
  height: 3px;
  border-radius: 0;
  background: linear-gradient(90deg, transparent, #1d5fd1, transparent);
  background-size: 220% 100%;
  animation: enterpriseLoadingBar 1s linear infinite;
}

.preview-meta {
  display: inline-flex;
  width: fit-content;
  min-height: 22px;
  align-items: center;
  border: 1px solid #dbe2ec;
  border-radius: 999px;
  background: #f8fafc;
  padding: 2px 8px;
  color: #475467;
  font-weight: 700;
}

.preview-edit-note {
  width: fit-content;
  border: 1px solid #dbe2ec;
  border-radius: 999px;
  background: #f8fafc;
  color: #667085;
  padding: 3px 9px;
  font-size: 12px;
  line-height: 1.4;
}

.preview-editable,
.preview-editable-cell {
  outline: none;
  transition: background 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.preview-editable {
  cursor: text;
}

.preview-editable:hover,
.preview-editable:focus {
  background: #fbfdff;
  box-shadow: inset 0 0 0 1px rgba(29, 95, 209, 0.22);
}

.preview-editable:focus {
  box-shadow: inset 0 0 0 2px rgba(29, 95, 209, 0.28);
}

.preview-editable-cell {
  cursor: text;
}

.preview-editable-cell:hover {
  background: #f4f8ff;
}

.preview-editable-cell:focus {
  background: #eef4ff;
  box-shadow: inset 0 0 0 2px rgba(29, 95, 209, 0.28);
}

.preview-markdown,
.raw-json pre {
  background: #f8fafc;
}

.preview-table th {
  background: #f8fafc;
  color: #1f2937;
}

.preview-table th,
.preview-table td {
  padding: 12px 14px;
}

.ws-chip {
  gap: 7px;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #f8fafc;
  color: #475467;
  font-size: 12px;
  font-weight: 700;
  box-shadow: none;
}

.ws-chip:hover {
  transform: none;
  box-shadow: none;
}

.ws-chip::before {
  width: 6px;
  height: 6px;
}

.ws-chip.ok {
  border-color: #b7e4cd;
  background: #ecfdf3;
  color: #067647;
}

.ws-chip.ok::before {
  background: #12b76a;
  animation: none;
}

.ws-chip.warn {
  border-color: #fedf89;
  background: #fffaeb;
  color: #93370d;
}

.ws-chip.warn::before {
  background: #f79009;
  animation: enterpriseStatusBlink 1.4s ease-in-out infinite;
}

.ws-chip.idle {
  border-color: #d0d5dd;
  background: #f8fafc;
  color: #667085;
}

.message,
.log,
.schedule-item,
.rule-item,
.webhook-item,
.module-item,
.usage-line {
  box-shadow: none;
  border-color: #dbe2ec;
}

.message:hover,
.schedule-item:hover,
.rule-item:hover,
.webhook-item:hover,
.module-item:hover {
  border-color: #b9c7dc;
  background: #fbfdff;
}

.usage-card,
.usage-section {
  box-shadow: none;
  border-color: #dbe2ec;
}

.usage-card strong {
  color: #101828;
}

@keyframes enterprisePreviewRefresh {
  0% {
    border-color: #dbe2ec;
    background: #ffffff;
  }
  45% {
    border-color: #9db8ed;
    background: #fbfdff;
  }
  100% {
    border-color: #dbe2ec;
    background: #ffffff;
  }
}

@keyframes enterpriseLoadingBar {
  0% {
    background-position: 120% 0;
  }
  100% {
    background-position: -120% 0;
  }
}

@keyframes enterpriseStatusBlink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

/* Liquid Glass / capsule layer: visual-only overrides that preserve the
   existing DOM ids and interaction hooks used by app.js. */
:root {
  --glass-bg: rgba(255, 255, 255, 0.58);
  --glass-bg-strong: rgba(255, 255, 255, 0.76);
  --glass-line: rgba(255, 255, 255, 0.72);
  --glass-line-soft: rgba(117, 143, 190, 0.22);
  --glass-shadow: 0 24px 64px rgba(38, 62, 108, 0.14), 0 4px 16px rgba(54, 83, 139, 0.08);
  --glass-blue: #356fe8;
  --glass-ink: #18243b;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 0%, rgba(173, 202, 255, 0.55), transparent 34%),
    radial-gradient(circle at 88% 8%, rgba(221, 190, 255, 0.42), transparent 31%),
    radial-gradient(circle at 50% 100%, rgba(179, 238, 229, 0.3), transparent 38%),
    linear-gradient(145deg, #eef4ff 0%, #f5f7fb 48%, #eaf3f7 100%);
}

.liquid-glass {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.13));
  border: 1px solid var(--glass-line);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
}

.app-shell {
  gap: 0;
  overflow: hidden;
  border-color: rgba(255, 255, 255, 0.78);
}

.sidebar {
  background: linear-gradient(180deg, rgba(246, 250, 255, 0.8), rgba(236, 243, 255, 0.56));
  border-right: 1px solid rgba(255, 255, 255, 0.74);
  backdrop-filter: blur(28px) saturate(135%);
  -webkit-backdrop-filter: blur(28px) saturate(135%);
}

.brand {
  border-bottom-color: rgba(117, 143, 190, 0.18);
}

.mark {
  border-radius: 14px;
  background: linear-gradient(145deg, #6e9dff, #7b66e8);
  box-shadow: 0 12px 24px rgba(72, 94, 207, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.side-card,
.panel,
.usage-card,
.usage-section {
  background: var(--glass-bg);
  border-color: var(--glass-line);
  box-shadow: 0 14px 34px rgba(49, 74, 122, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.52);
  backdrop-filter: blur(20px) saturate(135%);
  -webkit-backdrop-filter: blur(20px) saturate(135%);
}

.side-card {
  border-radius: 20px;
}

.panel {
  border-radius: 24px;
}

.nav-button,
.nav-button.is-active {
  border-radius: 999px !important;
}

.nav-button {
  border-color: transparent;
  color: #44516b;
}

.nav-button:hover {
  background: rgba(255, 255, 255, 0.5);
  border-color: rgba(255, 255, 255, 0.7);
  box-shadow: 0 8px 20px rgba(66, 96, 153, 0.08);
}

.nav-button.is-active {
  border-color: rgba(126, 158, 235, 0.38);
  background: linear-gradient(110deg, rgba(218, 231, 255, 0.96), rgba(241, 230, 255, 0.82));
  color: #2853b6;
  box-shadow: 0 10px 24px rgba(71, 101, 177, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.76);
}

.nav-button.is-active::before {
  left: 12px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--glass-blue);
  box-shadow: 0 0 0 4px rgba(53, 111, 232, 0.12);
}

.status-band > div {
  min-height: 62px;
  border-radius: 999px;
  border-color: var(--glass-line);
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.7), rgba(235, 241, 255, 0.56));
  box-shadow: 0 12px 28px rgba(55, 81, 130, 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(18px) saturate(135%);
  -webkit-backdrop-filter: blur(18px) saturate(135%);
}

.status-band > div:hover {
  border-color: rgba(125, 159, 230, 0.55);
  box-shadow: 0 16px 30px rgba(55, 81, 130, 0.13), inset 0 1px 0 rgba(255, 255, 255, 0.86);
}

.status-band strong {
  color: var(--glass-ink);
}

button,
.icon-button {
  border-radius: 999px !important;
  border-color: rgba(123, 149, 198, 0.26);
  background: rgba(255, 255, 255, 0.46);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.68), 0 6px 16px rgba(61, 89, 140, 0.07);
}

button:hover,
.icon-button:hover {
  border-color: rgba(94, 132, 205, 0.5);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 10px 22px rgba(61, 89, 140, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

button.primary {
  background: linear-gradient(110deg, #3f7bf0, #5d6ee4);
  border-color: rgba(70, 104, 215, 0.66);
  box-shadow: 0 10px 22px rgba(64, 95, 202, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.34);
}

button.primary:hover {
  background: linear-gradient(110deg, #346fe5, #515fda);
  border-color: rgba(61, 94, 200, 0.78);
}

input,
textarea,
select {
  border-radius: 14px;
  border-color: rgba(123, 149, 198, 0.28);
  background: rgba(255, 255, 255, 0.62);
  box-shadow: inset 0 1px 2px rgba(59, 84, 131, 0.04), 0 1px 0 rgba(255, 255, 255, 0.62);
}

input:focus,
textarea:focus,
select:focus,
button:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(78, 131, 237, 0.22);
  outline-offset: 2px;
  border-color: rgba(78, 131, 237, 0.62);
}

.compact-section,
.module-builder,
.message,
.log,
.schedule-item,
.rule-item,
.webhook-item,
.module-item,
.usage-line,
.preview-box {
  border-radius: 18px;
  border-color: var(--glass-line-soft);
  background: rgba(255, 255, 255, 0.38);
}

.preview-box {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.66), 0 12px 24px rgba(54, 79, 123, 0.06);
}

.ws-chip,
.status-badge,
.preview-meta,
.preview-edit-note {
  border-radius: 999px;
  border-color: rgba(114, 146, 213, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.68);
}

.usage-card strong {
  color: var(--glass-ink);
}

@media (max-width: 900px) {
  .app-shell {
    border-radius: 0;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.74);
  }

  .status-band > div {
    border-radius: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .liquid-glass,
  .side-card,
  .panel,
  .status-band > div,
  button,
  .nav-button {
    transition: none !important;
  }

  .tab-panel.is-active,
  .preview-box.is-updated,
  .preview-box.is-loading::after,
  .ws-chip.warn::before {
    animation: none !important;
  }
}
