:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #eef2f4;
  --text: #18202a;
  --muted: #667384;
  --line: #d8dee6;
  --accent: #246b5a;
  --accent-strong: #15513f;
  --blue: #275f9f;
  --warn: #956a13;
  --danger: #a33b36;
  --shadow: 0 8px 24px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Segoe UI, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(440px, 1.4fr);
  gap: 18px;
  align-items: center;
  padding: 18px 24px;
  background: rgba(246, 247, 249, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.title h1 {
  margin: 0 0 8px;
  font-size: 24px;
  line-height: 1.1;
  font-weight: 720;
  letter-spacing: 0;
}

.subline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  color: var(--muted);
}

.admin-link {
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration: none;
}

.admin-link:hover {
  text-decoration: underline;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-ok {
  border-color: rgba(36, 107, 90, 0.3);
  background: #e8f4ef;
  color: var(--accent-strong);
}

.badge-work {
  border-color: rgba(39, 95, 159, 0.28);
  background: #eaf1fa;
  color: var(--blue);
}

.badge-warn {
  border-color: rgba(149, 106, 19, 0.3);
  background: #fff3d8;
  color: var(--warn);
}

.badge-error {
  border-color: rgba(163, 59, 54, 0.28);
  background: #fdecea;
  color: var(--danger);
}

.badge-muted {
  background: var(--panel-2);
}

.metrics {
  display: grid;
  grid-template-columns: minmax(92px, 0.7fr) minmax(92px, 0.7fr) minmax(150px, 1fr) minmax(150px, 1fr);
  gap: 10px;
}

.metric {
  min-width: 0;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 18px;
}

.metric.wide strong {
  font-size: 14px;
}

main {
  width: min(1600px, 100%);
  margin: 0 auto;
  padding: 18px 24px 28px;
}

.filters {
  display: grid;
  grid-template-columns: minmax(190px, 1.1fr) minmax(160px, 1fr) minmax(140px, 0.8fr) minmax(130px, 0.75fr) minmax(120px, 0.7fr) minmax(150px, 0.8fr) auto auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.filters label {
  min-width: 0;
}

.filters label > span,
.check span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.filters input[type='search'],
.filters select {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  color: var(--text);
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}

.filters input:focus,
.filters select:focus {
  border-color: rgba(36, 107, 90, 0.55);
  box-shadow: 0 0 0 3px rgba(36, 107, 90, 0.12);
}

.check {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 36px;
  padding-bottom: 1px;
  white-space: nowrap;
}

.check span {
  margin: 0;
}

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

.actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  white-space: nowrap;
}

button {
  height: 36px;
  padding: 0 13px;
  color: var(--text);
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}

button:hover {
  background: #f0f4f5;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

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

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

.error {
  margin: 0 0 12px;
  padding: 10px 12px;
  color: var(--danger);
  background: #fdecea;
  border: 1px solid rgba(163, 59, 54, 0.28);
  border-radius: 8px;
}

.notice {
  margin: 0 0 12px;
  padding: 10px 12px;
  color: var(--accent-strong);
  background: #e8f4ef;
  border: 1px solid rgba(36, 107, 90, 0.3);
  border-radius: 8px;
}

.admin-main {
  max-width: 1100px;
}

.auth-panel {
  margin-bottom: 14px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-panel h2 {
  margin: 0 0 14px;
  font-size: 16px;
  line-height: 1.2;
}

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

.admin-grid label {
  min-width: 0;
}

.admin-grid label > span,
.details dt,
.hint {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.admin-grid input[type='text'],
.admin-grid input[type='password'] {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  color: var(--text);
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}

.admin-grid input:focus {
  border-color: rgba(36, 107, 90, 0.55);
  box-shadow: 0 0 0 3px rgba(36, 107, 90, 0.12);
}

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

.details div {
  min-width: 0;
  padding: 10px 12px;
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.details dt {
  margin-bottom: 4px;
}

.details dd {
  overflow: hidden;
  margin: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.actions.left {
  justify-content: flex-start;
}

.hint {
  margin: 12px 0 0;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 214px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 10px 12px;
  color: #3a4654;
  background: #eef2f4;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 800;
  text-align: left;
  text-transform: uppercase;
}

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid #edf0f3;
  vertical-align: middle;
}

tbody tr:hover {
  background: #f7faf9;
}

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

.num {
  text-align: right;
}

.game {
  max-width: 460px;
  font-weight: 700;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--panel-2);
  color: #354150;
  font-size: 12px;
  font-weight: 700;
}

.pill.pass {
  background: #fff3d8;
  color: var(--warn);
}

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

@media (max-width: 1180px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .actions {
    justify-content: start;
  }

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

@media (max-width: 760px) {
  .topbar {
    padding: 14px 14px;
  }

  main {
    padding: 14px;
  }

  .metrics,
  .filters {
    grid-template-columns: 1fr 1fr;
  }

  .metric.wide {
    grid-column: span 2;
  }

  .actions {
    grid-column: span 2;
  }

  .actions button {
    flex: 1;
  }

  .table-wrap {
    max-height: calc(100vh - 318px);
  }

  .admin-grid,
  .details {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 460px) {
  .metrics,
  .filters {
    grid-template-columns: 1fr;
  }

  .metric.wide,
  .actions {
    grid-column: auto;
  }
}
