:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-soft: #f8faf9;
  --text: #18221e;
  --muted: #66736e;
  --line: #dce4e0;
  --strong-line: #aab9b2;
  --accent: #0f766e;
  --accent-soft: #dff4ef;
  --warning: #a65f00;
  --warning-soft: #fff0d8;
  --danger: #b42318;
  --danger-soft: #fee4df;
  --ok: #177245;
  --ok-soft: #dff3e7;
  --shadow: 0 18px 48px rgba(23, 33, 29, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151515;
  --surface: #1f1f1f;
  --surface-soft: #262626;
  --text: #f0f0f0;
  --muted: #a3a3a3;
  --line: #343434;
  --strong-line: #505050;
  --accent: #25a18e;
  --accent-soft: #183832;
  --warning: #e4b45f;
  --warning-soft: #3a2d17;
  --danger: #ff8a7a;
  --danger-soft: #3b211f;
  --ok: #78d69c;
  --ok-soft: #183222;
  --shadow: 0 18px 56px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1160px;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 0%, rgba(37, 161, 142, 0.12), transparent 32%),
    var(--bg);
}

.login-card {
  display: grid;
  gap: 16px;
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.compact-login-body {
  padding: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(900px, 1fr);
  min-height: 100vh;
}

.nav-sidebar {
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 22px 18px;
}

.brand-block,
.workspace-header,
.panel-header,
.modal-header,
.modal-actions,
.list-row-top,
.meta-row,
.check-row,
.event-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-block {
  margin-bottom: 18px;
}

.admin-session-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 14px;
  background: var(--surface-soft);
}

.admin-session-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.admin-session-card strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-session-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mini-button {
  min-height: 32px;
  border: 1px solid var(--strong-line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 850;
}

.mini-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.1;
}

h2 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.2;
}

h3 {
  margin-bottom: 10px;
  font-size: 15px;
}

.view-switcher,
.preference-control,
.domain-switcher {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  background: var(--surface-soft);
}

.view-switcher {
  margin-bottom: 14px;
}

.preference-grid {
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
}

.view-button,
.preference-button,
.domain-button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.view-button.active,
.preference-button.active,
.domain-button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 6px rgba(23, 33, 29, 0.08);
}

.domain-switcher {
  width: 220px;
  min-width: 220px;
  padding: 3px;
}

.domain-filter {
  display: grid;
  gap: 4px;
}

.domain-filter-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  line-height: 1;
  text-transform: uppercase;
}

.domain-button {
  min-height: 32px;
  font-size: 12px;
}

.domain-button[data-wallet-domain="sandbox"].active {
  color: var(--warning);
}

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

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.nav-count {
  min-width: 28px;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.workspace {
  padding: 22px;
}

.workspace-section {
  display: grid;
  gap: 18px;
}

.workspace-section.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.workspace-header {
  min-height: 58px;
}

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

.players-layout {
  display: grid;
  grid-template-columns: 430px minmax(560px, 1fr);
  gap: 18px;
  align-items: start;
}

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

.player-stats .summary-card {
  background: var(--surface);
}

.player-filter-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) repeat(3, minmax(120px, 0.65fr));
  gap: 10px;
  width: 100%;
}

.wallet-filter-grid {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 10px;
  width: 100%;
}

.wallet-action-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid rgba(20, 184, 166, 0.38);
  border-radius: 8px;
  padding: 0.95rem 1rem;
  background: rgba(20, 184, 166, 0.08);
}

.wallet-action-panel div {
  display: grid;
  gap: 0.2rem;
}

.wallet-action-panel span {
  color: var(--muted);
  font-size: 0.82rem;
}

.payment-filter-grid {
  display: grid;
  grid-template-columns: 1fr 130px 150px;
  gap: 10px;
  width: 100%;
}

.games-filter-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(130px, 0.35fr));
  gap: 10px;
  width: 100%;
}

.payments-workspace {
  display: grid;
  gap: 18px;
}

.payments-shell,
.entity-shell {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.workspace-subnav {
  position: sticky;
  top: 18px;
  display: grid;
  align-content: start;
  grid-auto-rows: max-content;
  gap: 8px;
  min-height: calc(100vh - 36px);
  padding: 14px;
  border-right: 1px solid var(--line);
  background: var(--bg);
}

.workspace-subnav-title {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.workspace-subnav-item {
  height: 42px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
  text-align: left;
}

.workspace-subnav-item:hover,
.workspace-subnav-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.payments-content,
.entity-content {
  min-width: 0;
}

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

.panel-header {
  min-height: 78px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-header.compact {
  min-height: auto;
  align-items: stretch;
}

.players-panel {
  min-height: calc(100vh - 124px);
}

.player-panel {
  min-height: calc(100vh - 124px);
}

.events-panel {
  min-height: 300px;
}

.payments-table-panel {
  min-height: calc(100vh - 124px);
}

.form-field,
.search-field {
  display: grid;
  gap: 6px;
  width: 100%;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.form-field input,
.form-field select,
.form-field textarea,
.search-field input,
.search-field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.form-field input,
.form-field select,
.search-field input,
.search-field select {
  height: 42px;
}

.form-field textarea {
  min-height: 96px;
  padding: 10px 12px;
  line-height: 1.4;
  resize: vertical;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus,
.search-field input:focus,
.search-field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.primary-button,
.secondary-button,
.ghost-button {
  height: 40px;
  border-radius: 7px;
  padding: 0 14px;
  font-weight: 800;
}

.primary-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.secondary-button,
.ghost-button {
  border: 1px solid var(--strong-line);
  background: var(--surface);
  color: var(--text);
}

.ghost-button {
  border-color: transparent;
  color: var(--muted);
}

.secondary-button:hover,
.ghost-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.players-list {
  display: grid;
  gap: 0;
}

.players-table-wrap {
  overflow-x: auto;
}

.players-table {
  min-width: 760px;
}

.player-table-row {
  cursor: pointer;
}

.player-table-row:hover,
.player-table-row.active {
  background: var(--surface-soft);
}

.player-table-row.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.table-secondary {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
}

.player-row {
  width: 100%;
  min-width: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 15px 18px;
  background: var(--surface);
  text-align: left;
}

.player-row:hover,
.player-row.active {
  background: var(--surface-soft);
}

.player-row.active {
  box-shadow: inset 4px 0 0 var(--accent);
}

.list-row-top {
  min-width: 0;
  margin-bottom: 8px;
}

.player-email {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-id {
  color: var(--muted);
  font-size: 12px;
}

.system-id-line {
  margin-top: 5px;
  overflow: hidden;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  font-weight: 650;
  opacity: 0.78;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-ok {
  border-color: #b9e3cc;
  background: var(--ok-soft);
  color: var(--ok);
}

.status-warn {
  border-color: #f4c981;
  background: var(--warning-soft);
  color: var(--warning);
}

.status-danger {
  border-color: #f5b5ad;
  background: var(--danger-soft);
  color: var(--danger);
}

.status-muted {
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--muted);
}

.player-detail {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.detail-empty,
.empty-state,
.error-state {
  margin: 20px;
  border: 1px dashed var(--strong-line);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface-soft);
  color: var(--muted);
  line-height: 1.45;
}

.error-state {
  border-color: #f5b5ad;
  background: var(--danger-soft);
  color: var(--danger);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.summary-card,
.domain-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-soft);
}

.summary-label {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.summary-value {
  overflow: hidden;
  font-size: 15px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-copy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  gap: 10px;
}

.summary-copy-row .summary-value {
  min-width: 0;
}

.summary-copy-row .copy-id-button {
  height: 24px;
  min-width: 50px;
  font-size: 10px;
}

.section-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.meta-row {
  min-height: 32px;
  border-top: 1px solid var(--line);
  padding: 8px 0;
}

.meta-row:first-of-type {
  border-top: 0;
}

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

.meta-value {
  color: var(--text);
  font-size: 13px;
  font-weight: 850;
  text-align: right;
}

.checks-list {
  display: grid;
  gap: 10px;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.control-box {
  display: grid;
  align-content: start;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.check-row {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface);
}

.check-main {
  display: grid;
  gap: 4px;
}

.check-action {
  font-size: 14px;
  font-weight: 850;
  text-transform: capitalize;
}

.check-reasons {
  color: var(--muted);
  font-size: 12px;
}

.check-reasons-list {
  display: grid;
  gap: 3px;
  margin: 0;
  padding-left: 16px;
}

.check-reasons-empty {
  color: var(--muted);
}

.business-note {
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 14px 16px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.system-identity {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px dashed var(--strong-line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
}

.copy-identity {
  border-style: solid;
}

.system-identity span {
  font-weight: 800;
  text-transform: uppercase;
}

.system-identity code {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-value-group {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  gap: 8px;
}

.copy-id-button {
  position: relative;
  flex: 0 0 auto;
  min-width: 58px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  transition:
    transform 150ms ease,
    border-color 150ms ease,
    background 150ms ease,
    color 150ms ease;
}

.copy-id-button:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.copy-id-button:active {
  transform: translateY(0) scale(0.97);
}

.copy-id-button .copy-done {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
  transform: translateY(4px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.copy-id-button .copy-idle {
  display: block;
  transition:
    opacity 120ms ease,
    transform 120ms ease;
}

.copy-id-button.copied {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.copy-id-button.copied .copy-idle {
  opacity: 0;
  transform: translateY(-4px);
}

.copy-id-button.copied .copy-done {
  opacity: 1;
  transform: translateY(0);
}

.events-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 10px;
  padding: 16px;
}

.event-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
}

.ledger-list {
  display: grid;
  gap: 10px;
}

.ledger-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface);
}

.ledger-deltas {
  margin-top: 10px;
}

.payment-controls {
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr);
}

.payments-table-wrap {
  overflow: auto;
}

.payments-table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
}

.raw-ledger-table {
  min-width: 1320px;
}

.payment-outbox-table {
  min-width: 980px;
}

.payments-table th,
.payments-table td {
  border-bottom: 1px solid var(--line);
  padding: 13px 14px;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  white-space: nowrap;
}

.payments-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.payment-table-row {
  cursor: pointer;
  transition:
    background 120ms ease,
    box-shadow 120ms ease;
}

.payment-table-row:hover,
.payment-table-row:focus {
  background: var(--surface-soft);
  outline: none;
}

.payment-table-row.active {
  background: var(--accent-soft);
  box-shadow: inset 4px 0 0 var(--accent);
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding: 12px 14px;
  background: var(--surface);
}

.pagination-meta,
.pagination-page {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

.pagination-button {
  height: 32px;
  border: 1px solid var(--strong-line);
  border-radius: 7px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 850;
}

.pagination-button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.pagination-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.money-cell {
  font-weight: 850;
}

.payment-detail-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  justify-content: flex-end;
  background: rgba(0, 0, 0, 0.46);
}

.payment-detail-backdrop.hidden {
  display: none;
}

.payment-detail-drawer {
  width: min(920px, calc(100vw - 280px));
  min-width: 720px;
  height: 100vh;
  overflow: auto;
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: -22px 0 54px rgba(0, 0, 0, 0.28);
}

.payment-detail-drawer .player-detail {
  padding-bottom: 32px;
}

.empty-state.inline {
  margin: 0;
}

.event-type {
  color: var(--text);
  font-size: 14px;
  font-weight: 850;
}

.event-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.payload {
  max-height: 130px;
  overflow: auto;
  margin: 10px 0 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.event-action {
  width: 100%;
  margin-top: 10px;
}

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

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

.modal-card {
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.wide-modal {
  width: min(680px, 100%);
}

.modal-header,
.modal-actions {
  padding: 18px 20px;
}

.modal-header {
  border-bottom: 1px solid var(--line);
}

.form-body {
  display: grid;
  gap: 12px;
  padding: 20px;
}

.form-grid {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 10px;
}

.payment-form-grid {
  grid-template-columns: 1fr 120px;
}

.form-message {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.form-message.success {
  color: var(--ok);
}

.form-message.error {
  color: var(--danger);
}

.mode-business #bffStatus,
.mode-business .technical-only {
  display: none;
}

.mode-technical .business-only {
  display: none;
}

@media (max-width: 1180px) {
  body {
    min-width: 0;
  }

  .app-shell,
  .players-layout,
  .section-grid,
  .controls-grid,
  .wallet-filter-grid,
  .payment-filter-grid,
  .games-filter-grid,
  .player-filter-grid,
  .payment-form-grid {
    grid-template-columns: 1fr;
  }

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

  .players-panel,
  .player-panel {
    min-height: auto;
  }
}
