:root {
  color: #202421;
  background: #f3f5f3;
  font-family: "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  letter-spacing: 0;
  --surface: #ffffff;
  --surface-muted: #f7f8f7;
  --border: #d9dedb;
  --border-strong: #b7c0ba;
  --ink: #202421;
  --ink-muted: #68716b;
  --green: #266344;
  --green-hover: #1d5237;
  --green-soft: #e8f2ec;
  --red: #a23b3b;
  --red-hover: #873030;
  --red-soft: #f8eaea;
  --amber: #8a630d;
  --amber-soft: #f7f0dc;
  --blue: #315f8a;
  --shadow: 0 12px 36px rgba(24, 35, 28, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  min-width: 320px;
  background: #f3f5f3;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(49, 95, 138, 0.28);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 28px clamp(20px, 5vw, 72px);
  background: #eef1ef;
}

.auth-brand,
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.auth-brand {
  align-self: start;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border: 1px solid #1f2b23;
  border-radius: 4px;
  color: #ffffff;
  background: #26352b;
  font-family: Georgia, serif;
  font-size: 20px;
}

.auth-panel {
  width: min(100%, 400px);
  align-self: center;
  justify-self: center;
  display: grid;
  gap: 18px;
  padding: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-panel h1,
.section-header h1 {
  margin: 4px 0 0;
  font-size: 24px;
  line-height: 1.25;
}

.eyebrow {
  margin: 0;
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
}

.auth-panel label {
  margin-bottom: -10px;
  color: #404741;
  font-size: 13px;
  font-weight: 600;
}

input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  color: var(--ink);
  background: #ffffff;
}

input::placeholder {
  color: #8a928d;
}

.form-error {
  margin: -8px 0 0;
  color: var(--red);
  font-size: 13px;
}

.button,
.icon-button {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  font-weight: 600;
}

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.button-primary {
  color: #ffffff;
  background: var(--green);
}

.button-primary:hover:not(:disabled) {
  background: var(--green-hover);
}

.button-quiet,
.icon-button {
  border-color: var(--border);
  color: #3f4741;
  background: #ffffff;
}

.button-quiet:hover:not(:disabled),
.icon-button:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--surface-muted);
}

.button-danger {
  color: #ffffff;
  background: var(--red);
}

.button-danger:hover:not(:disabled) {
  background: var(--red-hover);
}

.button-wide {
  width: 100%;
}

.icon-button {
  display: inline-grid;
  width: 36px;
  height: 36px;
  padding: 0;
  place-items: center;
  font-size: 20px;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.brand-copy {
  display: grid;
  gap: 1px;
}

.brand-copy strong {
  font-size: 14px;
}

.brand-copy small {
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 500;
}

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

.environment-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-muted);
  font-size: 12px;
}

.environment-picker select {
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  color: var(--ink);
  background: #ffffff;
  font: inherit;
}

.connection-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-right: 8px;
  color: var(--ink-muted);
  font-size: 12px;
}

.connection-state span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2d8a58;
}

.tabs {
  display: flex;
  gap: 26px;
  min-height: 48px;
  padding: 0 clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.tab {
  position: relative;
  padding: 0 2px;
  border: 0;
  color: var(--ink-muted);
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

.tab::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  background: transparent;
}

.tab.is-active {
  color: var(--ink);
}

.tab.is-active::after {
  background: var(--green);
}

main {
  width: min(100%, 1500px);
  margin: 0 auto;
  padding: 26px clamp(18px, 4vw, 56px) 48px;
}

.overview {
  display: grid;
  grid-template-columns: repeat(7, minmax(115px, 1fr));
  margin-bottom: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  overflow: hidden;
}

.metric {
  min-height: 92px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 16px 18px;
  border-right: 1px solid var(--border);
}

.metric:last-child {
  border-right: 0;
}

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

.metric strong {
  font-size: 25px;
  line-height: 1;
}

.metric-alert strong {
  color: var(--red);
}

.metric-score strong {
  color: var(--blue);
}

.workspace {
  min-width: 0;
}

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

.updated-time {
  color: var(--ink-muted);
  font-size: 12px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.search {
  width: min(100%, 480px);
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 8px;
}

.segmented {
  display: inline-flex;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #ffffff;
}

.segmented button {
  min-width: 58px;
  padding: 0 12px;
  border: 0;
  border-radius: 3px;
  color: var(--ink-muted);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
}

.segmented button.is-active {
  color: #ffffff;
  background: #39473e;
}

.table-frame {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  overflow-x: auto;
}

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

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid #e6e9e7;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  height: 42px;
  color: #5e6761;
  background: var(--surface-muted);
  font-size: 11px;
  font-weight: 700;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: #fafbfa;
}

th:first-child,
td:first-child {
  width: 25%;
}

.actions-column,
.row-actions {
  width: 300px;
  text-align: right;
}

.player-cell {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.player-cell strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.mono {
  overflow: hidden;
  color: var(--ink-muted);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.status {
  display: inline-flex;
  min-width: 48px;
  min-height: 24px;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border: 1px solid transparent;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
}

.status-active {
  border-color: #bad8c6;
  color: var(--green);
  background: var(--green-soft);
}

.status-banned,
.status-rejected {
  border-color: #edc8c8;
  color: var(--red);
  background: var(--red-soft);
}

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

.row-actions .button {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.text-danger {
  border-color: #e9c2c2;
  color: var(--red);
  background: #ffffff;
}

.text-danger:hover:not(:disabled) {
  background: var(--red-soft);
}

.empty-row td {
  height: 150px;
  color: var(--ink-muted);
  text-align: center;
}

.loading-row td {
  height: 92px;
  color: var(--ink-muted);
  text-align: center;
}

.pagination {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--ink-muted);
  font-size: 12px;
}

.pagination > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.confirm-dialog {
  width: min(calc(100% - 32px), 430px);
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.confirm-dialog::backdrop {
  background: rgba(25, 30, 27, 0.5);
}

.confirm-dialog form {
  display: grid;
  gap: 14px;
  padding: 24px;
}

.confirm-dialog h2,
.confirm-dialog p {
  margin: 0;
}

.confirm-dialog h2 {
  font-size: 18px;
}

.confirm-dialog p {
  color: var(--ink-muted);
  line-height: 1.7;
}

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

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100% - 44px));
  padding: 12px 16px;
  border: 1px solid #25352b;
  border-radius: 5px;
  color: #ffffff;
  background: #26352b;
  box-shadow: var(--shadow);
  font-size: 13px;
  z-index: 20;
}

.toast.is-error {
  border-color: #772a2a;
  background: #8c3434;
}

@media (max-width: 1100px) {
  .overview {
    grid-template-columns: repeat(4, minmax(130px, 1fr));
  }

  .metric:nth-child(4) {
    border-right: 0;
  }

  .metric:nth-child(-n + 4) {
    border-bottom: 1px solid var(--border);
  }
}

@media (max-width: 720px) {
  .auth-shell {
    padding: 20px;
  }

  .auth-panel {
    padding: 26px 22px;
  }

  .topbar {
    align-items: flex-start;
    padding: 12px 16px;
  }

  .connection-state {
    display: none;
  }

  .brand-copy strong {
    max-width: 148px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .tabs {
    padding: 0 16px;
  }

  main {
    padding: 18px 14px 34px;
  }

  .overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 26px;
  }

  .metric {
    min-height: 78px;
    padding: 12px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
  }

  .metric:nth-child(2n) {
    border-right: 0;
  }

  .metric:nth-last-child(-n + 2) {
    border-bottom: 0;
  }

  .metric:last-child {
    grid-column: span 2;
  }

  .metric:nth-last-child(2) {
    border-bottom: 1px solid var(--border);
  }

  .section-header {
    align-items: flex-start;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .search {
    width: 100%;
  }

  .segmented {
    align-self: flex-start;
  }

  .pagination {
    align-items: flex-start;
    flex-direction: column;
    padding: 12px 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
