[hidden]{display:none!important}
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --border: #e3e8f0;
  --text: #1f2a44;
  --muted: #6b7a99;
  --primary: #4f6ef7;
  --primary-dark: #3b55d8;
  --green: #22a06b;
  --red: #d64545;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
}

.layout {
  display: flex;
  height: 100vh;
}

/* ===== 侧边栏 ===== */
.sidebar {
  width: 300px;
  min-width: 260px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
}
.brand-logo { font-size: 30px; }
.brand-name { font-weight: 700; font-size: 17px; }
.brand-sub { font-size: 12px; color: var(--muted); }

.quota-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #eef2ff;
  border: 1px solid #d9e1ff;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  color: #3b55d8;
}
.quota-box strong { font-size: 15px; }

.agent-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.agent-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  background: var(--panel);
}
.agent-card:hover { border-color: #b9c6f5; box-shadow: 0 2px 8px rgba(79,110,247,.08); }
.agent-card.active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(79,110,247,.15); }

.agent-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.agent-name { font-weight: 600; font-size: 15px; }

.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.badge-on { background: #e6f7ef; color: var(--green); }
.badge-off { background: #f1f3f8; color: var(--muted); }

.agent-desc {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
  line-height: 1.5;
  min-height: 32px;
}

.agent-card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.agent-price { font-size: 12px; color: var(--primary); font-weight: 600; }

.btn-activate {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 5px 14px;
  font-size: 12px;
  cursor: pointer;
}
.btn-activate:hover { background: var(--primary-dark); }

.sidebar-foot { border-top: 1px solid var(--border); padding-top: 10px; }

.btn-ghost {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}
.btn-ghost:hover { border-color: #b9c6f5; color: var(--primary); }

/* ===== 对话区 ===== */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chat-title { font-weight: 600; font-size: 15px; }
.chat-status { font-size: 12px; color: var(--muted); }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.empty-hint {
  margin: auto;
  text-align: center;
  color: var(--muted);
  line-height: 1.8;
}
.empty-icon { font-size: 42px; margin-bottom: 10px; }

.msg {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 14px;
  line-height: 1.7;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-user {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg-assistant {
  align-self: flex-start;
  background: var(--panel);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.composer {
  display: flex;
  gap: 10px;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}
.composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.6;
  max-height: 160px;
  outline: none;
}
.composer textarea:focus { border-color: var(--primary); }

.btn-send {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 0 22px;
  font-size: 14px;
  cursor: pointer;
  height: 42px;
}
.btn-send:disabled { opacity: .45; cursor: not-allowed; }
.btn-send:not(:disabled):hover { background: var(--primary-dark); }

/* ===== 用户区 ===== */
.user-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f7f9fd;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.user-guest, .user-logged {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.user-name { font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-actions { display: flex; gap: 6px; flex-shrink: 0; }
.btn-small-ghost {
  width: auto;
  padding: 4px 12px;
  font-size: 12px;
  border-radius: 6px;
}

/* ===== 登录 / 注册 ===== */
.auth-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.auth-tab {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: none;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
}
.auth-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
#authBody input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  margin-bottom: 10px;
  outline: none;
  box-sizing: border-box;
}
#authBody input:focus { border-color: var(--primary); }
#authBody .btn-primary { width: 100%; margin-top: 2px; }
#authHint { margin-top: 10px; text-align: center; }

/* ===== 弹窗 ===== */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--panel);
  border-radius: 16px;
  padding: 26px;
  width: 380px;
  max-width: 92vw;
  position: relative;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
}
.modal-wide { width: 640px; }
.modal h3 { margin-bottom: 8px; }
.modal-sub { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  font-size: 22px;
  color: var(--muted);
  cursor: pointer;
}

.price-tag {
  font-size: 30px;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
  margin: 14px 0;
}

.pay-actions { display: flex; justify-content: center; flex-direction: column; gap: 10px; }
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 11px;
  font-size: 15px;
  cursor: pointer;
}
.btn-primary:hover { background: var(--primary-dark); }

.manual-box {
  background: #f7f9fd;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  font-size: 13px;
  line-height: 1.7;
}
.manual-box code {
  background: #eef2ff;
  color: #3b55d8;
  padding: 2px 6px;
  border-radius: 5px;
  word-break: break-all;
}
.qr-code { display: block; word-break: break-all; font-size: 12px; }
.qr-note { color: var(--muted); font-size: 12px; }

.loading { color: var(--muted); font-size: 13px; text-align: center; padding: 10px; }
.error-text { color: var(--red); font-size: 13px; text-align: center; padding: 8px; }
.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 20px; }

/* 管理 */
.modal-wide input[type="password"] {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  margin-bottom: 10px;
  outline: none;
}
.orders { margin-top: 12px; max-height: 380px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.order-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
}
.order-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.order-side { display: flex; align-items: center; gap: 8px; }
.btn-small {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.btn-small:hover { background: var(--primary); color: #fff; }

/* ===== 窄屏 ===== */
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; max-height: 40vh; border-right: none; border-bottom: 1px solid var(--border); }
  .msg { max-width: 92%; }
}
