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

.hidden {
  display: none !important;
}

.popup-entry-code {
  white-space: nowrap;
  display: inline-block;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5;
  color: #333;
}

header {
  background: #1a56db;
  color: white;
  padding: 12px 24px;
  display: flex;
  align-items: baseline;
  gap: 16px;
}

header h1 {
  font-size: 1.4rem;
}

header p {
  font-size: 0.9rem;
  opacity: 0.85;
  flex: 1;
}

.btn-header {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.hint {
  font-size: 0.8rem;
  color: #6b7280;
  margin-top: 4px;
}

.main-layout {
  display: flex;
  height: calc(100vh - 56px);
}

.sidebar {
  width: 360px;
  min-width: 360px;
  background: white;
  border-right: 1px solid #ddd;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 16px 16px 0 16px;
}

.panel {
  margin-bottom: 24px;
}

/* Address search */
.search-container {
  position: relative;
}

#address-search {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #1a56db;
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
}

#address-search:focus {
  border-color: #1e40af;
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.15);
}

.suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #d1d5db;
  border-top: none;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 100;
  max-height: 250px;
  overflow-y: auto;
}

.suggestions.hidden {
  display: none;
}

.suggestion-item {
  padding: 10px 12px;
  cursor: pointer;
  font-size: 0.85rem;
  border-bottom: 1px solid #f0f0f0;
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-item:hover,
.suggestion-item.active {
  background: #eff6ff;
  color: #1a56db;
}

/* Marker clusters */
.custom-cluster {
  background: none !important;
  border: none !important;
}

.cluster-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: white;
  font-weight: 700;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.search-marker-pin {
  width: 24px;
  height: 24px;
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.search-marker-in {
  background: #059669;
}

.search-marker-out {
  background: #dc2626;
}

.panel h2 {
  font-size: 1rem;
  margin-bottom: 10px;
  color: #1a56db;
  border-bottom: 2px solid #e5e7eb;
  padding-bottom: 6px;
}

.panel-actions {
  display: flex;
  gap: 8px;
}

.tray {
  margin-top: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #f9fafb;
}

.tray summary {
  padding: 6px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
  user-select: none;
}

.tray[open] summary {
  border-bottom: 1px solid #e5e7eb;
}

.tray-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
}

.tray-option {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: #374151;
  cursor: pointer;
}

.tray-sep {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px dashed #d1d5db;
}

.btn {
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: opacity 0.2s;
}

.btn:hover {
  opacity: 0.85;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: #1a56db;
  color: white;
}

.btn-secondary {
  background: #6b7280;
  color: white;
}

.btn-warning {
  background: #d97706;
  color: white;
}

.btn-success {
  background: #059669;
  color: white;
}

.btn-danger {
  background: #dc2626;
  color: white;
}

.btn-sm {
  padding: 3px 8px;
  font-size: 0.75rem;
}

.item-list {
  margin-top: 6px;
}

.item-card {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 6px;
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.item-card .info {
  flex: 1;
}

.item-card .info .name {
  font-weight: 600;
}

.item-card .info .detail {
  color: #6b7280;
  font-size: 0.78rem;
}

.item-card .actions {
  display: flex;
  gap: 4px;
}

.status-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
}

.badge-in {
  background: #d1fae5;
  color: #065f46;
}

.badge-out {
  background: #fee2e2;
  color: #991b1b;
}

.badge-unknown {
  background: #e5e7eb;
  color: #6b7280;
}

.badge-new {
  background: #dbeafe;
  color: #1e40af;
}

.badge-transfer {
  background: #fef3c7;
  color: #92400e;
}

.badge-exception {
  background: #f59e0b;
  color: #fff;
  font-weight: 700;
}

.badge-code {
  background: #e0e7ff;
  color: #3730a3;
}

.badge-sped {
  background: #fce7f3;
  color: #be185d;
}

.item-exception {
  border: 2px solid #f59e0b;
  background: #fffbeb;
}

.exception-detail {
  font-size: 0.72rem;
  font-weight: 600;
  color: #d97706;
  margin-top: 2px;
}

.student-sections {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 8px;
  padding-bottom: 16px;
}

.student-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.student-section.hidden {
  display: none;
}

.section-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.section-header {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 6px 6px 0 0;
  margin-bottom: 0;
}

.section-filter {
  width: 100%;
  padding: 5px 10px;
  border: 1px solid #e5e7eb;
  border-top: none;
  font-size: 0.78rem;
  outline: none;
  background: #fafafa;
}

.section-filter:focus {
  background: #fff;
  border-color: #d1d5db;
}

.section-exception {
  background: #fef3c7;
  color: #92400e;
  border-left: 4px solid #f59e0b;
}

.section-out {
  background: #fee2e2;
  color: #991b1b;
  border-left: 4px solid #dc2626;
}

.section-in {
  background: #d1fae5;
  color: #065f46;
  border-left: 4px solid #059669;
}

.section-unchecked {
  background: #f3f4f6;
  color: #6b7280;
  border-left: 4px solid #9ca3af;
}

/* District summary table */
.district-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.district-table th {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 2px solid #e5e7eb;
  font-weight: 600;
  color: #374151;
}

.district-table th:last-child {
  text-align: right;
}

.district-table td {
  padding: 5px 10px;
  border-bottom: 1px solid #f0f0f0;
}

.district-table td:last-child {
  text-align: right;
  font-weight: 600;
}

.district-table tr:hover {
  background: #f9fafb;
}

.stats {
  margin-top: 10px;
  padding: 8px;
  background: #f0f2f5;
  border-radius: 6px;
  font-size: 0.8rem;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

#map {
  flex: 1;
  z-index: 0;
}

/* 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: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  border-radius: 10px;
  padding: 24px;
  min-width: 380px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-content h3 {
  margin-bottom: 16px;
  color: #1a56db;
}

.modal-content label {
  display: block;
  margin-bottom: 12px;
  font-size: 0.85rem;
  font-weight: 500;
}

.modal-content input,
.modal-content select {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  margin-top: 4px;
  font-size: 0.9rem;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  justify-content: flex-end;
}

/* Loading overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  font-size: 1.2rem;
  color: #1a56db;
}

.loading-overlay.hidden {
  display: none;
}

/* Login page */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #f0f2f5;
}

.login-box {
  background: white;
  border-radius: 12px;
  padding: 40px;
  width: 380px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.login-box h1 {
  color: #1a56db;
  margin-bottom: 4px;
}

.login-subtitle {
  color: #6b7280;
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.login-box label {
  display: block;
  text-align: left;
  margin-bottom: 12px;
  font-size: 0.85rem;
  font-weight: 500;
}

.login-box input {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  margin-top: 4px;
  font-size: 0.95rem;
}

.btn-full {
  width: 100%;
  padding: 10px;
  margin-top: 8px;
  font-size: 0.95rem;
}

.error-msg {
  color: #dc2626;
  font-size: 0.85rem;
  margin-bottom: 8px;
  text-align: left;
}

.error-msg.hidden {
  display: none;
}

/* Progress overlay */
.progress-overlay {
  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;
}

.progress-overlay.hidden {
  display: none;
}

.progress-box {
  background: white;
  border-radius: 10px;
  padding: 30px 40px;
  min-width: 400px;
  text-align: center;
}

.progress-label {
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: 12px;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-bar-track {
  width: 100%;
  height: 16px;
  background: #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: #1a56db;
  border-radius: 8px;
  transition: width 0.2s ease;
  width: 0%;
}

.progress-count {
  font-size: 0.85rem;
  color: #6b7280;
  margin-top: 8px;
}

.progress-stats {
  font-size: 0.8rem;
  color: #059669;
  margin-top: 4px;
}

/* Map legend */
#map-cards {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 900;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}

#funding-card,
#map-legend {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  padding: 8px 10px;
  font-size: 12px;
  max-width: 330px;
}

.legend-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  margin-bottom: 6px;
}

.legend-toggle {
  border: 1px solid #ccc;
  background: #f9fafb;
  border-radius: 4px;
  width: 20px;
  height: 20px;
  line-height: 1;
  cursor: pointer;
  font-size: 12px;
  color: #374151;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 5px 0;
  color: #374151;
}

.legend-swatch {
  flex: none;
  border-radius: 50%;
}

.legend-label {
  flex: 1;
}

.legend-count {
  font-weight: 700;
  color: #111827;
  padding-left: 24px;
}

.legend-total {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #e5e7eb;
  color: #6b7280;
}

.legend-pin {
  width: 24px;
  height: 24px;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.legend-sep {
  border-top: 1px solid #e5e7eb;
  margin: 7px 0;
}


/* District summary links */
.district-link {
  color: #1a56db;
  text-decoration: none;
  cursor: pointer;
}

.district-link:hover {
  text-decoration: underline;
}

/* Slow the map zoom transition (0.25s default -> 0.5s) */
.leaflet-zoom-anim .leaflet-zoom-animated {
  transition: transform 0.5s cubic-bezier(0, 0, 0.25, 1);
}

