:root {
  color-scheme: dark;
  --canvas: #111511;
  --canvas-raised: #171d17;
  --surface: #1e251e;
  --surface-hover: #273027;
  --line: #455342;
  --line-soft: #303a2f;
  --ink: #f0efe2;
  --muted: #aab2a4;
  --gold: #deb14e;
  --mint: #73c799;
  --coral: #e67569;
  --danger-bg: #4a2523;
  --focus: #f4cf73;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
}

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

button,
select { cursor: pointer; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 24px;
  background: #171b16;
  border-bottom: 1px solid var(--line-soft);
}

.topbar-brand,
.session-summary,
.surface-header,
.dialog-actions,
.detail-actions,
.audit-item-header,
.privacy-item { display: flex; align-items: center; }

.topbar-brand { gap: 10px; }

.topbar-brand strong,
.topbar-brand small { display: block; }

.topbar-brand strong { font-size: 14px; letter-spacing: 0; }
.topbar-brand small { margin-top: 2px; color: var(--muted); font-size: 12px; }

.brand-mark {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  color: #241b08;
  background: var(--gold);
  border: 1px solid #f2d682;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 850;
}

.session-summary { flex-wrap: wrap; justify-content: flex-end; gap: 8px; color: var(--muted); font-size: 13px; }

.role-badge,
.state-badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--mint);
  background: #19241b;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.state-warning { color: #ffefc2; background: #4a3c1e; border-color: #94763c; }

.admin-layout { display: grid; grid-template-columns: 226px minmax(0, 1fr); min-height: calc(100vh - 64px); }

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px 14px;
  background: var(--canvas-raised);
  border-right: 1px solid var(--line-soft);
}

.sidebar-label,
.eyebrow {
  margin: 0;
  color: var(--gold);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.sidebar-label { padding: 0 10px 7px; }

.nav-item {
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  text-align: left;
}

.nav-item:hover,
.nav-item.is-active { color: var(--ink); background: var(--surface-hover); border-color: var(--line-soft); }

.sidebar-note {
  margin-top: auto;
  padding: 12px 10px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.sidebar-note strong,
.sidebar-note span { display: block; }
.sidebar-note strong { color: var(--ink); margin-bottom: 4px; }

.workspace { min-width: 0; padding: 28px; }

.workspace-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

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

h1 { margin-bottom: 0; font-size: 26px; line-height: 1.15; letter-spacing: 0; }
h2 { margin-bottom: 0; font-size: 15px; line-height: 1.25; letter-spacing: 0; }

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

.filters { padding: 16px; margin-bottom: 18px; }

.search-form { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(150px, 180px) auto; align-items: end; gap: 12px; }

.search-field,
.filter-field,
.login-form label,
.action-dialog label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  color: var(--ink);
  background: #141914;
  border: 1px solid var(--line);
  border-radius: 6px;
}

textarea { min-height: 100px; resize: vertical; }
input::placeholder { color: #7d877c; }

.button {
  min-height: 40px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface-hover);
  font-weight: 700;
  white-space: nowrap;
}

.button:hover { filter: brightness(1.1); }
.button:disabled { cursor: not-allowed; opacity: 0.52; }
.button-primary { color: #251d0b; background: var(--gold); border-color: #f1d67d; }
.button-danger { color: #fff4ed; background: var(--danger-bg); border-color: #c75d55; }
.button-quiet { min-height: 34px; padding: 6px 10px; color: var(--muted); border-color: var(--line-soft); background: transparent; }
.button-compact { min-height: 34px; padding: 6px 10px; }

.directory-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.9fr); gap: 18px; align-items: start; }
.table-surface,
.detail-surface,
.audit-surface,
.privacy-surface { padding: 16px; }
.detail-surface { min-height: 432px; }
.surface-header { justify-content: space-between; gap: 12px; margin-bottom: 14px; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 620px; }
th,
td { padding: 11px 8px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; }
td { font-size: 13px; }
tbody tr { transition: background-color 120ms ease; }
tbody tr:hover { background: #222b21; }
.gold-value { color: var(--gold); font-variant-numeric: tabular-nums; white-space: nowrap; }

.player-row-button {
  min-height: 32px;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  font-weight: 750;
  text-align: left;
}

.player-row-button span { display: block; }
.player-id { margin-top: 3px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; font-weight: 500; }
.muted { color: var(--muted); font-size: 12px; }
.empty-state,
.detail-empty { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.empty-state { padding: 22px 8px 4px; }
.directory-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; }
.directory-pagination { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.status-badge { color: var(--ink); background: #252d25; border-color: #536151; }
.status-active { color: #c9f5d8; background: #173322; border-color: #3e8b5a; }
.status-suspended { color: #ffded8; background: #482724; border-color: #aa5a51; }
.status-pendingDeletion { color: #ffefc2; background: #4a3c1e; border-color: #94763c; }
.status-deleted { color: #d0d4cc; background: #303530; border-color: #5e685c; }

.detail-body { display: grid; gap: 18px; }
.detail-identity { display: grid; gap: 5px; padding-bottom: 16px; border-bottom: 1px solid var(--line-soft); }
.detail-identity h3 { margin: 0; font-size: 18px; }
.detail-id { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.detail-fact { min-width: 0; }
.detail-fact dt { margin-bottom: 4px; color: var(--muted); font-size: 11px; font-weight: 700; }
.detail-fact dd { margin: 0; color: var(--ink); font-size: 13px; overflow-wrap: anywhere; }
.detail-section { padding-top: 16px; border-top: 1px solid var(--line-soft); }
.detail-section h3 { margin-bottom: 10px; color: var(--gold); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; }
.detail-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.detail-list li { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; }
.detail-list strong { color: var(--ink); font-weight: 650; text-align: right; }
.detail-actions { flex-wrap: wrap; gap: 8px; padding-top: 2px; }
.detail-table-scroll { overflow-x: auto; }
.detail-table { min-width: 620px; }
.detail-table th,
.detail-table td { padding: 8px 6px; font-size: 12px; }
.detail-table td { overflow-wrap: anywhere; }
.detail-table td:last-child { white-space: nowrap; }
.wallet-section .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.audit-surface,
.privacy-surface { margin-top: 18px; }
.restriction-surface { margin-top: 18px; padding: 16px; }
.restriction-header { align-items: start; }
.restriction-copy { margin: -3px 0 16px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.restriction-form { display: grid; grid-template-columns: minmax(135px, 0.28fr) minmax(220px, 0.7fr) minmax(260px, 1fr) auto; align-items: end; gap: 12px; }
.restriction-country-field,
.restriction-reason-field,
.restriction-url-field { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 650; }
.restriction-form textarea { min-height: 40px; height: 78px; resize: vertical; }
.restriction-form .button { align-self: end; }
.restriction-table { min-width: 960px; }
.restriction-country { display: grid; gap: 3px; }
.restriction-country strong { font-size: 13px; }
.restriction-reason { min-width: 260px; line-height: 1.45; overflow-wrap: anywhere; }
.restriction-url { display: inline-block; max-width: 300px; color: var(--mint); font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
.restriction-url-missing { color: #ffefc2; font-size: 12px; }
.restriction-actions { display: flex; justify-content: flex-end; gap: 8px; }
.runtime-configuration-surface { margin-top: 18px; padding: 16px; }
.runtime-configuration-header { align-items: start; }
.runtime-configuration-copy { margin: -3px 0 16px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.runtime-config-form { display: grid; gap: 14px; }
.runtime-config-form fieldset { min-width: 0; margin: 0; padding: 14px; border: 1px solid var(--line-soft); border-radius: 6px; }
.runtime-config-form legend { padding: 0 6px; color: var(--gold); font-size: 12px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; }
.runtime-field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.runtime-field-grid label,
.runtime-test-row label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 650; }
.runtime-wide-field { grid-column: 1 / -1; }
.toggle-field { display: flex; align-items: center; gap: 8px; min-height: 32px; color: var(--ink); font-size: 13px; font-weight: 700; }
.toggle-field input { width: 18px; min-height: 18px; accent-color: var(--gold); }
.inline-toggle { align-self: end; }
.runtime-secret-status { display: flex; justify-content: space-between; gap: 12px; margin-top: 12px; color: var(--muted); font-size: 12px; }
.runtime-secret-status strong { color: var(--mint); font-weight: 700; }
.runtime-test-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 12px; margin-top: 12px; }
.runtime-test-row .button { align-self: end; }
.runtime-reward-preview { margin: 14px 0 0; color: var(--muted); font-size: 13px; }
.runtime-reward-preview strong { color: var(--gold); font-size: 16px; }
.runtime-economy-note { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.runtime-form-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.audit-log,
.privacy-list { display: grid; gap: 0; }
.audit-item,
.privacy-item { justify-content: space-between; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line-soft); }
.audit-item:first-child,
.privacy-item:first-child { border-top: 0; padding-top: 0; }
.audit-item-main { display: grid; gap: 4px; }
.audit-item-main strong { font-size: 13px; }
.audit-item-main span,
.audit-item-meta { color: var(--muted); font-size: 12px; }
.audit-item-meta { text-align: right; white-space: nowrap; }
.privacy-item { align-items: start; }
.privacy-item h3 { margin: 0 0 4px; font-size: 13px; }
.privacy-item p { margin: 0; color: var(--muted); font-size: 12px; }

.notice {
  margin-bottom: 16px;
  padding: 10px 12px;
  color: #fff1e9;
  background: #4c2924;
  border: 1px solid #ae5c53;
  border-radius: 6px;
  font-size: 13px;
}

.notice[data-tone="success"] { color: #e6ffec; background: #183b25; border-color: #438a5b; }

.action-dialog {
  width: min(500px, calc(100vw - 32px));
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.action-dialog::backdrop { background: rgb(4 7 4 / 72%); }
.action-dialog form { display: grid; gap: 13px; padding: 22px; }
.action-dialog header { border-bottom: 1px solid var(--line-soft); padding-bottom: 12px; }
.action-dialog h2 { margin-top: 4px; font-size: 20px; }
.dialog-copy { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.dialog-actions { justify-content: flex-end; gap: 8px; margin-top: 4px; }

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; background: #131813; }
.login-shell { width: min(420px, 100%); padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.login-shell .brand-mark { margin-bottom: 20px; width: 42px; height: 42px; }
.login-shell h1 { margin: 5px 0 9px; }
.login-copy { margin-bottom: 22px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.login-form { display: grid; gap: 11px; }
.login-form .button { margin-top: 4px; }
.login-error { margin: -7px 0 17px; padding: 9px 10px; color: #ffe8e3; background: var(--danger-bg); border: 1px solid #a85650; border-radius: 6px; font-size: 13px; }

@media (max-width: 1040px) {
  .directory-grid { grid-template-columns: minmax(0, 1fr); }
  .detail-surface { min-height: 0; }
}

@media (max-width: 720px) {
  .topbar { align-items: flex-start; flex-direction: column; padding: 14px 16px; }
  .session-summary { justify-content: flex-start; }
  .admin-layout { grid-template-columns: 1fr; }
  .sidebar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: center; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .sidebar-label { grid-column: 1 / -1; padding: 0 4px; }
  .sidebar-note { display: none; }
  .workspace { padding: 18px 14px; }
  .workspace-heading { align-items: flex-start; }
  .search-form { grid-template-columns: 1fr; }
  .search-form .button { width: 100%; }
  .restriction-form { grid-template-columns: 1fr; }
  .restriction-form .button { width: 100%; }
  .runtime-field-grid,
  .runtime-test-row { grid-template-columns: 1fr; }
  .runtime-wide-field { grid-column: auto; }
  .runtime-form-footer { align-items: stretch; flex-direction: column; }
  .runtime-form-footer .button { width: 100%; }
  .detail-grid { grid-template-columns: 1fr; }
  .audit-item { align-items: flex-start; flex-direction: column; }
  .audit-item-meta { text-align: left; white-space: normal; }
}

@media (max-width: 520px) {
  .table-scroll:not(.restriction-table-scroll) { overflow-x: visible; }
  table.player-table { min-width: 0; table-layout: fixed; }
  th,
  td { padding: 10px 8px; }
  .player-table th:nth-child(1) { width: 42%; }
  .player-table th:nth-child(2) { width: 34%; }
  .player-table th:nth-child(4) { width: 16%; }
  .player-table th:nth-child(3),
  .player-table td:nth-child(3),
  .player-table th:nth-child(5),
  .player-table td:nth-child(5),
  .player-table th:nth-child(6),
  .player-table td:nth-child(6) { display: none; }
}
