:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --text: #17202a;
  --muted: #667085;
  --line: #d8dee7;
  --primary: #126b5b;
  --primary-2: #0f5d50;
  --accent: #b9432f;
  --warn: #b7791f;
  --ok: #16845f;
  --shadow: 0 12px 30px rgba(30, 45, 62, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 18px;
  border-right: 1px solid var(--line);
  background: #fbfcfd;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 15px;
}

.brand span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #344054;
  text-align: left;
}

.nav-item:hover {
  background: var(--surface-2);
}

.nav-item.active {
  background: #dcece8;
  color: var(--primary-2);
  font-weight: 700;
}

.status-panel {
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
}

.status-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--muted);
}

.dot.online {
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(22, 132, 95, 0.14);
}

.main {
  min-width: 0;
  padding: 24px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

.topbar p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button,
.secondary-button,
.primary-button {
  min-height: 36px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.icon-button {
  width: 36px;
  font-size: 20px;
  line-height: 1;
}

.secondary-button,
.primary-button {
  padding: 0 13px;
  font-size: 13px;
  font-weight: 700;
}

.primary-button {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.primary-button:hover {
  background: var(--primary-2);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

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

.metric {
  padding: 16px;
}

.metric span,
.metric small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 26px;
  line-height: 1.1;
}

.layout-two {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.55fr);
  gap: 14px;
}

.panel {
  min-width: 0;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  font-size: 15px;
}

.panel-head span {
  color: var(--muted);
  font-size: 12px;
}

.feed,
.conversation-list,
.thread-panel,
.contact-grid,
.audit-list,
.api-grid {
  min-height: 240px;
}

.feed {
  display: grid;
  gap: 0;
}

.feed-item,
.conversation,
.audit-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.feed-item:last-child,
.conversation:last-child,
.audit-item:last-child {
  border-bottom: 0;
}

.feed-item strong,
.conversation strong,
.audit-item strong {
  display: block;
  font-size: 14px;
}

.feed-item p,
.conversation p,
.audit-item p {
  margin-top: 5px;
  color: #3d4a5c;
  font-size: 13px;
  line-height: 1.45;
}

.feed-item time,
.conversation time,
.audit-item time {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.queue {
  display: grid;
}

.queue div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.queue div:last-child {
  border-bottom: 0;
}

.queue span {
  color: var(--muted);
}

.message-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 14px;
  min-height: 650px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

input,
select {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
}

.conversation-list {
  max-height: 590px;
  overflow: auto;
}

.conversation {
  width: 100%;
  border-right: 0;
  border-left: 0;
  border-top: 0;
  background: #fff;
  text-align: left;
}

.conversation.active {
  background: #eef7f4;
}

.conversation-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.badge {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 999px;
  background: #f7e4df;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.badge.done {
  background: #e2f2ec;
  color: var(--ok);
}

.thread-panel {
  display: flex;
  flex-direction: column;
}

.thread-empty {
  display: grid;
  flex: 1;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
}

.thread {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  overflow: auto;
}

.bubble {
  max-width: 72%;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eef2f6;
}

.bubble.out {
  align-self: flex-end;
  background: #dcece8;
}

.bubble strong {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  color: var(--muted);
}

.bubble p {
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.bubble time {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
}

.contact-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
}

.contact {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.contact strong {
  display: block;
  font-size: 14px;
}

.contact span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.api-panel {
  min-height: 680px;
}

.api-toolbar {
  grid-template-columns: minmax(0, 1fr) 180px;
}

.api-warning {
  margin: 14px 16px 0;
  padding: 10px 12px;
  border: 1px solid #c7e3d7;
  border-radius: 8px;
  background: #f1faf6;
  color: #146548;
  font-size: 13px;
  line-height: 1.45;
}

.api-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 0;
  align-items: stretch;
}

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

.api-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.api-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(18, 107, 91, 0.14);
}

.api-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.api-card h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.35;
}

.method {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 6px;
  background: #e8eef7;
  color: #2e5d9f;
  font-size: 11px;
  font-weight: 800;
}

.method.put {
  background: #f4ead8;
  color: #946200;
}

.api-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.api-meta span {
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: #475467;
  font-size: 11px;
  font-weight: 700;
}

.api-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.api-action {
  min-height: 32px;
  border: 1px solid var(--primary);
  border-radius: 7px;
  background: #fff;
  color: var(--primary-2);
  font-size: 12px;
  font-weight: 700;
}

.api-action:hover {
  background: #eef7f4;
}

.api-caller {
  min-height: 520px;
  border-left: 1px solid var(--line);
  background: #fbfcfd;
}

.caller-empty {
  display: grid;
  min-height: 240px;
  place-items: center;
  padding: 18px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.api-call-form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.caller-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.caller-head strong,
.caller-head span {
  display: block;
}

.caller-head strong {
  font-size: 14px;
  line-height: 1.35;
}

.caller-head span:not(.method) {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.api-call-form label {
  display: grid;
  gap: 7px;
}

.api-call-form label span {
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

textarea {
  width: 100%;
  min-height: 190px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  resize: vertical;
}

.caller-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.api-response {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #c7e3d7;
  border-radius: 8px;
  background: #f1faf6;
}

.api-response.error {
  border-color: #ead1c9;
  background: #fff6f3;
}

.api-response strong {
  color: #146548;
  font-size: 13px;
}

.api-response.error strong {
  color: #8a3a28;
}

.api-response pre {
  max-height: 260px;
  margin: 0;
  overflow: auto;
  color: #223043;
  white-space: pre-wrap;
  word-break: break-word;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.settings-panel {
  max-width: 720px;
}

.settings-form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.settings-form label {
  display: grid;
  gap: 7px;
}

.settings-form span {
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

.settings-form button {
  justify-self: start;
}

.audit-list {
  max-height: 620px;
  overflow: auto;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: 12px;
  }

  .nav {
    display: flex;
    min-width: max-content;
  }

  .status-panel {
    display: none;
  }

  .metrics,
  .layout-two,
  .message-layout,
  .contact-grid,
  .api-grid,
  .api-workspace {
    grid-template-columns: 1fr;
  }

  .api-caller {
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 640px) {
  .main {
    padding: 16px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .brand span {
    display: none;
  }

  .message-layout {
    min-height: auto;
  }

  .bubble {
    max-width: 92%;
  }
}
