/* ── Reset & base ─────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: #1a1a1a;
  background: #f5f6f8;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: #6a6f78; }
.error { color: #b00020; padding: 8px 0; }

/* ── Login ───────────────────────────────────────────────── */
.login-body {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: linear-gradient(180deg,#1f3a55 0%,#0d1c2c 100%);
}
.login-card {
  background: white; padding: 36px 32px; border-radius: 12px; width: 360px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.login-card input {
  border: 1px solid #d3d6dc; padding: 9px 11px; border-radius: 6px;
}
.login-card button {
  background: #0a4d8c; color: white; border: 0; padding: 10px; border-radius: 6px;
  font-weight: 600;
}
.login-card button:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  background: white;
  border-bottom: 1px solid #e3e5ea;
  position: sticky; top: 0; z-index: 10;
}
.topbar > .brand { flex: 0 0 auto; }
.topbar > .tabs { flex: 0 0 auto; }
.topbar > .searchbar { flex: 1 1 auto; min-width: 0; }
.topbar > .user { flex: 0 0 auto; }
body[data-active-tab="analyze"] .topbar > .searchbar { display: none; }
body[data-active-tab="analyze"] .topbar > .user { margin-left: auto; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand .dot {
  width: 10px; height: 10px; border-radius: 50%; background: #0a4d8c;
}
.brand strong { font-size: 15px; }
.health { font-size: 12px; }

.searchbar { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; }
.searchbar input {
  border: 1px solid #d3d6dc; padding: 8px 12px; border-radius: 6px; min-width: 280px;
}
.searchbar select {
  border: 1px solid #d3d6dc; padding: 8px 8px; border-radius: 6px; background: white;
}
.searchbar button {
  background: #0a4d8c; color: white; border: 0; padding: 8px 14px; border-radius: 6px;
  font-weight: 600;
}
.searchbar button:disabled { opacity: 0.6; }

.user { display: flex; align-items: center; gap: 10px; }
.user button {
  background: white; border: 1px solid #d3d6dc; padding: 6px 10px; border-radius: 6px;
}

/* ── Tabs ────────────────────────────────────────────────── */
.tabs { display: flex; align-items: center; gap: 2px; }
.tabs .tab {
  text-decoration: none;
  color: #4b5360;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.1s;
}
.tabs .tab:hover { background: #f3f5f8; }
.tabs .tab.active {
  background: #eaf2fb;
  color: #0a4d8c;
  font-weight: 600;
}
.tab-section { display: block; }
.tab-section[hidden] { display: none; }

/* ── Layout ──────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 0;
  height: calc(100vh - 56px);
}
.left {
  background: white;
  border-right: 1px solid #e3e5ea;
  display: flex; flex-direction: column;
}
.right {
  background: #f5f6f8;
  overflow: auto;
  padding: 16px 18px;
}

/* ── Results ─────────────────────────────────────────────── */
#results-meta { padding: 14px 16px; font-size: 13px; }
.results { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; }
.result {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid #eef0f3;
  cursor: pointer;
}
.result:hover { background: #f8fafc; }
.result.active { background: #eaf2fb; }
.result input[type=checkbox] { margin-top: 4px; }
.result .org { font-weight: 600; color: #0a4d8c; }
.result .vsn {
  display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 999px;
  background: #eaecef; color: #444; margin-left: 6px;
}
.result .vsn.vc-validado { background: #def0d8; color: #2d602b; }
.result .vsn.vc-diagnostico { background: #fff4cf; color: #6a4f00; }
.result .vsn.vc-pre_projeto { background: #ffe1cf; color: #6a3500; }
.result .focal { font-size: 12px; color: #444; margin-top: 3px; }
.result .meta { font-size: 11px; color: #777; margin-top: 3px; }

.compare-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-top: 1px solid #eef0f3;
}
.compare-bar button {
  background: #0a4d8c; color: white; border: 0; padding: 6px 10px; border-radius: 6px;
}
.compare-bar button:disabled { background: #c4cad3; }

/* ── Chart pane & stats ─────────────────────────────────── */
.chart-pane {
  background: white; border-radius: 8px; padding: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  min-height: 200px;
  position: relative;
}
.chart-pane .empty { padding: 80px 20px; text-align: center; }
.chart-pane svg { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.chart-pane.loading { opacity: 0.6; }

.stats-card {
  background: white; border-radius: 8px; padding: 14px 16px; margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.stats-card h3 { margin: 0 0 8px; font-size: 14px; color: #0a4d8c; }
.stats-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 10px; }
.stats-grid .stat { background: #f7f9fb; padding: 8px 10px; border-radius: 6px; }
.stats-grid .stat label { font-size: 11px; color: #666; display: block; }
.stats-grid .stat strong { font-size: 18px; color: #1a3a5b; }
.stats-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.stats-table th { text-align: left; background: #f3f5f8; padding: 6px 8px; }
.stats-table td { padding: 6px 8px; border-bottom: 1px solid #eef0f3; }
.stats-table tr.clickable:hover { background: #f9fbfd; cursor: pointer; }

/* ── Analyze tab: upload form + my analyses + suggestions ─ */
.upload-form {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid #eef0f3;
}
.upload-form h3 {
  margin: 0 0 4px;
  font-size: 14px;
  color: #0a4d8c;
}
.upload-form label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: #4b5360;
}
.upload-form input[type=file],
.upload-form input[type=text],
.upload-form select {
  border: 1px solid #d3d6dc;
  padding: 7px 9px;
  border-radius: 6px;
  background: white;
  font-size: 13px;
}
.upload-form input[type=file] { padding: 6px 6px; }
.upload-form button[type=submit] {
  background: #0a4d8c;
  color: white;
  border: 0;
  padding: 9px 12px;
  border-radius: 6px;
  font-weight: 600;
  margin-top: 4px;
}
.upload-form button[type=submit]:disabled { opacity: 0.6; cursor: not-allowed; }
.upload-status { font-size: 12px; min-height: 16px; }
.upload-status.success { color: #2d602b; }
.upload-status.error { color: #b00020; }
.upload-status.muted { color: #6a6f78; }

.my-analyses-header {
  padding: 10px 16px 4px;
  border-bottom: 1px solid #eef0f3;
}
.my-analyses-header h3 {
  margin: 0; font-size: 13px; color: #4b5360; text-transform: uppercase; letter-spacing: 0.04em;
}
.result-empty {
  padding: 14px 16px;
  font-size: 13px;
  list-style: none;
}
.result .del-btn {
  background: transparent;
  border: 0;
  color: #999;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  align-self: start;
}
.result:hover .del-btn { color: #b00020; }
.result .del-btn:hover { color: #b00020; }

.suggestions-card {
  background: white;
  border-radius: 8px;
  padding: 14px 16px;
  margin-top: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  border-left: 3px solid #f0c050;
}
.suggestions-card > h3 {
  margin: 0 0 6px;
  font-size: 14px;
  color: #6a4f00;
}
.suggestions-status {
  font-size: 12px;
  min-height: 14px;
  margin-bottom: 4px;
}
.suggestions-status.error { color: #b00020; }
.suggestions-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.suggestion-section {
  border-top: 1px solid #eef0f3;
  padding: 8px 0 6px;
}
.suggestion-section:first-child { border-top: 0; }
.suggestion-section > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #1a3a5b;
  padding: 4px 0;
  user-select: none;
}
.suggestion-section > summary::-webkit-details-marker { display: none; }
.suggestion-section > summary::before {
  content: "▸";
  display: inline-block;
  width: 10px;
  font-size: 10px;
  color: #6a6f78;
  transition: transform 0.1s ease;
}
.suggestion-section[open] > summary::before { transform: rotate(90deg); }
.suggestion-section > summary:hover .sec-title { text-decoration: underline; }
.suggestion-section .sec-title { flex: 1; }
.count-badge {
  display: inline-block;
  min-width: 20px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #eaecef;
  color: #444;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}
.suggestion-section[data-section="lowSpan"] .count-badge,
.suggestion-section[data-section="singleChains"] .count-badge { background: #fff4cf; color: #6a4f00; }
.suggestion-section[data-section="highSpan"] .count-badge { background: #ffe1cf; color: #6a3500; }
.sec-help { font-size: 11px; margin: 4px 0 6px; }
.threshold-input {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #4b5360;
  padding: 6px 0 8px;
}
.threshold-input input {
  width: 50px;
  border: 1px solid #d3d6dc;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 12px;
}
.suggestion-list {
  list-style: none;
  margin: 4px 0 2px;
  padding: 0;
  max-height: 240px;
  overflow-y: auto;
}
.suggest-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 8px;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
  border-left: 2px solid transparent;
}
.suggest-item:hover { background: #f3f5f8; border-left-color: #c4cad3; }
.suggest-item.active { background: #fff8db; border-left-color: #f0c050; }
.suggest-item .si-name { font-weight: 600; color: #1a3a5b; }
.suggest-item .si-cargo { font-size: 11px; }
.suggest-item .si-arrow { font-size: 11px; }
.suggest-item .si-meta {
  margin-left: auto;
  font-size: 10px;
  color: #6a6f78;
  white-space: nowrap;
}
.suggest-item .si-actions-btn {
  margin-left: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: #6a6f78;
  font-size: 14px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
}
.suggest-item:hover .si-actions-btn { color: #1a3a5b; border-color: #c4cad3; }
.suggest-item .si-actions-btn:hover { background: #eaf2fb; color: #0d4a82; border-color: #9bc1ea; }
.suggest-item .undo-link {
  margin-left: 8px;
  font-size: 11px;
  color: #0d4a82;
  text-decoration: underline;
  cursor: pointer;
  opacity: 1;
}
.suggest-item .undo-link:hover { color: #062f57; }
.suggest-item.applied { text-decoration: line-through; opacity: 0.55; }
.suggest-item.applied .si-name,
.suggest-item.applied .si-cargo,
.suggest-item.applied .si-meta,
.suggest-item.applied .si-arrow { text-decoration: line-through; }
.suggest-item.applied .undo-link { text-decoration: none; opacity: 1; }
.suggest-item.applied.ghost { font-style: italic; }
.no-issues { padding: 6px 8px; font-size: 12px; }

/* Benchmark rows */
.benchmark-row { padding: 6px 0 4px; }
.benchmark-empty { font-size: 12px; padding: 4px 0; }
.bench-line { font-size: 12px; padding: 2px 0; }
.bench-label { color: #4b5360; }
.bench-value {
  font-size: 14px;
  margin-left: 4px;
}
.bench-cmp { font-size: 11px; }
.bench-cmp strong { font-weight: 600; }
.band-low { color: #2d602b; }     /* below median — usually a positive (lean) signal */
.band-high { color: #b00020; }    /* above p75 — flag */
.band-mid { color: #1a3a5b; }     /* within p25–p75 — neutral */

/* Function table */
.function-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 6px;
}
.function-table th {
  text-align: left;
  background: #f3f5f8;
  padding: 4px 8px;
  font-weight: 600;
  color: #4b5360;
  font-size: 11px;
}
.function-table td {
  padding: 5px 8px;
  border-bottom: 1px solid #eef0f3;
}
.function-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.function-table .small { font-size: 11px; color: #6a6f78; }
.function-table tr.band-high td:nth-child(2) { color: #b00020; font-weight: 700; }
.function-table tr.band-low  td:nth-child(2) { color: #2d602b; font-weight: 600; }
.function-table td:nth-child(2):not(:has(strong)) { color: #b0b5be; }
.function-table td.num:nth-child(3) { color: #4b5360; }
.function-table td.num:nth-child(4) { color: #6a6f78; }

/* ── Chart pane loading spinner (B3) ─────────────────────── */
#chart-pane.loading, #analyze-chart-pane.loading { position: relative; }
#chart-pane.loading::after, #analyze-chart-pane.loading::after {
  content: "Rendering chart…";
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 12px;
  background: rgba(255,255,255,0.7);
  color: #6a6f78; font-size: 13px;
  opacity: 0;
  animation: chart-spinner-fade 0.001s linear 0.2s forwards;
  pointer-events: none;
}
#chart-pane.loading::before, #analyze-chart-pane.loading::before {
  content: "";
  position: absolute; top: 50%; left: 50%;
  width: 32px; height: 32px;
  margin: -16px 0 0 -16px;
  border: 3px solid #e3e5ea;
  border-top-color: #0a4d8c;
  border-radius: 50%;
  opacity: 0;
  animation: chart-spinner-fade 0.001s linear 0.2s forwards, chart-spinner-rotate 0.8s linear 0.2s infinite;
  pointer-events: none;
  z-index: 1;
}
@keyframes chart-spinner-rotate { to { transform: rotate(360deg); } }
@keyframes chart-spinner-fade { to { opacity: 1; } }

/* ── Analyze tab: simulate mode UI ───────────────────────── */
/* HTML `hidden` attribute is equal specificity to a class selector — author
 * `display: flex` rules below would override the user-agent `display: none`.
 * Restore it explicitly so toggling `el.hidden = true/false` works as expected. */
[hidden] { display: none !important; }

.analyze-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.mode-switch {
  display: inline-flex;
  background: #ffffff;
  border: 1px solid #d3d6dc;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.mode-btn {
  background: transparent;
  border: 0;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: #4b5360;
  transition: background 0.1s, color 0.1s;
}
.mode-btn + .mode-btn { border-left: 1px solid #eef0f3; }
.mode-btn:hover { background: #f3f5f8; }
.mode-btn.active {
  background: #0a4d8c;
  color: white;
  font-weight: 600;
}

.scenario-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.scenario-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #4b5360;
}
.scenario-picker select {
  border: 1px solid #d3d6dc;
  padding: 5px 8px;
  border-radius: 6px;
  background: white;
  font-size: 13px;
  min-width: 180px;
}
.scenario-bar button {
  background: white;
  border: 1px solid #d3d6dc;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  color: #1a3a5b;
}
.scenario-bar button:hover { background: #f3f5f8; }
.scenario-bar button:disabled { opacity: 0.5; cursor: not-allowed; }
#scenario-new { background: #0a4d8c; color: white; border-color: #0a4d8c; font-weight: 600; }
#scenario-new:hover { background: #0d5aa3; }
#scenario-delete:hover { background: #fdecee; color: #b00020; border-color: #f0c0c5; }

/* Positioning wrapper around the analyze chart pane — anchors the original
 * toggle so it overlays the chart pane's left edge without being wiped when
 * the pane's innerHTML is replaced on each chart fetch. */
.analyze-chart-wrap { position: relative; }

/* "Hide / show original" toggle, lives over the chart pane (left edge). One
 * element with two visual modes:
 *   - default ("collapse" state): small button at top-left, "← Hide original"
 *   - .is-collapsed: full-height vertical rail on the left edge, "Original ▶"
 * The vertical rail style is what the user asked for when the original panel
 * is hidden — gives an obvious, edge-anchored affordance to bring it back. */
.original-toggle {
  position: absolute;
  left: 8px;
  top: 8px;
  background: white;
  border: 1px solid #d3d6dc;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  color: #3A4F5F;
  cursor: pointer;
  z-index: 10;
  transition: background 0.1s, border-color 0.1s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.original-toggle:hover { background: #f3f5f8; border-color: #7A8FA0; }
.original-toggle .original-toggle-vertical { display: none; }
.original-toggle .original-toggle-horizontal { display: inline; }

.original-toggle.is-collapsed {
  left: 0;
  top: 0;
  bottom: 0;
  height: 100%;
  width: 32px;
  border-radius: 0;
  border: none;
  border-right: 1px solid #7A8FA0;
  background: #FAFBFC;
  padding: 14px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #3A4F5F;
  font-weight: 600;
}
.original-toggle.is-collapsed:hover { background: #eaf2fb; border-right-color: #0a4d8c; color: #0a4d8c; }
.original-toggle.is-collapsed .original-toggle-horizontal { display: none; }
.original-toggle.is-collapsed .original-toggle-vertical {
  display: block;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 12px;
  letter-spacing: 0.05em;
}
.scenario-status { font-size: 11px; }

/* The chart pane in compare mode pulses when waiting for a "pick target" click. */
.chart-pane.sim-picking {
  outline: 2px dashed #5a8f60;
  outline-offset: 2px;
}

.focus-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 12px;
  margin-bottom: 10px;
  background: #fff8db;
  border-left: 3px solid #f0c050;
  border-radius: 4px;
  font-size: 12px;
  color: #6a4f00;
}
.focus-banner-text { flex: 1; }
.focus-banner strong { color: #1a3a5b; }
.focus-banner button {
  background: white;
  border: 1px solid #d3d6dc;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  color: #1a3a5b;
  cursor: pointer;
  font-weight: 600;
}
.focus-banner button:hover { background: #eaf2fb; border-color: #0a4d8c; }

/* Sibling picker modal — opens when user clicks an "Others (N hidden)" box. */
.sim-picker-modal { width: 460px; max-width: 92vw; }
.sim-picker-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 4px;
}
.sim-picker-header h3 { margin: 0; flex: 1; font-size: 15px; color: #1a3a5b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sim-picker-counter {
  font-size: 12px;
  color: #6a4f00;
  background: #fff4cf;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  flex: 0 0 auto;
}
.sim-picker-counter.is-full { background: #ddefdb; color: #2d602b; }
.sim-picker-help { font-size: 12px; margin: 0 0 10px; }
.sim-picker-list {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  max-height: 50vh;
  overflow-y: auto;
  border: 1px solid #eef0f3;
  border-radius: 6px;
}
.sim-picker-list li {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid #eef0f3;
  align-items: center;
  cursor: pointer;
  font-size: 13px;
}
.sim-picker-list li:last-child { border-bottom: 0; }
.sim-picker-list li:hover:not(.is-disabled) { background: #f3f5f8; }
.sim-picker-list li.is-checked { background: #eaf2fb; }
.sim-picker-list li.is-disabled { color: #9aa0aa; cursor: not-allowed; }
.sim-picker-list li.is-disabled .sp-name { color: #9aa0aa; }
.sim-picker-list input[type=checkbox] { margin: 0; cursor: inherit; }
.sim-picker-list .sp-main { min-width: 0; }
.sim-picker-list .sp-name { font-weight: 600; color: #1a3a5b; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sim-picker-list .sp-cargo { font-size: 11px; color: #6a6f78; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sim-picker-list .sp-meta {
  font-size: 11px;
  color: #4b5360;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.sim-picker-list .sp-meta .sp-size {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 6px;
  background: #eaecef;
  color: #444;
  border-radius: 999px;
  font-weight: 600;
}
.sim-picker-apply {
  background: #0a4d8c !important;
  color: white !important;
  border-color: #0a4d8c !important;
  font-weight: 600;
}
.sim-picker-apply:hover { background: #0d5aa3 !important; }
.sim-picker-apply:disabled { opacity: 0.5; cursor: not-allowed; background: #c4cad3 !important; border-color: #c4cad3 !important; }

/* Per-node eye icon injected post-render by decorateSimChartWithEyes(). */
.sim-focus-eye { cursor: pointer; transition: filter 0.1s ease; }
.sim-focus-eye:hover { filter: brightness(0.92) drop-shadow(0 1px 2px rgba(0,0,0,0.15)); }
.sim-focus-eye-active { filter: drop-shadow(0 0 2px rgba(240, 192, 80, 0.7)); }
.sim-focus-eye-active:hover { filter: brightness(0.95) drop-shadow(0 0 3px rgba(240, 192, 80, 0.9)); }

/* Per-node actions ellipsis (top-right, simulated side only) — opens the
 * mutation action menu. Same hover pattern as the eye for visual consistency. */
.sim-actions-btn { cursor: pointer; transition: filter 0.1s ease; }
.sim-actions-btn:hover { filter: brightness(0.94) drop-shadow(0 1px 2px rgba(0,0,0,0.15)); }

/* L-level side rulers (Consult chart). HTML overlay positioned over the
 * chart pane so the rulers stay glued to the white-area edges regardless of
 * how small or large the inner SVG renders. */
.consult-depth-ruler-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}
.consult-depth-ruler-rail {
  position: absolute;
  top: 12px;
  bottom: 12px;
  width: 0;
  border-left: 1px dashed #bdc4cd;
}
.consult-depth-ruler-rail-left  { left:  10px; }
.consult-depth-ruler-rail-right { right: 10px; }
.consult-depth-ruler-label {
  position: absolute;
  transform: translateY(-50%);
  font-size: 11px;
  font-weight: 600;
  color: #3A4F5F;
  background: white;
  padding: 1px 4px;
  border-radius: 3px;
  line-height: 1;
  letter-spacing: 0.04em;
}
.consult-depth-ruler-label-left  { left:  4px; }
.consult-depth-ruler-label-right { right: 4px; }

/* Divider + toggle below the focal results in the Consult tab — reveals the
 * focal-less ("No specific focal") hits if the user wants to browse them. */
.show-more-projects {
  list-style: none;
  padding: 8px 14px 10px;
  border-top: 1px dashed #e3e5ea;
  background: #fafbfc;
}
.show-more-btn {
  background: transparent;
  border: 0;
  color: #4b5360;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.show-more-btn:hover { background: #eef0f3; color: #0a4d8c; }

/* Mutation log */
.mutation-log-card {
  background: white;
  border-radius: 8px;
  padding: 12px 14px 14px;
  margin-top: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  border-left: 3px solid #5a8f60;
}
.mutation-log-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}
.mutation-log-header h3 {
  margin: 0;
  font-size: 14px;
  color: #2d4f30;
  flex: 0 0 auto;
}
.pending-action-hint {
  font-size: 12px;
  color: #2d4f30;
  background: #ddefdb;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}
.link-btn {
  background: transparent;
  border: 0;
  color: #6a6f78;
  font-size: 12px;
  cursor: pointer;
  margin-left: auto;
  padding: 2px 6px;
  border-radius: 4px;
}
.link-btn:hover { background: #f3f5f8; color: #b00020; }

.mutation-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.mutation-list li {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 8px;
  padding: 6px 4px;
  border-bottom: 1px solid #eef0f3;
  font-size: 13px;
  align-items: baseline;
}
.mutation-list li:last-child { border-bottom: 0; }
.mutation-list .mut-seq {
  color: #6a6f78;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}
.mutation-list .mut-desc strong { color: #1a3a5b; }
.mutation-list .mut-error {
  display: block;
  color: #b00020;
  font-size: 11px;
  margin-top: 2px;
}
.mutation-list li.is-error { background: #fdecee; border-radius: 4px; padding-left: 8px; }
.mutation-list .mut-undo {
  background: transparent;
  border: 1px solid #d3d6dc;
  color: #4b5360;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
}
.mutation-list .mut-undo:hover { background: #fdecee; color: #b00020; border-color: #f0c0c5; }
.mutation-empty { font-size: 12px; padding: 8px 4px 2px; }

/* Action menu popover */
.sim-action-menu {
  position: absolute;
  z-index: 50;
  background: white;
  border: 1px solid #d3d6dc;
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.18);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 240px;
  max-width: 320px;
}
.sim-action-menu-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 6px;
  border-bottom: 1px solid #eef0f3;
  margin-bottom: 4px;
}
.sim-action-menu-title {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  color: #1a3a5b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sim-action-menu-close {
  background: transparent;
  border: 0;
  color: #6a6f78;
  font-size: 16px;
  line-height: 1;
  padding: 0 4px;
}
.sim-action-menu-close:hover { color: #b00020; }
.sim-action-btn {
  background: transparent;
  border: 0;
  color: #1a3a5b;
  text-align: left;
  padding: 7px 10px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
}
.sim-action-btn:hover { background: #eaf2fb; }
.sim-action-btn-secondary { color: #4b5360; font-size: 12px; }
.sim-action-btn-secondary:hover { background: #f3f5f8; }
.sim-action-btn.is-recommended { background: #fff8db; font-weight: 600; }
.sim-action-btn.is-recommended:hover { background: #fff0b8; }
.recommended-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 6px;
  background: #f0c050;
  color: #4a3500;
  font-size: 10px;
  font-weight: 600;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  vertical-align: middle;
}

/* Edit modal */
.sim-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 28, 44, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.sim-modal {
  background: white;
  border-radius: 10px;
  padding: 18px 20px;
  width: 360px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.sim-modal h3 { margin: 0 0 12px; font-size: 15px; color: #1a3a5b; }
.sim-modal form { display: flex; flex-direction: column; gap: 12px; }
.sim-modal label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #4b5360; }
.sim-modal input {
  border: 1px solid #d3d6dc;
  padding: 7px 9px;
  border-radius: 6px;
  font-size: 13px;
}
.sim-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}
.sim-modal-actions button {
  border: 1px solid #d3d6dc;
  background: white;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
}
.sim-modal-actions button[type=submit] {
  background: #0a4d8c;
  color: white;
  border-color: #0a4d8c;
  font-weight: 600;
}
.sim-modal-actions button[type=submit]:hover { background: #0d5aa3; }

/* ── Login accessibility focus + tagline (P1, P2) ────────── */
.login-card .tagline {
  color: #6a6f78; font-size: 14px; margin: 4px 0 16px;
}
.login-card input:focus-visible,
.login-card button:focus-visible {
  outline: 3px solid #0a4d8c;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.6);
}

/* ── Span Recommendations (criteria-based) ─────────────────────────── */
.suggestion-section[data-section="spanRec"] .count-badge { background: #e4eefb; color: #0d4a82; }

.span-rec-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 0 8px;
}
.span-rec-filter {
  border: 1px solid #d3d6dc;
  background: white;
  color: #4b5360;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.span-rec-filter .filter-n {
  background: #eef0f3;
  color: #4b5360;
  font-size: 10px;
  font-weight: 600;
  padding: 0 5px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}
.span-rec-filter:hover { background: #f3f5f8; }
.span-rec-filter.active {
  background: #1a3a5b;
  border-color: #1a3a5b;
  color: white;
}
.span-rec-filter.active .filter-n { background: rgba(255,255,255,0.2); color: white; }
.span-rec-filter.chip-sub.active { background: #2d602b; border-color: #2d602b; }
.span-rec-filter.chip-in.active  { background: #1a3a5b; border-color: #1a3a5b; }
.span-rec-filter.chip-sobre.active { background: #b00020; border-color: #b00020; }

/* List items in the spanRec panel */
.span-rec-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
}
.span-rec-item .si-main {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
}
.span-rec-item .si-main .si-meta {
  margin-left: 0;
  white-space: normal;
}
.span-rec-item .si-criteria {
  display: inline-flex;
  gap: 3px;
}
.span-rec-item[data-verdict="sub-dimensionado"] { border-left-color: #2d602b; }
.span-rec-item[data-verdict="sobre-dimensionado"] { border-left-color: #b00020; }

/* Criterion dots — 3-letter monogram, color-tiered. Inversion for coordenacao
   is handled in JS (critTier). */
.crit-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  color: white;
  cursor: help;
  border: 1px solid rgba(0,0,0,0.05);
}
.crit-dot.tier-vh { background: #2d602b; }   /* Muito Alto (good) → green */
.crit-dot.tier-h  { background: #6ea35b; }
.crit-dot.tier-m  { background: #b0a44e; }
.crit-dot.tier-l  { background: #d57a3c; }
.crit-dot.tier-vl { background: #b00020; }   /* Muito Baixo (bad) → red */

/* Inline reference-base button (clickable) */
.ref-meta-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font: inherit;
  font-size: 10px;
  background: transparent;
  border: 1px dashed #c4cad3;
  color: #4b5360;
  padding: 1px 6px;
  border-radius: 4px;
  cursor: pointer;
}
.ref-meta-btn:hover { background: #f3f5f8; border-color: #9bc1ea; color: #0a4d8c; }
.ref-meta-btn.out-of-band-high { color: #b53d10; border-color: #f1be9d; }
.ref-meta-btn.out-of-band-high:hover { background: #fff0e6; }
.ref-meta-btn.out-of-band-low { color: #0d4a82; border-color: #a7c3e6; }
.ref-meta-btn.out-of-band-low:hover { background: #eaf2fb; }
.ref-meta-btn strong { font-weight: 700; }

/* Inspector modal — wider than the edit modal */
.span-rec-inspector-card { width: 560px; max-width: calc(100vw - 40px); }
.span-rec-summary-line {
  font-size: 13px;
  color: #1a3a5b;
  padding: 4px 0 8px;
}
.span-rec-note {
  background: #fff8db;
  border-left: 3px solid #f0c050;
  padding: 6px 10px;
  font-size: 12px;
  color: #6a4f00;
  margin: 4px 0 10px;
  border-radius: 4px;
}
.verdict-sub { color: #2d602b; }
.verdict-in { color: #1a3a5b; }
.verdict-sobre { color: #b00020; }
.span-rec-crit-table, .ref-sources-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 8px;
}
.span-rec-crit-table th, .ref-sources-table th {
  text-align: left;
  background: #f3f5f8;
  padding: 4px 8px;
  font-weight: 600;
  color: #4b5360;
  font-size: 11px;
}
.span-rec-crit-table td, .ref-sources-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #eef0f3;
  vertical-align: top;
}
.ref-sources-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.span-rec-crit-table .crit-row td:first-child {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  color: #1a3a5b;
}
.span-rec-ref-block { margin-top: 14px; }
.span-rec-ref-block h4 {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 600;
  color: #1a3a5b;
}
.span-rec-ref-block .small { font-size: 11px; margin-top: 6px; }

/* Ref sources popover (positioned absolutely by JS) */
.ref-sources-pop {
  position: fixed;
  z-index: 200;
  background: white;
  border: 1px solid #d3d6dc;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(13,28,44,0.18);
  width: 340px;
  max-height: 360px;
  overflow: auto;
  padding: 10px 12px;
  font-size: 12px;
}
.ref-sources-pop-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid #eef0f3;
  margin-bottom: 6px;
}
.ref-sources-pop-title { flex: 1; font-weight: 600; color: #1a3a5b; font-size: 12px; }
.ref-sources-pop-close {
  background: transparent;
  border: 0;
  font-size: 16px;
  line-height: 1;
  color: #6a6f78;
  cursor: pointer;
  padding: 0 4px;
}
.ref-sources-pop-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.ref-sources-pop-list li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px dotted #eef0f3;
}
.ref-sources-pop-list li:last-child { border-bottom: 0; }
.ref-sources-pop-list .ref-src-name { flex: 1; color: #1a3a5b; }
.ref-sources-pop-list .ref-src-stat { font-size: 11px; }
.small { font-size: 11px; }
