/* Sales Territory Optimizer - Tool-Specific Styles */

/* Badge variants */
.badge--secondary {
  background: #64748b;
}

/* Mode Toggle */
.mode-toggle {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.mode-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 1rem 1.5rem;
  border: 2px solid var(--app-border);
  border-radius: 8px;
  background: var(--app-card-bg);
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 1;
  min-width: 120px;
}

.mode-button:hover {
  border-color: var(--app-accent);
  background: #f0f7ff;
}

.mode-button.active {
  border-color: var(--app-accent);
  background: #e0f0ff;
}

.mode-icon {
  font-size: 1.5rem;
}

.mode-label {
  font-weight: 600;
  font-size: 0.9rem;
}

.mode-description {
  margin-top: 1rem;
  color: var(--app-muted);
  font-style: italic;
}

/* Upload Grid */
.upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.upload-box {
  padding: 1rem;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  background: #fafbfc;
}

.upload-box h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

/* Dropzone */
.dropzone {
  border: 2px dashed var(--app-border);
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--app-card-bg);
}

.dropzone:hover,
.dropzone.dropzone--dragover {
  border-color: var(--app-accent);
  background: #f0f7ff;
}

.dropzone-title {
  font-weight: 600;
  margin: 0 0 0.5rem 0;
}

.dropzone-note {
  color: var(--app-muted);
  font-size: 0.85rem;
  margin: 0 0 1rem 0;
}

.template-buttons {
  margin-top: 0.75rem;
  display: flex;
  gap: 0.5rem;
}

.upload-status {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--app-muted);
}

.upload-status.success {
  color: var(--app-success);
}

.upload-status.error {
  color: var(--app-danger);
}

/* Config Grid */
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.config-item label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.config-item select,
.config-item input[type="number"] {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--app-border);
  border-radius: 6px;
  font-size: 1rem;
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.radio-group label {
  font-weight: normal;
  cursor: pointer;
}

/* Weight Sliders */
.weight-sliders {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--app-border);
}

.weight-sliders h4 {
  margin: 0 0 1rem 0;
  color: var(--app-muted);
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.slider-row label {
  width: 140px;
  font-size: 0.9rem;
}

.slider-row input[type="range"] {
  flex: 1;
  accent-color: var(--app-accent);
}

.slider-row span {
  width: 40px;
  text-align: right;
  font-weight: 600;
  color: var(--app-accent);
}

.weight-intro {
  font-size: 0.85rem;
  color: var(--app-muted);
  margin: -0.5rem 0 1rem 0;
  line-height: 1.4;
}

/* Tooltip Icons */
.tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  font-size: 12px;
  color: var(--app-accent);
  cursor: help;
  position: relative;
  vertical-align: middle;
  margin-left: 4px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.tooltip-icon:hover {
  opacity: 1;
}

.tooltip-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--app-bg);
  color: var(--app-fg);
  border: 1px solid var(--app-border);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.4;
  width: 280px;
  max-width: 90vw;
  white-space: normal;
  text-align: left;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 1000;
  pointer-events: none;
}

.tooltip-icon::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--app-border);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 1001;
}

.tooltip-icon:hover::after,
.tooltip-icon:hover::before {
  opacity: 1;
  visibility: visible;
}

/* Tooltip positioning adjustments for edge cases */
.slider-row .tooltip-icon::after,
.config-item .tooltip-icon::after {
  left: auto;
  right: -10px;
  transform: none;
}

.slider-row .tooltip-icon::before,
.config-item .tooltip-icon::before {
  left: auto;
  right: 10px;
  transform: none;
}

/* Tooltip adjustments for table headers */
.rep-table th .tooltip-icon::after,
.accounts-table th .tooltip-icon::after {
  left: auto;
  right: 0;
  transform: none;
  min-width: 260px;
}

.rep-table th .tooltip-icon::before,
.accounts-table th .tooltip-icon::before {
  left: auto;
  right: 5px;
  transform: none;
}

/* Tooltip adjustments for scorecard items */
.score-label .tooltip-icon::after {
  width: 320px;
  left: 0;
  transform: none;
}

.score-label .tooltip-icon::before {
  left: 12px;
  transform: none;
}

/* Tooltip in section headers */
h2 .tooltip-icon,
h4 .tooltip-icon {
  font-size: 14px;
  width: 18px;
  height: 18px;
}

/* Action Buttons */
.action-buttons {
  margin-top: 1.5rem;
  display: flex;
  gap: 0.5rem;
}

.action-buttons .primary {
  flex: 1;
}

/* Map Styling */
.map-card {
  position: relative;
}

.map-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  padding: 0.5rem;
  background: #f8f9fb;
  border-radius: 6px;
}

.map-controls label {
  font-size: 0.85rem;
  color: var(--app-muted);
}

.map-controls select {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--app-border);
  border-radius: 4px;
  font-size: 0.85rem;
  background: white;
}

.territory-map {
  height: 500px;
  width: 100%;
  border-radius: 8px;
  z-index: 1;
}

.map-legend {
  margin-top: 1rem;
  padding: 0.75rem;
  background: #f8f9fb;
  border-radius: 6px;
}

/* Manual Mode Styling */
.manual-steps {
  margin-bottom: 1rem;
  padding: 1rem;
  background: #f0f7ff;
  border-radius: 8px;
  border-left: 4px solid var(--app-accent);
}

.manual-steps p {
  margin: 0.5rem 0;
  font-size: 0.9rem;
}

.manual-steps p:first-child {
  margin-top: 0;
}

.manual-steps p:last-child {
  margin-bottom: 0;
}

.manual-scenario-loader {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.manual-scenario-loader label {
  font-size: 0.9rem;
}

.manual-scenario-loader select {
  padding: 0.5rem;
  border: 1px solid var(--app-border);
  border-radius: 6px;
  font-size: 0.9rem;
  min-width: 200px;
}

.legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

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

.legend-color {
  width: 16px;
  height: 16px;
  border-radius: 4px;
}

/* Scorecard */
.scorecard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.score-item {
  padding: 1rem;
  background: #f8f9fb;
  border-radius: 8px;
}

.score-label {
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.score-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}

.score-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--app-accent), var(--app-success));
  border-radius: 4px;
  transition: width 0.5s ease;
}

.score-value {
  margin-top: 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--app-accent);
}

.overall-score {
  margin-top: 1.5rem;
  padding: 1rem;
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: white;
}

.overall-label {
  font-weight: 600;
  font-size: 1.1rem;
}

.overall-value {
  font-size: 2rem;
  font-weight: 700;
}

/* Territory Breakdown */
.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.territory-card {
  padding: 1rem;
  border: 2px solid;
  border-radius: 8px;
  background: var(--app-card-bg);
}

.territory-card h4 {
  margin: 0 0 0.75rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.territory-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.territory-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.territory-stat {
  display: flex;
  flex-direction: column;
}

.territory-stat .stat-label {
  color: var(--app-muted);
  font-size: 0.75rem;
}

.territory-stat .stat-value {
  font-weight: 600;
}

/* Comparison Section */
.comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.comparison-col h3 {
  margin-top: 0;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--app-border);
}

/* Export Buttons */
.export-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Objectives Grid */
.objectives-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.objective-item {
  padding: 1rem;
  background: #f8f9fb;
  border-radius: 8px;
  border-left: 4px solid var(--app-accent);
}

.objective-item strong {
  display: block;
  margin-bottom: 0.5rem;
  color: #1e40af;
}

.objective-item p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--app-muted);
}

/* Manual Drawing Controls */
.manual-controls {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0;
}

/* Hidden utility */
.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
  .mode-toggle {
    flex-direction: column;
  }
  
  .mode-button {
    flex-direction: row;
    justify-content: flex-start;
    padding: 0.75rem 1rem;
  }
  
  .comparison-grid {
    grid-template-columns: 1fr;
  }
  
  .territory-map {
    height: 350px;
  }
  
  .slider-row {
    flex-wrap: wrap;
  }
  
  .slider-row label {
    width: 100%;
    margin-bottom: 0.25rem;
  }
}

/* Small button variant */
button.small {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

/* Panel intro text */
.panel-intro {
  margin: 0 0 1rem 0;
  color: var(--app-muted);
  font-size: 0.9rem;
}

/* Scenario description */
.scenario-description {
  margin-top: 1rem;
  padding: 1rem;
  background: #f8f9fb;
  border-radius: 8px;
  border-left: 4px solid var(--app-accent);
}

.scenario-description:empty {
  display: none;
}

.scenario-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.scenario-controls__input {
  display: flex;
  gap: 0.5rem;
  flex: 1;
}

.scenario-controls__input select {
  flex: 1;
  min-width: 200px;
  padding: 0.5rem;
  border: 1px solid var(--app-border);
  border-radius: 6px;
  font-size: 1rem;
}

/* Additional notes (details) styling */
details.additional-notes {
  background: #f0f7ff;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
}

details.additional-notes summary {
  cursor: pointer;
  font-weight: 600;
  color: #1e40af;
}

details.additional-notes[open] summary {
  margin-bottom: 0.75rem;
}

details.additional-notes ul {
  margin: 0;
  padding-left: 1.25rem;
}

details.additional-notes li {
  margin-bottom: 0.5rem;
}

/* Algorithm Advanced Details */
.algorithm-advanced {
  margin-top: 1rem;
  background: #fafbfc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
}

.algorithm-advanced summary {
  font-weight: 600;
  color: #7c3aed;
  cursor: pointer;
  font-size: 0.9rem;
}

.algorithm-advanced[open] summary {
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e2e8f0;
}

.algorithm-detail {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.algorithm-detail:last-child {
  margin-bottom: 0;
}

.algorithm-detail h4 {
  margin: 0 0 0.5rem 0;
  color: #1e40af;
  font-size: 1rem;
  border-bottom: 2px solid #3b82f6;
  padding-bottom: 0.25rem;
}

.algo-overview {
  font-style: italic;
  color: #64748b;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.algo-math {
  font-size: 0.85rem;
  line-height: 1.6;
}

.algo-math p {
  margin: 0.5rem 0;
}

.algo-math ul,
.algo-math ol {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.algo-math li {
  margin-bottom: 0.25rem;
}

.formula {
  display: block;
  background: #f1f5f9;
  border-left: 3px solid #3b82f6;
  padding: 0.5rem 0.75rem;
  margin: 0.5rem 0;
  font-family: 'Cambria Math', 'Times New Roman', serif;
  font-size: 1rem;
  color: #1e293b;
  overflow-x: auto;
}

.algo-math strong {
  color: #1e40af;
}

.algo-math em {
  color: #7c3aed;
  font-style: normal;
  font-family: 'Cambria Math', 'Times New Roman', serif;
}

/* Worked examples in scoring explanations */
.formula-example {
  display: block;
  background: #ecfdf5;
  border-left: 3px solid #10b981;
  padding: 0.5rem 0.75rem;
  margin: 0.5rem 0;
  font-size: 0.85rem;
  color: #065f46;
  line-height: 1.5;
}

.formula-example strong {
  color: #047857;
}

/* Explanatory notes */
.formula-note {
  display: block;
  font-size: 0.8rem;
  color: #6b7280;
  font-style: italic;
  margin: 0.25rem 0 0.5rem 0;
  padding-left: 0.5rem;
}

/* Leaflet overrides */
.leaflet-control-zoom {
  border: none !important;
}

.leaflet-control-zoom a {
  background: var(--app-card-bg) !important;
  color: var(--app-text) !important;
}

.leaflet-draw-toolbar a {
  background: var(--app-card-bg) !important;
}

/* Draw toolbar button labels */
.leaflet-draw-toolbar a {
  position: relative;
  width: auto !important;
  padding-left: 30px !important;
  padding-right: 10px !important;
  font-size: 12px !important;
  line-height: 26px !important;
}

.leaflet-draw-toolbar a.leaflet-draw-draw-polygon::after {
  content: 'Draw Polygon';
}

.leaflet-draw-toolbar a.leaflet-draw-draw-rectangle::after {
  content: 'Draw Rectangle';
}

/* Constraints Panel Styles */
.scenario-constraints {
  margin-top: 1rem;
}

.constraints-panel {
  background: #f8fafc;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  overflow: hidden;
}

.constraints-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  cursor: pointer;
  background: #f1f5f9;
  font-weight: 600;
}

.constraints-panel summary:hover {
  background: #e2e8f0;
}

.constraints-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.constraints-summary {
  font-size: 0.85rem;
  font-weight: normal;
  color: var(--app-muted);
}

.constraints-content {
  padding: 1rem;
}

.constraints-lock-row {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--app-border);
}

.lock-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
}

.lock-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--app-accent);
}

.constraints-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.5rem;
}

.constraint-section {
  background: white;
  border: 1px solid var(--app-border);
  border-radius: 6px;
  padding: 0.75rem;
}

.constraint-section--wide {
  grid-column: 1 / -1;
}

.constraint-section h4 {
  margin: 0 0 0.75rem 0;
  font-size: 0.85rem;
  color: var(--app-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.constraint-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.constraint-row:last-child {
  margin-bottom: 0;
}

.constraint-row label {
  color: #475569;
}

.constraint-row input[type="number"] {
  width: 70px;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--app-border);
  border-radius: 4px;
  text-align: right;
  font-size: 0.9rem;
}

.constraint-row input[type="number"]:disabled {
  background: #f1f5f9;
  color: #64748b;
  cursor: not-allowed;
}

.constraint-row input[type="number"]:not(:disabled) {
  background: #fef3c7;
  border-color: #f59e0b;
}

.constraint-value {
  font-weight: 600;
  color: var(--app-accent);
}

/* Rep Table */
.rep-table-wrapper {
  overflow-x: auto;
}

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

.rep-table th,
.rep-table td {
  padding: 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--app-border);
}

.rep-table th {
  background: #f1f5f9;
  font-weight: 600;
  color: #475569;
  white-space: nowrap;
}

.rep-table td {
  white-space: nowrap;
}

.rep-table tbody tr:hover {
  background: #f8fafc;
}

/* Rep color indicator */
.rep-color-indicator {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
  border: 1px solid rgba(0,0,0,0.2);
}

.rep-color-emoji {
  margin-right: 4px;
}

/* Rep editable inputs */
.rep-editable {
  width: 70px;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--app-border);
  border-radius: 4px;
  text-align: right;
  font-size: 0.85rem;
}

.rep-editable:disabled {
  background: transparent;
  border-color: transparent;
  cursor: default;
}

/* Specialty badge styling */
.specialty-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  background: #e0f2fe;
  color: #0369a1;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
}

.rep-editable:not(:disabled) {
  background: #fef3c7;
  border-color: #f59e0b;
}

/* Accounts Table */
.accounts-count {
  font-weight: normal;
  font-size: 0.75rem;
  color: #6b7280;
}

.accounts-table-wrapper {
  overflow-x: auto;
  max-height: 300px;
  overflow-y: auto;
}

.accounts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.accounts-table th,
.accounts-table td {
  padding: 0.4rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--app-border);
}

.accounts-table th {
  background: #f1f5f9;
  font-weight: 600;
  color: #475569;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.accounts-table td {
  white-space: nowrap;
}

.accounts-table tbody tr:hover {
  background: #f0f7ff;
}

.accounts-table-toggle {
  margin-top: 0.5rem;
  text-align: center;
}

/* Constraints Actions */
.constraints-actions {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--app-border);
  display: flex;
  gap: 0.5rem;
}

.constraints-actions button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Footer Styling */
.app-footer {
  margin-top: 3rem;
  padding: 2rem 0;
  background: #f8fafc;
  border-top: 1px solid var(--app-border);
}

.footer-inner {
  max-width: var(--app-max-width, 960px);
  margin: 0 auto;
  padding: 0 1rem;
  text-align: center;
}

.footer-meta {
  font-size: 0.85rem;
  color: #6b7280;
  margin-bottom: 1rem;
}

.meta-separator {
  margin: 0 0.5rem;
}

.footer-citation {
  background: white;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem auto;
  max-width: 600px;
}

.citation-label {
  font-weight: 600;
  color: #1e40af;
  font-size: 0.9rem;
  display: block;
  margin-bottom: 0.5rem;
}

.citation-text {
  font-size: 0.9rem;
  color: #374151;
  margin: 0;
  line-height: 1.5;
}

.footer-copyright {
  margin-top: 1rem;
  font-size: 0.85rem;
  color: #9ca3af;
}

/* Comparison Section Styles */
.comparison-intro {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: #f0f7ff;
  border-radius: 8px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.comparison-intro .warning-text {
  color: #dc2626;
  font-weight: 500;
}

.comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 600px) {
  .comparison-grid {
    grid-template-columns: 1fr;
  }
}

.comparison-col {
  background: #fafbfc;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: 1rem;
}

.comparison-col h3 {
  margin: 0 0 0.25rem 0;
  font-size: 1rem;
}

.comparison-col--algo {
  background: #f0fdf4;
  border-color: #86efac;
}

.comparison-subtitle {
  margin: 0 0 1rem 0;
  font-size: 0.8rem;
  color: #6b7280;
}

.score-row {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid #e5e7eb;
  font-size: 0.9rem;
}

.score-row:last-child {
  border-bottom: none;
}

.score-row--total {
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  border-top: 2px solid var(--app-border);
  font-weight: 600;
}

.score-name {
  color: #4b5563;
}

.score-val {
  font-weight: 600;
  color: var(--app-accent);
}

.score-val--big {
  font-size: 1.2rem;
}

.comparison-verdict {
  margin-top: 1.5rem;
}

.verdict {
  padding: 1rem;
  border-radius: 8px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.verdict--win {
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #166534;
}

.verdict--tie {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  color: #92400e;
}

.verdict--lose {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

/* ============================================================================
   CONSTRAINT VIOLATIONS STYLING
   ============================================================================ */

.scorecard-violations-container {
  margin-bottom: 1.5rem;
}

.violations-banner {
  padding: 1rem 1.25rem;
  border-radius: 8px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-left: 4px solid #ef4444;
}

.violations-banner h4 {
  margin: 0 0 0.5rem 0;
  color: #991b1b;
  font-size: 1rem;
}

.violations-banner p {
  margin: 0.5rem 0;
  color: #991b1b;
  font-size: 0.9rem;
}

.violations-banner ul {
  margin: 0.75rem 0;
  padding-left: 1.5rem;
}

.violations-banner li {
  margin: 0.25rem 0;
  color: #7f1d1d;
  font-size: 0.9rem;
}

.violations-note {
  font-style: italic;
  color: #9a3412 !important;
  font-size: 0.85rem !important;
  margin-top: 0.75rem !important;
}

.violations-banner.violations-success {
  background: #dcfce7;
  border: 1px solid #86efac;
  border-left: 4px solid #22c55e;
}

.violations-banner.violations-success h4 {
  color: #166534;
}

.violations-banner.violations-success p {
  color: #166534;
}

/* Territory card violation styling */
.territory-card.has-violations {
  background: linear-gradient(135deg, #fef2f2 0%, #ffffff 50%);
  border-width: 2px;
}

.territory-card .violation-badge {
  margin-left: 0.5rem;
}

.territory-violations {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
}

.territory-violations strong {
  color: #991b1b;
}

.territory-violations ul {
  margin: 0.5rem 0 0 0;
  padding-left: 1.25rem;
}

.territory-violations li {
  margin: 0.25rem 0;
  color: #7f1d1d;
}

.territory-violations .violation-error {
  color: #991b1b;
  font-weight: 500;
}

.territory-violations .violation-warning {
  color: #92400e;
}

.stat-warning {
  color: #dc2626;
  font-weight: 600;
}

/* Breakdown stat styling when showing limits */
.territory-stat .stat-value {
  font-size: 0.85rem;
}

/* Comparison section violations */
.comparison-violations {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-left: 4px solid #ef4444;
  border-radius: 6px;
  color: #991b1b;
  font-size: 0.9rem;
}

.score-row--violations .score-val--warning {
  color: #dc2626;
  font-weight: 600;
}

.score-row--success .score-val--success {
  color: #16a34a;
  font-weight: 500;
}

/* ============================================================================
   ALGORITHM COMPARISON SECTION
   ============================================================================ */

.comparison-algorithms-section {
  margin-top: 2rem;
}

.algo-comparison-table-wrapper {
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

.algo-comparison-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.algo-comparison-table th,
.algo-comparison-table td {
  padding: 0.75rem 1rem;
  text-align: center;
  border-bottom: 1px solid var(--app-border);
}

.algo-comparison-table th {
  background: #f8fafc;
  font-weight: 600;
}

.algo-comparison-table th:first-child,
.algo-comparison-table td:first-child {
  text-align: left;
  font-weight: 500;
}

.algo-comparison-table .overall-row {
  background: #f0f9ff;
  font-weight: 600;
}

.algo-comparison-table .overall-row td {
  font-size: 1.1rem;
  padding: 1rem;
}

.algo-comparison-table .violations-row td {
  font-size: 0.85rem;
  color: #6b7280;
}

/* Algorithm selection buttons */
.algo-select-btn {
  background: transparent;
  border: 2px solid transparent;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--app-text);
}

.algo-select-btn:hover {
  background: #e0f0ff;
  border-color: var(--app-accent);
}

.algo-select-btn.active {
  background: var(--app-accent);
  color: white;
  border-color: var(--app-accent);
}

/* Best score highlighting */
.algo-comparison-table .best-score {
  background: #ecfdf5;
  color: #059669;
  font-weight: 600;
  position: relative;
}

.algo-comparison-table .best-score::after {
  content: '✓';
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
}

.algo-comparison-table .worst-score {
  color: #9ca3af;
}

/* Insights panel */
.algo-comparison-insights {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

.algo-comparison-insights h4 {
  margin: 0 0 0.5rem 0;
  font-size: 0.95rem;
  color: #92400e;
}

.algo-comparison-insights ul {
  margin: 0;
  padding-left: 1.25rem;
}

.algo-comparison-insights li {
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
  color: #78350f;
}

.algo-comparison-insights .insight-winner {
  font-weight: 600;
  color: #047857;
}

.algo-comparison-insights .insight-tradeoff {
  font-style: italic;
  color: #6b7280;
}

/* ============================================================================
   HEATMAP OVERLAY CONTROLS
   ============================================================================ */

.heatmap-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: 1rem;
  padding-left: 1rem;
  border-left: 1px solid var(--app-border);
}

.heatmap-controls label {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
}

.heatmap-buttons {
  display: flex;
  gap: 0.25rem;
}

.heatmap-btn {
  padding: 0.35rem 0.6rem;
  font-size: 0.75rem;
  border: 1px solid var(--app-border);
  border-radius: 4px;
  background: var(--app-card-bg);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.heatmap-btn:hover {
  background: #e0f0ff;
  border-color: var(--app-accent);
}

.heatmap-btn.active {
  background: var(--app-accent);
  color: white;
  border-color: var(--app-accent);
}

.heatmap-btn[data-overlay="none"].active {
  background: #6b7280;
  border-color: #6b7280;
}

/* Heatmap Legend */
.heatmap-legend {
  margin-top: 0.75rem;
  padding: 0.5rem 1rem;
  background: #f8fafc;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.heatmap-legend.hidden {
  display: none;
}

.heatmap-legend-bar {
  height: 12px;
  width: 150px;
  border-radius: 6px;
  background: linear-gradient(to right, #22c55e, #eab308, #ef4444);
}

.heatmap-legend-bar.potential {
  background: linear-gradient(to right, #86efac, #22c55e, #15803d);
}

.heatmap-legend-bar.probability {
  background: linear-gradient(to right, #fde68a, #f59e0b, #b45309);
}

.heatmap-legend-bar.distance {
  background: linear-gradient(to right, #22c55e, #eab308, #ef4444);
}

.heatmap-legend-labels {
  display: flex;
  justify-content: space-between;
  width: 150px;
  font-size: 0.75rem;
  color: #6b7280;
}

/* Map controls layout adjustment */
.map-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

/* ============================================================================
   REASSIGNMENT NOTIFICATION ANIMATION
   ============================================================================ */

@keyframes slideIn {
  from {
    transform: translateX(100px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.reassignment-popup hr {
  margin: 8px 0;
  border: none;
  border-top: 1px solid #e5e7eb;
}

.reassign-btn:hover {
  background: #1d4ed8 !important;
}

/* ============================================================================
   SENSITIVITY ANALYSIS SECTION
   ============================================================================ */

.sensitivity-section h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sensitivity-intro {
  color: #6b7280;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.sensitivity-controls {
  display: flex;
  align-items: flex-end;
  gap: 2rem;
  padding: 1rem;
  background: #f8fafc;
  border-radius: 8px;
  margin-bottom: 1.5rem;
}

.sensitivity-slider-group {
  flex: 1;
}

.sensitivity-slider-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.slider-with-value {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.slider-with-value input[type="range"] {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: #d1d5db;
  appearance: none;
  cursor: pointer;
}

.slider-with-value input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--app-accent);
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.slider-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--app-accent);
  min-width: 40px;
  text-align: center;
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: #9ca3af;
  margin-top: 0.25rem;
}

.sensitivity-results {
  margin-bottom: 1.5rem;
}

.sensitivity-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.sensitivity-col {
  padding: 1rem;
  border-radius: 8px;
  background: #f8fafc;
}

.sensitivity-col h4 {
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e5e7eb;
}

.sensitivity-col--new {
  background: #ecfdf5;
  border: 2px solid #10b981;
}

.sensitivity-scores {
  display: grid;
  gap: 0.5rem;
}

.sensitivity-score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem;
  background: white;
  border-radius: 4px;
}

.sensitivity-score-label {
  color: #6b7280;
  font-size: 0.9rem;
}

.sensitivity-score-value {
  font-weight: 600;
  font-size: 1rem;
}

.score-up {
  color: #10b981;
}

.score-down {
  color: #ef4444;
}

.score-neutral {
  color: #6b7280;
}

.sensitivity-delta {
  margin-top: 1rem;
  padding: 1rem;
  background: #fef3c7;
  border-radius: 8px;
  font-size: 0.9rem;
}

.sensitivity-chart-container {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e5e7eb;
}

.sensitivity-chart-container h4 {
  margin-bottom: 1rem;
}

.chart-note {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: #6b7280;
  font-style: italic;
}

