#admin-app { min-height: 100vh; }

.admin-link {
  display: block;
  margin-top: 1rem;
  text-align: center;
  color: var(--accent);
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--panel);
  border-bottom: 1px solid #2a3848;
}

.admin-header h1 { margin: 0; font-size: 1.25rem; }
.admin-header-actions { display: flex; gap: 0.75rem; align-items: center; }
.admin-header-actions a { color: var(--accent); text-decoration: none; }

.admin-tabs {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: #141c28;
  border-bottom: 1px solid #2a3848;
}

.tab {
  padding: 0.5rem 1rem;
  border: 1px solid #2a3848;
  border-radius: 8px;
  background: #2a3848;
  color: var(--text);
  cursor: pointer;
}

.tab.active { background: var(--accent); border-color: var(--accent); }

.tab-panel {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem;
}

.admin-form {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--panel);
  border-radius: 10px;
}

.admin-form h3 { margin-top: 0; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.admin-form label { display: block; margin-bottom: 0.75rem; color: var(--muted); font-size: 0.9rem; }
.admin-form input,
.admin-form textarea,
.admin-form select {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid #2a3848;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

.checkbox { display: flex !important; align-items: center; gap: 0.5rem; }
.checkbox input { width: auto; margin: 0; }

.card-list { display: grid; gap: 0.75rem; margin-top: 1rem; }

.card {
  padding: 0.85rem 1rem;
  background: var(--panel);
  border-radius: 10px;
  border: 1px solid #2a3848;
}

.card-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.card-meta { color: var(--muted); font-size: 0.85rem; margin-top: 0.35rem; }
.card-desc { margin: 0.5rem 0 0; font-size: 0.9rem; }
.card-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; }

.card-nicknames {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.nickname-chip {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: #1e2a3a;
  border: 1px solid #2a3848;
  font-size: 0.8rem;
  color: var(--text);
}

.code-block {
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px 14px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}
  margin-top: 1rem;
  overflow-x: auto;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border-radius: 10px;
  overflow: hidden;
}

.users-table th,
.users-table td {
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid #2a3848;
  text-align: left;
  vertical-align: middle;
}

.users-table th {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  background: #141c28;
}

.users-table input,
.users-table select {
  width: 100%;
  min-width: 110px;
  padding: 0.4rem 0.5rem;
  border: 1px solid #2a3848;
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

.users-actions {
  white-space: nowrap;
  display: flex;
  gap: 0.35rem;
}

.badge {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}
.badge.on { background: #1e8449; }
.badge.off { background: #7f8c8d; }

button.danger { background: #c0392b; }
button.danger:hover { background: #e74c3c; }

.success { color: #2ed573; margin-top: 1rem; }
.muted { color: var(--muted); }

.icon-picker-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.5rem;
}

.icon-picker-search {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid #2a3848;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.88rem;
}

.icon-picker-search:focus {
  outline: none;
  border-color: var(--accent);
}

.icon-picker-empty {
  grid-column: 1 / -1;
  padding: 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.icon-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
  max-height: 280px;
  overflow-y: auto;
  padding: 0.25rem;
  border: 1px solid #2a3848;
  border-radius: 8px;
}

.icon-option {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid #2a3848;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.icon-option.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.icon-option-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #fff;
  font-size: 11px;
  color: #fff;
  flex-shrink: 0;
}

.icon-option-label {
  font-size: 0.8rem;
  line-height: 1.1;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #fff;
  font-size: 11px;
  color: #fff;
  margin-right: 0.35rem;
}

.poi-image-preview {
  margin: 0.5rem 0 1rem;
}

.poi-image-preview img,
.card-poi-image {
  display: block;
  max-width: 240px;
  max-height: 160px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid #2a3848;
  margin-bottom: 0.5rem;
}

select {
  display: block;
  width: 100%;
  max-width: 420px;
  margin-top: 0.35rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid #2a3848;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

.trader-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 0.75rem;
}

.trader-columns .admin-form {
  margin-top: 1rem;
}

#tab-traders select {
  max-width: none;
  width: 100%;
}

#tab-traders .admin-form select {
  margin-top: 0.5rem;
  min-height: 180px;
}

#trader-item-list {
  min-height: 260px;
}

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

#admin-panel.admin-radiation-mode .tab-panel-radiation {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0.75rem 1rem 1rem;
  min-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
}

.rad-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.rad-topbar h2 { margin: 0 0 0.25rem; }
.rad-topbar-left .muted { margin: 0; font-size: 0.9rem; }

.radiation-editor-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 0.75rem;
  flex: 1;
  min-height: 0;
}

@media (max-width: 960px) {
  .radiation-editor-layout { grid-template-columns: 1fr; }
}

.radiation-map {
  height: calc(100vh - 280px);
  min-height: 420px;
  width: 100%;
  border-radius: 10px;
  border: 1px solid #2a3848;
  background: #0d1218;
}

.rad-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  align-items: flex-end;
  margin-bottom: 0.5rem;
}

.rad-toolbar label { margin: 0; min-width: 140px; }
select option {
  background: #1a2430;
  color: #e8eef4;
}

.rad-toolbar select { max-width: 220px; min-width: 140px; }
.rad-file-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

.rad-inline-label {
  display: inline-flex !important;
  align-items: center;
  gap: 0.5rem;
  margin: 0 !important;
  font-size: 0.9rem;
  min-width: auto !important;
}

.rad-inline-label input { width: 90px; margin: 0; }

.rad-bounds-panel {
  margin-top: 0.5rem;
  padding: 0.65rem 0.75rem;
  background: var(--panel);
  border-radius: 10px;
  border: 1px solid #2a3848;
}

.rad-bounds-panel h4 { margin: 0 0 0.5rem; font-size: 0.9rem; }

.rad-overlay-preview {
  display: block;
  max-width: 200px;
  max-height: 120px;
  margin-top: 0.5rem;
  border-radius: 8px;
  border: 1px solid #2a3848;
}

.rad-sidebar {
  background: var(--panel);
  border: 1px solid #2a3848;
  border-radius: 10px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: calc(100vh - 280px);
}

.rad-sidebar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.rad-sidebar-head h3 { margin: 0; font-size: 0.95rem; }

.rad-zone-select {
  width: 100%;
  max-width: none !important;
  min-height: 180px;
  font-size: 0.82rem;
}

.rad-zone-tier-select {
  width: 100%;
  max-width: none !important;
}

.rad-zone-edit {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#rad-zone-tier-add {
  align-self: flex-start;
}

#rad-add-zone-btn.active {
  background: var(--accent);
  border-color: var(--accent);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

#rad-status.error { color: #ff6b6b; }

.rad-zone-handle {
  background: transparent !important;
  border: none !important;
}

.rad-zone-handle span {
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
}

/* ============================================================
   Roads Editor
   ============================================================ */

.admin-roads-panel {
  max-width: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

.roads-editor-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: calc(100vh - 112px);
  min-height: 480px;
}

@media (max-width: 900px) {
  .roads-editor-layout { grid-template-columns: 1fr; height: auto; }
}

/* Sidebar */
.roads-sidebar {
  background: var(--panel);
  border-right: 1px solid #2a3848;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.roads-sidebar h2 { margin: 0; font-size: 1.1rem; }

.roads-hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

/* Type selector */
.roads-type-selector label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.road-type-btns {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.road-type-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid #2a3848;
  border-radius: 8px;
  background: #1a2430;
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

.road-type-btn.active {
  border-color: var(--accent);
  background: #0f1e2e;
}

.rt-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.3);
}

/* Tools */
.roads-tools {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.roads-tool-btn {
  padding: 0.5rem 0.75rem;
  border: 1px solid #2a3848;
  border-radius: 8px;
  background: #1a2430;
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s;
}

.roads-tool-btn:hover { background: #2a3848; }
.roads-tool-btn.active { background: var(--accent); border-color: var(--accent); }
.roads-tool-btn.danger { border-color: #c0392b; }
.roads-tool-btn.danger:hover { background: #c0392b; }

/* Stats */
.roads-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0.35rem 0;
  border-top: 1px solid #2a3848;
  border-bottom: 1px solid #2a3848;
}

.draw-idle { color: var(--muted); }
.draw-drawing { color: #c084fc; }

/* List header */
.roads-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.roads-list-header h3 { margin: 0; font-size: 0.9rem; }

button.secondary.small {
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
}

/* Segment list */
.roads-segment-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.roads-empty {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 1rem 0;
}

.road-seg-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  background: #0f1826;
  border: 1px solid #2a3848;
  border-radius: 8px;
  transition: border-color 0.15s;
}

.road-seg-item.selected { border-color: var(--accent); }

.seg-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.2);
}

.seg-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.seg-type { font-size: 0.82rem; font-weight: 600; }
.seg-pts { font-size: 0.75rem; color: var(--muted); }

.seg-focus-btn,
.seg-delete-btn {
  padding: 0.2rem 0.4rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.9rem;
  border-radius: 5px;
  transition: background 0.15s;
}

.seg-focus-btn:hover { background: #2a3848; }
.seg-delete-btn:hover { background: #c0392b44; }

/* Map */
.roads-map-container {
  width: 100%;
  height: 100%;
  min-height: 400px;
  background: #0d1218;
}

/* Leaflet popup overrides for dark mode in admin */
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: #1a2634 !important;
  color: #e8f0ff !important;
  border: 1px solid #2e3e52;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5) !important;
  font-family: inherit;
}

.leaflet-popup-content {
  margin: 8px 12px !important;
}

.leaflet-popup-close-button {
  color: #95a5a6 !important;
  padding: 4px !important;
}

.leaflet-popup-close-button:hover {
  color: #ff4757 !important;
}

.roads-popup-btn {
  transition: background 0.15s ease, transform 0.1s ease;
}

.roads-popup-btn:active {
  transform: scale(0.97);
}

.admin-poi-ref {
  opacity: 0.92;
}

.poi-admin-layout {
  display: grid;
  grid-template-columns: minmax(320px, 1.2fr) minmax(280px, 1fr);
  gap: 1rem;
  margin-top: 0.75rem;
  min-height: 520px;
}

.poi-admin-map {
  height: 520px;
  border-radius: 10px;
  border: 1px solid #2a3848;
  background: #1a2332;
}

.poi-admin-side {
  max-height: 520px;
  overflow-y: auto;
}

@media (max-width: 960px) {
  .poi-admin-layout {
    grid-template-columns: 1fr;
  }
  .poi-admin-map {
    height: 360px;
  }
  .poi-admin-side {
    max-height: none;
  }
}

