:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e3e6eb;
  --border-strong: #cfd4dc;
  --text: #1d2433;
  --muted: #6b7385;
  --accent: #2f6fed;
  --accent-hover: #245bd0;
  --accent-soft: #eaf1fe;
  --danger: #d23b3b;
  --radius: 6px;
  --header: 52px;
  --sidebar: 210px;
  --control: 36px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

#app {
  height: 100%;
}

[hidden] {
  display: none !important;
}

button,
input {
  font: inherit;
  color: inherit;
}

input[type='text'],
input[type='password'],
input[type='date'] {
  width: 100%;
  height: var(--control);
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
.select-button:focus-visible,
.button:focus-visible,
.menu-group:focus-visible,
.submenu-link:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

/* Fields */

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.filters > .field {
  flex: 0 1 250px;
}

.filters > .field.date {
  flex-basis: 160px;
}

.filters > .field.user-id {
  flex-basis: 320px;
}

.filters > .field.rtp {
  flex-basis: 90px;
}

.field.game-name {
  flex: 0 1 360px;
}

fieldset.field {
  margin: 0;
  padding: 0;
  border: 0;
}

fieldset.field > legend {
  padding: 0;
  margin-bottom: 4px;
}

.checks {
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--control);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}

.check input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.input-group {
  display: flex;
  gap: 6px;
}

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

.form-error:empty {
  display: none;
}

/* Buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--control);
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.button:hover {
  background: var(--bg);
}

.button:disabled {
  opacity: 0.6;
  cursor: default;
}

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

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

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

.button.ghost:hover {
  color: var(--text);
  background: var(--bg);
}

.button.ghost.danger:hover:not(:disabled) {
  color: var(--danger);
}

.button.icon {
  flex: none;
  width: var(--control);
  padding: 0;
}

.button.wide {
  width: 100%;
}

/* Select */

.select {
  position: relative;
}

.select-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  height: var(--control);
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  text-align: left;
  cursor: pointer;
}

.select-button svg {
  flex: none;
  color: var(--muted);
  transition: transform 0.15s;
}

.select-button[aria-expanded='true'] svg {
  transform: rotate(180deg);
}

.select-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select-popup {
  position: absolute;
  z-index: 10;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgb(16 24 40 / 0.1);
}

.select-search {
  margin-bottom: 6px;
  height: 32px !important;
}

.select-list {
  max-height: 240px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.select-option,
.select-empty {
  padding: 7px 10px;
  border-radius: 4px;
  white-space: nowrap;
}

.select-option {
  cursor: pointer;
}

.select-option.active {
  background: var(--bg);
}

.select-option.selected {
  color: var(--accent);
  font-weight: 600;
}

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

/* Login */

.login {
  display: grid;
  place-items: center;
  height: 100%;
  padding: 16px;
}

.login-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 340px;
  padding: 32px 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgb(16 24 40 / 0.05);
}

.login-title {
  margin: 0 0 6px;
  font-size: 18px;
  letter-spacing: 0.14em;
  text-align: center;
}

/* Shell */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  grid-template-rows: var(--header) minmax(0, 1fr);
  height: 100%;
}

.header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text);
  text-decoration: none;
}

.sidebar {
  padding: 16px 10px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.menu,
.submenu {
  margin: 0;
  padding: 0;
  list-style: none;
}

.menu > li + li {
  margin-top: 12px;
}

.menu-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 6px 10px;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.menu-group svg {
  transition: transform 0.15s;
}

.menu-group[aria-expanded='false'] svg {
  transform: rotate(-90deg);
}

.submenu {
  margin-top: 2px;
}

.submenu-link {
  display: block;
  padding: 7px 10px 7px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
}

.submenu-link:hover {
  background: var(--bg);
}

.submenu-link.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.content {
  padding: 20px 24px;
  overflow: auto;
}

.placeholder {
  display: grid;
  place-items: center;
  height: 100%;
  min-height: 160px;
  color: var(--muted);
}

/* Panels */

.panel {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.panel-title {
  margin: 0 0 14px;
  font-size: 13px;
  letter-spacing: 0.1em;
}

/* Launch */

.launch {
  display: flex;
  gap: 20px;
  height: 100%;
  min-height: 520px;
}

.launch-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.actions {
  align-items: center;
}

.frame {
  flex: 1;
  min-height: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.user {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 14px;
  align-self: flex-start;
  width: 280px;
}

.user .panel-title {
  margin-bottom: 0;
}

.user .row > .field {
  flex: 1;
}

#user-balance {
  font-variant-numeric: tabular-nums;
}

/* Games */

.games {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 720px;
}

.games-table td {
  padding-top: 4px;
  padding-bottom: 4px;
}

/* Stats */

.stats {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.result {
  transition: opacity 0.15s;
}

.result.loading {
  opacity: 0.5;
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.table th,
.table td {
  padding: 9px 14px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.table th:first-child,
.table td:first-child {
  text-align: left;
}

.table th {
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.table tbody tr:hover {
  background: #fafbfc;
}

.table tfoot td {
  font-weight: 700;
  border-top: 2px solid var(--border-strong);
  border-bottom: 0;
}

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

@media (max-width: 960px) {
  .launch {
    flex-direction: column;
    height: auto;
  }

  .frame {
    min-height: 480px;
  }

  .user {
    align-self: stretch;
    width: auto;
  }
}

@media (max-width: 640px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--header) auto minmax(0, 1fr);
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .content {
    padding: 16px;
  }

  .filters > .field {
    flex: 1 1 100%;
  }
}