/* AMIGO UI extensions: responsive sidebar and regional controls. */
#amigo_sidebar_toggle {
  display: none;
  margin: 10px 0 12px 0;
}

@media (max-width: 767px) {
  #amigo_sidebar_toggle {
    display: inline-block;
  }

  body.amigo-sidebar-collapsed #amigo_layout > .row > div:first-child {
    display: none;
  }

  body.amigo-sidebar-collapsed #amigo_layout > .row > div:last-child {
    width: 100%;
  }
}


.amigo-sidebar-actions-bottom .btn,
.amigo-sidebar-actions-bottom .btn-wsjg-sm {
  width: 100%;
}

.amigo-affinity-controls {
  display: block;
}

@media (min-width: 992px) {
  .amigo-affinity-controls {
    display: flex;
    gap: 24px;
    align-items: flex-start;
  }

  .amigo-affinity-control {
    flex: 1 1 0;
    min-width: 0;
  }
}

/* Conservative insight panels for profile size, robustness and two-municipality comparison. */
.amigo-insight-alert {
  margin-bottom: 10px;
  padding: 9px 12px;
}

.amigo-compare-panel {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 12px 14px;
  margin: 0 0 12px 0;
}

.amigo-compare-panel h4 {
  margin-top: 0;
  margin-bottom: 10px;
}

.amigo-compare-summary {
  margin: 8px 0 10px 0;
  font-size: 13px;
}

.amigo-compare-table {
  margin-bottom: 0;
}

.amigo-muted-note {
  color: #6b7280;
  font-size: 13px;
  margin-top: 6px;
}


.amigo-sim-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

.amigo-sim-label {
  min-width: 0;
}

.amigo-sim-symbol {
  margin-left: auto;
  text-align: right;
  white-space: nowrap;
  letter-spacing: -1px;
  font-weight: 700;
  opacity: 0.95;
}


/* Numeric support for the profile robustness panel. */
.amigo-robustness-alert {
  overflow: hidden;
}

.amigo-robustness-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
  margin-top: 8px;
  margin-bottom: 6px;
}

.amigo-robustness-metric {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 4px;
  padding: 4px 6px;
  min-width: 0;
}

.amigo-robustness-label {
  color: #374151;
  min-width: 0;
}

.amigo-robustness-value {
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

@media (max-width: 767px) {
  .amigo-robustness-metrics {
    grid-template-columns: 1fr;
  }
}

/* Low-risk usability additions: copy action, badges, selected table marker and method notes. */
.amigo-benchmark-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.amigo-copy-benchmark {
  white-space: nowrap;
}

.amigo-copy-benchmark.amigo-copy-ok,
.amigo-copy-ok {
  opacity: 0.85;
}

.amigo-profile-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
  margin: 0 0 10px 0;
}

.amigo-profile-badge-row-tight {
  margin-bottom: 8px;
}

.amigo-profile-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #eef2ff;
  color: #1f2937;
}

.amigo-profile-badge-small {
  background: #fff7ed;
}

.amigo-profile-badge-large {
  background: #e0f2fe;
}

.amigo-profile-badge-normal {
  background: #ecfdf5;
}

.amigo-profile-badge-alt {
  background: #f3f4f6;
}

.amigo-profile-badge-detail {
  color: #4b5563;
  font-size: 13px;
  line-height: 1.35;
}

.amigo-selected-municipality-cell {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.amigo-selected-municipality-badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 700;
  background: #fef3c7;
  color: #78350f;
  border: 1px solid rgba(120, 53, 15, 0.18);
}

.amigo-method-note {
  margin: 8px 0 14px 0;
  padding: 7px 10px;
  border-left: 3px solid #cbd5e1;
  background: #f8fafc;
  color: #4b5563;
  font-size: 12px;
  line-height: 1.35;
}

@media (max-width: 767px) {
  .amigo-benchmark-actions {
    align-items: stretch;
  }

  .amigo-benchmark-actions .btn,
  .amigo-benchmark-actions .btn-wsjg,
  .amigo-benchmark-actions .btn-wsjg-sm {
    width: 100%;
  }
}

/* v17: compact benchmark copy icon, manual comparison similarity and wijk links. */
.amigo-copy-benchmark-icon {
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 6px 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.amigo-copy-benchmark-icon i {
  margin: 0;
}

.amigo-compare-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.amigo-compare-summary-text {
  min-width: 220px;
  flex: 1 1 auto;
}

.amigo-manual-similarity {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 4px 8px;
  min-width: 180px;
  max-width: 260px;
  vertical-align: middle;
}

.amigo-manual-similarity .amigo-sim-cell {
  min-width: 118px;
}

.amigo-manual-similarity-score {
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}

.amigo-wijk-benchmark-link {
  white-space: nowrap;
  font-weight: 700;
}

@media (max-width: 767px) {
  .amigo-copy-benchmark-icon {
    width: 100%;
    min-width: 100%;
  }

  .amigo-manual-similarity {
    width: 100%;
    max-width: none;
    justify-content: space-between;
  }
}


/* v22: profile intelligence / profile narrative tab. */
.amigo-profile-intelligence-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(240px, 0.8fr) minmax(240px, 0.8fr);
  gap: 12px;
  margin: 8px 0 16px 0;
}

.amigo-profile-intelligence-card {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #ffffff;
  padding: 12px 14px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.amigo-profile-intelligence-card-wide {
  min-width: 0;
}

.amigo-profile-intelligence-card h4 {
  margin-top: 0;
  margin-bottom: 8px;
}

.amigo-profile-intelligence-card p {
  margin-bottom: 7px;
  line-height: 1.38;
}

.amigo-profile-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 82px;
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 800;
  margin-bottom: 8px;
}

.amigo-profile-score-good {
  background: #dcfce7;
  color: #14532d;
  border: 1px solid #86efac;
}

.amigo-profile-score-medium {
  background: #fef3c7;
  color: #78350f;
  border: 1px solid #fde68a;
}

.amigo-profile-score-low {
  background: #fee2e2;
  color: #7f1d1d;
  border: 1px solid #fecaca;
}

.amigo-profile-card-note,
.amigo-profile-section-note {
  color: #4b5563;
  font-size: 13px;
  line-height: 1.35;
}

.amigo-profile-table {
  font-size: 13px;
}

.amigo-profile-table th {
  white-space: nowrap;
}

@media (max-width: 991px) {
  .amigo-profile-intelligence-grid {
    grid-template-columns: 1fr;
  }
}


/* v23: richer, data-driven profile intelligence presentation. */
.amigo-profile-hero {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 16px;
  padding: 18px 20px;
  margin: 8px 0 16px 0;
  border-radius: 16px;
  background: linear-gradient(135deg, #f8fbff 0%, #eef6ff 100%);
  border: 1px solid #dbeafe;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.07);
}

.amigo-profile-hero-main {
  min-width: 0;
  flex: 1 1 auto;
}

.amigo-profile-kicker {
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-weight: 800;
  color: #0369a1;
  margin-bottom: 4px;
}

.amigo-profile-hero h3 {
  margin: 0 0 8px 0;
  font-size: 22px;
  line-height: 1.25;
}

.amigo-profile-lead {
  color: #334155;
  max-width: 920px;
  line-height: 1.45;
  margin-bottom: 12px;
}

.amigo-profile-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.amigo-profile-chip {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 6px 9px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #fff;
  font-size: 12px;
  white-space: nowrap;
}

.amigo-profile-chip-label {
  color: #64748b;
  font-weight: 600;
}

.amigo-profile-chip-value {
  color: #0f172a;
  font-weight: 800;
}

.amigo-profile-chip-primary {
  border-color: #93c5fd;
  background: #eff6ff;
}

.amigo-profile-chip-alt {
  border-color: #fbbf24;
  background: #fffbeb;
}

.amigo-profile-chip-position {
  border-color: #c4b5fd;
  background: #f5f3ff;
}

.amigo-profile-hero-score {
  width: 180px;
  flex: 0 0 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .74);
  border: 1px solid rgba(148, 163, 184, .28);
  border-radius: 14px;
  padding: 10px;
}

.amigo-profile-score-large {
  min-width: 96px;
  font-size: 18px;
}

.amigo-profile-score-title {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 800;
  color: #334155;
  text-align: center;
}

.amigo-profile-score-bar {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  margin-top: 9px;
  background: #e5e7eb;
  overflow: hidden;
}

.amigo-profile-score-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: #0369a1;
}

.amigo-profile-intelligence-grid-v23 {
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, .85fr) minmax(260px, .85fr);
}

.amigo-profile-nature-title {
  display: inline-block;
  margin-bottom: 10px;
  padding: 5px 8px;
  border-radius: 8px;
  background: #f1f5f9;
  font-weight: 800;
  color: #334155;
}

.amigo-profile-metric-tile {
  border: 1px solid #e2e8f0;
  background: #ffffff;
  border-radius: 10px;
  padding: 9px 10px;
  margin-bottom: 8px;
}

.amigo-profile-metric-label {
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.amigo-profile-metric-value {
  color: #0f172a;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.25;
  margin-top: 2px;
}

.amigo-profile-metric-note {
  color: #64748b;
  font-size: 12px;
  line-height: 1.3;
  margin-top: 2px;
}

.amigo-profile-signal {
  margin-top: 12px;
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
}

.amigo-profile-signal > span {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 900;
  color: #475569;
  margin-bottom: 4px;
}

.amigo-profile-signal p {
  margin: 0;
  color: #334155;
}

.amigo-profile-signal-positive {
  background: #ecfdf5;
  border-color: #bbf7d0;
}

.amigo-profile-signal-neutral {
  background: #fffbeb;
  border-color: #fde68a;
}

.amigo-profile-signal-warning {
  background: #fff1f2;
  border-color: #fecdd3;
}

.amigo-profile-mini-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: -4px 0 16px 0;
}

.amigo-profile-metric-wide {
  grid-column: span 2;
}

.amigo-profile-section-card {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #ffffff;
  padding: 12px 14px;
  margin: 12px 0;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .04);
}

.amigo-profile-section-card h4 {
  margin-top: 0;
}

@media (max-width: 1199px) {
  .amigo-profile-intelligence-grid-v23 {
    grid-template-columns: 1fr;
  }
  .amigo-profile-mini-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .amigo-profile-metric-wide {
    grid-column: span 1;
  }
}

@media (max-width: 767px) {
  .amigo-profile-hero {
    flex-direction: column;
  }
  .amigo-profile-hero-score {
    width: 100%;
    flex-basis: auto;
  }
  .amigo-profile-mini-metrics {
    grid-template-columns: 1fr;
  }
}


/* v24: tooltip affordance for profile-distance terminology. */
.amigo-profile-metric-label[id],
.amigo-robustness-label[id] {
  cursor: help;
  text-decoration: underline dotted rgba(51, 65, 85, 0.55);
  text-underline-offset: 3px;
}

/* v30: keep regional-affinity controls compact and aligned on wide viewports. */
@media (min-width: 992px) {
  .amigo-affinity-control-checkbox {
    flex: 0 0 230px;
    padding-top: 26px;
  }

  .amigo-affinity-control-checkbox .form-group,
  .amigo-affinity-control-checkbox .checkbox {
    margin-bottom: 0;
  }
}

.amigo-profile-contrast-note {
  margin: 8px 0 10px 0;
  padding: 8px 10px;
  border-left: 3px solid #cbd5e1;
  background: #f8fafc;
  border-radius: 4px;
  color: #334155;
}

.amigo-profile-benchmark-options {
  margin: 8px 0 14px 0;
  padding: 8px 12px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 10px;
  background: rgba(248, 250, 252, 0.78);
}
.amigo-profile-benchmark-options .checkbox {
  margin-top: 0;
  margin-bottom: 0;
}
.amigo-profile-closest-note {
  border-left-color: rgba(37, 99, 235, 0.45);
}

/* v32: place the optional closest-peer benchmark control inside the narrative card. */
.amigo-profile-benchmark-options-in-card {
  margin-top: 12px;
  margin-bottom: 2px;
  background: rgba(255, 255, 255, 0.74);
}

.amigo-wijk-benchmark-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  text-decoration: none !important;
  font-size: 12px;
}

/* v37: lightweight comparable-municipality filters and diagnostics */
.amigo-table-filter-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  padding: 10px 12px;
  margin: 10px 0 12px 0;
  border: 1px solid rgba(15, 23, 42, 0.10);
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.86);
}
.amigo-table-filter-panel .checkbox {
  margin-top: 0;
  margin-bottom: 0;
}
.amigo-filter-panel-title {
  font-weight: 600;
  color: #334155;
  margin-right: 4px;
}
.amigo-profile-detail-warning {
  margin: 6px 0 10px 0;
  padding: 7px 9px;
  border-left: 3px solid #d97706;
  background: #fff7ed;
  color: #7c2d12;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.35;
}
.amigo-profile-detail-warning-info {
  border-left-color: #2563eb;
  background: #eff6ff;
  color: #1e3a8a;
}
.amigo-debug-footer {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.06);
  color: #334155;
  font-size: 11px;
  font-family: Menlo, Consolas, monospace;
}
