@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600;9..40,700&display=swap');

:root {
  --bg-page: #f1f5f9;
  --bg-card: #ffffff;
  --accent: #16a34a;
  --accent-muted: rgba(22, 163, 74, 0.12);
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg-page);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

#map {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
}

.zoom-level-display {
  position: fixed;
  bottom: 12px;
  left: 12px;
  z-index: 2;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-family: monospace;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: var(--shadow);
}

.map-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: rgba(241, 245, 249, 0.95);
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.map-loading-overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.map-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: map-loading-spin 0.8s linear infinite;
}

.map-loading-text {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-muted);
}

@keyframes map-loading-spin {
  to { transform: rotate(360deg); }
}

.map-controls {
  position: fixed;
  top: 12px;
  right: 12px;
  left: auto;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 320px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.map-controls.is-minimized .controls-body {
  display: none;
}

.controls-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.controls-header h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.controls-header-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.controls-body {
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.menu-toggle-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.menu-toggle-btn:hover {
  background: #f8fafc;
}

.menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 170px;
  min-width: 170px;
  display: none;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0.35rem;
  z-index: 5;
}

#coverage-dropdown.state-picker-open {
  width: 200px;
  min-width: 200px;
}

.menu-dropdown.is-open {
  display: grid;
  gap: 0.2rem;
}

.app-menu {
  position: relative;
}

.menu-item-btn {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.86rem;
  color: var(--text);
  padding: 0.45rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
}

.menu-item-btn:hover {
  background: #f1f5f9;
}

.menu-item-btn.is-active {
  background: rgba(34, 197, 94, 0.14);
  color: #15803d;
  font-weight: 600;
}

.state-filter-section {
  margin-top: 0.25rem;
  padding-top: 0.25rem;
  border-top: 1px solid var(--border);
}

.state-filter-toggle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.state-filter-toggle:hover {
  color: var(--text);
}

.state-picker-panel {
  margin-top: 0.35rem;
  padding: 0.5rem;
  background: #f8fafc;
  border-radius: 6px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.2s ease;
}

.state-picker-panel.is-open {
  max-height: 220px;
}

.state-picker-actions {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.state-picker-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-family: inherit;
  background: #e2e8f0;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text);
}

.state-picker-btn:hover {
  background: #cbd5e1;
}

.state-checkbox-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.2rem;
  max-height: 160px;
  overflow-y: auto;
}

.state-checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0.2rem 0;
}

.state-checkbox-item:hover {
  color: var(--accent);
}

.state-checkbox-item input {
  margin: 0;
  cursor: pointer;
}

.style-row {
  display: grid;
  gap: 0.35rem;
}

.style-row label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.style-row select {
  width: 100%;
  padding: 0.45rem 0.6rem;
  font-size: 0.875rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.style-row select:focus {
  outline: none;
  border-color: var(--accent);
}

.search-form {
  display: grid;
  gap: 0.4rem;
  grid-template-columns: 1fr auto;
  align-items: center;
}

.search-form input {
  width: 100%;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
}

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

#parcel-id-search {
  grid-template-columns: 0.45fr 1fr auto;
}

.parcel-btn {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-family: inherit;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-muted);
  border: 1px solid var(--accent);
  border-radius: 6px;
  cursor: pointer;
}

.parcel-btn:hover {
  background: rgba(22, 163, 74, 0.2);
}

.parcel-btn.active {
  background: var(--accent);
  color: white;
}

.overlay-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.reportall-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.reportall-toggle-btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  font-family: inherit;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
}

.reportall-toggle-btn:hover {
  background: #e2e8f0;
  color: var(--text);
}

.reportall-dropdown {
  display: none;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.5rem;
  background: #f8fafc;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.reportall-dropdown.is-open {
  display: flex;
}

.parcel-popup {
  position: fixed;
  top: 12px;
  left: 52px;
  right: auto;
  width: 360px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 240px);
  z-index: 4;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.parcel-popup.is-closed {
  transform: translateX(calc(-100% - 24px));
  opacity: 0;
  pointer-events: none;
}

.parcel-popup.is-minimized .parcel-popup-header {
  border-bottom: none;
}

.parcel-popup.is-minimized #parcel-details-content {
  display: none;
}

.parcel-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.parcel-popup-header h4 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.parcel-popup-actions {
  display: flex;
  gap: 0.25rem;
}

.parcel-popup-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.parcel-popup-btn:hover {
  background: #f1f5f9;
  color: var(--text);
}

#parcel-details-content {
  padding: 0.75rem 1rem;
  overflow-y: auto;
  font-size: 0.875rem;
  line-height: 1.5;
}

.parcel-placeholder {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.parcel-error {
  color: #dc2626;
}

.info-topcards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.info-card {
  padding: 0.5rem;
  background: #f8fafc;
  border-radius: 6px;
}

.info-card-full {
  grid-column: 1 / -1;
}

.info-value {
  font-weight: 600;
  font-size: 0.9rem;
}

.info-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.info-section {
  margin-bottom: 1rem;
}

.info-section h5 {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.parcel-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.parcel-table td {
  padding: 0.35rem 1rem 0.35rem 0;
  vertical-align: top;
  line-height: 1.4;
}

.parcel-key {
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  width: 1%;
}

.record-back-btn {
  margin-bottom: 0.75rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  font-family: inherit;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

.record-back-btn:hover {
  background: #e2e8f0;
}

.record-picker-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.record-picker-card {
  padding: 0.6rem;
  text-align: left;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}

.record-picker-card:hover {
  background: #f1f5f9;
  border-color: var(--accent);
}

.record-picker-pid {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.record-picker-owner {
  font-weight: 600;
  font-size: 0.9rem;
}

.record-picker-address {
  font-size: 0.8rem;
  color: var(--text-muted);
}
