:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --text: #202124;
  --muted: #687078;
  --line: #d8dfdc;
  --accent: #1f7a68;
  --accent-dark: #155c4e;
  --danger: #a33c32;
  --shadow: 0 12px 28px rgba(33, 38, 34, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

button,
a {
  cursor: pointer;
}

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

.dashboard-topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(14px, 3vw, 28px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  position: sticky;
  top: 0;
  z-index: 20;
}

.dashboard-topbar h1 {
  margin: 0;
  font-size: 22px;
}

.dashboard-topbar p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.dashboard-actions a,
.dashboard-actions button,
.panel-head button,
.login-panel button,
.upload-form button,
.row-action {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.dashboard-actions button,
.panel-head button,
.login-panel button,
.upload-form button {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.dashboard-actions button:hover,
.panel-head button:hover,
.login-panel button:hover,
.upload-form button:hover {
  background: var(--accent-dark);
}

.login-panel,
.dashboard-main {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 18px clamp(12px, 3vw, 28px);
}

.login-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: center;
}

.login-panel h2 {
  margin: 0 0 8px;
}

.login-panel p {
  margin: 0;
  color: var(--muted);
}

.login-panel form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 80px;
  gap: 8px;
}

.login-panel input {
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}

.user-create-form {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 14px 16px 0;
}

.user-create-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.user-create-form input {
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  outline: none;
}

.user-create-form input:focus {
  border-color: var(--accent);
}

.user-create-form button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: #ffffff;
  background: var(--accent);
}

.user-create-form button:hover {
  background: var(--accent-dark);
}

.dashboard-main {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 18px;
}

.tabs {
  align-self: start;
  display: grid;
  gap: 8px;
  position: sticky;
  top: 92px;
}

.tab {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.tab.active {
  color: #ffffff;
  border-color: var(--accent);
  background: var(--accent);
}

.panel {
  display: none;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel.active {
  display: block;
}

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

.panel-head h2 {
  margin: 0;
  font-size: 16px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  padding: 14px;
}

.stat-card {
  min-height: 92px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

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

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

th {
  color: var(--muted);
  font-weight: 600;
  background: #fbfcfb;
}

tbody tr:hover {
  background: #f5faf7;
}

.mono {
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
  flex: 0 0 auto;
}

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

.profile-cell {
  max-width: 360px;
  color: var(--text);
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-active {
  color: var(--accent);
  font-weight: 700;
}

.status-disabled {
  color: var(--danger);
  font-weight: 700;
}

.user-records-panel {
  margin: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  overflow: hidden;
}

.payment-notices {
  margin: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  overflow: hidden;
}

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

.user-records-head h3 {
  margin: 0;
  font-size: 15px;
}

.user-records-head span {
  color: var(--muted);
  font-size: 13px;
}

.conversation-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  min-height: 520px;
}

.message-view {
  border-left: 1px solid var(--line);
  background: #fbfcfb;
}

.message-view h3 {
  margin: 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}

.messages-view {
  display: grid;
  gap: 10px;
  max-height: 680px;
  overflow: auto;
  padding: 12px;
  color: var(--muted);
}

.msg-item {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.msg-role {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}

.msg-content {
  color: var(--text);
  white-space: pre-wrap;
  line-height: 1.6;
}

.msg-data-notice {
  display: grid;
  gap: 4px;
  padding: 8px 10px;
  border: 1px solid #e5d4bd;
  border-radius: 6px;
  background: #fff8ed;
  color: #8b5a16;
  font-size: 12px;
  line-height: 1.5;
}

.msg-data-notice strong {
  color: #6f4510;
  font-size: 12px;
}

.profile-record {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.profile-record > strong {
  color: var(--text);
  font-size: 14px;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.profile-row {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
}

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

.profile-row b {
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.conversation-record {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.conversation-record-head {
  display: grid;
  gap: 4px;
}

.conversation-record-head strong {
  color: var(--text);
  font-size: 14px;
}

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

.conversation-record-messages {
  display: grid;
  gap: 8px;
}

.system-info {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.info-row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.info-row strong {
  color: var(--muted);
  font-weight: 600;
}

.table-manager {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.table-card,
.hint-block {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.table-card {
  display: grid;
  gap: 5px;
}

.table-card strong {
  font-size: 15px;
}

.table-card span,
.hint-block {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.upload-form {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto;
  gap: 10px;
  align-items: end;
}

.file-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.file-field input {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.inline-check {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
  white-space: nowrap;
}

.inline-check input {
  width: 16px;
  height: 16px;
}

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

.row-action.danger-action {
  color: var(--danger);
  border-color: rgba(163, 60, 50, 0.35);
}

.row-action:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

@media (max-width: 980px) {
  .dashboard-main,
  .conversation-layout {
    grid-template-columns: 1fr;
  }

  .tabs {
    position: static;
    grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  }

  .upload-form {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .user-create-form {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .message-view {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

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

@media (max-width: 640px) {
  .dashboard-topbar,
  .login-panel {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .dashboard-actions,
  .login-panel form,
  .tabs {
    grid-template-columns: 1fr;
    display: grid;
  }

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