:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0a0d14;
  color: #e8edf5;
  --bg: #0a0d14;
  --panel: #111622;
  --panel-soft: #0d121c;
  --border: #222b3d;
  --border-strong: #303b52;
  --text: #e8edf5;
  --muted: #8e9ab0;
  --muted-2: #68758b;
  --primary: #5f7cff;
  --primary-hover: #6f88ff;
  --danger: #a33a49;
  --danger-soft: #2a151b;
  --success: #4fc48b;
  --success-soft: #12251d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body.modal-open {
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 250px;
  padding: 24px 18px;
  background: #111622;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 18px;
  z-index: 20;
}

.brand {
  font-weight: 800;
  font-size: 22px;
}

.subtitle {
  color: #8490a6;
  font-size: 12px;
  line-height: 1.4;
}

.sidebar nav {
  display: grid;
  gap: 4px;
}

.sidebar a {
  color: #ccd5e6;
  text-decoration: none;
  padding: 9px 12px;
  border-radius: 7px;
}

.sidebar a:hover {
  background: #1a2232;
}

.sidebar footer {
  margin-top: auto;
  color: var(--muted-2);
  font-size: 12px;
}

.content {
  margin-left: 250px;
  padding: 30px 34px;
  max-width: 1700px;
}

header h1,
.page-header h1 {
  margin: 0 0 5px;
  font-size: 30px;
}

header p,
.page-header p {
  margin: 0;
  color: var(--muted);
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.card,
.panel,
.game {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
}

.card span {
  display: block;
  color: #8895aa;
  font-size: 13px;
}

.card strong {
  display: block;
  font-size: 28px;
  margin-top: 8px;
}

.panel h2 {
  margin-top: 0;
}

.panel-table {
  padding: 0;
  overflow: hidden;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 18px;
}

.stack {
  display: grid;
  gap: 12px;
}

.compact-form {
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  color: #9ba7b9;
  font-size: 13px;
}

input,
textarea,
select {
  width: 100%;
  background: #0b1019;
  border: 1px solid #2b354a;
  color: #edf3ff;
  border-radius: 7px;
  padding: 9px 10px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #536cda;
  box-shadow: 0 0 0 3px rgba(95, 124, 255, 0.12);
}

textarea {
  min-height: 78px;
  resize: vertical;
}

label small,
.form-help {
  color: var(--muted-2);
  font-size: 12px;
  line-height: 1.45;
}

.btn,
button {
  border: 0;
  border-radius: 7px;
  padding: 9px 13px;
  background: var(--primary);
  color: white;
  font-weight: 700;
  line-height: 1.2;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-primary:hover,
button:hover {
  background: var(--primary-hover);
}

.btn-secondary,
.ghost {
  background: #1a2232;
  color: #dce5f4;
  border: 1px solid #2b354a;
}

.btn-secondary:hover,
.ghost:hover {
  background: #222c3e;
}

.btn-quiet {
  background: transparent;
  color: #aebbd0;
  border: 1px solid #2b354a;
}

.btn-quiet:hover {
  background: #171e2b;
  color: white;
}

.btn-danger-ghost {
  background: transparent;
  color: #e58d99;
  border: 1px solid #57303a;
}

.btn-danger-ghost:hover {
  background: var(--danger-soft);
  color: #ffadb7;
}

.danger {
  background: var(--danger);
}

.btn-sm {
  padding: 7px 10px;
  font-size: 12px;
}

.table-toolbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.table-toolbar h2 {
  margin: 0 0 3px;
  font-size: 17px;
}

.muted {
  margin: 0;
  color: var(--muted-2);
  font-size: 12px;
}

.table-search {
  width: min(340px, 100%);
}

.table-search input {
  height: 36px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

.data-table {
  min-width: 1080px;
}

th,
td {
  padding: 11px 13px;
  border-bottom: 1px solid #1e2635;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  color: #7f8ba0;
  background: #0e131d;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

tbody tr {
  transition: background 0.12s ease;
}

tbody tr:hover {
  background: #121927;
}

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

.number {
  text-align: right;
}

.actions-column {
  width: 1%;
  text-align: right;
}

.table-primary {
  color: #f1f5fb;
  font-weight: 700;
}

.table-secondary {
  color: var(--muted-2);
  font-size: 12px;
  margin-top: 3px;
}

.text-truncate {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inline-code {
  display: inline-block;
  padding: 3px 6px;
  border: 1px solid #283247;
  border-radius: 5px;
  background: #0b1019;
  color: #b7c5dc;
  font-size: 12px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.status-active {
  background: #10251c;
  border-color: #24543d;
  color: #79d6a6;
}

.status-inactive {
  background: #24202a;
  border-color: #4a4054;
  color: #b7a8c1;
}

.table-date,
.table-time {
  display: block;
}

.table-time {
  color: var(--muted-2);
  font-size: 11px;
  margin-top: 2px;
}

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

.inline-form {
  display: inline;
  margin: 0;
}

.empty-state {
  padding: 36px 20px;
  color: var(--muted);
  text-align: center;
}

.secret,
.alert {
  padding: 12px;
  border-radius: 8px;
  margin: 12px 0 18px;
  background: #2a1f24;
  border: 1px solid #6b3944;
}

.secret {
  background: var(--success-soft);
  border-color: #2e654b;
}

.secret-row {
  display: grid;
  grid-template-columns: minmax(180px, auto) minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}

.secret-row strong,
.secret-row span {
  display: block;
}

.secret-row span {
  color: #8ebba4;
  font-size: 12px;
  margin-top: 3px;
}

.secret code {
  display: block;
  overflow-wrap: anywhere;
  padding: 8px 10px;
  border-radius: 6px;
  background: #0b1712;
  color: #b5e8ca;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal.is-open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 5, 10, 0.75);
  backdrop-filter: blur(3px);
}

.modal-dialog {
  position: relative;
  z-index: 1;
  width: min(620px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: #111622;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.45);
}

.modal-lg {
  width: min(900px, 100%);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

.modal-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.modal-close {
  width: 34px;
  height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  background: transparent;
  color: #98a6bb;
  border: 1px solid transparent;
  font-size: 22px;
}

.modal-close:hover {
  background: #1a2232;
  border-color: #2b354a;
  color: white;
}

.modal-form,
.modal-body {
  padding: 20px;
}

.modal-form {
  display: grid;
  gap: 14px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}

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

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

.switch-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-soft);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  color: #bdc8d9;
}

.check-row input {
  width: auto;
  margin: 0;
}

.manage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.subpanel {
  padding: 16px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 9px;
}

.subpanel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.subpanel-header h3 {
  margin: 0;
  font-size: 15px;
}

.subpanel-header span {
  color: var(--muted-2);
  font-size: 11px;
  text-transform: uppercase;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: min(420px, 100%);
}

.login-card h1 {
  margin: 0;
}

.login-card p {
  color: var(--muted);
}

details {
  margin-top: 10px;
}

summary {
  cursor: pointer;
  color: #9fb0cc;
}

.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;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1050px) {
  .content {
    padding: 24px;
  }

  .manage-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 850px) {
  .sidebar {
    position: static;
    width: auto;
    height: auto;
  }

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

  .sidebar footer {
    display: none;
  }

  .content {
    margin-left: 0;
    padding: 18px;
  }

  .grid2,
  .two-columns,
  .switch-grid {
    grid-template-columns: 1fr;
  }

  .page-header,
  .table-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .table-search {
    width: 100%;
  }

  .secret-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .sidebar nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .page-header .btn {
    width: 100%;
  }

  .modal {
    padding: 10px;
  }

  .modal-dialog {
    max-height: calc(100vh - 20px);
  }

  .modal-header,
  .modal-form,
  .modal-body {
    padding: 15px;
  }

  .modal-footer {
    flex-direction: column-reverse;
  }

  .modal-footer .btn {
    width: 100%;
  }
}
