:root {
  --ink: #202124;
  --muted: #666d73;
  --line: #d8dde1;
  --bg: #f6f7f5;
  --panel: #ffffff;
  --accent: #16735f;
  --accent-strong: #0e5847;
  --warn: #a54b22;
  --danger: #9d2a35;
  --shadow: 0 12px 28px rgba(31, 37, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  min-height: 38px;
  padding: 0 14px;
}

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

button.secondary {
  color: var(--ink);
  background: #e7ece8;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  line-height: 1.5;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px 1fr;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #eef2ef;
  padding: 22px 16px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
}

.brand p,
.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.tab-button {
  width: 100%;
  background: transparent;
  color: var(--ink);
  text-align: left;
  border: 1px solid transparent;
}

.tab-button.active,
.tab-button:hover {
  background: #fff;
  border-color: var(--line);
}

.workspace {
  min-width: 0;
  padding: 22px;
}

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

.topbar h2,
.panel h3 {
  margin: 0;
}

.status-pill {
  min-width: 96px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 8px 12px;
  text-align: center;
  color: var(--muted);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.6fr);
  gap: 16px;
}

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

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

.chat-panel {
  min-height: 680px;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9faf8;
  padding: 14px;
}

.bubble {
  max-width: 76%;
  border-radius: 8px;
  padding: 11px 12px;
  line-height: 1.55;
}

.bubble.user {
  align-self: flex-end;
  background: #dfeee8;
}

.bubble.agent {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--line);
}

.bubble.safety {
  border-color: #edc3c8;
  background: #fff6f6;
}

.bubble small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
}

.composer {
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 10px;
  margin-top: 12px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.metrics div,
.voice-box,
.kv div,
.list-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 12px;
}

.metrics span,
.voice-box span,
.kv dt,
.small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.metrics strong,
.voice-box p,
.kv dd {
  margin: 0;
  word-break: break-word;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(140px, 1fr) 76px;
  gap: 8px;
  align-items: center;
}

.inline-form.wide {
  grid-template-columns: 1fr 80px 80px;
  margin-bottom: 14px;
}

.panel-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}

.wechat-form {
  display: grid;
  gap: 10px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.toggle {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.toggle input {
  width: auto;
}

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

.list-item strong {
  display: block;
  margin-bottom: 4px;
}

.list-item p {
  margin: 0;
  color: var(--muted);
}

.kv {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
}

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

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

  .nav-tabs {
    grid-template-columns: repeat(6, minmax(120px, 1fr));
    overflow-x: auto;
  }

  .split,
  .composer,
  .inline-form,
  .inline-form.wide {
    grid-template-columns: 1fr;
  }
}
