:root {
  --bg: #0d0f16;
  --panel: #171a24;
  --panel-2: #1f2330;
  --text: #f6f7ff;
  --muted: #aab1c4;
  --muted-2: #7e879d;
  --border: #303548;
  --pink: #ff3d9a;
  --purple: #6a4cff;
  --yellow: #ffd666;
  --green: #58d68d;
  --red: #ff6b6b;
  --blue: #6bb8ff;
  --shadow: rgba(0, 0, 0, .35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(106, 76, 255, .18), transparent 30%),
    radial-gradient(circle at top right, rgba(255, 61, 154, .16), transparent 30%),
    var(--bg);
}

.hidden {
  display: none !important;
}

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

.login-card {
  width: min(440px, 100%);
  background: linear-gradient(180deg, rgba(31, 35, 48, .98), rgba(23, 26, 36, .98));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 18px 40px var(--shadow);
}

.brand {
  color: var(--pink);
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-size: 12px;
  margin-bottom: 8px;
}

.login-card h1 {
  margin: 0 0 10px;
}

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

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 340px 1fr;
  grid-template-rows: auto 1fr;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(23, 26, 36, .94);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
}

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

.user-box {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.logout {
  color: white;
  text-decoration: none;
  background: rgba(255, 255, 255, .08);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}

.sidebar {
  padding: 14px;
  border-right: 1px solid var(--border);
  background: rgba(14, 17, 25, .82);
  overflow: auto;
  max-height: calc(100vh - 70px);
  position: sticky;
  top: 70px;
}

.content {
  padding: 16px;
  overflow: auto;
}

.panel,
.chart-card,
.map-card,
.table-card,
.stat-card {
  background: linear-gradient(180deg, rgba(31, 35, 48, .98), rgba(23, 26, 36, .98));
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 18px var(--shadow);
}

.panel {
  padding: 13px;
  margin-bottom: 13px;
}

.panel h2,
.chart-card h2,
.map-card h2,
.table-card h2 {
  margin: 0 0 10px;
  font-size: 14px;
}

label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin: 10px 0 5px;
}

select,
input[type="date"],
input[type="file"],
input[type="range"] {
  width: 100%;
}

select,
input[type="date"],
input[type="file"] {
  background: #10131b;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
}

.check {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--text);
  font-size: 13px;
}

.primary-button {
  width: 100%;
  border: 0;
  border-radius: 9px;
  padding: 10px 12px;
  color: white;
  font-weight: 800;
  cursor: pointer;
  background: linear-gradient(90deg, var(--purple), var(--pink));
  margin-top: 12px;
}

.small-muted {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

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

.stat-card {
  padding: 14px;
}

.stat-value {
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
}

.stat-label {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

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

.chart-card,
.table-card,
.map-card {
  padding: 13px;
}

.bar-row {
  display: grid;
  grid-template-columns: 130px 1fr 54px;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
  color: var(--muted);
  font-size: 12px;
}

.bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--purple), var(--pink));
}

.map-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.map-scroll {
  max-height: 75vh;
  overflow: auto;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.08);
}

.map-wrap {
  position: relative;
  width: 2048px;
  height: 2048px;
  transform-origin: top left;
  background:
    linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px),
    radial-gradient(circle at center, rgba(255,61,154,.1), transparent 45%),
    #0a0d13;
  background-size: 128px 128px, 128px 128px, auto, auto;
  overflow: hidden;
}

#spawnImage,
#mapCanvas {
  position: absolute;
  inset: 0;
  width: 2048px;
  height: 2048px;
}

#spawnImage {
  object-fit: fill;
}

.table-scroll {
  max-height: 420px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  padding: 8px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 2;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  background: rgba(255,255,255,.08);
}

.pill.LOGGED_OUT { color: var(--red); }
.pill.CHANGED_WORLD { color: var(--green); }
.pill.USED_WARP { color: var(--blue); }
.pill.TIME_LIMIT { color: var(--yellow); }

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: #10131b;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 12px;
  box-shadow: 0 12px 28px var(--shadow);
  max-width: 360px;
  z-index: 100;
}

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

  .sidebar {
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

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

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