:root {
  --bg-primary: #0a0d14;
  --bg-secondary: #111622;
  --bg-card: #161c2d;
  --bg-card-hover: #1e263c;
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(245, 158, 11, 0.4);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --gold: #f59e0b;
  --gold-glow: rgba(245, 158, 11, 0.25);
  --cyan: #06b6d4;
  --green: #10b981;
  --red: #ef4444;
  --purple: #8b5cf6;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Navbar */
.navbar {
  background: rgba(17, 22, 34, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1000;
  padding: 14px 0;
}

.nav-container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.35rem;
  font-weight: 800;
  cursor: pointer;
}

.brand .highlight {
  color: var(--green);
  margin-left: 3px;
}

.nav-links {
  display: flex;
  gap: 8px;
}

.nav-link {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-link:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
  color: var(--gold);
  background: rgba(245, 158, 11, 0.12);
}

.admin-link {
  color: #f87171 !important;
}

.admin-link:hover, .admin-link.active {
  background: rgba(239, 68, 68, 0.15) !important;
}

.counter-pill {
  background: var(--red);
  color: #fff;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 999px;
  font-weight: 800;
}

/* User pill */
.nav-auth {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 4px 12px 4px 6px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.user-pill:hover {
  border-color: var(--gold);
  background: var(--bg-card-hover);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.user-details {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
}

.coins-badge {
  font-size: 0.75rem;
  color: var(--gold);
  font-weight: 700;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.btn-primary {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #000;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
}

.btn-block {
  width: 100%;
}

/* Tabs */
.main-content {
  max-width: 1300px;
  margin: 0 auto;
  padding: 30px 24px;
  width: 100%;
}

.tab-pane {
  display: none;
}

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

/* Personal Card */
.personal-card {
  background: linear-gradient(135deg, #161c2d, #101626);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 30px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.personal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.personal-identity {
  display: flex;
  align-items: center;
  gap: 20px;
}

.player-bust {
  width: 64px;
  height: 64px;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.4));
}

.name-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.name-row h2 {
  font-size: 1.8rem;
  font-weight: 800;
}

.uuid-text {
  font-size: 0.75rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-dim);
  margin-top: 4px;
}

.coins-hero {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: var(--radius-md);
  padding: 16px 24px;
  text-align: right;
}

.coins-title {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--gold);
}

.coins-val {
  font-size: 2.2rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.1;
  margin: 4px 0;
}

.coins-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.world-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.world-card {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
}

.urban-theme {
  border-left: 4px solid var(--gold);
}

.galaxy-theme {
  border-left: 4px solid var(--cyan);
}

.world-card-header {
  margin-bottom: 14px;
}

.world-badge {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--text-dim);
}

.world-card-body .stat-line {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  font-size: 0.9rem;
}

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

.stat-v {
  font-weight: 700;
  color: #fff;
}

.stat-v.highlight {
  color: var(--gold);
}

.stat-v.text-green {
  color: var(--green);
}

/* Welcome Banner */
.welcome-banner {
  background: radial-gradient(circle at 50% 0%, rgba(16, 185, 129, 0.12), transparent 70%), var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 50px 30px;
  text-align: center;
  margin-bottom: 30px;
}

.welcome-inner {
  max-width: 750px;
  margin: 0 auto;
}

.tag-pill {
  display: inline-block;
  background: rgba(16, 185, 129, 0.12);
  color: var(--green);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.welcome-inner h1 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 12px;
}

.welcome-inner p {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-bottom: 28px;
}

.welcome-cta {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

/* Connection Bar */
.connection-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 24px;
  margin-bottom: 30px;
}

.conn-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.conn-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 700;
}

.status-pill.online {
  color: var(--green);
}

.status-pill.offline {
  color: var(--red);
}

.status-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.whitelist-badge {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--cyan);
}

.server-ip-box {
  font-family: 'JetBrains Mono', monospace;
  background: rgba(0, 0, 0, 0.4);
  color: var(--gold);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.08);
  width: fit-content;
}

.server-ip-box:hover {
  background: rgba(245, 158, 11, 0.15);
}

/* Tables */
.section-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.section-card-header {
  margin-bottom: 18px;
}

.section-card-header h3 {
  font-size: 1.3rem;
  font-weight: 800;
}

.section-card-header .subtitle {
  font-size: 0.85rem;
  color: var(--text-dim);
}

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

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

.data-table th, .data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.data-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.2);
}

.player-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.player-avatar {
  width: 32px;
  height: 32px;
  border-radius: 6px;
}

/* Rank Badges */
.rank-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 800;
}

.rank-owner { background: #ef4444; color: #fff; }
.rank-admin { background: #dc2626; color: #fff; }
.rank-mvp { background: #06b6d4; color: #000; }
.rank-vip { background: #10b981; color: #000; }
.rank-default { background: rgba(255, 255, 255, 0.1); color: var(--text-muted); }

/* MAP SECTION */
.map-wrapper {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.map-controls-bar {
  padding: 18px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

.map-title-box h2 {
  font-size: 1.4rem;
  font-weight: 800;
}

.map-title-box p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

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

.segmented-control {
  display: flex;
  background: var(--bg-card);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.segment-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.segment-btn.active {
  background: var(--gold);
  color: #000;
}

.map-container {
  height: 600px;
  width: 100%;
  background: #0f172a;
}

.map-footer-bar {
  padding: 12px 24px;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.coords-pill {
  font-family: 'JetBrains Mono', monospace;
  background: var(--bg-card);
  padding: 4px 10px;
  border-radius: 6px;
  color: var(--gold);
  border: 1px solid var(--border);
}

.dim-pill {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--bg-card);
  padding: 4px 12px;
  border-radius: 6px;
  color: var(--text-main);
  font-weight: 700;
  font-size: 0.85rem;
  border: 1px solid var(--border);
}

/* Leaflet Custom Marker Icons */
.map-player-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.map-player-marker img {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 2px solid var(--gold);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

.map-player-marker span {
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  margin-top: 2px;
  white-space: nowrap;
}

/* Forms */
.form-container {
  max-width: 600px;
  margin: 0 auto;
}

.form-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px;
}

.form-header {
  margin-bottom: 24px;
}

.form-header h2 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.form-header p {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
}

.input-with-preview {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-preview input {
  padding-right: 48px;
}

.input-avatar {
  position: absolute;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 4px;
}

input[type="text"], textarea {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s ease;
}

input[type="text"]:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
}

/* Admin Panel */
.admin-wrapper {
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.admin-header {
  background: var(--bg-secondary);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-badge {
  display: inline-block;
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.admin-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.admin-section h3 {
  margin-bottom: 16px;
  font-size: 1.25rem;
}

.sub-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.manual-add-box {
  display: flex;
  gap: 8px;
}

.manual-add-box input {
  padding: 6px 12px;
  font-size: 0.85rem;
  width: 180px;
}

.requests-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.request-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.req-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.req-avatar {
  width: 44px;
  height: 44px;
  border-radius: 8px;
}

.req-name {
  font-size: 1.1rem;
  font-weight: 800;
}

.req-who {
  font-size: 0.8rem;
  color: var(--gold);
}

.req-body {
  font-size: 0.9rem;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.2);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
}

.req-actions {
  display: flex;
  gap: 10px;
  margin-top: auto;
}

.btn-approve {
  background: var(--green);
  color: #000;
  flex: 1;
}

.btn-reject {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.3);
  flex: 1;
}

/* Modals */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

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

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 460px;
  width: 100%;
  padding: 30px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.modal-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg-card);
  padding: 4px;
  border-radius: var(--radius-sm);
  margin-bottom: 22px;
  border: 1px solid var(--border);
}

.modal-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.modal-tab.active {
  background: var(--gold);
  color: #000;
}

.input-with-button {
  display: flex;
  gap: 8px;
}

.input-with-button input {
  flex: 1;
}

.modal-help-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 14px;
  text-align: center;
  line-height: 1.5;
}

.modal-help-text a {
  color: var(--gold);
  text-decoration: none;
  font-weight: 700;
}

.modal-help-text a:hover {
  text-decoration: underline;
}

.modal-help-text code {
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--cyan);
}

.modal-tip {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 8px;
  line-height: 1.4;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--green);
  color: #000;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 9999;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 768px) {
  .nav-container {
    flex-direction: column;
    gap: 12px;
  }
  .personal-header {
    flex-direction: column;
    text-align: center;
  }
  .personal-identity {
    flex-direction: column;
  }
}
