:root {
  --red: #e30613;
  --bg: #f6f6f6;
  --panel: #ffffff;
  --text: #171717;
  --muted: #707070;
  --line: #e8e8e8;
  --soft-red: rgba(227, 6, 19, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
a,
input {
  font: inherit;
}

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

button {
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: var(--red);
  color: var(--red);
}

button.primary {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}

button.primary:hover {
  color: #fff;
  filter: brightness(0.96);
}

input {
  height: 38px;
  min-width: 180px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  outline: none;
}

input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--soft-red);
}

.admin-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 18px;
  background: #111;
  color: #fff;
}

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

.nav button {
  width: 100%;
  height: 46px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  justify-content: flex-start;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  text-align: left;
}

.nav button.active,
.nav button:hover {
  background: rgba(227, 6, 19, 0.18);
  color: #fff;
}

.main {
  padding: 32px;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-thumb {
  width: 72px;
  max-height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.chat-thumb.large {
  width: 160px;
  max-height: 160px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
}

.break-all {
  word-break: break-all;
}

.text-danger {
  color: var(--red);
}

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

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 38px;
}

p {
  margin: 8px 0 0;
  color: var(--muted);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background: var(--bg);
}

.login-panel {
  width: 420px;
  display: grid;
  gap: 16px;
  padding: 28px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.08);
}

.login-panel label,
.config-row label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.login-panel input {
  width: 100%;
}

.login-error {
  margin: 0;
  color: var(--red);
}

.notice {
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 10px;
  background: #fff4f4;
  color: var(--red);
}

.toast-stack {
  position: fixed;
  top: 22px;
  right: 24px;
  z-index: 50;
  display: grid;
  gap: 10px;
  pointer-events: none;
}

.toast {
  min-width: 220px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #1f1f1f;
  color: #fff;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.18);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success {
  background: #18823a;
}

.toast.error {
  background: var(--red);
}

.overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.metric {
  min-height: 112px;
  padding: 20px;
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.04);
}

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

.metric strong {
  display: block;
  margin-top: 12px;
  font-size: 30px;
  line-height: 36px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 14px;
  border-radius: 10px;
  background: var(--panel);
}

.toolbar-main,
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-actions {
  justify-content: flex-end;
}

.toolbar input {
  width: 320px;
}

.filter-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-tab {
  border-color: var(--line);
  color: var(--muted);
  background: #fff;
}

.filter-tab.active {
  border-color: var(--red);
  color: var(--red);
  background: var(--soft-red);
}

.panel {
  min-height: 520px;
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.04);
  overflow: hidden;
}

.form-panel {
  padding: 20px;
  margin-bottom: 18px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.section-head h2 {
  margin: 0;
  font-size: 20px;
}

.section-head p {
  margin-top: 6px;
}

.config-list {
  display: grid;
  gap: 12px;
}

.config-row {
  display: grid;
  grid-template-columns: 90px 160px 200px 1fr;
  align-items: end;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.check-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  height: 38px;
}

.check-label input {
  min-width: auto;
  width: 16px;
  height: 16px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

th {
  color: var(--muted);
  background: #fbfbfb;
  font-weight: 700;
}

td small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.tag {
  display: inline-flex;
  align-items: center;
  min-width: 58px;
  justify-content: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: #f1f1f1;
  color: #555;
  font-size: 12px;
  font-weight: 700;
}

.tag.red,
.tag.used {
  background: var(--soft-red);
  color: var(--red);
}

.tag.green,
.tag.unused {
  background: #edf8f0;
  color: #18823a;
}

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

.row-actions button {
  height: 32px;
  padding: 0 10px;
  border-color: var(--red);
  color: var(--red);
  background: #fff;
}

.row-actions button:hover {
  border-color: var(--red);
  color: #fff;
  background: var(--red);
}

.row-actions button.danger {
  border-color: var(--red);
  color: var(--red);
}

.row-actions button.danger:hover {
  color: #fff;
  background: var(--red);
}

.empty {
  padding: 72px;
  text-align: center;
  color: var(--muted);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 14px 16px;
}

.dialog-root:empty {
  display: none;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.32);
  z-index: 30;
}

.dialog {
  width: 380px;
  max-width: 100%;
  padding: 22px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.2);
}

.dialog-wide {
  width: 520px;
}

.dialog-large {
  width: 760px;
}

.dialog h2 {
  margin: 0 0 12px;
  font-size: 20px;
  line-height: 28px;
}

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

.dialog input {
  width: 100%;
  margin-top: 6px;
}

.dialog-form {
  display: grid;
  gap: 12px;
}

.dialog-tools {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 12px;
}

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

.dialog-check {
  display: flex !important;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-height: 38px;
  padding: 0;
  color: var(--text) !important;
}

.dialog-check input {
  width: auto;
  margin: 0;
}

.settings-tabs {
  display: flex;
  width: fit-content;
  max-width: 100%;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.settings-tabs button {
  min-width: 88px;
  border-color: transparent;
  background: transparent;
}

.settings-tabs button.active {
  border-color: #e30613;
  background: #fff5f3;
  color: #e30613;
}

.settings-panel {
  max-width: 1180px;
}

.settings-panel .game-account-list + .settings-subhead {
  margin-top: 24px;
}

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

.settings-grid label {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.settings-grid input {
  width: 100%;
  min-width: 0;
}

.settings-wide {
  grid-column: 1 / -1;
}

.settings-subhead {
  margin-top: 28px;
  margin-bottom: 14px;
}

.settings-config-row {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
}

.settings-config-row label {
  min-width: 0;
}

.settings-config-row input {
  width: 100%;
  min-width: 0;
}

.settings-check {
  height: 38px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

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

.settings-check em {
  font-style: normal;
  color: var(--muted);
  font-size: 13px;
}

.settings-check-group {
  height: auto;
  min-height: 38px;
  flex-wrap: wrap;
  padding: 8px 12px;
}

.settings-check-group label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.settings-region-group {
  height: auto;
  min-height: 38px;
  flex-wrap: wrap;
  padding: 6px;
}

.settings-region-option {
  height: 30px;
  padding: 0 10px;
  border-color: transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.settings-region-option:hover {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.settings-region-option.active {
  border-color: var(--red);
  background: var(--soft-red);
  color: var(--red);
}

.settings-region-option.active:hover {
  border-color: var(--red);
  background: var(--soft-red);
  color: var(--red);
}

.game-account-list {
  display: grid;
  gap: 14px;
}

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

.game-account-head,
.game-account-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.game-account-head strong,
.game-account-head small {
  display: block;
}

.game-account-head small {
  color: var(--muted);
}

.game-account-actions {
  justify-content: flex-end;
}

.dialog-table {
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.dialog-table table {
  table-layout: auto;
}

.empty.mini {
  padding: 36px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.loading-root {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.62);
}

.loading-root[hidden] {
  display: none;
}

.loading-card {
  min-width: 220px;
  padding: 24px;
  border-radius: 12px;
  background: #fff;
  text-align: center;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.12);
}

.loading-card strong,
.loading-card p {
  display: block;
}

.loading-card p {
  margin-top: 6px;
}

.loading-spinner {
  width: 34px;
  height: 34px;
  display: inline-block;
  margin-bottom: 12px;
  border: 3px solid #f0c8cb;
  border-top-color: var(--red);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

.chat-toolbar input {
  width: 360px;
}

.chat-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
  min-height: 620px;
}

.chat-room-panel,
.chat-message-panel {
  min-height: 620px;
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.04);
  overflow: hidden;
}

.chat-panel-head {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfbfb;
}

.chat-panel-head strong {
  display: block;
  font-size: 16px;
}

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

.chat-message-search {
  display: flex;
  gap: 8px;
}

.chat-message-search input {
  width: 260px;
  min-width: 0;
}

.chat-room-list,
.chat-message-list {
  height: 482px;
  overflow: auto;
}

.chat-room-item {
  width: 100%;
  height: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--text);
  text-align: left;
}

.chat-room-item:hover,
.chat-room-item.active {
  background: #fff7f7;
  color: var(--text);
}

.chat-room-item.active {
  box-shadow: inset 3px 0 0 var(--red);
}

.room-main,
.room-meta,
.room-latest {
  min-width: 0;
}

.room-main strong,
.room-main small,
.room-meta em,
.room-meta small,
.room-latest {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-main small,
.room-meta small,
.room-latest {
  color: var(--muted);
  font-size: 12px;
}

.room-meta {
  text-align: right;
}

.room-meta em {
  font-style: normal;
  color: var(--red);
  font-size: 12px;
  font-weight: 700;
}

.room-latest {
  grid-column: 1 / -1;
}

.chat-message-list {
  padding: 14px;
}

.chat-message-list.empty-state {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.chat-message-item {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.chat-message-item:first-child {
  padding-top: 0;
}

.chat-message-item.deleted {
  opacity: 0.72;
}

.message-meta {
  min-width: 0;
}

.message-meta strong,
.message-meta span,
.message-meta time,
.message-meta em {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-meta span,
.message-meta time,
.message-meta em {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.message-meta em {
  color: var(--red);
  font-style: normal;
}

.message-body {
  min-width: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
}

.chat-pager {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
}

.chat-pager button {
  height: 34px;
  padding: 0 12px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
