:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel-2: #f9fafc;
  --text: #172033;
  --muted: #667085;
  --line: #dce1ea;
  --primary: #1663ff;
  --primary-2: #0b4cd7;
  --green: #15a46e;
  --red: #d92d20;
  --amber: #b7791f;
  --shadow: 0 12px 30px rgba(18, 28, 45, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 232px 1fr; }
.sidebar {
  background: #101828;
  color: #fff;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; min-height: 40px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px;
  display: grid; place-items: center;
  background: #ffffff; color: #1663ff; font-weight: 800;
}
.brand strong { display: block; font-size: 15px; }
.brand span { display: block; color: #a8b2c4; font-size: 12px; margin-top: 2px; }
.nav { display: grid; gap: 4px; }
.nav button {
  width: 100%;
  border: 0;
  background: transparent;
  color: #cad3e1;
  border-radius: 8px;
  padding: 10px 11px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav button.active, .nav button:hover { background: #1d2939; color: #fff; }
.side-footer { margin-top: auto; color: #a8b2c4; font-size: 12px; padding: 8px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 64px;
  background: rgba(255,255,255,.9);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 4;
  backdrop-filter: blur(12px);
}
.topbar h1 { margin: 0; font-size: 18px; }
.userbar { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.content { padding: 24px; max-width: 1440px; width: 100%; margin: 0 auto; }
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 520px) 1fr;
  background: #f5f7fb;
}
.login-panel { padding: 64px; display: flex; flex-direction: column; justify-content: center; }
.login-panel h1 { margin: 0 0 10px; font-size: 30px; }
.login-panel p { color: var(--muted); margin: 0 0 26px; line-height: 1.7; }
.login-visual {
  margin: 18px;
  border-radius: 8px;
  background:
    linear-gradient(rgba(16,24,40,.78), rgba(16,24,40,.6)),
    url("https://images.unsplash.com/photo-1497366754035-f200968a6e72?auto=format&fit=crop&w=1800&q=80") center/cover;
  color: #fff;
  display: flex;
  align-items: flex-end;
  padding: 44px;
}
.login-visual h2 { max-width: 680px; margin: 0; font-size: 40px; line-height: 1.18; }
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 7px; }
.field label { font-size: 13px; color: #344054; font-weight: 650; }
.input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}
textarea { min-height: 90px; resize: vertical; line-height: 1.6; }
.input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22,99,255,.12); }
.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: #344054;
  border-radius: 8px;
  min-height: 38px;
  padding: 8px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); }
.btn.icon { width: 36px; padding: 0; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.grid { display: grid; gap: 16px; }
.agent-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.agent-card { padding: 18px; min-height: 184px; display: flex; flex-direction: column; }
.agent-card h3 { margin: 0 0 10px; font-size: 18px; }
.agent-card p { margin: 0; color: var(--muted); line-height: 1.65; flex: 1; }
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 9px; background: #eef4ff; color: #175cd3; font-size: 12px; font-weight: 650; }
.badge.green { background: #ecfdf3; color: #067647; }
.badge.gray { background: #f2f4f7; color: #475467; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { padding: 16px; }
.stat span { color: var(--muted); font-size: 12px; }
.stat strong { display: block; margin-top: 8px; font-size: 24px; }
.chat-layout { height: calc(100vh - 112px); display: grid; grid-template-columns: 270px 1fr; gap: 16px; }
.history { overflow: hidden; display: flex; flex-direction: column; }
.history-head { padding: 14px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 8px; }
.history-list { overflow: auto; padding: 8px; display: grid; gap: 6px; }
.history-item {
  border: 0; background: transparent; border-radius: 8px; padding: 10px; text-align: left; color: var(--text);
}
.history-item.active, .history-item:hover { background: #eef4ff; }
.history-item small { display: block; color: var(--muted); margin-top: 4px; }
.chat-main { display: flex; flex-direction: column; overflow: hidden; }
.chat-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; }
.chat-head h2 { margin: 0 0 4px; font-size: 18px; }
.chat-head p { margin: 0; color: var(--muted); line-height: 1.5; }
.messages { flex: 1; overflow: auto; padding: 20px; display: grid; gap: 14px; align-content: start; background: var(--panel-2); }
.empty-chat {
  border: 1px dashed #b7c4d8;
  background: #fff;
  border-radius: 8px;
  padding: 22px;
  color: var(--muted);
  line-height: 1.7;
}
.msg { display: grid; gap: 7px; max-width: 860px; }
.msg.user { margin-left: auto; }
.msg-role { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 12px; }
.bubble {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  white-space: pre-wrap;
  line-height: 1.72;
  box-shadow: 0 8px 18px rgba(18, 28, 45, .05);
}
.msg.user .bubble { background: #1663ff; border-color: #1663ff; color: #fff; }
.composer { border-top: 1px solid var(--line); padding: 14px; background: #fff; display: grid; gap: 10px; }
.composer-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: end; }
.composer textarea { min-height: 78px; max-height: 180px; }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tab { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 12px; }
.tab.active { background: #101828; color: #fff; border-color: #101828; }
.split { display: grid; grid-template-columns: 1.1fr .9fr; gap: 16px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 13px; }
th { color: #475467; background: #f8fafc; font-weight: 700; }
.toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 12px; }
.notice { padding: 10px 12px; border: 1px solid #fedf89; background: #fffaeb; color: #93370d; border-radius: 8px; margin-bottom: 12px; }
.toast { position: fixed; right: 20px; bottom: 20px; background: #101828; color: #fff; border-radius: 8px; padding: 12px 14px; box-shadow: var(--shadow); z-index: 10; max-width: 360px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 920px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 5; flex-direction: row; align-items: center; overflow-x: auto; padding: 10px; }
  .brand span, .side-footer { display: none; }
  .nav { display: flex; }
  .nav button { white-space: nowrap; }
  .content { padding: 14px; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .login-panel { padding: 32px 20px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .chat-layout, .split { grid-template-columns: 1fr; height: auto; }
  .history { max-height: 260px; }
  .chat-main { min-height: 70vh; }
  .composer-row { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .topbar { padding: 0 14px; }
  .topbar h1 { font-size: 16px; }
  .userbar span { display: none; }
  .stats { grid-template-columns: 1fr; }
  .login-panel h1 { font-size: 24px; }
}
