:root {
  color-scheme: dark;
  --bg: #0b1020;
  --panel: #121a2d;
  --panel-2: #0f1627;
  --line: #26324c;
  --text: #eef3ff;
  --muted: #9aa8c6;
  --accent: #7aa2ff;
  --success: #69d79f;
  --warn: #f2c66d;
  --danger: #ff7d8a;
  --shadow: 0 20px 50px rgba(0, 0, 0, .2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top, #111a30 0, var(--bg) 42%);
  color: var(--text);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #cbd7ff;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  padding: 30px max(22px, calc((100vw - 1320px)/2));
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.eyebrow {
  color: var(--accent);
  font-size: 11px;
  letter-spacing: .16em;
  font-weight: 700;
}

h1 {
  margin: 3px 0 5px;
  font-size: 28px;
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

.toolbar {
  display: flex;
  gap: 10px;
}

.button {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 11px;
  padding: 10px 15px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.button:hover {
  transform: translateY(-1px);
  border-color: #3a4c73;
}

.button.primary {
  background: #1d2f61;
  border-color: #375aa7;
}

.button.success {
  background: #183d2c;
  border-color: #2d7452;
}

.button:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
}

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.page {
  width: min(1320px, calc(100% - 44px));
  margin: 24px auto 60px;
}

.dropzone {
  border: 1px dashed #415173;
  background: rgba(13, 21, 40, .66);
  border-radius: 18px;
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: .15s;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(38, 63, 120, .22);
}

.drop-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: #18284c;
  font-size: 23px;
  color: var(--accent);
}

.dropzone strong,
.dropzone span {
  display: block;
}

.dropzone span {
  color: var(--muted);
  margin-top: 3px;
}

.status-card {
  margin: 16px 0;
  padding: 16px 18px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #65708a;
}

.status-title {
  font-weight: 700;
}

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

.badge {
  margin-left: auto;
  padding: 4px 9px;
  border-radius: 999px;
  background: #413816;
  color: var(--warn);
  font-size: 12px;
}

.hidden {
  display: none !important;
}

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

.stat-card {
  background: linear-gradient(180deg, rgba(24, 35, 60, .95), rgba(18, 26, 45, .95));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 15px;
}

.stat-card span {
  color: var(--muted);
  font-size: 12px;
}

.stat-card strong {
  display: block;
  font-size: 20px;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow: auto;
  padding-bottom: 8px;
}

.tab {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 10px;
  padding: 8px 13px;
  cursor: pointer;
  color: var(--muted);
}

.tab.active {
  background: #17284d;
  color: var(--text);
  border-color: #385797;
}

.panel {
  margin-top: 10px;
  background: rgba(18, 26, 45, .92);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.panel-head {
  padding: 18px;
  display: flex;
  justify-content: space-between;
  gap: 15px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

h2 {
  margin: 0;
  font-size: 18px;
}

.panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

.search {
  min-width: 230px;
  background: #0d1424;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  padding: 8px 10px;
  outline: none;
}

.search:focus,
input:focus,
select:focus {
  border-color: #4668b1;
  box-shadow: 0 0 0 3px rgba(70, 104, 177, .14);
}

.head-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

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

select,
input {
  background: #0d1424;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  padding: 8px 10px;
  outline: none;
}

.actor-list {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.actor-card {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel-2);
  padding: 15px;
}

.actor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.actor-id {
  font-size: 12px;
  color: var(--muted);
}

.actor-name {
  font-size: 17px;
  font-weight: 700;
}

.grid-fields {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
}

.param-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.param-grid input {
  width: 100%;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

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

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
}

.status-pill.on {
  background: #183a2a;
  color: var(--success);
}

.status-pill.off {
  background: #281b24;
  color: #b9a1aa;
}

.switch-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.switch-control input {
  appearance: none;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  padding: 0;
  position: relative;
  cursor: pointer;
  background: #2a3348;
  transition: .15s;
}

.switch-control input::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 3px;
  left: 3px;
  border-radius: 50%;
  background: #bcc7de;
  transition: .15s;
}

.switch-control input:checked {
  background: #2f6d4f;
}

.switch-control input:checked::after {
  left: 19px;
  background: white;
}

.item-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 16px;
}

.item-card {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.item-card .name {
  min-width: 0;
}

.item-card strong {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-card small {
  display: block;
  color: var(--muted);
}

.item-card input {
  width: 92px;
}

.party-grid {
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 12px;
}

.field-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-card>span {
  color: var(--muted);
  font-size: 12px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #182037;
}

.safe-note {
  margin-top: 14px;
  border: 1px solid #30444a;
  background: #0e211c;
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.safe-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: #173d2f;
  color: var(--success);
  font-weight: 800;
}

.safe-note p {
  margin: 2px 0 0;
  color: #adc6bc;
}

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

footer {
  text-align: center;
  padding: 0 20px 30px;
  color: #6e7b97;
  font-size: 12px;
}

@media (max-width: 1000px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

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

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

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

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
  }

  .toolbar {
    width: 100%;
  }

  .toolbar .button {
    flex: 1;
    text-align: center;
  }

  .page {
    width: min(100% - 24px, 1320px);
    margin-top: 12px;
  }

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

  .panel-head {
    flex-direction: column;
    align-items: stretch;
  }

  .head-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .search {
    min-width: 0;
    width: 100%;
  }

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

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

.shape-card {
  margin: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.shape-title {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.shape-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.shape-chip {
  display: inline-flex;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #151c30;
  font-size: 12px;
  color: #c7d1e8;
}

.mutation-box {
  min-width: 100px;
  text-align: right;
}

.mutation-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.mutation-box strong {
  display: block;
  font-size: 22px;
}

.map-groups {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.map-group {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-2);
  overflow: hidden;
}

.map-group-head {
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}

.map-kicker {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.map-group h3 {
  margin: 2px 0 0;
  font-size: 17px;
}

.map-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.current-map-badge {
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--accent-strong);
  background: #182b3e;
  border: 1px solid #254762;
}

.self-switch-table th,
.self-switch-table td {
  text-align: center;
}

.self-switch-table th:first-child,
.self-switch-table td:first-child {
  text-align: left;
  min-width: 120px;
}

.self-switch-cell {
  width: 76px;
}

.self-switch-toggle {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}

.self-switch-toggle input {
  appearance: none;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  padding: 0;
  position: relative;
  cursor: pointer;
  background: #2a3348;
  transition: .15s;
  margin: 0;
}

.self-switch-toggle input::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 3px;
  left: 3px;
  border-radius: 50%;
  background: #bcc7de;
  transition: .15s;
}

.self-switch-toggle input:checked {
  background: #2f6d4f;
}

.self-switch-toggle input:checked::after {
  left: 21px;
  background: #fff;
}

.self-switch-toggle span {
  width: 14px;
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
}

.table-input {
  width: 160px;
  max-width: 100%;
}

@media (max-width: 720px) {
  .shape-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .mutation-box {
    text-align: left;
  }

  .map-group-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .map-meta {
    justify-content: flex-start;
  }

  .self-switch-cell {
    width: 60px;
  }
}