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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: #0f1419;
  color: #e7e9ea;
  height: 100vh;
  overflow: hidden;
}

.hidden { display: none !important; }

/* Auth */
#auth-panel {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: #0f1419;
  z-index: 1000;
}
#auth-panel h2 { font-size: 2rem; margin-bottom: 1.5rem; color: #1d9bf0; }
.auth-tabs {
  display: flex; gap: 0; margin-bottom: 1rem; width: 300px;
  border-bottom: 1px solid #2f3336;
}
.auth-tab {
  flex: 1; padding: 0.6rem; background: transparent;
  border: none; border-bottom: 2px solid transparent;
  border-radius: 0; color: #71767b; font-size: 0.95rem;
  cursor: pointer; transition: color 0.15s, border-color 0.15s;
}
.auth-tab:hover { color: #e7e9ea; }
.auth-tab.active { color: #1d9bf0; border-bottom-color: #1d9bf0; }
.auth-form {
  display: flex; flex-direction: column; gap: 0.75rem;
  width: 300px;
}

input, textarea, select {
  padding: 0.6rem 0.8rem;
  border: 1px solid #333;
  border-radius: 8px;
  background: #1a1f25;
  color: #e7e9ea;
  font-size: 0.95rem;
}
input:focus, textarea:focus { border-color: #1d9bf0; outline: none; }
textarea { min-height: 80px; resize: vertical; }

button {
  padding: 0.6rem 1rem;
  border: none; border-radius: 8px;
  background: #333; color: #e7e9ea;
  cursor: pointer; font-size: 0.9rem;
  transition: background 0.15s;
}
button:hover { background: #444; }
button.primary { background: #1d9bf0; color: #fff; }
button.primary:hover { background: #1a8cd8; }
button.secondary { background: transparent; border: 1px solid #555; }
button.small { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
button.full-w { width: 100%; }

.btn-row { display: flex; gap: 0.5rem; }

.error { color: #f4212e; font-size: 0.85rem; margin-top: 0.25rem; }
.hint { color: #71767b; font-size: 0.8rem; }

/* Layout */
#app { display: flex; height: 100vh; }

#sidebar {
  width: 360px; min-width: 360px;
  background: #15181c;
  border-right: 1px solid #2f3336;
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: width 0.2s, min-width 0.2s;
}

.sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid #2f3336;
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
}
.sidebar-header h2 { color: #1d9bf0; flex: 1; font-size: 1.2rem; }
#user-info { font-size: 0.8rem; color: #71767b; }

/* Rank */
.rank-badge { font-size: 0.75rem; color: #1d9bf0; font-weight: 600; }
.rank-section {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid #2f3336;
}
.rank-info {
  display: flex; justify-content: space-between; align-items: center;
}
.rank-name { font-size: 0.9rem; color: #e7e9ea; font-weight: 600; }
.rank-progress { font-size: 0.75rem; color: #71767b; }
.rank-stats {
  display: flex; gap: 1rem; margin-top: 0.25rem;
  font-size: 0.8rem; color: #71767b;
}

/* Invites */
.invite-section {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid #2f3336;
}
.invite-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.85rem; color: #e7e9ea;
}
.invite-list { display: flex; flex-direction: column; gap: 0.25rem; }
.invite-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.3rem 0;
  font-size: 0.8rem;
}
.invite-code {
  background: #1e2227; padding: 0.15rem 0.4rem; border-radius: 4px;
  font-family: monospace; cursor: pointer; color: #e7e9ea;
  font-size: 0.85rem;
}
.invite-code:hover { background: #2f3336; }
.invite-active .invite-status { color: #00ba7c; }
.invite-used .invite-status { color: #71767b; }
.invite-used .invite-code { color: #71767b; }
.invite-empty { font-size: 0.8rem; color: #71767b; margin: 0; }

#observer-controls { padding: 0.75rem 1rem; }

/* Executor zone controls */
#executor-zone-controls { padding: 0.75rem 1rem; border-bottom: 1px solid #2f3336; }
.zone-status {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem;
}
.zone-status span { font-size: 0.85rem; color: #71767b; }
.zone-btns { display: flex; gap: 0.4rem; }
.zone-setup {
  margin-top: 0.75rem;
  display: flex; flex-direction: column; gap: 0.5rem;
}
.zone-radius-label {
  font-size: 0.85rem; color: #e7e9ea;
  display: flex; justify-content: space-between;
}
.zone-radius-label span { color: #1d9bf0; font-weight: 600; }
#zone-radius-slider {
  width: 100%; cursor: pointer;
  accent-color: #1d9bf0;
}
.zone-center-marker {
  width: 16px; height: 16px;
  background: #1d9bf0;
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 2px 8px rgba(29,155,240,0.5);
}
.zone-center-marker:active { cursor: grabbing; }
.zone-empty-hint {
  padding: 1rem; color: #71767b; font-size: 0.9rem;
}



.incident-list { flex: 1; overflow-y: auto; }
.incident-card {
  padding: 1rem;
  border-bottom: 1px solid #2f3336;
  cursor: pointer;
  transition: background 0.15s;
}
.incident-card:hover { background: #1e2227; }
.incident-card h4 { margin-bottom: 0.25rem; }
.incident-card .meta { font-size: 0.8rem; color: #71767b; }

.badge {
  display: inline-block; padding: 0.15rem 0.5rem;
  border-radius: 12px; font-size: 0.75rem; font-weight: 600;
}
.badge-open { background: #1d9bf033; color: #1d9bf0; }
.badge-voting { background: #a855f733; color: #a855f7; }
.badge-confirmed { background: #06b6d433; color: #06b6d4; }
.badge-in_progress { background: #ffd60a33; color: #ffd60a; }
.badge-review { background: #f4843333; color: #f48433; }
.badge-resolved { background: #00ba7c33; color: #00ba7c; }
.badge-rejected { background: #ef444433; color: #ef4444; }

/* Voting section */
.vote-section {
  margin-top: 0.75rem; padding: 0.75rem;
  background: #1e2227; border-radius: 8px;
}
.vote-section h4 { margin-bottom: 0.5rem; font-size: 0.9rem; }
.vote-status {
  display: flex; gap: 0.75rem; margin-bottom: 0.5rem;
  font-size: 0.85rem; color: #71767b;
}
.vote-status .approve-count { color: #00ba7c; }
.vote-status .reject-count { color: #ef4444; }
.vote-buttons {
  display: flex; gap: 0.5rem;
}
.vote-buttons button { flex: 1; }
.btn-reject {
  background: #ef444433; color: #ef4444; border: 1px solid #ef4444;
}
.btn-reject:hover { background: #ef444455; }
.vote-cast { font-size: 0.85rem; color: #71767b; font-style: italic; }

/* Map */
#map-container { flex: 1; position: relative; }
#map { width: 100%; height: 100%; }

.map-hint {
  position: absolute; top: 1rem; left: 50%; transform: translateX(-50%);
  background: #1d9bf0; color: #fff; padding: 0.6rem 1.2rem;
  border-radius: 12px; font-size: 0.9rem; font-weight: 600;
  z-index: 10; pointer-events: none;
  animation: pulse-hint 1.5s ease-in-out infinite;
  box-shadow: 0 4px 12px rgba(29,155,240,0.4);
}
@keyframes pulse-hint {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Map search */
.map-search {
  position: absolute; top: 0.75rem; left: 0.75rem;
  z-index: 10; width: 320px;
}
.map-search input {
  width: 100%; padding: 0.6rem 0.8rem;
  background: #1a1f25ee; border: 1px solid #333; border-radius: 10px;
  color: #e7e9ea; font-size: 0.9rem;
  backdrop-filter: blur(8px);
}
.map-search input:focus { border-color: #1d9bf0; }
.search-results {
  margin-top: 4px; background: #1a1f25ee;
  border: 1px solid #333; border-radius: 10px;
  max-height: 240px; overflow-y: auto;
  backdrop-filter: blur(8px);
}
.search-result-item {
  padding: 0.5rem 0.75rem; cursor: pointer;
  border-bottom: 1px solid #2f3336;
  font-size: 0.85rem; color: #e7e9ea;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: #1d9bf022; }
.search-result-item .search-type {
  font-size: 0.7rem; color: #71767b; margin-left: 0.25rem;
}

/* Create form in sidebar */
.create-form {
  padding: 1rem;
  display: flex; flex-direction: column; gap: 0.6rem;
  border-top: 1px solid #2f3336;
  overflow-y: auto;
}
.create-form h3 { color: #1d9bf0; margin-bottom: 0.25rem; }
.coord-display {
  display: flex; align-items: center; justify-content: space-between;
  background: #1a1f25; padding: 0.5rem 0.75rem; border-radius: 8px;
  font-size: 0.85rem; color: #71767b;
}

/* Incident meta grid */
.meta-grid { display: flex; flex-direction: column; gap: 0.4rem; }
.meta-row {
  display: flex; justify-content: space-between; align-items: center;
  background: #1e2227; padding: 0.4rem 0.6rem; border-radius: 8px;
  font-size: 0.85rem;
}
.meta-label { color: #71767b; }
.meta-value { color: #e7e9ea; font-weight: 500; }
.priority-low { color: #00ba7c; }
.priority-medium { color: #1d9bf0; }
.priority-high { color: #ffd60a; }
.priority-critical { color: #f4212e; font-weight: 700; }

/* Modal */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;

  z-index: 500;
}
.modal-content {
  background: #1a1f25;
  border-radius: 16px;
  padding: 1.5rem;
  width: 400px; max-height: 80vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 0.75rem;
}
.modal-content h3 { color: #1d9bf0; }

.coord-row { display: flex; gap: 0.5rem; }
.coord-row input { flex: 1; }

.photos { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.photos img {
  width: 80px; height: 80px;
  object-fit: cover; border-radius: 8px;
  cursor: pointer;
}

/* MapLibre popup */
.maplibregl-popup-content {
  background: #1a1f25 !important;
  color: #e7e9ea !important;
  border-radius: 12px !important;
  padding: 0.75rem !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5) !important;
}
.maplibregl-popup-close-button { color: #e7e9ea !important; }
.popup-thumb { width: 100%; max-height: 120px; object-fit: cover; border-radius: 8px; margin-top: 0.5rem; }

/* Resolution info */
.resolution-info {
  background: #1e2227; border-radius: 10px; padding: 0.75rem;
  border-left: 3px solid #f48433;
}
.resolution-info h4 { color: #f48433; margin-bottom: 0.4rem; font-size: 0.9rem; }
.resolution-info p { font-size: 0.9rem; white-space: pre-wrap; }

/* Resolve form */
.resolve-form {
  display: flex; flex-direction: column; gap: 0.5rem;
  background: #1e2227; border-radius: 10px; padding: 0.75rem;
}
.resolve-form h4 { color: #1d9bf0; font-size: 0.9rem; }
.resolve-photos-section { display: flex; flex-direction: column; gap: 0.4rem; }

/* Return form */
.return-form {
  display: flex; flex-direction: column; gap: 0.5rem;
  background: #1e2227; border-radius: 10px; padding: 0.75rem;
}

/* Review comment (returned by moderator) */
.review-comment-info {
  background: #ef444422; border: 1px solid #ef4444; border-radius: 10px;
  padding: 0.75rem; margin-bottom: 0.5rem;
}
.review-comment-info h4 { color: #ef4444; font-size: 0.9rem; margin-bottom: 0.3rem; }
.review-comment-info p { font-size: 0.85rem; color: #e7e9ea; white-space: pre-wrap; }

/* Preview marker for new incident */
.preview-marker {
  width: 24px; height: 24px;
  background: #f4212e;
  border: 3px solid #fff;
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 2px 8px rgba(244,33,46,0.5);
  animation: marker-drop 0.3s ease-out;
}
.preview-marker:active { cursor: grabbing; }
@keyframes marker-drop {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Notifications */
.notif-btn {
  position: relative;
  background: transparent;
  font-size: 1.1rem;
  padding: 0.3rem 0.5rem;
}
.notif-btn:hover { background: #2f3336; }
.notif-badge {
  position: absolute; top: -2px; right: -4px;
  background: #f4212e; color: #fff;
  font-size: 0.65rem; font-weight: 700;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px; line-height: 1;
}
.notif-panel {
  position: absolute; top: 0; left: 0;
  width: 360px; height: 100%;
  background: #15181c;
  border-right: 1px solid #2f3336;
  z-index: 400;
  display: flex; flex-direction: column;
}
.notif-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #2f3336;
  display: flex; align-items: center; gap: 0.5rem;
}
.notif-header h3 { flex: 1; color: #1d9bf0; font-size: 1rem; }
.notif-list {
  flex: 1; overflow-y: auto;
}
.notif-item {
  display: flex; gap: 0.6rem; padding: 0.75rem 1rem;
  border-bottom: 1px solid #2f3336;
  cursor: pointer;
  transition: background 0.15s;
  background: #1a1f2588;
}
.notif-item:hover { background: #1e2227; }
.notif-item-read { background: transparent; }
.notif-item-read .notif-message { color: #71767b; }
.notif-icon { font-size: 1.2rem; flex-shrink: 0; margin-top: 2px; }
.notif-body { flex: 1; min-width: 0; }
.notif-message { font-size: 0.85rem; line-height: 1.3; }
.notif-time { font-size: 0.75rem; color: #71767b; margin-top: 0.2rem; }
.notif-empty { padding: 1rem; color: #71767b; font-size: 0.9rem; }

/* Admin controls */
#admin-controls { padding: 0.5rem 1rem; border-bottom: 1px solid #2f3336; }

/* Category manager */
.cat-add-row { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }
.cat-add-row input { flex: 1; }
.cat-list { display: flex; flex-direction: column; gap: 0.25rem; max-height: 300px; overflow-y: auto; }
.cat-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 0.6rem; background: #1e2227; border-radius: 8px;
}
.cat-name { font-size: 0.9rem; }
.cat-actions { display: flex; gap: 0.3rem; }

/* Violator section in detail */
.violator-section {
  border-top: 1px solid #2f3336; padding-top: 0.5rem;
}
.create-violator-section {
  border-top: 1px solid #2f3336; padding-top: 0.5rem; margin-top: 0.3rem;
}
.create-violator-section h4 { color: #1d9bf0; font-size: 0.9rem; margin-bottom: 0.4rem; }
.violator-section h4 { color: #1d9bf0; font-size: 0.9rem; margin-bottom: 0.4rem; }
.violator-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.35rem 0.5rem; background: #1e2227; border-radius: 6px;
  margin-bottom: 0.25rem;
}
.violator-name {
  font-size: 0.85rem; cursor: pointer; color: #1d9bf0;
}
.violator-name:hover { text-decoration: underline; }
.violator-add { position: relative; margin-top: 0.4rem; }
.violator-add input { width: 100%; }
.violator-results {
  position: absolute; left: 0; right: 0; top: 100%;
  background: #1a1f25; border: 1px solid #333; border-radius: 8px;
  max-height: 180px; overflow-y: auto; z-index: 10;
  margin-top: 2px;
}
.violator-result-item {
  padding: 0.4rem 0.6rem; cursor: pointer;
  font-size: 0.85rem; border-bottom: 1px solid #2f3336;
}
.violator-result-item:last-child { border-bottom: none; }
.violator-result-item:hover { background: #1d9bf022; }
.violator-create { color: #1d9bf0; font-weight: 600; }
