/* === Reset & Base === */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f6fa;
  color: #2d3436;
  min-height: 100vh;
}
a { color: #0984e3; text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Navbar === */
.navbar {
  background: #2d3436;
  color: #fff;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: 56px;
}
.nav-left { display: flex; align-items: center; gap: 0.75rem; }
.nav-brand { font-size: 1.3rem; font-weight: 700; }
.nav-brand a { color: #fff; text-decoration: none; }
.nav-links { display: flex; align-items: center; gap: 0.75rem; }
.nav-user { font-size: 0.85rem; opacity: 0.8; }

/* === Hamburger === */
.hamburger {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 28px;
}
.hamburger span {
  display: block;
  height: 3px;
  width: 100%;
  background: #fff;
  border-radius: 2px;
  transition: all 0.3s;
}

/* === Sidebar === */
.sidebar {
  position: fixed;
  top: 56px;
  left: 0;
  bottom: 0;
  width: 260px;
  background: #fff;
  box-shadow: 2px 0 12px rgba(0,0,0,0.08);
  z-index: 900;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
}
.sidebar.open { transform: translateX(0); }

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.3);
  z-index: 899;
}
.sidebar-overlay.open { display: block; }

/* On desktop, no overlay needed */
@media (min-width: 900px) {
  .sidebar-overlay.open { display: none; }
}

.sidebar-section {
  padding: 0 1rem;
  margin-bottom: 1.5rem;
}
.sidebar-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #636e72;
  margin-bottom: 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid #eee;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  color: #2d3436;
  text-decoration: none;
  font-size: 0.9rem;
  transition: background 0.15s;
}
.sidebar-link:hover { background: #f0f2f5; text-decoration: none; }
.sidebar-link.active { background: #e8f0fe; color: #0984e3; font-weight: 600; }
.sidebar-icon { font-size: 1rem; width: 1.2em; text-align: center; }

/* Sidebar footer */
.sidebar-footer {
  margin-top: auto;
  padding: 1rem 1.2rem;
  font-size: 0.7rem;
  color: #999;
  text-align: center;
  border-top: 1px solid #eee;
  line-height: 1.5;
}
.sidebar-footer strong { color: #667eea; font-size: 0.8rem; }

/* Filter section */
.filter-actions {
  display: flex;
  gap: 0.3rem;
  margin-bottom: 0.5rem;
}
.btn-xs {
  padding: 0.15rem 0.5rem;
  font-size: 0.7rem;
  border-radius: 4px;
  background: #f0f2f5;
  border: 1px solid #ddd;
  cursor: pointer;
  color: #2d3436;
}
.btn-xs:hover { background: #e0e3e6; }

.group-filter-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0;
  font-size: 0.85rem;
  cursor: pointer;
}
.group-filter-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.group-filter-count {
  font-size: 0.75rem;
  color: #999;
  margin-left: auto;
}

/* === Layout adjustments for sidebar === */
body.sidebar-open #map {
  left: 260px;
}
body.sidebar-open .container {
  margin-left: 260px;
}

/* === Buttons === */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s;
}
.btn-primary { background: #0984e3; color: #fff; }
.btn-primary:hover { background: #0870c4; text-decoration: none; }
.btn-danger { background: #d63031; color: #fff; }
.btn-danger:hover { background: #b71c1c; }
.btn-outline { background: transparent; border: 1px solid rgba(255,255,255,0.4); color: #fff; }
.btn-outline:hover { background: rgba(255,255,255,0.1); text-decoration: none; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }

/* === Auth Pages === */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.auth-container {
  background: #fff;
  padding: 2.5rem;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 400px;
  text-align: center;
}
.auth-container h1 { color: #667eea; margin-bottom: 0.5rem; font-size: 2rem; }
.auth-container h2 { margin-bottom: 1.5rem; font-weight: 400; color: #636e72; }
.auth-link { margin-top: 1rem; font-size: 0.9rem; }

/* === Forms === */
.form-group {
  text-align: left;
  margin-bottom: 1rem;
  flex: 1;
}
.form-group label {
  display: block;
  margin-bottom: 0.3rem;
  font-weight: 500;
  font-size: 0.85rem;
  color: #636e72;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.95rem;
  transition: border 0.2s;
}
.form-group input:focus, .form-group select:focus {
  border-color: #0984e3;
  outline: none;
  box-shadow: 0 0 0 3px rgba(9,132,227,0.1);
}
.form-row { display: flex; gap: 1rem; }
.form-inline { display: flex; align-items: center; gap: 1rem; }
.input-with-btn { display: flex; gap: 0.5rem; }
.input-with-btn input { flex: 1; }

/* === Alerts === */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.alert.error { background: #ffeef0; color: #d63031; border: 1px solid #fab1b1; }
.alert.success { background: #eafff5; color: #00b894; border: 1px solid #a3e4cb; }
.success-text { color: #00b894; }
.error-text { color: #d63031; }
.hint { font-size: 0.85rem; color: #636e72; margin-bottom: 0.5rem; }

/* === Layout === */
.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 76px 1.5rem 2rem;
}
.card {
  background: #fff;
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.card h2 { margin-bottom: 1rem; font-size: 1.2rem; }

/* === Table === */
.points-table {
  width: 100%;
  border-collapse: collapse;
}
.points-table th, .points-table td {
  text-align: left;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid #eee;
  vertical-align: middle;
}
.points-table th {
  background: #f8f9fa;
  font-weight: 600;
  font-size: 0.85rem;
  color: #636e72;
}

/* === Photos & Avatars === */
.thumb-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}
.avatar-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #667eea;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
}

/* === Map === */
#map {
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
}

/* === Custom Markers === */
.custom-marker {
  background: none !important;
  border: none !important;
}
.marker-photo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  position: relative;
}
.marker-photo::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid #fff;
}
.marker-initial {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  position: relative;
}
.marker-initial::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid #fff;
}

/* === Popups === */
.popup-content { max-width: 250px; text-align: center; }
.popup-content h3 { margin: 0.5rem 0 0.3rem; font-size: 1rem; }
.popup-photo {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  margin-top: 0.5rem;
}
.popup-address { font-size: 0.8rem; color: #636e72; }
.popup-group {
  font-size: 0.75rem;
  color: #fff;
  background: #667eea;
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 10px;
  margin-bottom: 0.3rem;
}

/* === Modal === */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.modal-content {
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}
.form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* === Navbar logo === */
.navbar-logo {
  height: 32px;
  width: 32px;
  border-radius: 4px;
  object-fit: contain;
  margin-right: 0.5rem;
  vertical-align: middle;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* === Badge === */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  background: #e74c3c;
  color: #fff;
  vertical-align: middle;
}

/* === Super-admin navbar === */
.navbar-super { background: #1a1a2e; }

/* === Super-admin users table === */
.table-wrapper { overflow-x: auto; }
.sa-users-table th, .sa-users-table td { white-space: nowrap; font-size: 0.85rem; }
.tenant-col-header {
  text-align: center;
  font-size: 0.7rem;
  max-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tenant-cell { text-align: center; }
.tenant-cell input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

/* Origin tenant = blue highlight */
.origin-tenant {
  background: #dbeafe !important;
}
.origin-tenant input[type="checkbox"] {
  accent-color: #3b82f6;
}

/* Batch action bar */
.batch-bar {
  background: #2d3436;
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  flex-wrap: wrap;
}
.batch-bar .btn { margin: 0; }
.batch-tenant-select {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  border: 1px solid #636e72;
  background: #fff;
  font-size: 0.8rem;
}

/* === Page header === */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.page-header h1 { margin: 0; }
.page-header-actions { display: flex; gap: 0.5rem; align-items: center; }

/* === Tenant selection === */
.tenant-select-container {
  background: #fff;
  padding: 2.5rem;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 700px;
  text-align: center;
}
.tenant-select-container h1 { color: #667eea; margin-bottom: 0.5rem; font-size: 2rem; }
.tenant-select-container h2 { margin-bottom: 1.5rem; font-weight: 400; color: #636e72; }

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

.tenant-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1rem;
  border: 2px solid #eee;
  border-radius: 12px;
  text-decoration: none;
  color: #2d3436;
  transition: all 0.2s;
}
.tenant-card:hover {
  border-color: #667eea;
  box-shadow: 0 4px 12px rgba(102,126,234,0.2);
  text-decoration: none;
  transform: translateY(-2px);
}

.tenant-logo-wrapper {
  width: 64px;
  height: 64px;
  margin-bottom: 0.75rem;
}
.tenant-card-logo {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: contain;
}
.tenant-card-initial {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  background: #667eea;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 700;
}
.tenant-card-name { font-weight: 600; font-size: 1rem; margin-bottom: 0.25rem; }
.tenant-card-role { font-size: 0.75rem; color: #636e72; text-transform: uppercase; }

.tenant-select-footer {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid #eee;
}

/* === Color dots === */
.color-dot {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  vertical-align: middle;
}
.color-red { background: #e74c3c; }
.color-blue { background: #3498db; }
.color-green { background: #2ecc71; }
.color-orange { background: #f39c12; }
.color-purple { background: #9b59b6; }
.color-teal { background: #1abc9c; }
.color-pink { background: #e84393; }
.color-gray { background: #636e72; }

/* Color select styling */
select option[value="red"] { color: #e74c3c; }
select option[value="blue"] { color: #3498db; }
select option[value="green"] { color: #2ecc71; }
select option[value="orange"] { color: #f39c12; }
select option[value="purple"] { color: #9b59b6; }
select option[value="teal"] { color: #1abc9c; }
select option[value="pink"] { color: #e84393; }
select option[value="gray"] { color: #636e72; }

/* === Outline dark button === */
.btn-outline-dark {
  background: transparent;
  border: 1px solid #ccc;
  color: #2d3436;
}
.btn-outline-dark:hover { background: #f5f6fa; text-decoration: none; }

/* === Responsive === */
@media (max-width: 900px) {
  body.sidebar-open #map { left: 0; }
  body.sidebar-open .container { margin-left: 0; }
}
@media (max-width: 768px) {
  .form-row { flex-direction: column; }
  .navbar { padding: 0.5rem 1rem; }
  .nav-links { gap: 0.3rem; flex-wrap: wrap; }
  .nav-user { display: none; }
  .container { padding-top: 66px; }
}
