:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #2b3a55;
  --brand2: #3f5578;
  --ok: #0f9d58;
  --warn: #b45309;
  --err: #d93025;
  --bubble-user: #2b3a55;
  --bubble-bot: #eef2f9;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  padding: 24px 16px 60px;
}

.wrap { max-width: 900px; margin: 0 auto; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.top h1 { font-size: 18px; font-weight: 700; letter-spacing: .3px; }
.top .sub { color: var(--muted); font-size: 12px; }
.top a { color: var(--brand2); text-decoration: none; font-size: 13px; }
.top a:hover { text-decoration: underline; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 2px 10px rgba(31, 41, 55, .04);
  margin-bottom: 14px;
}

.card h2 {
  font-size: 14px; font-weight: 600; margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.card h2 .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand2); }

label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }

input[type=text], input[type=number], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fbfcfe;
  outline: none;
  transition: .18s;
}
input:focus, textarea:focus, select:focus {
  border-color: #8aa2c8; background: #fff;
  box-shadow: 0 0 0 4px rgba(63, 85, 120, .08);
}
textarea { resize: vertical; min-height: 80px; line-height: 1.5; font-size: 13px; }

button {
  border: none; border-radius: 10px; padding: 10px 16px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  background: var(--brand); color: #fff; transition: .18s;
}
button:hover { background: var(--brand2); transform: translateY(-1px); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
button.ghost { background: #eef1f7; color: var(--brand); }
button.ghost:hover { background: #e3e8f2; }
button.danger { background: #fdecea; color: var(--err); }
button.small { padding: 6px 10px; font-size: 12px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 120px; }

.hint { font-size: 12px; color: var(--muted); margin-top: 8px; }
.msg { font-size: 13px; margin-top: 10px; padding: 8px 12px; border-radius: 8px; display: none; }
.msg.show { display: block; }
.msg.ok { background: #e8f5ec; color: #0b6b3a; }
.msg.err { background: #fdecea; color: var(--err); }

.tag {
  display: inline-block; padding: 1px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600; line-height: 18px;
}
.tag.on { background: #e8f5ec; color: #0b6b3a; }
.tag.off { background: #f1f2f4; color: #6b7280; }
.tag.ai { background: #eaf0fb; color: #24457a; }
.tag.kw { background: #fff4e5; color: #96500b; }

.statusbar {
  display: flex; gap: 14px; flex-wrap: wrap; align-items: center;
  font-size: 12px; color: var(--muted);
  padding-bottom: 12px; border-bottom: 1px dashed var(--line); margin-bottom: 14px;
}
.statusbar b { color: var(--ink); font-weight: 600; }

.cols { display: grid; grid-template-columns: 1fr 1.2fr; gap: 14px; }
@media (max-width: 760px) { .cols { grid-template-columns: 1fr; } }

.rules { max-height: 300px; overflow: auto; font-size: 13px; }
.rules .item { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.rules .item:last-child { border-bottom: 0; }
.rules .kw { font-weight: 600; color: var(--brand); }
.rules .rep { color: var(--muted); font-size: 12px; margin-top: 2px; }

.chat {
  height: 340px; overflow-y: auto; background: #f7f9fc;
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; display: flex; flex-direction: column; gap: 10px;
}
.bubble { max-width: 84%; padding: 9px 12px; border-radius: 12px; font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.bubble.user { align-self: flex-end; background: var(--bubble-user); color: #fff; border-bottom-right-radius: 4px; }
.bubble.bot { align-self: flex-start; background: var(--bubble-bot); border-bottom-left-radius: 4px; }
.bubble .meta { display: block; font-size: 10px; opacity: .65; margin-top: 4px; }

.chat-input { display: flex; gap: 8px; margin-top: 10px; }
.chat-input input { flex: 1; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
td code { background: #f3f5f9; padding: 2px 6px; border-radius: 5px; font-size: 12px; }

.pill { font-size: 11px; padding: 2px 8px; border-radius: 20px; background: #eef1f7; color: var(--brand); }
.footer { text-align: center; color: #9aa3af; font-size: 12px; margin-top: 24px; }
