:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --ink: #151922;
  --muted: #667085;
  --line: #dfe3ea;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --teal: #0f766e;
  --amber: #b45309;
  --danger: #dc2626;
  --shadow: 0 18px 48px rgba(18, 24, 40, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(120deg, rgba(37, 99, 235, 0.08), transparent 28%),
    linear-gradient(300deg, rgba(15, 118, 110, 0.08), transparent 22%),
    var(--bg);
}

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

button {
  cursor: pointer;
}

.boot {
  display: grid;
  min-height: 100vh;
  place-items: center;
  color: var(--muted);
}

.login-page {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 480px);
  min-height: 100vh;
  padding: 32px;
  gap: 32px;
}

.login-visual {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: calc(100vh - 64px);
  padding: 40px;
  border: 1px solid var(--line);
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.68)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='700' viewBox='0 0 900 700'%3E%3Cg fill='none' stroke='%23cbd5e1' stroke-width='1'%3E%3Cpath d='M80 160h680M80 260h560M80 360h720M80 460h620M220 80v540M420 80v540M620 80v540'/%3E%3C/g%3E%3Cg fill='%232563eb' fill-opacity='.12'%3E%3Crect x='120' y='110' width='170' height='84' rx='10'/%3E%3Crect x='470' y='210' width='230' height='84' rx='10'/%3E%3Crect x='240' y='405' width='280' height='94' rx='10'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand-lockup,
.brand-button {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-button {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
}

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

.brand-lockup span:last-child {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.login-visual h1 {
  max-width: 800px;
  margin: 80px 0 0;
  font-size: clamp(36px, 6vw, 72px);
  line-height: 1.02;
  letter-spacing: 0;
}

.login-visual p {
  max-width: 680px;
  color: #344054;
  font-size: 18px;
  line-height: 1.8;
}

.login-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.login-metrics span,
.summary-strip > div,
.panel,
.agent-card,
.guide-panel,
.form-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
}

.login-metrics span {
  padding: 16px;
  color: var(--muted);
}

.login-metrics b,
.summary-strip b {
  display: block;
  color: var(--ink);
  font-size: 22px;
}

.login-panel {
  display: grid;
  place-items: center;
}

.form-card,
.admin-form,
.model-form {
  display: grid;
  width: 100%;
  gap: 16px;
}

.form-card {
  padding: 28px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: 20px;
  letter-spacing: 0;
}

label {
  display: grid;
  gap: 8px;
  color: #344054;
  font-size: 14px;
  font-weight: 650;
}

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

textarea {
  resize: vertical;
  line-height: 1.6;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.primary-btn,
.ghost-btn,
.nav-item,
.conversation-item,
.copy-btn {
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 10px 14px;
  font-weight: 750;
}

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

.primary-btn:hover {
  background: var(--primary-dark);
}

.primary-btn:disabled,
.ghost-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.ghost-btn {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.full {
  width: 100%;
}

.muted {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
  height: 100vh;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(18px);
}

.sidebar nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  width: 100%;
  border-color: transparent;
  background: transparent;
  color: #475467;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: #eef4ff;
  color: var(--primary);
}

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

.account-card span {
  color: var(--muted);
  font-size: 13px;
}

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

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

.topbar h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
}

.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #16a34a;
}

.workbench-grid,
.admin-layout {
  display: grid;
  gap: 18px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.summary-strip > div {
  padding: 16px;
}

.summary-strip span {
  color: var(--muted);
  font-size: 13px;
}

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

.agent-card {
  display: grid;
  min-height: 220px;
  padding: 18px;
}

.agent-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.agent-card h2 {
  margin: 0;
}

.agent-card-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.agent-card p {
  color: #475467;
  line-height: 1.7;
}

.agent-card .primary-btn {
  align-self: end;
}

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

.conversation-panel,
.chat-main {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
}

.conversation-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
}

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

.conversation-item {
  display: grid;
  gap: 4px;
  width: 100%;
  border-color: var(--line);
  background: #fff;
  text-align: left;
}

.conversation-item.active {
  border-color: var(--primary);
  background: #eef4ff;
}

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

.chat-main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.guide-panel {
  display: grid;
  gap: 6px;
  margin: 14px;
  padding: 14px;
  background: #f8fafc;
}

.guide-panel span {
  color: #475467;
  line-height: 1.6;
}

.messages {
  display: grid;
  align-content: start;
  gap: 18px;
  overflow: auto;
  padding: 10px 18px 18px;
}

.message {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  max-width: 880px;
}

.message.user {
  justify-self: end;
  grid-template-columns: minmax(0, 1fr) 34px;
}

.message.user .avatar {
  grid-column: 2;
  grid-row: 1;
  background: var(--primary);
}

.message.user .bubble {
  grid-column: 1;
  background: #eef4ff;
}

.message.assistant .avatar {
  background: var(--teal);
}

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

.bubble pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.72;
  font-family: inherit;
}

.copy-btn {
  margin-top: 12px;
  border-color: var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.empty-chat,
.empty-state {
  display: grid;
  place-items: center;
  min-height: 300px;
  padding: 32px;
  color: var(--muted);
  text-align: center;
}

.empty-chat h2,
.empty-state h2 {
  color: var(--ink);
}

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

.composer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

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

.panel {
  padding: 18px;
}

.admin-board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.check-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 18px;
  color: #475467;
}

.model-line {
  margin: 0 0 10px;
  color: #475467;
}

.table,
.usage-table {
  display: grid;
  gap: 10px;
}

.table-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px 140px;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.agent-row {
  grid-template-columns: minmax(0, 1fr) 130px 90px;
}

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

.model-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

.inline-check input {
  width: auto;
}

.secret-state {
  color: var(--teal);
  font-size: 13px;
  font-weight: 800;
}

.usage-row {
  display: grid;
  grid-template-columns: 170px 90px 150px 90px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #475467;
  font-size: 13px;
}

.usage-row strong {
  color: var(--teal);
}

.usage-row.error strong {
  color: var(--danger);
}

.usage-row p {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 48px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111827;
  color: #fff;
  box-shadow: var(--shadow);
}

@media (max-width: 1080px) {
  .agent-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chat-layout,
  .split,
  .admin-board {
    grid-template-columns: 1fr;
    height: auto;
  }

  .conversation-panel {
    height: 220px;
  }

  .chat-main {
    min-height: 640px;
  }
}

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

  .login-page {
    padding: 14px;
  }

  .login-visual {
    min-height: auto;
    padding: 24px;
  }

  .login-metrics,
  .summary-strip,
  .agent-grid,
  .model-form,
  .usage-row,
  .table-row,
  .agent-row {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .main {
    padding: 16px;
  }

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

  .chat-layout {
    gap: 12px;
  }
}
