/* Base Styles */
:root {
  --railroad-blue: #0F4C81;
  --railroad-gray: #555555;
  --railroad-amber: #FFC107;
  --railroad-light: #F8F9FA;
  --white: #FFFFFF;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-800: #1F2937;
  --blue-50: #EFF6FF;
  --blue-700: #1D4ED8;
  --green-50: #ECFDF5;
  --green-800: #065F46;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --border-radius-sm: 0.25rem;
  --border-radius-md: 0.375rem;
  --border-radius-lg: 0.5rem;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--railroad-light);
  color: var(--gray-800);
}

body {
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header */
.header {
  background-color: var(--railroad-blue);
  color: var(--white);
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow-md);
  z-index: 10;
}

/* Tab Navigation */
.header-nav {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

.nav-tab {
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.nav-tab:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Address Autocomplete Styles */
.address-autocomplete {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--gray-300);
  border-top: none;
  border-radius: 0 0 var(--border-radius-md) var(--border-radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  max-height: 300px;
  overflow-y: auto;
}

.autocomplete-item {
  padding: 0.75rem;
  border-bottom: 1px solid var(--gray-200);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

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

.autocomplete-item:hover,
.autocomplete-item.active {
  background-color: var(--blue-50);
}

.autocomplete-main {
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 0.25rem;
}

.autocomplete-details {
  font-size: 0.875rem;
  color: var(--gray-600);
  margin-bottom: 0.25rem;
}

.autocomplete-confidence {
  font-size: 0.75rem;
  color: var(--gray-500);
  font-weight: 500;
}

/* Make address search input container relative for autocomplete positioning */
.address-search-container {
  position: relative;
}

.nav-tab.active {
  background: white;
  color: var(--railroad-blue);
  border-color: white;
}

/* Page Management */
.page {
  display: none;
}

.page.active {
  display: block;
}

/* Hamburger Menu */
.hamburger-menu {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 1001;
  background: var(--white);
  border: 2px solid var(--railroad-blue);
  border-radius: var(--border-radius-md);
  padding: 0.75rem;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 30px;
  height: 30px;
}

.hamburger-menu:hover {
  background: var(--blue-50);
  transform: scale(1.05);
}

.hamburger-menu span {
  display: block;
  height: 3px;
  width: 100%;
  background: var(--railroad-blue);
  border-radius: 2px;
  transition: all 0.3s ease;
}

.hamburger-menu.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.hamburger-menu.active span:nth-child(2) {
  opacity: 0;
}

.hamburger-menu.active span:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -6px);
}

/* View Controls */
.view-controls {
  margin: 1rem 0;
  padding: 1rem;
  background: var(--blue-50);
  border-radius: var(--border-radius-md);
  border: 1px solid var(--gray-200);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.control-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-800);
}

.toggle-group {
  display: flex;
  gap: 0.25rem;
  background: var(--white);
  border-radius: var(--border-radius-md);
  padding: 0.25rem;
  border: 1px solid var(--gray-300);
}

.toggle-btn {
  flex: 1;
  padding: 0.5rem 1rem;
  border: none;
  background: transparent;
  color: var(--gray-800);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.toggle-btn.active {
  background: var(--railroad-blue);
  color: var(--white);
  box-shadow: var(--shadow-sm);
}

.toggle-btn:hover:not(.active) {
  background: var(--gray-100);
}

/* Clear button is reused in business selection panel - keep only essential styles */
.clear-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  background: var(--gray-200);
  border: none;
  border-radius: var(--border-radius-sm);
  color: var(--gray-800);
  cursor: pointer;
  transition: background-color 0.2s ease;
  white-space: nowrap;
  min-width: fit-content;
}

.clear-btn:hover {
  background: var(--gray-300);
}

/* GeoJSON Viewer */
.geojson-viewer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--white);
  z-index: 5;
  display: flex;
  flex-direction: column;
}

.geojson-viewer.hidden {
  display: none;
}

.viewer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: var(--railroad-blue);
  color: var(--white);
  box-shadow: var(--shadow-sm);
}

.viewer-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.viewer-controls {
  display: flex;
  gap: 0.5rem;
}

.export-btn, .copy-btn {
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: var(--white);
  border-radius: var(--border-radius-sm);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.export-btn:hover, .copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}


.viewer-content {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.usa-map {
  flex: 1;
  min-height: 400px;
  background: var(--gray-100);
  border-right: 1px solid var(--gray-200);
}

.json-display {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--white);
}

.json-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: var(--gray-100);
  border-bottom: 1px solid var(--gray-200);
}

.json-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-800);
}

.json-output {
  flex: 1;
  margin: 0;
  padding: 1rem;
  background: var(--white);
  border: none;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.875rem;
  line-height: 1.4;
  overflow: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.header-subtitle {
  font-size: 0.875rem;
  opacity: 0.8;
  display: none;
}

@media (min-width: 768px) {
  .header-subtitle {
    display: block;
  }
}

/* Main Content */
.main {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* Allow scrolling for API test page */
.main.api-test-page {
  overflow: auto;
}

#map {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background-color: var(--gray-100);
}

/* Side Panel */
#side-panel {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 10;
  background-color: var(--white);
  background-opacity: 0.95;
  width: 300px;
  max-width: 30%;
  padding: 0.75rem;
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: transform 0.3s ease-in-out;
}

#side-panel.collapsed {
  transform: translateX(-100%);
}

.panel-section {
  border-bottom: 1px solid var(--gray-200);
  padding-bottom: 0.75rem;
}

.panel-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

/* Sidebar Business Section */
.sidebar-business-section {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--gray-200);
}

.sidebar-btn {
  width: 100%;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.btn-icon {
  font-size: 1rem;
  opacity: 0.8;
}

.sidebar-help-text {
  font-size: 0.75rem;
  color: #888;
  margin: 0;
  line-height: 1.3;
}

.legend-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--railroad-blue);
  margin: 0 0 0.75rem 0;
}

.legend-content {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

@media (max-width: 768px) {
  #side-panel {
    width: 240px;
    max-width: 60%;
    font-size: 0.9rem;
  }
}

.info-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--railroad-blue);
  margin-bottom: 0.5rem;
}

.info-icon {
  height: 1.25rem;
  width: 1.25rem;
}

.info-header h2 {
  font-size: 1.125rem;
  font-weight: 500;
  margin: 0;
}

.rate-subheading {
  font-size: 0.75rem;
  color: var(--gray-800);
  opacity: 0.8;
  margin: 0.25rem 0 0 0;
  font-style: italic;
}

.status-message {
  padding: 0.75rem;
  background-color: var(--blue-50);
  border: 1px solid #DBEAFE;
  border-radius: var(--border-radius-md);
  color: var(--railroad-blue);
  margin-bottom: 0.75rem;
}

.route-info {
  padding: 0.75rem;
  background-color: var(--green-50);
  border: 1px solid #D1FAE5;
  border-radius: var(--border-radius-md);
  margin-bottom: 0.75rem;
}

.route-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.route-label {
  font-weight: 500;
  color: var(--green-800);
}

.route-value {
  color: var(--green-800);
  font-weight: 600;
}

.legend {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--gray-600);
}

.legend-item {
  display: flex;
  align-items: center;
}

.legend-line {
  display: inline-block;
  width: 1rem;
  height: 0.25rem;
  border-radius: var(--border-radius-sm);
  margin-right: 0.25rem;
}

.railroad-line {
  background-color: var(--railroad-gray);
}

.route-line {
  background-color: var(--railroad-amber);
}

.legend-text {
  font-size: 0.75rem;
}

@media (min-width: 768px) {
  .hamburger-menu {
    top: 1.5rem;
    left: 1.5rem;
  }
}

/* Route Calculator Styles */
.route-section {
  margin-bottom: 30px;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

.route-section h4 {
  margin: 0 0 15px 0;
  color: #2c3e50;
  font-size: 16px;
  font-weight: 600;
}

.route-section h5 {
  margin: 15px 0 10px 0;
  color: #34495e;
  font-size: 14px;
  font-weight: 500;
}

.business-selector, .multimodal-selector {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.business-input-group, .address-input-group, .coords-input-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.coords-input-group {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr;
  gap: 10px;
  align-items: center;
}

.business-select, .address-input, .coord-input {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  background: white;
}

.business-select {
  min-height: 38px;
}

.address-input {
  width: 100%;
}

.coord-input {
  width: 120px;
}

.route-options {
  margin: 10px 0;
}

.route-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #555;
  cursor: pointer;
}

.route-options input[type="checkbox"] {
  margin: 0;
}

.quick-test-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.quick-test-btn {
  background: #3498db;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: background-color 0.2s;
}

.quick-test-btn:hover {
  background: #2980b9;
}

/* Buttons */
.btn {
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius-md);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  border: none;
  font-family: inherit;
  font-size: 0.875rem;
}

.primary-btn {
  background-color: var(--railroad-blue);
  color: var(--white);
}

.primary-btn:hover {
  background-color: var(--blue-700);
}

.primary-btn:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(15, 76, 129, 0.5);
}

.secondary-btn {
  background-color: var(--gray-100);
  color: var(--gray-800);
}

.secondary-btn:hover {
  background-color: var(--gray-200);
}

.secondary-btn:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(229, 231, 235, 0.5);
}

/* Footer */
.footer {
  background-color: var(--gray-800);
  color: var(--white);
  padding: 0.5rem;
  text-align: center;
  font-size: 0.75rem;
}

.footer p {
  margin: 0;
}

/* Address Search Section */
.address-search-section {
  margin-bottom: 12px;
}

.search-input-container {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.address-search-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}

.address-search-input:focus {
  outline: none;
  border-color: #0F4C81;
  box-shadow: 0 0 0 2px rgba(15, 76, 129, 0.1);
}

.search-address-btn {
  padding: 8px 12px;
  background: #0F4C81;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

.search-address-btn:hover {
  background: #0a3c6b;
}

.clear-address-btn {
  padding: 8px 12px;
  background: #dc2626;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

.clear-address-btn:hover {
  background: #b91c1c;
}

.search-status {
  font-size: 12px;
  color: #6b7280;
  min-height: 16px;
}

.search-status.success {
  color: #22c55e;
}

.search-status.error {
  color: #ef4444;
}

.find-multimodal-btn {
  background: #8b5cf6;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.find-multimodal-btn:hover {
  background: #7c3aed;
}

.find-multimodal-btn:disabled {
  background: #d1d5db;
  cursor: not-allowed;
}

.business-to-transload-btn {
  background: #059669;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.business-to-transload-btn:hover {
  background: #047857;
}

.business-to-transload-btn:disabled {
  background: #d1d5db;
  cursor: not-allowed;
}


.closest-transload-container {
  margin-bottom: 8px;
}

.find-closest-transload-btn {
  background: #f59e0b;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  width: 100%;
}

.find-closest-transload-btn:hover {
  background: #d97706;
}

.find-closest-transload-btn:disabled {
  background: #d1d5db;
  cursor: not-allowed;
}

/* Utility Classes */
.hidden {
  display: none;
}

.marker-start, .marker-end {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.25);
}

.marker-start {
  background-color: var(--railroad-blue);
}

.marker-end {
  background-color: var(--railroad-amber);
}

/* Old legends - now integrated into side panel */
/* .legend {
  position: absolute;
  left: 1rem;
  background: rgba(255,255,255,0.9);
  padding: 0.5rem;
  border-radius: 4px;
  font-size: 0.9rem;
  z-index: 2;
} */
.legend-item {
  display: flex;
  align-items: center;
  margin-right: 0.5rem;
  font-size: 0.85rem;
  white-space: nowrap;
}
.legend-color {
  width: 12px;
  height: 12px;
  margin-right: 6px;
  border: 1px solid #333;
}

.legend-circle {
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border: 1px solid #fff;
  border-radius: 50%;
  display: inline-block;
}

.facility-type {
  font-size: 0.8rem;
  color: #666;
  font-style: italic;
}
#per-rail div {
  font-size: 0.9rem;
}

/* Shipping cost styles */
.cost-line {
  font-size: 0.85rem;
  color: var(--gray-800);
  opacity: 0.8;
  margin-top: 0.5rem;
  padding-left: 0.25rem;
}

.cost-total {
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
  color: var(--railroad-blue);
  padding-left: 0.25rem;
}

#per-rail hr {
  margin: 1rem 0 0.75rem 0;
  border: none;
  border-top: 1px solid var(--gray-200);
}

/* Modal styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  border-radius: 8px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid #eee;
}

.modal-header h3 {
  margin: 0;
  color: #333;
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #666;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-btn:hover {
  color: #333;
}

.modal-body {
  padding: 20px;
}

.api-section {
  margin-bottom: 30px;
}

.api-section h4 {
  margin: 0 0 15px 0;
  color: #2563eb;
  font-size: 16px;
}

.api-section textarea {
  width: 100%;
  height: 80px;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-family: monospace;
  font-size: 12px;
  resize: vertical;
  margin-bottom: 10px;
  box-sizing: border-box;
}

.api-section input {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  margin-bottom: 10px;
  box-sizing: border-box;
}

.btn-group {
  display: flex;
  gap: 10px;
}

/* Progress Bar Styles */
.progress-container {
  display: none;
  margin: 1rem 0;
  padding: 1rem;
  background: var(--white);
  border-radius: var(--border-radius-md);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}

.progress-container.active {
  display: block;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.progress-title {
  font-weight: 600;
  color: var(--railroad-blue);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.progress-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--gray-200);
  border-top: 2px solid var(--railroad-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.progress-percentage {
  font-weight: 600;
  color: var(--railroad-blue);
  font-size: 0.875rem;
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background-color: var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--railroad-blue), var(--railroad-amber));
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-steps {
  display: flex;
  gap: 0.75rem;
  font-size: 0.75rem;
  color: var(--gray-800);
  flex-wrap: wrap;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--border-radius-sm);
  background: var(--gray-100);
}

.progress-step.completed {
  background: var(--green-50);
  color: var(--green-800);
}

.progress-step.active {
  background: var(--blue-50);
  color: var(--blue-700);
}

.progress-step-icon {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gray-300);
}

.progress-step.completed .progress-step-icon {
  background: var(--green-800);
}

.progress-step.active .progress-step-icon {
  background: var(--blue-700);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.api-results {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 4px;
  padding: 15px;
  margin-top: 20px;
  font-family: monospace;
  font-size: 12px;
  white-space: pre-wrap;
  max-height: 300px;
  overflow-y: auto;
}

.api-results:empty {
  display: none;
}

/* URL Section Styling */
.url-section input[type="text"] {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 10px;
  font-family: 'Courier New', monospace;
}

.url-section p {
  margin-bottom: 10px;
  color: #666;
}

.url-section .btn {
  width: 100%;
}

/* Result Status Styling */
.success {
  background: #d4edda;
  color: #155724;
  padding: 15px;
  border-radius: 6px;
  border: 1px solid #c3e6cb;
}

.error {
  background: #f8d7da;
  color: #721c24;
  padding: 15px;
  border-radius: 6px;
  border: 1px solid #f5c6cb;
}

.loading {
  background: #d1ecf1;
  color: #0c5460;
  padding: 15px;
  border-radius: 6px;
  border: 1px solid #bee5eb;
  text-align: center;
}

/* Debug Display Styling */
.debug-display {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 12px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: #495057;
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
  margin-top: 10px;
}

.debug-display:empty {
  display: none;
}

.debug-display .debug-step {
  margin-bottom: 8px;
  padding: 4px 8px;
  border-left: 3px solid #007bff;
  background: #e7f3ff;
}

.debug-display .debug-error {
  border-left-color: #dc3545;
  background: #f8d7da;
  color: #721c24;
}

.debug-display .debug-success {
  border-left-color: #28a745;
  background: #d4edda;
  color: #155724;
}

/* Business ID Input Panel Styling */
.sidebar-section-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #333;
}

.business-id-inputs {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.input-group label {
  font-size: 12px;
  color: #666;
  font-weight: 500;
}

.input-group input[type="number"] {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  width: 100%;
  box-sizing: border-box;
}

.input-group input[type="number"]:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.sidebar-btn {
  width: 100%;
  margin-top: 8px;
}

/* Atlas API Interface Styling */
.atlas-api-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.atlas-test-inputs {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

.atlas-test-inputs input[type="text"] {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  width: 100%;
  box-sizing: border-box;
  font-family: 'Courier New', monospace;
}

.atlas-test-inputs input[type="text"]:focus {
  outline: none;
  border-color: #17a2b8;
  box-shadow: 0 0 0 2px rgba(23, 162, 184, 0.25);
}

.atlas-status {
  max-height: 200px;
  overflow-y: auto;
  padding: 8px;
  background: #f8f9fa;
  border-radius: 6px;
  border: 1px solid #e9ecef;
  font-size: 12px;
  margin-top: 8px;
}

.atlas-status-item {
  padding: 4px 8px;
  margin-bottom: 4px;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.4;
}

.atlas-status-item.processing {
  background: #fff3cd;
  color: #856404;
  border-left: 3px solid #ffc107;
}

.atlas-status-item.success {
  background: #d4edda;
  color: #155724;
  border-left: 3px solid #28a745;
}

.atlas-status-item.error {
  background: #f8d7da;
  color: #721c24;
  border-left: 3px solid #dc3545;
}

.atlas-status-item.info {
  background: #d1ecf1;
  color: #0c5460;
  border-left: 3px solid #17a2b8;
}

.atlas-status-item.warning {
  background: #fff3cd;
  color: #856404;
  border-left: 3px solid #ffc107;
}

/* Atlas Demo Modal Styling */
.atlas-demo-modal {
  max-width: 800px;
  max-height: 90vh;
}

.demo-section {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #eee;
}

.demo-section:last-child {
  border-bottom: none;
}

.demo-section h3 {
  margin: 0 0 12px 0;
  color: #333;
  font-size: 16px;
}

.endpoints-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.endpoint-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

.endpoint-method {
  background: #17a2b8;
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  min-width: 50px;
  text-align: center;
}

.endpoint-url {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: #495057;
  flex: 1;
}

.endpoint-description {
  font-size: 13px;
  color: #6c757d;
  flex: 1;
}

.workflow-steps {
  margin: 0;
  padding-left: 20px;
}

.workflow-steps li {
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.5;
}

.sample-urls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sample-url {
  padding: 8px 12px;
  background: #e9ecef;
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.sample-url:hover {
  background: #dee2e6;
}

.network-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

.network-status.ready {
  background: #d4edda;
  border-color: #c3e6cb;
}

.network-status.loading {
  background: #fff3cd;
  border-color: #ffeaa7;
}

.status-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.network-status.ready .status-indicator {
  background: #28a745;
}

.network-status.loading .status-indicator {
  background: #ffc107;
  animation: pulse 1.5s infinite;
}

.status-text {
  font-size: 14px;
  font-weight: 500;
}

.network-status.ready .status-text {
  color: #155724;
}

.network-status.loading .status-text {
  color: #856404;
}

.demo-actions {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

/* Atlas Results Modal Styling */
.atlas-results-modal {
  max-width: 900px;
  max-height: 90vh;
}

.results-section {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #eee;
}

.results-section:last-child {
  border-bottom: none;
}

.results-section h3 {
  margin: 0 0 12px 0;
  color: #333;
  font-size: 16px;
}

.route-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.summary-item {
  padding: 8px 12px;
  background: #f8f9fa;
  border-radius: 6px;
  font-size: 14px;
}

.summary-item strong {
  color: #495057;
}

.railroad-breakdown {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.railroad-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  padding: 8px 12px;
  background: #f8f9fa;
  border-radius: 6px;
  align-items: center;
}

.railroad-name {
  font-weight: 600;
  color: #495057;
}

.railroad-miles {
  font-size: 13px;
  color: #6c757d;
}

.railroad-cost {
  font-weight: 600;
  color: #28a745;
}

.export-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Button variants for Atlas interface */
.info-btn {
  background: #17a2b8;
  color: white;
  border: 1px solid #17a2b8;
}

.info-btn:hover {
  background: #138496;
  border-color: #138496;
}

/* Business Selection Panel */
.business-selection-panel {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.selection-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  min-height: 32px;
  padding: 4px 0;
}

.selection-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #495057;
}

.selected-businesses {
  min-height: 60px;
  margin-bottom: 12px;
}

.no-selection {
  color: #6c757d;
  font-style: italic;
  font-size: 13px;
  text-align: center;
  padding: 20px;
}

.business-item {
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.business-info {
  flex: 1;
}

.business-name {
  font-weight: 600;
  font-size: 13px;
  color: #212529;
  margin-bottom: 4px;
}

.business-location {
  font-size: 11px;
  color: #6c757d;
}

.business-number {
  background: #007bff;
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

/* Routing Mode Toggle */
.routing-mode-section {
  margin: 12px 0;
  padding: 10px;
  background: #f0f4f8;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}

.routing-mode-toggle {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.routing-mode-toggle .mode-option {
  display: flex;
  align-items: flex-start;
  padding: 8px 10px;
  background: white;
  border: 2px solid #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.routing-mode-toggle .mode-option:hover {
  border-color: #94a3b8;
}

.routing-mode-toggle .mode-option:has(input:checked) {
  border-color: var(--railroad-blue);
  background: #eff6ff;
}

.routing-mode-toggle input[type="radio"] {
  margin-right: 10px;
  margin-top: 3px;
  accent-color: var(--railroad-blue);
}

.routing-mode-toggle .mode-label {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.routing-mode-toggle .mode-label strong {
  font-size: 13px;
  color: #1e293b;
}

.routing-mode-toggle .mode-label small {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}

.route-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.find-route-btn {
  background: #28a745;
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  flex: 1;
  white-space: nowrap;
}

.find-route-btn:hover:not(:disabled) {
  background: #218838;
}

.find-route-btn:disabled {
  background: #6c757d;
  cursor: not-allowed;
  opacity: 0.6;
}

.clear-route-btn {
  background: #dc3545;
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.clear-route-btn:hover {
  background: #c82333;
}

/* Enhanced Rail Line Analysis Styles */
.rail-distance-breakdown,
.interchange-details {
  margin-top: 1rem;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius-md);
  padding: 0.75rem;
}

.analysis-placeholder {
  color: var(--gray-500);
  font-style: italic;
  text-align: center;
  padding: 1rem;
  font-size: 0.875rem;
}

.rail-analysis-item {
  border-bottom: 1px solid var(--gray-200);
  padding: 0.75rem 0;
  transition: background-color 0.2s;
}

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

.rail-analysis-item:hover {
  background-color: var(--gray-50);
}

.rail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}

.rail-name {
  font-weight: 600;
  color: var(--gray-800);
  margin-left: 0.5rem;
  flex: 1;
}

.rail-percentage {
  font-size: 0.75rem;
  color: var(--gray-600);
  background: var(--gray-100);
  padding: 0.25rem 0.5rem;
  border-radius: var(--border-radius-sm);
  font-weight: 600;
}

.rail-details {
  margin-left: 1.25rem;
}

.rail-distance {
  font-size: 0.875rem;
  color: var(--gray-600);
}

.rail-analysis-total {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 2px solid var(--railroad-blue);
}

.total-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.total-label {
  font-weight: 600;
  color: var(--gray-800);
}

.total-distance {
  font-weight: 700;
  color: var(--railroad-blue);
  font-size: 1.125rem;
}

/* Interchange Details Styles */
.interchange-summary {
  margin-bottom: 1rem;
}

.interchange-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.interchange-icon {
  font-size: 1.25rem;
}

.interchange-count {
  font-weight: 600;
  color: var(--gray-800);
  font-size: 1.125rem;
}

.interchange-sequence {
  margin: 1rem 0;
  padding: 0.75rem;
  background: var(--gray-50);
  border-radius: var(--border-radius-md);
}

.sequence-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 0.5rem;
}

.sequence-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.railroad-segment {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: var(--border-radius-sm);
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.interchange-arrow {
  color: var(--gray-600);
  font-weight: 600;
  font-size: 0.875rem;
}

.interchange-costs {
  margin-top: 1rem;
  padding: 0.75rem;
  background: var(--blue-50);
  border-radius: var(--border-radius-md);
  border: 1px solid var(--blue-200);
}

.cost-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 0.25rem;
}

.cost-amount {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--railroad-blue);
  margin-bottom: 0.25rem;
}

.cost-note {
  font-size: 0.75rem;
  color: var(--gray-600);
}

.single-railroad {
  text-align: center;
  padding: 1rem;
  background: var(--green-50);
  border-radius: var(--border-radius-md);
  border: 1px solid var(--green-200);
}

.single-rail-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--green-800);
}

.single-rail-icon {
  color: var(--green-600);
  font-size: 1.125rem;
}


/* Test Page Styles */
.test-container {
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.test-header {
  text-align: center;
  margin-bottom: 2rem;
}

.test-header h2 {
  color: var(--railroad-blue);
  margin-bottom: 0.5rem;
}

.test-content {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 2rem;
}

.test-panel, .json-viewer-panel, .api-info-panel {
  background: white;
  border-radius: var(--border-radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
}

.test-panel h3, .json-viewer-panel h3, .api-info-panel h3 {
  color: var(--railroad-blue);
  margin-bottom: 1rem;
  font-size: 1.125rem;
}

.test-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.test-btn {
  padding: 0.75rem 1rem;
  background: var(--railroad-blue);
  color: white;
  border: none;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
}

.test-btn:hover:not(:disabled) {
  background: #0d3d66;
  transform: translateY(-1px);
}

.test-btn:disabled {
  background: var(--gray-300);
  cursor: not-allowed;
}

.test-status {
  padding: 0.75rem;
  background: var(--gray-100);
  border-radius: var(--border-radius-md);
  font-size: 0.875rem;
  color: var(--gray-800);
}

.json-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.control-btn {
  padding: 0.5rem 0.75rem;
  background: var(--gray-200);
  color: var(--gray-800);
  border: none;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.2s ease;
}

.control-btn:hover {
  background: var(--gray-300);
}

.json-display {
  background: #f8f9fa;
  border: 1px solid var(--gray-300);
  border-radius: var(--border-radius-md);
  padding: 1rem;
  font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
  font-size: 0.75rem;
  line-height: 1.4;
  white-space: pre-wrap;
  max-height: 500px;
  overflow-y: auto;
  color: #333;
}

.endpoint-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.endpoint-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.endpoint-item code {
  background: var(--gray-100);
  padding: 0.5rem;
  border-radius: var(--border-radius-sm);
  font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
  font-size: 0.75rem;
  color: var(--railroad-blue);
  font-weight: 600;
}

.endpoint-item span {
  font-size: 0.875rem;
  color: var(--gray-800);
}

/* Mobile responsive adjustments for test page */
@media screen and (max-width: 768px) {
  .test-content {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .test-container {
    padding: 1rem;
  }
}


/* Test Map Styles */
.test-map-container {
  height: 300px;
  border: 1px solid var(--gray-300);
  border-radius: var(--border-radius-md);
  margin-bottom: 1rem;
  background: #f8f9fa;
}

.test-map {
  width: 100%;
  height: 100%;
  border-radius: var(--border-radius-md);
}

.json-display {
  min-height: 200px;
}

/* Manual Testing Styles */
.manual-test-section {
  margin-bottom: 1rem;
}

.url-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.url-input-group label {
  font-weight: 500;
  color: var(--railroad-blue);
  font-size: 0.875rem;
}

.url-input {
  padding: 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--border-radius-md);
  font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
  font-size: 0.875rem;
  width: 100%;
  box-sizing: border-box;
}

.url-input:focus {
  outline: none;
  border-color: var(--railroad-blue);
  box-shadow: 0 0 0 3px rgba(15, 76, 129, 0.1);
}

.quick-tests {
  margin-top: 1rem;
}

.quick-tests h4 {
  margin: 0 0 0.5rem 0;
  font-size: 0.875rem;
  color: var(--gray-800);
  font-weight: 500;
}

.quick-test-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.quick-test-btn {
  padding: 0.5rem 0.75rem;
  background: var(--gray-100);
  color: var(--gray-800);
  border: 1px solid var(--gray-300);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  font-size: 0.75rem;
  font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
  text-align: left;
  transition: all 0.2s ease;
}

.quick-test-btn:hover {
  background: var(--gray-200);
  border-color: var(--railroad-blue);
}

.quick-test-btn:active {
  transform: translateY(1px);
}

#manual-test-status {
  font-size: 0.875rem;
}

#manual-test-status.success {
  background: var(--green-50);
  color: var(--green-800);
  border: 1px solid var(--green-200);
}

#manual-test-status.error {
  background: #FEF2F2;
  color: #B91C1C;
  border: 1px solid #FECACA;
}

#manual-test-status.loading {
  background: var(--blue-50);
  color: var(--railroad-blue);
  border: 1px solid #DBEAFE;
}

/* ============ Login Overlay Styles ============ */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, var(--railroad-blue) 0%, #1a365d 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.login-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.login-container {
  background: white;
  padding: 2.5rem;
  border-radius: var(--border-radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 400px;
  margin: 1rem;
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-header h2 {
  color: var(--railroad-blue);
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 0.5rem 0;
}

.login-header p {
  color: var(--railroad-gray);
  font-size: 0.9rem;
  margin: 0;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.login-input {
  padding: 0.875rem 1rem;
  font-size: 1rem;
  border: 2px solid var(--gray-200);
  border-radius: var(--border-radius-md);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}

.login-input:focus {
  border-color: var(--railroad-blue);
  box-shadow: 0 0 0 3px rgba(15, 76, 129, 0.1);
}

.login-input::placeholder {
  color: var(--gray-300);
}

.login-btn {
  padding: 0.875rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: white;
  background: var(--railroad-blue);
  border: none;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.login-btn:hover {
  background: #0d3f6b;
}

.login-btn:active {
  transform: translateY(1px);
}

.login-btn:disabled {
  background: var(--gray-300);
  cursor: not-allowed;
}

.login-error {
  color: #dc2626;
  font-size: 0.875rem;
  text-align: center;
  min-height: 1.25rem;
}
