:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-muted: #f1f5f9;
  --line: #d9e2ec;
  --line-strong: #bac8d8;
  --text: #132238;
  --muted: #61738a;
  --soft: #8a9aab;
  --primary: #1769e0;
  --primary-strong: #0f55c2;
  --primary-soft: #e8f1ff;
  --green: #0f9f6e;
  --green-soft: #e6f7f1;
  --amber: #b7791f;
  --amber-soft: #fff3d6;
  --red: #d92d20;
  --red-soft: #fff0ee;
  --violet: #6b4eff;
  --shadow: 0 12px 30px rgba(19, 34, 56, 0.08);
  --radius: 8px;
  --sidebar: 248px;
}

* {
  box-sizing: border-box;
}

html,
body,
.app {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

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

a {
  color: inherit;
  text-decoration: none;
}

.entry-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(241, 245, 249, 0.88)),
    url("data:image/svg+xml,%3Csvg width='1400' height='900' viewBox='0 0 1400 900' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='1400' height='900' fill='%23f6f8fb'/%3E%3Cg fill='none' stroke='%23c7d4e5' stroke-width='1' opacity='.68'%3E%3Cpath d='M0 110h1400M0 220h1400M0 330h1400M0 440h1400M0 550h1400M0 660h1400M0 770h1400M140 0v900M280 0v900M420 0v900M560 0v900M700 0v900M840 0v900M980 0v900M1120 0v900M1260 0v900'/%3E%3C/g%3E%3Cg fill='%23ffffff' stroke='%23cbd7e6'%3E%3Crect x='784' y='186' width='354' height='208' rx='8'/%3E%3Crect x='914' y='472' width='310' height='172' rx='8'/%3E%3C/g%3E%3Cg fill='%231769e0' opacity='.16'%3E%3Crect x='826' y='230' width='180' height='16' rx='4'/%3E%3Crect x='826' y='270' width='260' height='12' rx='3'/%3E%3Crect x='826' y='302' width='230' height='12' rx='3'/%3E%3C/g%3E%3C/svg%3E");
  background-position: center;
  background-size: cover;
}

.entry-shell {
  width: min(1040px, 100%);
  display: grid;
  grid-template-columns: minmax(280px, 0.78fr) minmax(420px, 1fr);
  gap: 18px;
  align-items: stretch;
}

.entry-copy {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  padding: 26px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
}

.entry-copy h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.16;
}

.entry-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.78;
}

.entry-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.entry-card {
  min-height: 300px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  padding: 22px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

.entry-card:hover,
.entry-card.active {
  transform: translateY(-2px);
  border-color: #9fc0ef;
  box-shadow: var(--shadow);
}

.entry-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
}

.entry-card strong {
  font-size: 22px;
  line-height: 1.2;
}

.entry-card span {
  color: var(--muted);
  line-height: 1.72;
}

.entry-card em {
  margin-top: auto;
  color: var(--primary);
  font-style: normal;
  font-weight: 800;
}

.login-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 440px) 1fr;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.76)),
    url("data:image/svg+xml,%3Csvg width='1600' height='900' viewBox='0 0 1600 900' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='1600' height='900' fill='%23f6f8fb'/%3E%3Cg fill='none' stroke='%23c7d4e5' stroke-width='1'%3E%3Cpath d='M0 130h1600M0 260h1600M0 390h1600M0 520h1600M0 650h1600M0 780h1600M160 0v900M320 0v900M480 0v900M640 0v900M800 0v900M960 0v900M1120 0v900M1280 0v900M1440 0v900' opacity='.65'/%3E%3Cpath d='M120 710c210-140 450-160 720-60s470 20 650-140' stroke='%231769e0' stroke-width='4' opacity='.22'/%3E%3Cpath d='M180 250c220 90 360 90 540 20s340-70 610 80' stroke='%230f9f6e' stroke-width='4' opacity='.16'/%3E%3C/g%3E%3Cg fill='%23ffffff' stroke='%23cbd7e6'%3E%3Crect x='830' y='188' width='430' height='236' rx='8'/%3E%3Crect x='904' y='520' width='360' height='172' rx='8'/%3E%3Crect x='1060' y='96' width='260' height='88' rx='8'/%3E%3C/g%3E%3Cg fill='%23132238' opacity='.12'%3E%3Crect x='872' y='232' width='224' height='16' rx='3'/%3E%3Crect x='872' y='270' width='330' height='12' rx='3'/%3E%3Crect x='872' y='302' width='300' height='12' rx='3'/%3E%3Crect x='872' y='334' width='250' height='12' rx='3'/%3E%3Crect x='944' y='560' width='220' height='14' rx='3'/%3E%3Crect x='944' y='596' width='280' height='12' rx='3'/%3E%3Crect x='944' y='628' width='240' height='12' rx='3'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
  background-position: center;
}

.login-panel {
  min-height: 100vh;
  padding: 48px;
  background: rgba(255, 255, 255, 0.96);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 28px;
}

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

.login-title {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
}

.login-copy {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.form-stack {
  display: grid;
  gap: 14px;
}

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

.field label,
.field-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

.textarea {
  min-height: 108px;
  line-height: 1.65;
  resize: vertical;
}

.textarea.large {
  min-height: 220px;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 105, 224, 0.12);
}

.input.compact,
.select.compact {
  padding: 8px 10px;
}

.btn {
  min-height: 38px;
  border-radius: var(--radius);
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease;
}

.btn:hover {
  border-color: var(--line-strong);
  box-shadow: 0 8px 18px rgba(19, 34, 56, 0.08);
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn.primary:hover {
  background: var(--primary-strong);
  border-color: var(--primary-strong);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn.danger {
  color: var(--red);
  border-color: #ffd0ca;
  background: var(--red-soft);
}

.btn.icon-only {
  width: 36px;
  min-height: 36px;
  padding: 0;
}

.icon {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

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

.shell-desktop .agent-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.shell-web .main {
  max-width: 1440px;
}

.sidebar {
  min-width: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  background: #ffffff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 14px;
  border-bottom: 1px solid var(--line);
}

.side-brand strong {
  display: block;
  line-height: 1.2;
}

.side-brand span {
  color: var(--soft);
  font-size: 12px;
}

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

.nav-label {
  padding: 10px 10px 4px;
  color: var(--soft);
  font-size: 12px;
  font-weight: 750;
}

.nav-item {
  min-height: 38px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  color: var(--muted);
  font-weight: 700;
}

.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.nav-item:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.side-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.user-chip {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  display: grid;
  gap: 3px;
  background: var(--surface-muted);
}

.user-chip strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chip span {
  color: var(--soft);
  font-size: 12px;
}

.main {
  min-width: 0;
  padding: 22px 28px 36px;
}

.topline {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-title {
  display: grid;
  gap: 4px;
}

.page-title h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
}

.page-title p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  gap: 14px;
}

.metrics-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
  display: grid;
  gap: 8px;
}

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

.metric strong {
  font-size: 26px;
  line-height: 1;
}

.agent-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 18px;
}

.agent-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  min-height: 210px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    border-color 0.16s ease;
}

.agent-card:hover {
  transform: translateY(-2px);
  border-color: #9fc0ef;
  box-shadow: var(--shadow);
}

.agent-card h2 {
  margin: 0;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.agent-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.agent-card .card-footer {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
  background: var(--surface-muted);
  color: var(--muted);
}

.badge.green {
  color: var(--green);
  background: var(--green-soft);
}

.badge.amber {
  color: var(--amber);
  background: var(--amber-soft);
}

.badge.red {
  color: var(--red);
  background: var(--red-soft);
}

.badge.blue {
  color: var(--primary);
  background: var(--primary-soft);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
}

.chat-layout {
  height: calc(100vh - 58px);
  min-height: 620px;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 14px;
}

.conversation-list {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

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

.panel-head h2,
.panel-head h3 {
  margin: 0;
  font-size: 15px;
}

.conversation-scroll {
  overflow: auto;
  padding: 8px;
  display: grid;
  gap: 6px;
  align-content: start;
}

.conversation-item {
  width: 100%;
  text-align: left;
  border-radius: var(--radius);
  padding: 10px;
  background: transparent;
  color: var(--muted);
  display: grid;
  gap: 4px;
}

.conversation-item strong {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item span {
  font-size: 12px;
  color: var(--soft);
}

.conversation-item.active,
.conversation-item:hover {
  background: var(--surface-muted);
}

.chat-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
}

.chat-header {
  min-height: 66px;
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

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

.chat-header p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.messages {
  overflow: auto;
  padding: 18px;
  display: grid;
  gap: 14px;
  align-content: start;
  background:
    linear-gradient(rgba(246, 248, 251, 0.72), rgba(246, 248, 251, 0.72)),
    repeating-linear-gradient(0deg, transparent, transparent 35px, rgba(217, 226, 236, 0.36) 36px);
}

.message-row {
  display: grid;
  gap: 6px;
  width: min(760px, 92%);
  min-width: 0;
}

.message-row.user {
  justify-self: end;
}

.message-meta {
  color: var(--soft);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.message-row.user .message-meta {
  justify-content: flex-end;
}

.message {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--surface);
  color: var(--text);
  line-height: 1.72;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.message-row.user .message {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.message-actions {
  display: flex;
  gap: 6px;
}

.composer {
  border-top: 1px solid var(--line);
  padding: 12px;
  display: grid;
  gap: 10px;
  background: #fff;
}

.composer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.composer textarea {
  min-height: 72px;
  max-height: 180px;
}

.guide-panel {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  padding: 18px;
  max-width: 760px;
  display: grid;
  gap: 10px;
}

.guide-panel h2 {
  margin: 0;
  font-size: 18px;
}

.guide-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  gap: 14px;
  align-items: start;
}

.section {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.section-body {
  padding: 14px;
}

.table-wrap {
  overflow: auto;
}

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

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

.table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  background: var(--surface-muted);
}

.table td {
  line-height: 1.55;
}

.table tr:last-child td {
  border-bottom: 0;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.empty {
  padding: 26px;
  color: var(--muted);
  text-align: center;
}

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

.small {
  font-size: 12px;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.advanced {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.advanced summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 750;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  max-width: 420px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.toast.error {
  border-color: #ffc8c1;
  color: var(--red);
}

.toast.success {
  border-color: #b9ebd8;
  color: var(--green);
}

.loading {
  min-height: 240px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.mobile-topbar {
  display: none;
}

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

  .agent-grid,
  .shell-desktop .agent-grid,
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .entry-view {
    padding: 18px;
  }

  .entry-options {
    grid-template-columns: 1fr;
  }

  .entry-card {
    min-height: auto;
  }

  .login-view {
    grid-template-columns: 1fr;
  }

  .login-panel {
    min-height: 100vh;
    padding: 28px;
  }

  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
    padding: 10px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .side-brand,
  .side-footer,
  .nav-label {
    display: none;
  }

  .nav-group {
    display: flex;
    width: 100%;
    min-width: 0;
    overflow: auto;
  }

  .nav-item {
    white-space: nowrap;
  }

  .main {
    padding: 16px;
  }

  .topline {
    align-items: flex-start;
    flex-direction: column;
  }

  .agent-grid,
  .shell-desktop .agent-grid,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .agent-card {
    min-height: auto;
  }

  .agent-card .card-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .chat-layout {
    height: auto;
    min-height: 0;
    grid-template-columns: 1fr;
  }

  .conversation-list {
    max-height: 220px;
  }

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

  .composer-row {
    grid-template-columns: 1fr;
  }

  .split {
    grid-template-columns: 1fr;
  }
}
