:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --line: #d9e0e8;
  --text: #18202b;
  --muted: #667386;
  --accent: #0f766e;
  --accent-2: #115e59;
  --danger: #b42318;
  --shadow: 0 16px 48px rgba(24, 32, 43, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.modal-open {
  overflow: hidden;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled,
input:disabled,
textarea:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: 100vh;
  height: 100dvh;
  min-height: 640px;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-right: 1px solid var(--line);
  background: #fbfcfd;
  padding: 20px;
  overflow-y: auto;
}

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

.mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 800;
}

.brand h1,
.chat-header h2,
.panel h2,
.empty h3 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 17px;
}

.brand p,
.hint,
.empty p,
.eyebrow {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

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

.panel h2 {
  margin-bottom: 14px;
  font-size: 15px;
}

.row h2 {
  margin-bottom: 0;
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 12px;
  color: #394354;
  font-size: 13px;
}

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

input,
select {
  height: 40px;
  padding: 0 11px;
}

textarea {
  min-height: 68px;
  max-height: 180px;
  resize: vertical;
  padding: 12px;
  line-height: 1.55;
}

.compact-textarea {
  min-height: 64px;
  max-height: 110px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

button,
.secondary {
  min-height: 40px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  padding: 0 14px;
  font-weight: 700;
}

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

.secondary {
  width: 100%;
  border: 1px solid var(--line);
  background: #f8fafc;
  color: #394354;
}

.secondary:hover,
.icon-button:hover {
  background: #e9eef5;
}

.hidden {
  display: none;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 88px;
  gap: 8px;
  margin-top: 4px;
}

.checkbox-row {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 8px;
  margin: 6px 0 12px;
  color: #394354;
  font-weight: 700;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.mini-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.1);
  color: var(--accent-2);
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.quota-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
  margin: 12px 0;
}

.quota-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
}

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

.quota-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.quota-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.18s ease;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.42);
  padding: 24px;
}

.modal-backdrop.hidden {
  display: none;
}

.membership-modal {
  width: min(940px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.22);
  padding: 22px;
}

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

.modal-header h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.modal-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.modal-stats div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
}

.modal-stats span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.modal-stats strong {
  display: block;
  margin-top: 6px;
  font-size: 15px;
}

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

.plan-card {
  position: relative;
  display: flex;
  min-height: 180px;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--text);
  padding: 16px;
  text-align: left;
}

.plan-card:hover,
.plan-card.selected,
.plan-card.current {
  border-color: rgba(15, 118, 110, 0.48);
  background: rgba(15, 118, 110, 0.06);
  color: var(--text);
}

.plan-card strong {
  font-size: 16px;
}

.plan-card b {
  font-size: 22px;
}

.plan-card small {
  color: #334155;
  font-weight: 800;
}

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

.plan-tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.12);
  color: var(--accent-2);
  padding: 0 8px;
  font-size: 11px;
  font-weight: 900;
}

.plan-tag.hot {
  background: #fff1f2;
  color: #be123c;
}

.upgrade-contact {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 16px;
  align-items: center;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 14px;
}

.qr-placeholder {
  display: grid;
  width: 96px;
  height: 96px;
  place-items: center;
  border: 1px dashed rgba(15, 118, 110, 0.45);
  border-radius: 8px;
  background: white;
  color: var(--accent-2);
  font-size: 24px;
  font-weight: 900;
}

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

.upgrade-contact p {
  margin: 7px 0 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.upgrade-contact span {
  color: #475569;
  font-size: 13px;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.admin-stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 9px;
}

.admin-stat strong,
.admin-stat span {
  display: block;
}

.admin-stat strong {
  font-size: 17px;
}

.admin-stat span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.admin-user-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.admin-user {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
}

.admin-user.disabled-user {
  background: #f8fafc;
  color: #64748b;
}

.admin-user-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.admin-user-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.admin-field,
.admin-check {
  margin: 0;
}

.admin-field span,
.admin-check span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.admin-field input,
.admin-field select {
  height: 36px;
}

.admin-check {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 0 9px;
}

.admin-check input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.recent-audit {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.recent-audit strong {
  color: #334155;
  font-size: 13px;
}

.audit-item {
  border-top: 1px solid var(--line);
  padding-top: 6px;
  word-break: break-word;
}

.icon-button {
  display: grid;
  min-width: 36px;
  width: 36px;
  height: 36px;
  min-height: 36px;
  place-items: center;
  background: #eef2f6;
  color: #18202b;
  padding: 0;
  font-size: 20px;
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}

.session-item {
  display: block;
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  background: #f8fafc;
  color: #273142;
  text-align: left;
  padding: 10px;
  font-weight: 600;
}

.session-item.active {
  border-color: rgba(15, 118, 110, 0.35);
  background: rgba(15, 118, 110, 0.08);
  color: var(--accent-2);
}

.chat {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100vh;
  height: 100dvh;
  min-width: 0;
  overflow: hidden;
  position: relative;
}

.chat.is-dragging::after {
  content: "松开添加文件";
  position: absolute;
  inset: 12px;
  z-index: 5;
  display: grid;
  place-items: center;
  border: 2px dashed rgba(15, 118, 110, 0.55);
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.86);
  color: var(--accent-2);
  font-weight: 800;
  pointer-events: none;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  padding: 18px 24px;
}

.chat-header h2 {
  font-size: 20px;
}

.eyebrow {
  margin: 0 0 3px;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  background: var(--surface-2);
  color: #475569;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.pill.ok {
  background: rgba(15, 118, 110, 0.12);
  color: var(--accent-2);
}

.pill.bad {
  background: rgba(180, 35, 24, 0.12);
  color: var(--danger);
}

.messages {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 28px 24px;
}

.empty {
  max-width: 680px;
  margin: 12vh auto 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 24px;
  box-shadow: var(--shadow);
}

.empty h3 {
  font-size: 22px;
}

.message {
  display: flex;
  margin: 0 auto 14px;
  max-width: 780px;
}

.bubble {
  max-width: min(680px, 86%);
  border-radius: 8px;
  padding: 12px 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

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

.message.user .bubble {
  background: var(--accent);
  color: white;
}

.message.assistant .bubble {
  border: 1px solid var(--line);
  background: var(--surface);
}

.message.system .bubble {
  margin: 0 auto;
  background: #fff7ed;
  color: #9a3412;
}

.composer {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 12px;
  align-items: end;
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 16px 24px;
}

.composer-main {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.composer-main:focus-within,
.composer-main.has-attachments {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.08);
}

.attachment-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  border-bottom: 1px solid var(--line);
  padding: 6px 8px;
}

.file-input {
  display: none;
}

.attachment-list {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.attachment-hint {
  color: var(--muted);
  font-size: 13px;
}

.attachment-chip,
.message-attachment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  color: #334155;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
}

.attachment-chip.is-failed {
  border-color: #fecdd3;
  background: #fff1f2;
  color: #be123c;
}

.attachment-remove {
  display: grid;
  width: 20px;
  min-width: 20px;
  height: 20px;
  min-height: 20px;
  place-items: center;
  border-radius: 999px;
  background: transparent;
  color: #64748b;
  padding: 0;
  line-height: 1;
}

.attachment-remove:hover {
  background: #e2e8f0;
  color: #1f2937;
}

.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.composer-main textarea {
  min-height: 84px;
  max-height: 84px;
  border: 0;
  resize: none;
  box-shadow: none;
}

.composer-main textarea:focus {
  box-shadow: none;
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 100vh;
    min-height: 100dvh;
  }

  .sidebar {
    max-height: 45vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .chat {
    height: auto;
    min-height: 0;
  }

  .modal-stats,
  .plans-grid,
  .upgrade-contact {
    grid-template-columns: 1fr;
  }

  .membership-modal {
    max-height: calc(100vh - 24px);
    padding: 18px;
  }
}

@media (min-width: 861px) and (max-width: 1120px) {
  .plans-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
