:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #667085;
  --line: #dfe3e8;
  --surface: #ffffff;
  --canvas: #f5f6f7;
  --primary: #0b6e4f;
  --primary-hover: #085c42;
  --accent: #e4572e;
  --danger: #b42318;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
}
button, input, select, textarea { font: inherit; }
button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
button:hover { border-color: #aeb6bf; }
button.primary { color: #fff; border-color: var(--primary); background: var(--primary); }
button.primary:hover { background: var(--primary-hover); }
button.secondary { background: transparent; }
button.danger { color: var(--danger); }

.topbar {
  min-height: 76px;
  padding: 14px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  color: #fff;
  background: #202a33;
  border-bottom: 4px solid var(--accent);
}
h1, h2, p { margin: 0; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 17px; }
.topbar p { margin-top: 5px; color: #c9d1d8; }
.toolbar { display: flex; align-items: center; gap: 8px; }
.status { padding: 6px 10px; border-radius: 999px; font-size: 12px; }
.status.online { color: #d7f9e9; background: #176c4f; }
.status.offline { color: #ffe8e4; background: #71362e; }

main { width: min(1180px, calc(100% - 32px)); margin: 22px auto 48px; }
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  background: var(--surface);
}
.metrics div { padding: 16px 20px; border-right: 1px solid var(--line); }
.metrics div:last-child { border-right: 0; }
.metrics span { display: block; color: var(--muted); }
.metrics strong { display: block; margin-top: 4px; font-size: 24px; }

.tabs { display: flex; gap: 24px; margin-top: 24px; border-bottom: 1px solid var(--line); }
.tab { padding: 10px 2px; border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: transparent; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 650; }
.panel { display: none; padding: 22px 0; }
.panel.active { display: block; }
.section-head { min-height: 42px; display: flex; justify-content: space-between; align-items: flex-start; }

.list { border: 1px solid var(--line); background: var(--surface); }
.list.empty { padding: 30px; color: var(--muted); text-align: center; }
.list-row {
  min-height: 62px;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(240px, 2fr) auto;
  gap: 16px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: 0; }
.list-row small { display: block; margin-top: 4px; color: var(--muted); }
.last-message { color: #344054; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; gap: 8px; }
.manual-label { color: var(--accent); font-weight: 650; }

.rule-form {
  display: grid;
  grid-template-columns: 1fr 150px 2fr auto;
  gap: 8px;
  margin-bottom: 14px;
}
input, select, textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid #cdd3d9;
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #97cdbb; border-color: var(--primary); }
.simulate-form { width: min(720px, 100%); display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.simulate-form textarea { min-height: 110px; grid-column: 1 / -1; resize: vertical; }
.simulate-form button { justify-self: start; }
pre {
  margin-top: 16px;
  padding: 14px;
  min-height: 70px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #1f2933;
  color: #e8eef2;
  white-space: pre-wrap;
}
#toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 380px;
  padding: 12px 16px;
  border-radius: 6px;
  color: #fff;
  background: #202a33;
  opacity: 0;
  transform: translateY(8px);
  transition: 160ms ease;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 760px) {
  .topbar { align-items: flex-start; flex-direction: column; padding: 14px 16px; }
  .toolbar { width: 100%; flex-wrap: wrap; }
  main { width: min(100% - 20px, 1180px); margin-top: 12px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metrics div:nth-child(2) { border-right: 0; }
  .metrics div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .tabs { gap: 10px; overflow-x: auto; }
  .tab { white-space: nowrap; }
  .rule-form, .simulate-form { grid-template-columns: 1fr; }
  .simulate-form textarea { grid-column: auto; }
  .list-row { grid-template-columns: 1fr; gap: 8px; }
}

