:root {
  color-scheme: dark;
  --ink: #f6f1e7;
  --muted: #a9b5c7;
  --line: rgba(255,255,255,.14);
  --accent: #d8b45f;
  --teal: #57c7b6;
  --danger: #ff6b6b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 20% 15%, rgba(87,199,182,.16), transparent 30rem),
    radial-gradient(circle at 78% 8%, rgba(216,180,95,.12), transparent 28rem),
    linear-gradient(135deg, #080b11 0%, #111723 58%, #090c12 100%);
  color: var(--ink);
}

.page-shell {
  min-height: 100vh;
  display: grid;
  align-items: center;
  padding: clamp(24px, 5vw, 72px);
}

.hero,
.panel {
  width: min(760px, 100%);
  margin: 0 auto;
}

.panel {
  width: min(540px, 100%);
}

.brand,
.topline,
.session,
.actions,
.roles {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: .18em;
  text-transform: uppercase;
  margin-bottom: 28px;
}

.topline {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 46px;
}

.topline .brand {
  margin-bottom: 0;
}

.session {
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.mark {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--accent);
  font-weight: 700;
}

h1 {
  margin: 0 0 12px;
  font-size: clamp(38px, 7vw, 76px);
  line-height: .98;
  letter-spacing: 0;
}

.panel h1 {
  font-size: clamp(34px, 6vw, 54px);
}

p {
  margin: 0 0 28px;
  color: var(--muted);
  line-height: 1.55;
  font-size: clamp(17px, 2vw, 21px);
}

form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

input[type="text"],
input[type="password"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.06);
  color: var(--ink);
  padding: 12px 13px;
  font: inherit;
  outline: none;
}

textarea {
  font: 13px/1.45 Consolas, "Courier New", monospace;
  resize: vertical;
}

input:focus {
  border-color: rgba(87,199,182,.62);
}

.roles {
  gap: 16px;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  padding: 12px 13px;
}

.roles label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.actions {
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.button,
button {
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 12px 18px;
  text-decoration: none;
  font: inherit;
  cursor: pointer;
  background: rgba(255,255,255,.04);
}

.button.primary,
button.primary {
  border-color: rgba(87,199,182,.42);
  background: rgba(87,199,182,.12);
}

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

.button:hover,
button:hover {
  background: rgba(87,199,182,.2);
}

.message {
  border: 1px solid rgba(255,255,255,.14);
  padding: 12px 13px;
  color: var(--ink);
  background: rgba(255,255,255,.06);
  margin-bottom: 16px;
}

.message.ok {
  border-color: rgba(87,199,182,.38);
  color: var(--teal);
}

.message.error {
  border-color: rgba(255,107,107,.38);
  color: var(--danger);
}

footer {
  margin-top: 70px;
  color: rgba(246,241,231,.48);
  font-size: 13px;
}

.admin-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
  background: #f3f5f9;
  color: #161b28;
  transition: grid-template-columns .18s ease;
}

.admin-layout.sidebar-collapsed {
  grid-template-columns: 74px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  width: 280px;
  background: #252c36;
  color: #dce6f4;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  transition: width .18s ease;
  z-index: 10;
}

.admin-layout.sidebar-collapsed .sidebar {
  width: 74px;
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 244px;
  padding: 0 0 18px;
  border-bottom: 1px solid rgba(255,255,255,.14);
}

.sidebar-head strong,
.nav-link,
.nav-section {
  white-space: nowrap;
}

.brand-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.client-version-label {
  color: #9fb0c5;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.admin-layout.sidebar-collapsed .brand-copy {
  display: none;
}

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

.nav-section {
  margin: 18px 0 6px;
  color: #9eaab9;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 13px;
}

.nav-link {
  display: flex;
  align-items: center;
  height: 42px;
  border: 0;
  background: transparent;
  color: #e4edf9;
  padding: 0 10px;
  text-decoration: none;
  overflow: hidden;
}

.nav-link::before {
  content: "▦";
  width: 34px;
  flex: 0 0 34px;
  color: #aeb9c8;
}

.nav-link.active,
.nav-link:hover {
  background: rgba(255,255,255,.08);
}

.logout {
  margin-top: auto;
}

.logout::before {
  content: "↗";
}

.admin-main {
  min-width: 0;
  display: grid;
  grid-template-rows: 70px 1fr;
}

.admin-topbar {
  background: #ffffff;
  border-bottom: 1px solid #dfe3ea;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
}

.sidebar-toggle {
  min-width: 76px;
  height: 44px;
  border-radius: 4px;
  border: 0;
  background: #ef4d43;
  color: #fff;
  padding: 0 14px;
}

.admin-content {
  padding: clamp(24px, 4vw, 48px);
}

.admin-content h1 {
  color: #101521;
  font-size: clamp(28px, 4vw, 42px);
  margin-bottom: 12px;
}

.admin-content p {
  color: #667184;
  max-width: 760px;
}

.admin-content .message {
  max-width: 720px;
  background: #fff;
  color: #101521;
}

.admin-content .message.ok {
  color: #087567;
}

.admin-content .message.error {
  color: #c93434;
}

.admin-form {
  max-width: 520px;
  background: #fff;
  border: 1px solid #dfe3ea;
  padding: 22px;
  margin-bottom: 28px;
}

.wide-form {
  max-width: 980px;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
}

.wide-form button {
  justify-self: start;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.release-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 320px;
}

.release-editor-form textarea {
  min-height: 360px;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 22px;
}

.filter-button {
  min-width: 92px;
  background: #fff;
  border: 1px solid #cfd6e2;
}

.filter-button.active {
  background: #111827;
  border-color: #111827;
  color: #fff;
}

.admin-form input[type="text"],
.admin-form input[type="password"],
.admin-form input[type="datetime-local"],
.admin-form select {
  background: #fff;
  color: #111827;
  border-color: #cfd6e2;
}

.selected-account {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  color: #9aa7ba;
  font-size: 14px;
}

.selected-account strong {
  display: block;
  border: 1px solid #cfd6e2;
  background: #f8fafc;
  color: #111827;
  min-height: 46px;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 700;
}

.admin-content .button,
.admin-content button {
  color: #111827;
  border-color: #cfd6e2;
}

.admin-content .button.primary,
.admin-content button.primary {
  background: #111827;
  border-color: #111827;
  color: #fff;
}

.admin-content button:disabled {
  opacity: .48;
  cursor: not-allowed;
}

.admin-panel {
  background: #fff;
  border: 1px solid #dfe3ea;
  padding: 22px;
  max-width: 980px;
}

.wide-panel {
  max-width: 1180px;
}

.admin-panel h2 {
  margin: 0 0 16px;
  color: #101521;
  font-size: 20px;
}

.manager-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.item-workbench {
  display: grid;
  gap: 18px;
}

.item-search-row {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.item-table-wrap {
  max-height: 430px;
  overflow: auto;
  border: 1px solid #e5e9f0;
}

.item-table-wrap .admin-table th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.item-icon-cell {
  width: 46px;
  min-width: 46px;
  text-align: center;
}

.item-icon-preview {
  width: 32px;
  height: 32px;
  display: inline-block;
  object-fit: contain;
  image-rendering: pixelated;
  background: #101827;
  border: 1px solid #d6dde8;
}

.item-icon-missing::after {
  content: "";
  width: 32px;
  height: 32px;
  display: inline-block;
  background: #eef2f7;
  border: 1px dashed #b7c1d1;
}

.item-editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 14px 18px;
}

.item-editor-grid .wide-field {
  grid-column: 1 / -1;
}

.item-release-form {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(240px, 1fr) auto;
  gap: 14px;
  align-items: end;
}

.item-icon-upload {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid #d9e0ea;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr) auto;
  gap: 14px;
  align-items: end;
}

.compact-grid {
  grid-template-columns: minmax(130px, 180px) 1fr;
  padding: 0;
}

.compact-grid dt,
.compact-grid dd {
  padding: 9px 0;
}

.compact-grid code {
  display: inline-block;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  color: #111827;
}

.small-copy {
  font-size: 15px;
}

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

.admin-table {
  width: 100%;
  border-collapse: collapse;
  color: #1f2937;
  font-size: 14px;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid #e5e9f0;
  padding: 11px 12px;
  text-align: left;
  white-space: nowrap;
}

.admin-table th {
  background: #f4f6fa;
  color: #4b5563;
  font-weight: 700;
}

.admin-table .admin-access-row {
  cursor: pointer;
}

.admin-table .account-row {
  cursor: pointer;
}

.admin-table .admin-access-row:hover,
.admin-table .admin-access-row:focus,
.admin-table .account-row:hover,
.admin-table .account-row:focus {
  background: #f8fafc;
  outline: none;
}

.admin-table .admin-access-row.selected {
  background: #eef6ff;
}

.admin-table .empty-cell {
  color: #667184;
  text-align: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
}

.pill-gm {
  background: #fff4d6;
  color: #8a5d00;
}

.pill-player {
  background: #eef2ff;
  color: #3730a3;
}

.pill-ok {
  background: #e8f8f2;
  color: #087567;
}

.pill-danger {
  background: #ffecec;
  color: #c93434;
}

.button.danger,
button.danger {
  background: #c93434;
  border-color: #c93434;
  color: #fff;
}

.button.compact,
button.compact {
  padding: 7px 10px;
  font-size: 13px;
}

.content-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.stat-chip {
  min-width: 112px;
  border: 1px solid #dfe3ea;
  background: #fff;
  padding: 12px 14px;
  display: grid;
  gap: 2px;
  text-align: right;
}

.stat-chip strong {
  font-size: 28px;
  line-height: 1;
  color: #111827;
}

.stat-chip span,
.muted-cell {
  color: #667184;
  font-size: 13px;
}

.table-panel {
  max-width: none;
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  color: #667184;
  font-size: 14px;
}

.table-scroll {
  overflow: auto;
  border: 1px solid #e5e9f0;
}

.online-players-table th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.online-players-table .mono-cell {
  max-width: 240px;
  overflow-wrap: anywhere;
  white-space: normal;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

.tracking-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.gm-control-panel {
  max-width: none;
  margin-bottom: 16px;
  padding: 0;
}

.gm-control-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid #dfe3ea;
}

.gm-control-head h2 {
  margin: 0 0 5px;
  font-size: 20px;
}

.gm-control-head p {
  margin: 0;
  color: #667184;
  font-size: 14px;
}

.gm-control-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.gm-settings-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  padding: 18px 20px 20px;
}

.gm-settings-form label {
  display: grid;
  gap: 6px;
  color: #667184;
  font-size: 13px;
}

.gm-settings-form input[type="text"],
.gm-settings-form input[type="password"],
.gm-settings-form input[type="number"] {
  width: 100%;
  height: 36px;
  border: 1px solid #cfd6e2;
  background: #fff;
  color: #111827;
  padding: 0 10px;
}

.gm-settings-form .toggle-field {
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: #111827;
  font-weight: 600;
}

.gm-enabled-toggle,
.gm-hash-toggle,
.gm-settings-submit {
  grid-column: span 2;
}

.gm-settings-submit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #667184;
  font-size: 13px;
}

.tracking-stats > div {
  border: 1px solid #dfe3ea;
  background: #fff;
  padding: 12px 14px;
  display: grid;
  gap: 3px;
}

.tracking-stats strong {
  color: #111827;
  font-size: 22px;
  line-height: 1;
}

.tracking-stats span {
  color: #667184;
  font-size: 13px;
}

.live-tracking-grid {
  display: grid;
  grid-template-columns: minmax(430px, 520px) minmax(520px, 1fr);
  gap: 16px;
  align-items: stretch;
}

.tracking-list-panel,
.tracking-map-panel {
  max-width: none;
}

.tracking-list-panel .table-toolbar input[type="search"] {
  width: min(320px, 100%);
  height: 36px;
  border: 1px solid #cfd6e2;
  background: #fff;
  color: #111827;
  padding: 0 12px;
}

.tracking-table td:first-child {
  min-width: 150px;
}

.tracking-table td:first-child strong,
.tracking-table td:first-child span {
  display: block;
}

.tracking-table td:first-child span {
  margin-top: 3px;
  color: #667184;
  font-size: 12px;
}

.tracking-table .selected-row {
  background: #eef6ff;
}

.tracking-table tbody tr {
  cursor: pointer;
}

.tracking-table .mono-cell {
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  white-space: nowrap;
}

.tracking-map-panel {
  min-height: 640px;
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr);
  padding: 0;
  overflow: hidden;
  position: relative;
}

.tracking-map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #dfe3ea;
}

.tracking-map-toolbar strong,
.tracking-map-toolbar span {
  display: block;
}

.tracking-map-toolbar span {
  margin-top: 3px;
  color: #667184;
  font-size: 13px;
}

.tracking-map-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

#trackingMap {
  width: 100%;
  height: 100%;
  min-height: 520px;
  display: block;
  background: #f5f7fa;
  cursor: grab;
}

#trackingMap:active {
  cursor: grabbing;
}

.tracking-context-menu {
  position: absolute;
  z-index: 20;
  min-width: 190px;
  border: 1px solid #cfd6e2;
  background: #fff;
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.16);
  padding: 6px;
}

.tracking-context-menu button {
  width: 100%;
  border: 0;
  background: transparent;
  color: #111827;
  text-align: left;
  padding: 9px 10px;
  cursor: pointer;
}

.tracking-context-menu button:hover {
  background: #eef3f8;
}

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

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

.modal-panel {
  width: min(760px, 100%);
  max-height: min(720px, calc(100vh - 48px));
  overflow: auto;
  background: #fff;
  color: #111827;
  border: 1px solid #dfe3ea;
  box-shadow: 0 24px 80px rgba(15,23,42,.24);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 22px;
  border-bottom: 1px solid #e5e9f0;
}

.modal-head h2 {
  margin: 0 0 6px;
  font-size: 24px;
}

.modal-head p {
  margin: 0;
  font-size: 14px;
}

.modal-close {
  align-self: start;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(150px, 220px) 1fr;
  margin: 0;
  padding: 22px;
}

.detail-grid dt,
.detail-grid dd {
  border-bottom: 1px solid #edf0f5;
  padding: 10px 0;
}

.detail-grid dt {
  color: #667184;
  font-weight: 700;
}

.detail-grid dd {
  margin: 0;
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 22px 22px;
}

.account-actions form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
}

.account-actions label {
  min-width: 190px;
  color: #667184;
}

.account-actions input[type="text"],
.account-actions input[type="datetime-local"],
.account-actions select {
  background: #fff;
  color: #111827;
  border-color: #cfd6e2;
}

.settings-panel {
  padding: 0;
  max-width: 980px;
}

.settings-head {
  padding: 16px 20px;
  border-bottom: 1px solid #dfe3ea;
}

.settings-head h2 {
  margin: 0;
}

.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 20px 20px 0;
  border-bottom: 1px solid #dfe3ea;
}

.settings-tab {
  min-width: 74px;
  height: 42px;
  border: 1px solid transparent;
  background: #fff;
  color: #667184;
}

.settings-tab.active {
  color: #111827;
  border-color: #cfd6e2;
  border-bottom-color: #fff;
  transform: translateY(1px);
}

.settings-form {
  display: grid;
  gap: 22px;
  padding: 28px 36px 0;
}

.settings-row {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(240px, 1fr);
  align-items: start;
  gap: 12px;
}

.settings-row > span:first-child {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #111827;
  font-weight: 500;
}

.settings-row i {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #45d01d;
  flex: 0 0 auto;
}

.settings-row input[type="number"],
.settings-row input[type="text"] {
  width: 100%;
  height: 38px;
  border: 1px solid #cfd6e2;
  background: #fff;
  color: #111827;
  padding: 0 12px;
}

.settings-row small {
  display: block;
  margin-top: 7px;
  color: #667184;
  line-height: 1.45;
}

.toggle-field {
  min-height: 38px;
  display: block;
}

.toggle-field input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: #111827;
}

.settings-submit {
  display: flex;
  justify-content: flex-end;
  margin: 8px -36px 0;
  padding: 12px 20px;
  border-top: 1px solid #dfe3ea;
  background: #eef3f7;
}

@media (max-width: 760px) {
  .settings-row {
    grid-template-columns: 1fr;
  }

  .tracking-stats,
  .live-tracking-grid,
  .gm-settings-form {
    grid-template-columns: 1fr;
  }

  .gm-control-head,
  .gm-settings-submit {
    display: grid;
  }

  .gm-enabled-toggle,
  .gm-hash-toggle,
  .gm-settings-submit {
    grid-column: auto;
  }

  .tracking-map-panel {
    min-height: 520px;
  }

  #trackingMap {
    min-height: 420px;
  }
}
